aboutsummaryrefslogtreecommitdiff
path: root/app/dispatch
diff options
context:
space:
mode:
authorMitch Riedstra <Mitch@riedstra.us>2017-10-25 15:39:56 -0400
committerMitch Riedstra <Mitch@riedstra.us>2017-10-25 15:39:56 -0400
commitc74a4e1b2251cac6adbb812d0f3a98cca89dfcc8 (patch)
treefb37c3c32076120639bcb588484f2526f3e8af12 /app/dispatch
parentfae5a7e38ef7084990724df51488f54c52ec592d (diff)
downloaddispatch-tracker-c74a4e1b2251cac6adbb812d0f3a98cca89dfcc8.tar.gz
dispatch-tracker-c74a4e1b2251cac6adbb812d0f3a98cca89dfcc8.tar.xz
Further adjustments to the invoice format. Allow default bill to to be set for superusers
Diffstat (limited to 'app/dispatch')
-rw-r--r--app/dispatch/models.py4
-rw-r--r--app/dispatch/static/print.css27
-rw-r--r--app/dispatch/static/style.css8
-rw-r--r--app/dispatch/templates/dispatch/drivers/detail.html5
-rw-r--r--app/dispatch/templates/dispatch/invoice/detail-table.html11
-rw-r--r--app/dispatch/templates/dispatch/nav.html2
-rw-r--r--app/dispatch/urls.py3
-rw-r--r--app/dispatch/views.py31
8 files changed, 72 insertions, 19 deletions
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 @@
<div class="row">
<div class="col s12">
<div class="right-align">
- <a class="btn green" href="{% url 'identity_edit' ident.pk %}">
+ {% if request.user.is_superuser %}
+ <a class="btn orange" href="{% url 'identity_default' object.pk ident.pk %}">Make Default Bill To</a>
+ {% endif %}
+ <a class="btn green" href="{% url 'identity_edit' object.pk ident.pk %}">
Edit
</a>
</div>
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 @@
<td>{{item.total}}</td>
</tr>
{% endfor %}
- <tr>
+ <tr class="spacer-row">
<td></td>
<td></td>
<td></td>
@@ -77,13 +77,4 @@
</div>
<style>
-.invoice-table table {
- border-collapse: collapse;
-}
-.invoice-table th, .invoice-table td, .invoice-table table {
- border: 1px solid black;
-}
-.invoice-table tr {
- height: 52px;
-}
</style>
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 %}
<li><a href="{% url 'load_list' %}">Loads</a></li>
+ <li><a href="{% url 'invoice_list' %}">Invoices</a></li>
{% if request.user.is_superuser %}
<li><a href="{% url 'driver_list' %}">Drivers</a></li>
<li><a href="{% url 'customer_list' %}">Customers</a></li>
- <li><a href="{% url 'invoice_list' %}">Invoices</a></li>
{% else %}
<li><a href="{% url 'driver_summary' request.user.id %}">Summary</a>
<li><a href="{% url 'driver_details' request.user.id %}">My Account</a></li>
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<user_id>\d+)/identity/(?P<pk>\d+)$', views.IdentityDetail.as_view(), name='identity_detail'),
url(r'^drivers/(?P<user_id>\d+)/identity/new/$', views.IdentityCreate.as_view(), name='identity_create'),
- url(r'^identity/edit/(?P<pk>\d+)$', views.IdentityUpdate.as_view(), name='identity_edit'),
+ url(r'^drivers/(?P<user_id>\d+)/identity/edit/(?P<pk>\d+)$', views.IdentityUpdate.as_view(), name='identity_edit'),
+ url(r'^drivers/(?P<user_id>\d+)/identity/default/(?P<pk>\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"