Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show only breaking participants in check-in screen #2556

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
47 changes: 45 additions & 2 deletions tabbycat/checkins/templates/CheckInStatusContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@
</button>
</div>

<div class="btn-group mb-md-0 mb-3" v-if="!isForVenues">
<!-- Filter for Breaking status -->
<div class="btn-group mb-md-0 mb-3" v-if="this.isBreakRound">
<button
v-for="(optionState, optionKey) in filterByBreaking || {}"
:key="optionKey"
type="button"
:class="['btn btn-outline-primary', optionState ? 'active' : '']"
@click="setListContext('filterByBreaking', optionKey, !optionState)">
<span v-if="optionKey === 'All'" v-text="gettext('All')"></span>
<span v-if="optionKey === 'Breaking'" v-text="gettext('Breaking')"></span>
</button>
</div>

<div class="btn-group mb-md-0 mb-3" v-if="!isForVenues">
<button v-for="(optionState, optionKey) in this.filterByType"
:key="optionKey" type="button"
:class="['btn btn-outline-primary', optionState ? 'active' : '']"
Expand Down Expand Up @@ -145,6 +158,10 @@ export default {
filterByPresence: {
All: true, Absent: false, Present: false,
},
filterByBreaking: {
All: true,
Breaking: false,
},
sockets: ['checkins'],
// Keep internal copy as events needs to be mutated by the websocket
// pushed changes and the data is never updated by the parent
Expand All @@ -158,6 +175,8 @@ export default {
tournamentSlug: String,
forAdmin: Boolean,
teamSize: Number,
breakingTeamShortNames: Array,
isBreakRound: Boolean,
},
computed: {
statsAbsent: function () {
Expand Down Expand Up @@ -220,7 +239,9 @@ export default {
})
},
entitiesBySortingSetting: function () {
if (this.sortByGroup.Category === true) {
if (this.filterByBreaking.Breaking === true) {
return this.entitiesByBreaking
} else if (this.sortByGroup.Category === true) {
return this.venuesByCategory
} else if (this.sortByGroup.Priority === true) {
return this.venuesByPriority
Expand All @@ -233,6 +254,28 @@ export default {
}
return this.entitiesByTime
},
entitiesByBreaking: function () {
const isBreaking = (entityByPresence) => {
if (entityByPresence.type === 'Adjudicator') {
return entityByPresence.breaking
} else if (this.breakingTeamShortNames.includes(entityByPresence.name)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could using team IDs be shorter and avoid needing to escape the strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

return true
}
return false
}
if (this.filterByBreaking.All) {
return this.entitiesByPresence // No filter
} else if (this.filterByBreaking.Breaking) {
console.log('Breaking Teams and Adjudicators')
// print each object in the array
const temp = this.entitiesByPresence.filter(isBreaking)
for (let i = 0; i < temp.length; i++) {
console.log(temp[i])
}
Comment on lines +269 to +274
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using console, as it's just for debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's just temporary, will remove

return this.entitiesByPresence.filter(isBreaking)
}
return this.entitiesByPresence
},
tournamentSlugForWSPath: function () {
return this.tournamentSlug
},
Expand Down
6 changes: 5 additions & 1 deletion tabbycat/checkins/templates/checkin_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
:assistant-url="assistantUrl"
:team-codes="teamCodes"
:for-admin="forAdmin"
:team-size="teamSize">
:team-size="teamSize"
:breaking-team-short-names="breakingTeamShortNames"
:is-break-round="isBreakRound">
</check-in-status-container>
</div>

Expand All @@ -30,6 +32,8 @@
'teamCodes': {{ team_codes }},
'forAdmin': {% if for_admin %}true{% else %}false{% endif %},
'teamSize': {{ team_size }},
'breakingTeamShortNames': {{ breaking_team_short_names|safe }},
'isBreakRound': {% if is_break_round %}true{% else %}false{% endif %},
}
</script>
{{ block.super }}
Expand Down
19 changes: 18 additions & 1 deletion tabbycat/checkins/views.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to set breaking_team_short_names for CheckInVenuesStatusView as well

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from actionlog.mixins import LogActionMixin
from actionlog.models import ActionLogEntry
from breakqual.models import BreakingTeam
from options.utils import use_team_code_names
from participants.models import Person, Speaker
from participants.serializers import InstitutionSerializer
Expand Down Expand Up @@ -67,7 +68,17 @@ class CheckInPeopleStatusView(BaseCheckInStatusView):

edit_permission = Permission.EDIT_PARTICIPANT_CHECKIN

def is_break_round(self):
"""Checks if the current round is a break round."""
break_rounds = self.tournament.break_rounds()
return self.tournament.current_round in break_rounds

def get_breaking_team_short_names(self):
breaking_teams = BreakingTeam.objects.filter(break_category__tournament=self.tournament).select_related('team', 'team__institution', 'break_category', 'break_category__tournament').all()
return set(breaking_team.team.short_name for breaking_team in breaking_teams)

def get_context_data(self, **kwargs):
breaking_team_short_names = self.get_breaking_team_short_names()

team_codes = use_team_code_names(self.tournament, admin=self.for_admin, user=self.request.user)
kwargs["team_codes"] = json.dumps(team_codes)
Expand All @@ -83,12 +94,15 @@ def get_context_data(self, **kwargs):
adjudicators.append({
'id': adj.id, 'name': adj.get_public_name(self.tournament), 'type': 'Adjudicator',
'identifier': [code], 'locked': False, 'independent': adj.independent,
'institution': institution,
'institution': institution, 'breaking': adj.breaking,
})
kwargs["adjudicators"] = json.dumps(adjudicators)

speakers = []
for speaker in Speaker.objects.filter(team__tournament=self.tournament).select_related('team', 'team__institution', 'checkin_identifier'):
breaking = False
if speaker.team.code_name in breaking_team_short_names:
breaking = True
try:
code = speaker.checkin_identifier.barcode
except ObjectDoesNotExist:
Expand All @@ -100,8 +114,11 @@ def get_context_data(self, **kwargs):
'identifier': [code], 'locked': False,
'team': speaker.team.code_name if team_codes else speaker.team.short_name,
'institution': institution,
'breaking': breaking,
})
kwargs["speakers"] = json.dumps(speakers)
kwargs["is_break_round"] = self.is_break_round()
kwargs["breaking_team_short_names"] = json.dumps(list(breaking_team_short_names))

return super().get_context_data(**kwargs)

Expand Down
Loading