Changed bus roll to be a pdf view. Small changes needed to be able to email to companies.
Dropdown selection in admin > buses > Email Bus Roll To Company Will email bus roll only to the company the route is a member of. Will show all to the admin in a pdf file. Recipients are currently hardcoded for testing purposes.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
from coord.models import Bus, BusStop, TravellerRoute
|
||||
|
||||
|
||||
def bus_roll_context(queryset=None):
|
||||
bus_routes = []
|
||||
if queryset is None:
|
||||
buses = Bus.objects.all()
|
||||
else:
|
||||
buses = queryset
|
||||
|
||||
for bus in buses:
|
||||
bus_route = []
|
||||
|
||||
for bus_stop in BusStop.objects.filter(bus=bus):
|
||||
traveller_list = []
|
||||
for trav_route in TravellerRoute.objects.filter(busStop=bus_stop):
|
||||
traveller = trav_route.traveller
|
||||
if not traveller.is_active():
|
||||
continue
|
||||
is_fared = "---"
|
||||
if traveller.eligibility_status == "2":
|
||||
is_fared = "Y"
|
||||
traveller_list.append({
|
||||
'display': f"{traveller} ({traveller.get_year_level_display()}, {traveller.school.shortName})",
|
||||
'isFared': is_fared
|
||||
})
|
||||
stop_result = {
|
||||
'stop_num': bus_stop.get_stop_number(),
|
||||
'name': bus_stop.address,
|
||||
'am': bus_stop.am_time,
|
||||
'pm': bus_stop.pm_time,
|
||||
'travellers': traveller_list
|
||||
}
|
||||
# print(traveller_list)
|
||||
bus_route.append(stop_result)
|
||||
|
||||
# Todo Add shuttles
|
||||
|
||||
bus_routes.append({'bus': bus, 'stops': bus_route})
|
||||
return {'routes': bus_routes}
|
||||
Reference in New Issue
Block a user