fixed client dashboard
fixed employee sidebar nomenclatures buttons
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.views.generic import TemplateView, ListView, CreateView, UpdateView
|
||||
|
||||
from booking.models import Booking
|
||||
@@ -22,15 +25,33 @@ class EmployeeDashboardView(LoginRequiredMixin, UserPassesTestMixin, TemplateVie
|
||||
return self.request.user.user_type == 'EM' or self.request.user.is_superuser
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
today = timezone.now()
|
||||
last_week = today - timedelta(days=7)
|
||||
|
||||
context = super().get_context_data(**kwargs)
|
||||
containers = Container.objects.filter(expedited=False).count()
|
||||
preinfos = Preinfo.objects.filter(received=False).count()
|
||||
bookings = Booking.objects.filter(status='active').count()
|
||||
|
||||
containers_queryset = Container.objects.all()
|
||||
containers = containers_queryset.filter(expedited=False).count()
|
||||
containers_week = containers_queryset.filter(received_on__gte=last_week).count()
|
||||
|
||||
preinfos_queryset = Preinfo.objects.all()
|
||||
preinfos = preinfos_queryset.filter(received=False).count()
|
||||
preinfos_week = preinfos_queryset.filter(created_on__gte=last_week).count()
|
||||
|
||||
bookings_queryset = Booking.objects.filter(status='active')
|
||||
bookings = bookings_queryset.filter(status='active').count()
|
||||
bookings_week = bookings_queryset.filter(created_on__gte=last_week).count()
|
||||
|
||||
context['containers'] = containers
|
||||
context['preinfos'] = preinfos
|
||||
context['bookings'] = bookings
|
||||
context['recent_containers'] = Container.objects.order_by('-expedited_on', '-received_on')[:10]
|
||||
context['containers_week'] = containers_week
|
||||
context['preinfos_week'] = preinfos_week
|
||||
context['bookings_week'] = bookings_week
|
||||
|
||||
context['recent_containers'] = containers_queryset.order_by('-expedited_on', '-received_on')[:10]
|
||||
context['recent_payments'] = Payment.objects.order_by('-created_on')[:10]
|
||||
print('context prepared')
|
||||
return context
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user