diff options
| author | Mitch Riedstra <Mitch@riedstra.us> | 2017-11-10 11:05:05 -0500 |
|---|---|---|
| committer | Mitch Riedstra <Mitch@riedstra.us> | 2017-11-10 11:05:05 -0500 |
| commit | c80bafec506beef3184381ae7f9b55edd438e45a (patch) | |
| tree | f4b635116fda59198d5c7eca664f917b6cc3a5e3 /app/dispatch/views.py | |
| parent | 33a6e5cb02189b7621a279c32c12b5c3d83ba680 (diff) | |
| download | dispatch-tracker-c80bafec506beef3184381ae7f9b55edd438e45a.tar.gz dispatch-tracker-c80bafec506beef3184381ae7f9b55edd438e45a.tar.xz | |
Fix typo in 'payment_identifier' Add pagination to Drivers, Customers and Invoices. Filter invoices by paid/unpaid.
Diffstat (limited to 'app/dispatch/views.py')
| -rw-r--r-- | app/dispatch/views.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/dispatch/views.py b/app/dispatch/views.py index b729922..62fc73f 100644 --- a/app/dispatch/views.py +++ b/app/dispatch/views.py @@ -81,6 +81,7 @@ class FilteredDeleteView(DeleteView): class DriverList(UserPassesTestMixin, ListView): template_name = "dispatch/drivers/list.html" model = User + paginate_by = 10 def test_func(self): return self.request.user.is_superuser @@ -214,6 +215,7 @@ class DriverUpdate(UserPassesTestMixin, UpdateView): class CustomerList(ListView): template_name = "dispatch/companies/list.html" model = Customer + paginate_by = 10 class CustomerCreate(UserPassesTestMixin, CreateView): @@ -535,7 +537,7 @@ class InvoiceEdit(UserPassesTestMixin, FilteredUpdateView): default_fields = [] superuser_fields = ['user', 'owner', 'bill_to', 'invoice_id', 'invoice_date', 'due_date', 'paid', - 'payment_identifer'] + 'payment_identifier'] def set_fields(self, user): if user.is_superuser: @@ -559,10 +561,19 @@ class InvoiceEdit(UserPassesTestMixin, FilteredUpdateView): class InvoiceList(FilteredListView): template_name = "dispatch/invoice/list.html" model = Invoice + paginate_by = 10 def get_queryset(self): # TODO: allow for a pagination base_qs = super(InvoiceList, self).get_queryset() + + # I don't really like this hack, but whatever + if self.request.GET.get('paid') == "1": + base_qs = base_qs.filter(paid=True) + else: + # Show the unpaid ones by default + base_qs = base_qs.filter(paid=False) + # Give me the newest ones first return base_qs.order_by('-pk') |
