Added date selector to shuttles and traveller counts

This commit is contained in:
John Mullins
2024-12-13 09:36:41 +11:00
parent 320303f95f
commit dabce7f360
3 changed files with 9 additions and 9 deletions
+4 -4
View File
@@ -19,9 +19,9 @@ def bus_roll_context(queryset=None, include_bus_stops=True, date=None):
shuttle_routes = []
for shuttle in Shuttle.objects.filter(bus=bus):
shuttle_routes.append(shuttle_route_context(shuttle))
shuttle_routes.append(shuttle_route_context(shuttle, date))
bus_routes.append({'bus': bus, 'route_stops': route_stops, 'shuttle_routes': shuttle_routes})
bus_routes.append({'name': bus.route_name, 'traveller_count': bus.traveller_count(date), 'seating_capacity': bus.seating_capacity, 'bus': bus, 'route_stops': route_stops, 'shuttle_routes': shuttle_routes})
if date is None:
date = datetime.date.today()
return {'routes': bus_routes, 'date': date.strftime('%Y-%m-%d')}
@@ -115,10 +115,10 @@ def route_paged_context(bus, date=None):
return route_stops
def shuttle_route_context(shuttle):
def shuttle_route_context(shuttle, date=None):
shuttle_travellers = []
for traveller in Traveller.objects.filter(shuttle=shuttle):
if traveller._is_active():
if traveller._is_active(date):
shuttle_travellers.append({
'display': f"{traveller} ({traveller.get_year_level_display()}, {traveller.school})",
})