From 39ce14804afd7b3fe051046a8ec15a45d9bc4655 Mon Sep 17 00:00:00 2001 From: Krophil Date: Sat, 2 Sep 2017 15:05:36 +0200 Subject: [PATCH] Add refillings list --- counter/templates/counter/counter_list.jinja | 6 ++-- .../templates/counter/refilling_list.jinja | 33 +++++++++++++++++++ counter/urls.py | 2 ++ counter/views.py | 20 +++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 counter/templates/counter/refilling_list.jinja diff --git a/counter/templates/counter/counter_list.jinja b/counter/templates/counter/counter_list.jinja index bc6144b2..b807a7d3 100644 --- a/counter/templates/counter/counter_list.jinja +++ b/counter/templates/counter/counter_list.jinja @@ -18,7 +18,8 @@ {% trans %}Stats{% endtrans %} - {% endif %} {% if user.is_owner(c) %} - {% trans %}Props{% endtrans %} + {% trans %}Props{% endtrans %} - + {% trans %}Refillings list{% endtrans %} {% endif %} {% endfor %} @@ -39,7 +40,8 @@ {% trans %}Create new stock{% endtrans%} - {% endif %} {% if user.is_owner(c) %} - {% trans %}Props{% endtrans %} + {% trans %}Props{% endtrans %} - + {% trans %}Refillings list{% endtrans %} {% endif %} {% endfor %} diff --git a/counter/templates/counter/refilling_list.jinja b/counter/templates/counter/refilling_list.jinja new file mode 100644 index 00000000..13ebcaf3 --- /dev/null +++ b/counter/templates/counter/refilling_list.jinja @@ -0,0 +1,33 @@ +{% extends "core/base.jinja" %} +{% from 'core/macros.jinja' import paginate %} + +{% block title %} +{%- trans %}Refilling list{% endtrans %} -- {{ counter.name }} +{% endblock %} + +{% block content %} +

{% trans %}Refilling{% endtrans %}

+ + + + + + + + + {%- for refilling in object_list %} + + + + + + + +
{% trans %}Customer{% endtrans %}{% trans %}Amount{% endtrans %}{% trans %}Payment method{% endtrans %}{% trans %}Seller{% endtrans %}{% trans %}Actions{% endtrans %}
{{ refilling.customer }}{{ refilling.amount }}{{ refilling.payment_method }}{{ refilling.operator }}Delete
+ + {%- endfor %} +{% if is_paginated %} + {{ paginate(page_obj, paginator) }} +{% endif %} +{%- endblock %} + diff --git a/counter/urls.py b/counter/urls.py index 5f939804..aaade292 100644 --- a/counter/urls.py +++ b/counter/urls.py @@ -56,6 +56,8 @@ urlpatterns = [ url(r'^admin/eticket/(?P[0-9]+)$', EticketEditView.as_view(), name='edit_eticket'), url(r'^admin/selling/(?P[0-9]+)/delete$', SellingDeleteView.as_view(), name='selling_delete'), url(r'^admin/refilling/(?P[0-9]+)/delete$', RefillingDeleteView.as_view(), name='refilling_delete'), + url(r'^admin/(?P[0-9]+)/refillings$', CounterRefillingListView.as_view(), name='refilling_list'), + ] diff --git a/counter/views.py b/counter/views.py index 9d4963f8..bc008d54 100644 --- a/counter/views.py +++ b/counter/views.py @@ -1280,3 +1280,23 @@ class EticketPDFView(CanViewMixin, DetailView): p.showPage() p.save() return response + + +class CounterRefillingListView(CounterAdminTabsMixin, CounterAdminMixin, ListView): + """ + List of refillings on a counter + """ + model = Refilling + template_name = 'counter/refilling_list.jinja' + current_tab = "counters" + paginate_by = 30 + + def dispatch(self, request, *args, **kwargs): + self.counter = get_object_or_404(Counter, pk=kwargs['counter_id']) + self.queryset = Refilling.objects.filter(counter__id=self.counter.id) + return super(CounterRefillingListView, self).dispatch(request, *args, **kwargs) + + def get_context_data(self, **kwargs): + kwargs = super(CounterRefillingListView, self).get_context_data(**kwargs) + kwargs['counter'] = self.counter + return kwargs