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:
John Mullins
2023-08-29 12:40:34 +10:00
parent 2f1ae0586b
commit 0c8de0285a
7 changed files with 119 additions and 74 deletions
+6 -4
View File
@@ -9,6 +9,8 @@ from django.utils.http import urlencode
from import_export.admin import ImportExportModelAdmin
from .adminClone import CloneModelAdmin
from .context_helpers import bus_roll_context
from .email_helpers import email_companies_bus_roll, render_to_pdf
from .models import *
from .views import bus_roll
@@ -33,11 +35,11 @@ class ExportCsvMixin:
class BusRollMixin:
def bus_roll(self, request, queryset):
return bus_roll(request, queryset)
def show_bus_roll(self, request, queryset):
return render_to_pdf('reports/bus_roll.html', bus_roll_context(queryset))
def email_company(self, request, queryset):
pass
return email_companies_bus_roll(request, queryset)
email_company.short_description = "Email Bus Roll to Company"
@@ -81,7 +83,7 @@ class BusesAdmin(MyImportExportModelAdmin, admin.ModelAdmin, BusRollMixin):
list_filter = ["company"]
list_display = ["route_name", "company", "contract_number", "route_travellers"]
readonly_fields = ["traveller_count"]
actions = ["email_company", "bus_roll"]
actions = ["email_company", "show_bus_roll"]
inlines = [DriverInline, BusStopInline]
fieldsets = [
(None, {'fields': [