aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--app/dispatch/models.py3
-rw-r--r--app/dispatch/templates/dispatch/drivers/detail.html136
-rw-r--r--app/dispatch/templates/dispatch/drivers/list.html6
-rw-r--r--app/dispatch/templates/dispatch/drivers/summary.html115
-rw-r--r--app/dispatch/templates/dispatch/generic_load_listing.html2
-rw-r--r--app/dispatch/templates/dispatch/identity/create.html15
-rw-r--r--app/dispatch/templates/dispatch/identity/detail.html42
-rw-r--r--app/dispatch/templates/dispatch/identity/edit.html18
-rw-r--r--app/dispatch/templates/dispatch/loads/detail.html2
-rw-r--r--app/dispatch/templates/dispatch/nav.html4
-rw-r--r--app/dispatch/urls.py9
-rw-r--r--app/dispatch/views.py90
13 files changed, 322 insertions, 123 deletions
diff --git a/README.md b/README.md
index e413e29..e23bae5 100644
--- a/README.md
+++ b/README.md
@@ -5,11 +5,10 @@ Requirements going forward:
* Settings:
* `default_bill_to` must be set
+ * Identity Edit page needs a little bit of work for regular users
* Delete Views are completely fucked--this needs to be fixed
- * Drivers will be able to generate a weekly PDF invoice
* Upload Invoice logos on Identity Objects for use in Invoices
* Change "user" to Vendor on the "Add Load Page"
- * Users must be able to initially create new load objects
* Change Name To "Load Pay System" -- we're going to think about it
* Freight Invoicing System
* Weekly Total Invoices from the Company(Driver) to software owner
diff --git a/app/dispatch/models.py b/app/dispatch/models.py
index d525818..13650ac 100644
--- a/app/dispatch/models.py
+++ b/app/dispatch/models.py
@@ -65,6 +65,9 @@ class Identity(models.Model):
st = Settings(key="default_bill_to", value=int(self.pk))
st.save()
+ def get_absolute_url(self):
+ return '/drivers/view/{:d}'.format(self.user.pk)
+
class Settings(models.Model):
key = models.CharField(max_length=256)
value = models.CharField(max_length=256)
diff --git a/app/dispatch/templates/dispatch/drivers/detail.html b/app/dispatch/templates/dispatch/drivers/detail.html
index fc197b5..8ce409d 100644
--- a/app/dispatch/templates/dispatch/drivers/detail.html
+++ b/app/dispatch/templates/dispatch/drivers/detail.html
@@ -1,115 +1,97 @@
{% extends 'dispatch/base.html' %}
-{% block title %}Details - {{ object.first_name }} {{ object.last_name }}{% endblock %}
+{% block title %}View User {{object.username}}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
- <h1>Summary for {{ object.first_name }} {{ object.last_name }}</h1>
- <h2>Loads for {{week_dates.start_date|date:"l, F, d"}} to {{week_dates.end_date|date:"l, F, d"}}</h2>
+ <h1>
+ User: {{object.first_name}} {{object.last_name}} ( {{object.username}} )
+ </h1>
</div>
-</div>
+</div>
<div class="row">
<div class="col s12">
<div class="right-align">
- <a class="btn orange" href="{% url 'invoice_generate' object.pk%}?date={{week_dates.start_date|date:"m/d/Y"}}">Generate Invoice For Listing</a>
+ <a class="btn green" href="{% url 'driver_edit' object.pk %}">Edit</a>
</div>
</div>
</div>
-
-{% if not request.user.is_superuser %}
<div class="row">
<div class="col s12">
<table>
- <thead>
- <tr>
- <td>Date</td>
- <td>Description</td>
- <td>Total</td>
- <td></td>
- </tr>
- </thead>
- <tbody>
- {% for load in loads_nosplit %}
- <tr>
- <td>{{load.date}}</td>
- <td>{{load.description}}</td>
- <td>{{load.amount}}</td>
- <td class="right-align">
- <a href="{% url 'load_detail' load.id %}" class="btn green">
- View
- </a>
- </td>
- </tr>
- {% endfor %}
- </tbody>
+ <tr>
+ <th>First Name:</th>
+ <td>{{object.first_name}}</td>
+ </tr>
+ <tr>
+ <th>Last Name:</th>
+ <td>{{object.last_name}}</td>
+ </tr>
+ <tr>
+ <th>Username:</th>
+ <td>{{object.username}}</td>
+ </tr>
+ <tr>
+ <th>Email:</th>
+ <td>{{object.email}}</td>
+ </tr>
</table>
</div>
</div>
-{% endif %}
+
+
+{% if ident is not None %}
+<div class="row">
+ <div class="col s12">
+ <div class="right-align">
+ <a class="btn green" href="{% url 'identity_edit' ident.pk %}">
+ Edit
+ </a>
+ </div>
+ </div>
+</div>
<div class="row">
<div class="col s12">
<table>
- <thead>
- <tr>
- <td>Number of Loads</td>
- <td>Average Load cost</td>
- <td>Total Load cost</td>
- </tr>
- </thead>
<tr>
- <td>{{stats.count}}</td>
- <td>${{stats.average|stringformat:".3f"}}</td>
- <td>${{stats.sum}}</td>
+ <th>Name:</th>
+ <td>{{ident.name}}</td>
+ </tr>
+ <tr>
+ <th>Address:</th>
+ <td>{{ident.address}}</td>
+ </tr>
+ <tr>
+ <th>City:</th>
+ <td>{{ident.city}}</td>
+ </tr>
+ <tr>
+ <th>State:</th>
+ <td>{{ident.state}}</td>
+ </tr>
+ <tr>
+ <th>Zip Code:</th>
+ <td>{{ident.zip_code}}</td>
</tr>
</table>
</div>
</div>
-
-
-
-
-
+{% else %}
<div class="row">
- <div class="col s6 left-align">
- <a href="{% url 'driver_detail' object.id %}?date={{week_dates.previous_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
- </div>
- <div class="col s6 right-align">
- <a href="{% url 'driver_detail' object.id %}?date={{week_dates.next_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons right">arrow_forward</i> Next</a>
+ <div class="col s12">
+ <div class="right-align">
+ <a class="btn green" href="{% url 'identity_create' object.pk %}">Create New Identity</a>
</div>
+ </div>
</div>
-
-{% if stats.incomplete_loads > 0 %}
<div class="row">
- <div class="col s12 m8 offset-m2">
- <div class="card red z-depth-3">
- <div class="card-content black-text">
- <span class="card-title">
- Note: One or more loads has a 0 amount that needs attention
- </span>
- </div>
- </div>
+ <div class="col s12">
+ No Identity found.
</div>
</div>
{% endif %}
-{% if request.user.is_superuser %}
- {% load custom_tags %}
- {% listForCommaString "Customer,Amount,Description" as load_headers %}
- {% include "dispatch/generic_load_listing.html" %}
-{% endif %}
-
-<!--
-<div class="row">
- <div class="col s6 left-align">
- <a href="{% url 'driver_detail' object.id %}?date={{week_dates.previous_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
- </div>
- <div class="col s6 right-align">
- <a href="{% url 'driver_detail' object.id %}?date={{week_dates.next_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons right">arrow_forward</i> Next</a>
- </div>
-</div>
--->
-
{% endblock %}
diff --git a/app/dispatch/templates/dispatch/drivers/list.html b/app/dispatch/templates/dispatch/drivers/list.html
index 4153fe9..8b7508b 100644
--- a/app/dispatch/templates/dispatch/drivers/list.html
+++ b/app/dispatch/templates/dispatch/drivers/list.html
@@ -23,10 +23,8 @@
<td>{{ driver.last_name }}</td>
<td>{{ driver.email }}</td>
<td class="right-align">
- {% if user.is_superuser %}
- <a href="{% url 'driver_edit' driver.id %}" class="btn orange">Edit</a>
- {% endif %}
- <a href="{% url 'driver_detail' driver.id %}" class="btn blue">View</a>
+ <a href="{% url 'driver_details' driver.id %}" class="btn orange">Edit</a>
+ <a href="{% url 'driver_summary' driver.id %}" class="btn blue">View</a>
</td>
</tr>
{% empty %}
diff --git a/app/dispatch/templates/dispatch/drivers/summary.html b/app/dispatch/templates/dispatch/drivers/summary.html
new file mode 100644
index 0000000..d849e9d
--- /dev/null
+++ b/app/dispatch/templates/dispatch/drivers/summary.html
@@ -0,0 +1,115 @@
+{% extends 'dispatch/base.html' %}
+
+{% block title %}Details - {{ object.first_name }} {{ object.last_name }}{% endblock %}
+
+{% block content %}
+<div class="row">
+ <div class="col s12">
+ <h1>Summary for {{ object.first_name }} {{ object.last_name }}</h1>
+ <h2>Loads for {{week_dates.start_date|date:"l, F, d"}} to {{week_dates.end_date|date:"l, F, d"}}</h2>
+ </div>
+</div>
+
+<div class="row">
+ <div class="col s12">
+ <div class="right-align">
+ <a class="btn orange" href="{% url 'invoice_generate' object.pk%}?date={{week_dates.start_date|date:"m/d/Y"}}">Generate Invoice For Listing</a>
+ </div>
+ </div>
+</div>
+
+{% if not request.user.is_superuser %}
+<div class="row">
+ <div class="col s12">
+ <table>
+ <thead>
+ <tr>
+ <td>Date</td>
+ <td>Description</td>
+ <td>Total</td>
+ <td></td>
+ </tr>
+ </thead>
+ <tbody>
+ {% for load in loads_nosplit %}
+ <tr>
+ <td>{{load.date}}</td>
+ <td>{{load.description}}</td>
+ <td>{{load.amount}}</td>
+ <td class="right-align">
+ <a href="{% url 'load_detail' load.id %}" class="btn green">
+ View
+ </a>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+</div>
+{% endif %}
+
+<div class="row">
+ <div class="col s12">
+ <table>
+ <thead>
+ <tr>
+ <td>Number of Loads</td>
+ <td>Average Load cost</td>
+ <td>Total Load cost</td>
+ </tr>
+ </thead>
+ <tr>
+ <td>{{stats.count}}</td>
+ <td>${{stats.average|stringformat:".3f"}}</td>
+ <td>${{stats.sum}}</td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+
+
+
+
+<div class="row">
+ <div class="col s6 left-align">
+ <a href="{% url 'driver_summary' object.id %}?date={{week_dates.previous_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
+ </div>
+ <div class="col s6 right-align">
+ <a href="{% url 'driver_summary' object.id %}?date={{week_dates.next_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons right">arrow_forward</i> Next</a>
+ </div>
+</div>
+
+{% if stats.incomplete_loads > 0 %}
+<div class="row">
+ <div class="col s12 m8 offset-m2">
+ <div class="card red z-depth-3">
+ <div class="card-content black-text">
+ <span class="card-title">
+ Note: One or more loads has a 0 amount that needs attention
+ </span>
+ </div>
+ </div>
+ </div>
+</div>
+{% endif %}
+
+{% if request.user.is_superuser %}
+ {% load custom_tags %}
+ {% listForCommaString "Customer,Amount,Description" as load_headers %}
+ {% include "dispatch/generic_load_listing.html" %}
+{% endif %}
+
+<!--
+<div class="row">
+ <div class="col s6 left-align">
+ <a href="{% url 'driver_summary' object.id %}?date={{week_dates.previous_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
+ </div>
+ <div class="col s6 right-align">
+ <a href="{% url 'driver_summary' object.id %}?date={{week_dates.next_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons right">arrow_forward</i> Next</a>
+ </div>
+</div>
+-->
+
+{% endblock %}
diff --git a/app/dispatch/templates/dispatch/generic_load_listing.html b/app/dispatch/templates/dispatch/generic_load_listing.html
index 7fb42f1..5512184 100644
--- a/app/dispatch/templates/dispatch/generic_load_listing.html
+++ b/app/dispatch/templates/dispatch/generic_load_listing.html
@@ -37,7 +37,7 @@
{% endif %}
{% endif %}
{% if "Driver" in load_headers %}
- <td><a href="{% url 'driver_detail' load.user.id %}">{{ load.user.first_name }} {{ load.user.last_name }}</a></td>
+ <td><a href="{% url 'driver_summary' load.user.id %}">{{ load.user.first_name }} {{ load.user.last_name }}</a></td>
{% endif %}
{% if "Amount" in load_headers %}
diff --git a/app/dispatch/templates/dispatch/identity/create.html b/app/dispatch/templates/dispatch/identity/create.html
new file mode 100644
index 0000000..90cdd8e
--- /dev/null
+++ b/app/dispatch/templates/dispatch/identity/create.html
@@ -0,0 +1,15 @@
+{% extends 'dispatch/base.html' %}
+
+
+{% block content %}
+<div class="row">
+ <div class="col s12 m6">
+ <h1>New Identity</h1>
+ </div>
+</div>
+
+<form action="" method="post">{% csrf_token %}
+ {{ form.as_p }}
+ <input type="submit" class="btn green" value="Save" />
+</form>
+{% endblock %}
diff --git a/app/dispatch/templates/dispatch/identity/detail.html b/app/dispatch/templates/dispatch/identity/detail.html
new file mode 100644
index 0000000..491c59e
--- /dev/null
+++ b/app/dispatch/templates/dispatch/identity/detail.html
@@ -0,0 +1,42 @@
+{% extends 'dispatch/base.html' %}
+
+{% block title %}Identity for {{object.user.username}}{% endblock %}
+
+{% block content %}
+<div class="row">
+ <div class="col s12 m6">
+ <h1>
+ Identity for {{object.user.username}}
+ </h1>
+ </div>
+</div>
+
+<div class="row">
+ <div class="col s12">
+ <table>
+ <tr>
+ <th>Name:</th>
+ <td>{{object.name}}</td>
+ </tr>
+ <tr>
+ <th>Address:</th>
+ <td>{{object.address}}</td>
+ </tr>
+ <tr>
+ <th>City:</th>
+ <td>{{object.city}}</td>
+ </tr>
+ <tr>
+ <th>State:</th>
+ <td>{{object.state}}</td>
+ </tr>
+ <tr>
+ <th>Zip Code:</th>
+ <td>{{object.zip_code}}</td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+{% endblock %}
+
diff --git a/app/dispatch/templates/dispatch/identity/edit.html b/app/dispatch/templates/dispatch/identity/edit.html
new file mode 100644
index 0000000..a48a8d1
--- /dev/null
+++ b/app/dispatch/templates/dispatch/identity/edit.html
@@ -0,0 +1,18 @@
+{% extends 'dispatch/base.html' %}
+
+{% block title %}Edit Identity for {{object.user.username}}{% endblock %}
+
+{% block content %}
+<div class="row">
+ <div class="col s12 m6">
+ <h1>
+ Identity for {{object.user.username}}
+ </h1>
+ </div>
+</div>
+
+<form action="" method="post">{% csrf_token %}
+ {{ form.as_p }}
+ <input type="submit" class="btn blue" value="Update" />
+</form>
+{% endblock %}
diff --git a/app/dispatch/templates/dispatch/loads/detail.html b/app/dispatch/templates/dispatch/loads/detail.html
index d8feea3..62a8b30 100644
--- a/app/dispatch/templates/dispatch/loads/detail.html
+++ b/app/dispatch/templates/dispatch/loads/detail.html
@@ -23,7 +23,7 @@
<tr>
<th>User</th>
- <td><a href="{% url 'driver_detail' object.user.id %}">{{object.user}}</a></td>
+ <td><a href="{% url 'driver_summary' object.user.id %}">{{object.user}}</a></td>
</tr>
<tr>
diff --git a/app/dispatch/templates/dispatch/nav.html b/app/dispatch/templates/dispatch/nav.html
index 532b2a9..a4fc8cb 100644
--- a/app/dispatch/templates/dispatch/nav.html
+++ b/app/dispatch/templates/dispatch/nav.html
@@ -5,8 +5,8 @@
<li><a href="{% url 'customer_list' %}">Customers</a></li>
<li><a href="{% url 'invoice_list' %}">Invoices</a></li>
{% else %}
- <li><a href="{% url 'driver_detail' request.user.id %}">Summary</a>
- <li><a href="{% url 'driver_edit' request.user.id %}">My Account</a></li>
+ <li><a href="{% url 'driver_summary' request.user.id %}">Summary</a>
+ <li><a href="{% url 'driver_details' request.user.id %}">My Account</a></li>
{% endif %}
<li><a href="{% url 'logout' %}">Logout</a></li>
{% else %}
diff --git a/app/dispatch/urls.py b/app/dispatch/urls.py
index 71f886a..9992489 100644
--- a/app/dispatch/urls.py
+++ b/app/dispatch/urls.py
@@ -11,9 +11,14 @@ urlpatterns = [
url(r'^logout/$', authviews.LogoutView.as_view(next_page='/'), name='logout'),
url(r'^drivers/$', views.DriverList.as_view(), name='driver_list'),
- url(r'^drivers/view/(?P<pk>\d+)$', views.DriverDetail.as_view(), name='driver_detail'),
+ url(r'^drivers/summary/(?P<pk>\d+)$', views.DriverSummary.as_view(), name='driver_summary'),
+ url(r'^drivers/view/(?P<pk>\d+)$', views.DriverDetail.as_view(), name='driver_details'),
url(r'^drivers/edit/(?P<pk>\d+)$', views.DriverUpdate.as_view(), name='driver_edit'),
+ 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'^customers/$', views.CustomerList.as_view(), name='customer_list'),
url(r'^customers/new$', views.CustomerCreate.as_view(), name='customer_new'),
url(r'^customers/view/(?P<pk>\d+)$', views.CustomerDetail.as_view(), name='customer_detail'),
@@ -26,14 +31,12 @@ urlpatterns = [
url(r'^loads/edit/(?P<pk>\d+)$', views.LoadUpdate.as_view(), name='load_edit'),
url(r'^loads/delete/(?P<pk>\d+)$', views.LoadDelete.as_view(), name='load_delete'),
-
url(r'^loads/upload/(?P<load_id>\d+)$', views.PaperworkUpload, name='paperwork_upload'),
url(r'^loads/(?P<load_id>\d+)/paperwork/delete/(?P<pk>\d+)$', \
views.PaperworkDelete, name='paperwork_delete'),
url(r'^loads/(?P<load_id>\d+)/paperwork/dl/(?P<pk>\d+)$', \
views.PaperworkDownload, name='paperwork_download'),
-
url(r'^invoices/$', views.InvoiceList.as_view(), name='invoice_list'),
url(r'^invoices/view/(?P<pk>\d+)$', views.InvoiceDetail.as_view(), name='invoice_detail'),
# url(r'^invoices/edit/(?P<pk>\d+)$', views.InvoiceEdit.as_view(), name='invoice_edit'),
diff --git a/app/dispatch/views.py b/app/dispatch/views.py
index 32be26c..ac399f6 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
+from dispatch.models import Customer, Load, Paperwork, Invoice, Settings, Identity
from dispatch.forms import AddPaperworkForm
from django.contrib.auth.models import User
from django.contrib.auth.mixins import UserPassesTestMixin
@@ -72,7 +72,7 @@ class DriverList(UserPassesTestMixin, ListView):
def test_func(self):
return self.request.user.is_superuser
-class DriverDetail(UserPassesTestMixin, LoadDateSort):
+class DriverDetail(UserPassesTestMixin, DetailView):
template_name = "dispatch/drivers/detail.html"
model = User
@@ -85,6 +85,27 @@ class DriverDetail(UserPassesTestMixin, LoadDateSort):
# Shit gets fucky with super() really fast, but this seems to work
context = super(DriverDetail, self).get_context_data(**kwargs)
+ try:
+ context['ident'] = Identity.objects.get(user=self.get_object().pk)
+ except:
+ context['ident'] = None
+
+ return context
+
+
+class DriverSummary(UserPassesTestMixin, LoadDateSort):
+ template_name = "dispatch/drivers/summary.html"
+ model = User
+
+ def test_func(self):
+ # Seems a little hacky at first but it works!
+ return self.request.user.is_superuser or \
+ self.get_object().pk is self.request.user.id
+
+ def get_context_data(self, **kwargs):
+ # Shit gets fucky with super() really fast, but this seems to work
+ context = super(DriverSummary, self).get_context_data(**kwargs)
+
stats = {};
stats['count'], stats['average'], stats['sum'] = (0,0,0)
stats['incomplete_loads'] = 0
@@ -113,6 +134,13 @@ class DriverUpdate(UserPassesTestMixin, UpdateView):
success_url = reverse_lazy('driver_list')
fields = ['username', 'first_name','last_name','email','groups', 'is_active']
+ def get_context_data(self, **kwargs):
+ # Shit gets fucky with super() really fast, but this seems to work
+ context = super(DriverUpdate, self).get_context_data(**kwargs)
+
+
+ return context
+
def test_func(self):
# Seems a little hacky at first but it works!
return self.request.user.is_superuser or \
@@ -279,6 +307,33 @@ def PaperworkDownload(request, load_id, pk):
except Exception as e:
print(e)
+# 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}))
+
+class IdentityCreate(UserPassesTestMixin, CreateView):
+ template_name = "dispatch/identity/edit.html"
+ model = Identity
+ fields = ['user', 'name', 'address', 'city', 'state', 'zip_code']
+
+ def test_func(self):
+ return self.request.user.is_superuser or \
+ self.get_object().user.pk is self.request.user.pk
+
+class IdentityUpdate(UserPassesTestMixin, UpdateView):
+ template_name = "dispatch/identity/edit.html"
+ model = Identity
+ fields = ['user', 'name', 'address', 'city', 'state', 'zip_code']
+
+ def test_func(self):
+ return self.request.user.is_superuser or \
+ self.get_object().user.pk is self.request.user.pk
# Invoice
@@ -309,42 +364,11 @@ def InvoiceGenerateForDates(request, pk):
return redirect(reverse('invoice_list'))
-
-
-
-# class InvoiceEdit(UserPassesTestMixin, UpdateView):
-# template_name = "dispatch/invoice/edit.html"
-# model = Invoice
-# fields = ['invoice_date','due_date']
-#
-# def test_func(self):
-# # Seems a little hacky at first but it works!
-# return self.request.user.is_superuser or \
-# self.get_object().user.pk is self.request.user.pk
-#
-# class InvoiceCreate(CreateView):
-# template_name = "dispatch/invoice/create.html"
-# model = Invoice
-# fields = ['invoice_date', 'due_date']
-#
-# def get(self,request):
-# if request.user.is_superuser:
-# self.fields.insert(1,'user')
-# return super(LoadCreate, self).get(request)
-#
-# def form_valid(self, form):
-# if not self.request.user.is_superuser:
-# load = form.save(commit=False)
-# load.user = self.request.user
-# return super(LoadCreate, self).form_valid(form)
-
class InvoiceDelete(UserPassesTestMixin, DeleteView):
template_name = "dispatch/invoice/list.html"
model = Invoice
success_url = reverse_lazy('invoice_list')
def test_func(self):
- print (self.request.user.is_superuser)
- print(self.get_object().user.pk is self.request.user.pk)
return self.request.user.is_superuser or \
self.get_object().user.pk is self.request.user.pk