Added traveller count to shuttle roll and removed inactive from roll

This commit is contained in:
John Mullins
2023-10-11 13:14:52 +11:00
parent 5fd3bbfa87
commit ff8b4c21fc
2 changed files with 12 additions and 7 deletions
+7 -6
View File
@@ -50,15 +50,16 @@ def bus_roll_context(queryset=None):
})
shuttle_travellers = []
has_shuttle = False
shuttle_count = 0
for shuttle in Shuttle.objects.filter(bus=bus):
has_shuttle = True
for traveller in Traveller.objects.filter(shuttle=shuttle):
shuttle_travellers.append({
'display': f"{traveller} ({traveller.get_year_level_display()}, {traveller.school})",
})
if traveller.is_active():
shuttle_travellers.append({
'display': f"{traveller} ({traveller.get_year_level_display()}, {traveller.school})",
})
shuttle_count += 1
bus_routes.append({'route_name': bus.route_name, 'company': bus.company, 'traveller_count': traveller_count, 'seating_capacity': bus.seating_capacity, 'route_stops': route_stops, 'has_shuttle': has_shuttle, 'shuttle_travellers': shuttle_travellers})
bus_routes.append({'route_name': bus.route_name, 'company': bus.company, 'traveller_count': traveller_count, 'seating_capacity': bus.seating_capacity, 'route_stops': route_stops, 'shuttle_count': shuttle_count, 'shuttle_travellers': shuttle_travellers})
return {'routes': bus_routes}