diff --git a/busManager/coord/context_helpers.py b/busManager/coord/context_helpers.py index aebd3b6..ab41e89 100644 --- a/busManager/coord/context_helpers.py +++ b/busManager/coord/context_helpers.py @@ -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})", }) diff --git a/busManager/coord/models.py b/busManager/coord/models.py index 78c562f..f016fa7 100644 --- a/busManager/coord/models.py +++ b/busManager/coord/models.py @@ -85,10 +85,10 @@ class Bus(models.Model): def __str__(self): return f"{self.route_name}" - def traveller_count(self): + def traveller_count(self, date=None): count = 0 for traveller in Traveller.objects.filter(bus_stops__bus=self): - if traveller._is_active(): + if traveller._is_active(date): count += 1 return count diff --git a/busManager/coord/templates/reports/bus_roll.html b/busManager/coord/templates/reports/bus_roll.html index 7fea2a0..2ca9384 100644 --- a/busManager/coord/templates/reports/bus_roll.html +++ b/busManager/coord/templates/reports/bus_roll.html @@ -19,11 +19,11 @@ {% for route in routes %} {% if route.route_stops %} -
Date: {{ date }}
- Total Travellers: {{ route.bus.traveller_count }}
- Seating Capacity: {{ route.bus.seating_capacity }}
+ Total Travellers: {{ route.traveller_count }}
+ Seating Capacity: {{ route.seating_capacity }}