From d4a6113e312797de3c88f9775d35af87c464ba2d Mon Sep 17 00:00:00 2001 From: John Mullins Date: Wed, 11 Oct 2023 13:22:02 +1100 Subject: [PATCH] Moved roll some context to bus object Added first_name to traveller ordering --- busManager/coord/context_helpers.py | 2 +- busManager/coord/email_helpers.py | 2 +- busManager/coord/models.py | 2 +- busManager/coord/templates/reports/bus_roll.html | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/busManager/coord/context_helpers.py b/busManager/coord/context_helpers.py index 9262a1d..4478fb6 100644 --- a/busManager/coord/context_helpers.py +++ b/busManager/coord/context_helpers.py @@ -59,7 +59,7 @@ def bus_roll_context(queryset=None): }) 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, 'shuttle_count': shuttle_count, '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}) return {'routes': bus_routes} diff --git a/busManager/coord/email_helpers.py b/busManager/coord/email_helpers.py index 671571d..3582a50 100644 --- a/busManager/coord/email_helpers.py +++ b/busManager/coord/email_helpers.py @@ -29,7 +29,7 @@ def email_companies_bus_roll(request, query_set=None): company_route = [] for route in context.get("routes"): - if route.get("company") == company: + if route.get("bus").company == company: company_route.append(route) if not company_route: continue diff --git a/busManager/coord/models.py b/busManager/coord/models.py index 9c9312e..58c9516 100644 --- a/busManager/coord/models.py +++ b/busManager/coord/models.py @@ -241,7 +241,7 @@ class Traveller(models.Model): shuttle = models.ForeignKey(Shuttle, on_delete=models.SET_NULL, blank=True, null=True) class Meta: - ordering = ["last_name"] + ordering = ["last_name", "first_name"] def __str__(self): return f"{self.first_name} {self.last_name}" diff --git a/busManager/coord/templates/reports/bus_roll.html b/busManager/coord/templates/reports/bus_roll.html index e09e914..4c81cf6 100644 --- a/busManager/coord/templates/reports/bus_roll.html +++ b/busManager/coord/templates/reports/bus_roll.html @@ -18,15 +18,15 @@ {% for route in routes %} -

{{ route.route_name }}

+

{{ route.bus.route_name }}

Total Travellers: {{ route.traveller_count }}
- Seating Capacity: {{ route.seating_capacity }} + Seating Capacity: {{ route.bus.seating_capacity }}

{% for stop in route.route_stops %} {% if stop.page_break %}
-

{{ route.route_name }}

+

{{ route.bus.route_name }}

{% endif %} @@ -79,7 +79,7 @@

{{ route.route_name }} (Shuttle)

Total Travellers: {{ route.shuttle_count }}
- Seating Capacity: {{ route.seating_capacity }} + Seating Capacity: {{ route.bus.seating_capacity }}

{% for traveller in route.shuttle_travellers %}