Skip to content

Commit

Permalink
Fix bug where old leader signups displayed active
Browse files Browse the repository at this point in the history
In short, the current system will accept a leader's signup, but then
even if that person is *removed* from the collection of a trip's
leaders, they will remain present in the total leader count (notably,
where the leader count itself is inaccurate)!

There are other parts of that issue that remain in need of a solution,
but this at least corrects the error of miscategorizing leader signups.
  • Loading branch information
DavidCain committed May 18, 2022
1 parent 0e3e620 commit d7a8277
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 13 additions & 2 deletions ws/templates/for_templatetags/view_trip.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@

{# The leader table is so participants can see leader notes #}
{# (or so leaders can see who's driving on other trips) #}
{% if has_notes and signups.leader or viewing_participant.is_leader and trip.leaders.count %}
{% if has_notes and signups.leaders_on_trip or viewing_participant.is_leader and trip.leaders.count %}
<h3>Leaders ({{ trip.leaders.count }})</h3>
{% signup_table signups.leader has_notes show_drivers=viewing_participant.is_leader all_participants=trip.leaders%}
{% signup_table signups.leaders_on_trip has_notes show_drivers=viewing_participant.is_leader all_participants=trip.leaders %}
{% endif %}

{# A list of previous leaders who signed up is useful to #}
{# - Any individuals in the list (who may be confused about their status) #}
{# - Trip creator, or other leaders curious about headcount #}
{% if has_notes and signups.leaders_off_trip %}
<h3>Leader signups, no longer on trip</h3>
<div class="alert alert-info">
These individuals previously signed up as leaders, but are no longer leaders on the trip.
</div>
{% signup_table signups.leaders_off_trip has_notes show_drivers=viewing_participant.is_leader %}
{% endif %}

{% if signups.on_trip %}
Expand Down
7 changes: 6 additions & 1 deletion ws/templatetags/trip_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def get_signups(model=models.SignUp):
signups = signups.select_related('participant', 'trip')
return signups.select_related('participant__lotteryinfo')

trip_leaders = trip.leaders.all()
leader_signups = get_signups(models.LeaderSignUp)
context = {
'trip': trip,
'is_trip_leader': perm_utils.leader_on_trip(participant, trip),
Expand All @@ -149,7 +151,10 @@ def get_signups(model=models.SignUp):
'waitlist': wl_signups,
'off_trip': signups.filter(on_trip=False).exclude(pk__in=wl_signups),
'on_trip': signups.filter(on_trip=True),
'leader': get_signups(models.LeaderSignUp),
'leaders_on_trip': [s for s in leader_signups if s.participant in trip_leaders],
'leaders_off_trip': [
s for s in leader_signups if s.participant not in trip_leaders
],
}
context['has_notes'] = (
bool(trip.notes)
Expand Down

0 comments on commit d7a8277

Please sign in to comment.