development branch created to preserve working deploy project
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from django.db.models import QuerySet
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import TemplateView, RedirectView
|
||||
from django.views.generic import TemplateView, RedirectView, ListView
|
||||
from django.shortcuts import render
|
||||
|
||||
from accounts.models import DepotUser
|
||||
@@ -39,6 +40,34 @@ class DashboardRedirectView(RedirectView):
|
||||
return reverse_lazy('index')
|
||||
|
||||
|
||||
class AllowedVehiclesView(ListView):
|
||||
template_name = 'common/allowed-vehicles.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
lines_vehicles = {}
|
||||
queryset = Booking.objects.filter(status='active')
|
||||
for booking in queryset:
|
||||
if lines_vehicles.get(booking.line.name) is None:
|
||||
lines_vehicles[booking.line.name] = set()
|
||||
vehicles = lines_vehicles[booking.line.name]
|
||||
vehicles.update(booking.vehicles_left.split(','))
|
||||
lines_vehicles[booking.line.name] = vehicles
|
||||
context['objects'] = lines_vehicles
|
||||
|
||||
context['objects'] = [
|
||||
type('Obj', (), {
|
||||
'id': line_name,
|
||||
'line': line_name,
|
||||
'vehicles': ', '.join(sorted(vehicles))
|
||||
}) for line_name, vehicles in lines_vehicles.items()
|
||||
]
|
||||
|
||||
return context
|
||||
|
||||
def get_queryset(self):
|
||||
return DepotUser.objects.none()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user