From c74a4e1b2251cac6adbb812d0f3a98cca89dfcc8 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Wed, 25 Oct 2017 15:39:56 -0400 Subject: Further adjustments to the invoice format. Allow default bill to to be set for superusers --- app/dispatch/models.py | 4 ++- app/dispatch/static/print.css | 27 +++++++++++++++++++ app/dispatch/static/style.css | 8 ++++++ .../templates/dispatch/drivers/detail.html | 5 +++- .../templates/dispatch/invoice/detail-table.html | 11 +------- app/dispatch/templates/dispatch/nav.html | 2 +- app/dispatch/urls.py | 3 ++- app/dispatch/views.py | 31 ++++++++++++++++++---- 8 files changed, 72 insertions(+), 19 deletions(-) (limited to 'app/dispatch') diff --git a/app/dispatch/models.py b/app/dispatch/models.py index 13650ac..dd088c4 100644 --- a/app/dispatch/models.py +++ b/app/dispatch/models.py @@ -60,7 +60,9 @@ class Identity(models.Model): def set_default(self): try: - Settings.objects.get(key="default_bill_to").value + st = Settings.objects.get(key="default_bill_to") + st.value = str(self.pk) + st.save() except ObjectDoesNotExist: st = Settings(key="default_bill_to", value=int(self.pk)) st.save() diff --git a/app/dispatch/static/print.css b/app/dispatch/static/print.css index 6fc7ed3..f312c31 100644 --- a/app/dispatch/static/print.css +++ b/app/dispatch/static/print.css @@ -8,7 +8,34 @@ footer, nav, .hide-print { display: none !important; } box-shadow: none !important; } +body { + font-size: .75rem; +} + +td, td, tr th, tr td { + padding: 5px 5px !important; + font-size: .75rem; +} + +.invoice-table table { + border-collapse: collapse; +} + +.invoice-table th, .invoice-table td, .invoice-table table { + border: 1px solid black; +} + +.spacer-row { + height: 1.5rem; +} +.invoice-table tr { + /* height: 52px; */ +} + +.container { + width: 100% !important; +} @page { /*size: 29.7cm 42cm; -> that would be a regular A4 page */ diff --git a/app/dispatch/static/style.css b/app/dispatch/static/style.css index 8b08af7..8c0a424 100644 --- a/app/dispatch/static/style.css +++ b/app/dispatch/static/style.css @@ -6,3 +6,11 @@ body { main { flex: 1 0 auto; } + +.invoice-table table { + border-collapse: collapse; +} + +.invoice-table th, .invoice-table td, .invoice-table table { + border: 1px solid black; +} diff --git a/app/dispatch/templates/dispatch/drivers/detail.html b/app/dispatch/templates/dispatch/drivers/detail.html index 8ce409d..9e4e7f3 100644 --- a/app/dispatch/templates/dispatch/drivers/detail.html +++ b/app/dispatch/templates/dispatch/drivers/detail.html @@ -46,7 +46,10 @@
diff --git a/app/dispatch/templates/dispatch/invoice/detail-table.html b/app/dispatch/templates/dispatch/invoice/detail-table.html index acb6e01..37fa2a5 100644 --- a/app/dispatch/templates/dispatch/invoice/detail-table.html +++ b/app/dispatch/templates/dispatch/invoice/detail-table.html @@ -56,7 +56,7 @@ {{item.total}} {% endfor %} - + @@ -77,13 +77,4 @@
diff --git a/app/dispatch/templates/dispatch/nav.html b/app/dispatch/templates/dispatch/nav.html index a4fc8cb..a5f09e5 100644 --- a/app/dispatch/templates/dispatch/nav.html +++ b/app/dispatch/templates/dispatch/nav.html @@ -1,9 +1,9 @@ {% if request.user.is_authenticated %}
  • Loads
  • +
  • Invoices
  • {% if request.user.is_superuser %}
  • Drivers
  • Customers
  • -
  • Invoices
  • {% else %}
  • Summary
  • My Account
  • diff --git a/app/dispatch/urls.py b/app/dispatch/urls.py index 9992489..9d8b77b 100644 --- a/app/dispatch/urls.py +++ b/app/dispatch/urls.py @@ -17,7 +17,8 @@ urlpatterns = [ url(r'^drivers/(?P\d+)/identity/(?P\d+)$', views.IdentityDetail.as_view(), name='identity_detail'), url(r'^drivers/(?P\d+)/identity/new/$', views.IdentityCreate.as_view(), name='identity_create'), - url(r'^identity/edit/(?P\d+)$', views.IdentityUpdate.as_view(), name='identity_edit'), + url(r'^drivers/(?P\d+)/identity/edit/(?P\d+)$', views.IdentityUpdate.as_view(), name='identity_edit'), + url(r'^drivers/(?P\d+)/identity/default/(?P\d+)$', views.SetDefaultIdentity, name='identity_default'), url(r'^customers/$', views.CustomerList.as_view(), name='customer_list'), url(r'^customers/new$', views.CustomerCreate.as_view(), name='customer_new'), diff --git a/app/dispatch/views.py b/app/dispatch/views.py index ac399f6..bf4c3fb 100644 --- a/app/dispatch/views.py +++ b/app/dispatch/views.py @@ -10,7 +10,7 @@ from django.views.generic import TemplateView,ListView from django.views.generic.detail import DetailView from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.core.urlresolvers import reverse_lazy -from dispatch.models import Customer, Load, Paperwork, Invoice, Settings, Identity +from dispatch.models import Customer, Load, Paperwork, Invoice, UserInvoiceNumber, Settings, Identity from dispatch.forms import AddPaperworkForm from django.contrib.auth.models import User from django.contrib.auth.mixins import UserPassesTestMixin @@ -307,15 +307,36 @@ def PaperworkDownload(request, load_id, pk): except Exception as e: print(e) + + +# User Invoice Numbers + +class UserInvoiceNumberUpdate(UserPassesTestMixin, UpdateView): + template_name = "dispatch/userinvoicenumber/edit.html" + model = UserInvoiceNumber + fields = ['number'] + + def get(self,request, *args, **kwargs): + if request.user.is_superuser: + self.fields.insert(1,'user') + return super(UserInvoiceNumberUpdate, self).get(request) + + def test_func(self): + return self.request.user.is_superuser or \ + self.get_object().user.pk is self.request.user.pk + + # Identity class IdentityDetail(DetailView): template_name = "dispatch/identity/detail.html" model = Identity -def SetDefaultIdentity(request, pk): - ident = Ident.objects.get(pk=pk) - ident.set_default() - return redirect(reverse('identity_detail', kwargs={'pk': pk})) +def SetDefaultIdentity(request, user_id, pk): + if request.user.is_superuser: + print("WORKS") + ident = Identity.objects.get(pk=pk) + ident.set_default() + return redirect(reverse('driver_details', kwargs={'pk': user_id})) class IdentityCreate(UserPassesTestMixin, CreateView): template_name = "dispatch/identity/edit.html" -- cgit v1.2.3