buttons in table footer
This commit is contained in:
+9
-7
@@ -1,12 +1,14 @@
|
||||
from django.urls import path, include
|
||||
from common import views
|
||||
|
||||
from common.views.barrier_views import BarrierDashboardView
|
||||
from common.views.employee_views import EmployeeDashboardView
|
||||
from common.views.client_views import ClientDashboardView
|
||||
from common.views.shared_views import IndexView, DashboardRedirectView
|
||||
urlpatterns = [
|
||||
path('', views.IndexView.as_view(), name='index'),
|
||||
path('', IndexView.as_view(), name='index'),
|
||||
path('dashboard/', include([
|
||||
path('', views.DashboardRedirectView.as_view(), name='dashboard'),
|
||||
path('client/', views.ClientDashboardView.as_view(), name='client_dashboard'),
|
||||
path('barrier/', views.BarrierDashboardView.as_view(), name='barrier_dashboard'),
|
||||
path('employee/', views.EmployeeDashboardView.as_view(), name='employee_dashboard'),
|
||||
path('', DashboardRedirectView.as_view(), name='dashboard'),
|
||||
path('client/', ClientDashboardView.as_view(), name='client_dashboard'),
|
||||
path('barrier/', BarrierDashboardView.as_view(), name='barrier_dashboard'),
|
||||
path('employee/', EmployeeDashboardView.as_view(), name='employee_dashboard'),
|
||||
]))
|
||||
]
|
||||
|
||||
@@ -8,12 +8,16 @@ def filter_queryset_by_user(queryset, user):
|
||||
If the user has a line, it filters by that line.
|
||||
If the user has a company, it filters by all lines associated with that company.
|
||||
"""
|
||||
|
||||
print(f'user: {user}, user company: {user.company}, user line: {user.line}')
|
||||
if user.line:
|
||||
return queryset.filter(line=user.line)
|
||||
filtered = queryset.filter(line=user.line)
|
||||
print(f"Filtering by line: {user.line.id}, count: {filtered.count()}")
|
||||
return filtered
|
||||
elif user.company:
|
||||
company_lines = user.company.line_company.all()
|
||||
return queryset.filter(line__in=company_lines)
|
||||
filtered = queryset.filter(line__in=company_lines)
|
||||
print(f"Filtering by company: {user.company.id}, count: {filtered.count()}")
|
||||
return filtered
|
||||
return queryset
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class BarrierDashboardView(TemplateView):
|
||||
template_name = 'barrier/barrier-dashboard.html'
|
||||
extra_context = {
|
||||
'title': 'Client Dashboard',
|
||||
'description': 'This is the client dashboard page.',
|
||||
}
|
||||
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return render(request, self.template_name, self.extra_context)
|
||||
@@ -0,0 +1,13 @@
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class ClientDashboardView(TemplateView):
|
||||
template_name = 'client-dashboard-content.html'
|
||||
extra_context = {
|
||||
'title': 'Client Dashboard',
|
||||
'description': 'This is the client dashboard page.',
|
||||
}
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return render(request, self.template_name, self.extra_context)
|
||||
@@ -0,0 +1,23 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from booking.models import Booking
|
||||
from containers.models import Container
|
||||
from preinfo.models import Preinfo
|
||||
|
||||
|
||||
class EmployeeDashboardView(TemplateView):
|
||||
template_name = 'employee-dashboard-content.html'
|
||||
extra_context = {
|
||||
'title': 'Employee Dashboard',
|
||||
'description': 'This is the depot employee dashboard page.',
|
||||
}
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
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()
|
||||
context['containers'] = containers
|
||||
context['preinfos'] = preinfos
|
||||
context['bookings'] = bookings
|
||||
return context
|
||||
@@ -39,43 +39,11 @@ class DashboardRedirectView(RedirectView):
|
||||
return reverse_lazy('index')
|
||||
|
||||
|
||||
class ClientDashboardView(TemplateView):
|
||||
template_name = 'client-dashboard-content.html'
|
||||
extra_context = {
|
||||
'title': 'Client Dashboard',
|
||||
'description': 'This is the client dashboard page.',
|
||||
}
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return render(request, self.template_name, self.extra_context)
|
||||
|
||||
class BarrierDashboardView(TemplateView):
|
||||
template_name = 'barrier/barrier-dashboard.html'
|
||||
extra_context = {
|
||||
'title': 'Client Dashboard',
|
||||
'description': 'This is the client dashboard page.',
|
||||
}
|
||||
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return render(request, self.template_name, self.extra_context)
|
||||
|
||||
class EmployeeDashboardView(TemplateView):
|
||||
template_name = 'employee-dashboard-content.html'
|
||||
extra_context = {
|
||||
'title': 'Employee Dashboard',
|
||||
'description': 'This is the depot employee dashboard page.',
|
||||
}
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
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()
|
||||
context['containers'] = containers
|
||||
context['preinfos'] = preinfos
|
||||
context['bookings'] = bookings
|
||||
return context
|
||||
|
||||
|
||||
# class ClientPreinfoView(TemplateView):
|
||||
# template_name = 'client-preinfo-content.html'
|
||||
|
||||
Reference in New Issue
Block a user