diff --git a/busManager/coord/context_helpers.py b/busManager/coord/context_helpers.py index 4478fb6..6d95927 100644 --- a/busManager/coord/context_helpers.py +++ b/busManager/coord/context_helpers.py @@ -15,7 +15,6 @@ def bus_roll_context(queryset=None): for bus in buses: route_stops = [] page_size = 3 # Account for traveller numbers at the top of the first page - traveller_count = 0 for bus_stop in BusStop.objects.filter(bus=bus): traveller_routes = TravellerRoute.objects.filter(busStop=bus_stop) traveller_list = [] @@ -32,7 +31,6 @@ def bus_roll_context(queryset=None): }) stop_size = len(traveller_list) - traveller_count += stop_size page_break = False page_size += table_header_size + stop_size if page_size > page_max_size: @@ -49,17 +47,17 @@ def bus_roll_context(queryset=None): 'page_break': page_break }) - shuttle_travellers = [] - shuttle_count = 0 + shuttle_routes = [] for shuttle in Shuttle.objects.filter(bus=bus): + shuttle_travellers = [] for traveller in Traveller.objects.filter(shuttle=shuttle): if traveller.is_active(): shuttle_travellers.append({ 'display': f"{traveller} ({traveller.get_year_level_display()}, {traveller.school})", }) - shuttle_count += 1 + shuttle_routes.append({'shuttle': shuttle, 'shuttle_travellers': shuttle_travellers}) - bus_routes.append({'bus': bus, 'traveller_count': traveller_count, 'route_stops': route_stops, 'shuttle_count': shuttle_count, 'shuttle_travellers': shuttle_travellers}) + bus_routes.append({'bus': bus, 'route_stops': route_stops, 'shuttle_routes': shuttle_routes}) return {'routes': bus_routes} diff --git a/busManager/coord/templates/reports/bus_roll.html b/busManager/coord/templates/reports/bus_roll.html index 4c81cf6..5b5aefd 100644 --- a/busManager/coord/templates/reports/bus_roll.html +++ b/busManager/coord/templates/reports/bus_roll.html @@ -20,7 +20,7 @@ {% for route in routes %}
- Total Travellers: {{ route.traveller_count }}
+ Total Travellers: {{ route.bus.traveller_count }}
Seating Capacity: {{ route.bus.seating_capacity }}
- {% if route.shuttle_count > 0 %} -
- Total Travellers: {{ route.shuttle_count }}
- Seating Capacity: {{ route.bus.seating_capacity }}
+ Total Travellers: {{ shuttle_route.shuttle.traveller_count }}
| {{ traveller.display }} |
- {% endif %} + {% endfor %} {% endfor %} \ No newline at end of file