diff options
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') |
