From 5bbd0193cf8415732900b79555504ace63cc794c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 8 Dec 2015 22:43:20 +0100 Subject: [PATCH] lingo: add a new manager page to list recent transactions (#9252) --- combo/apps/lingo/manager_views.py | 26 +++++-- combo/apps/lingo/models.py | 1 - .../lingo/templates/lingo/manager_base.html | 2 +- .../lingo/templates/lingo/manager_home.html | 9 +++ .../lingo/templates/lingo/regie_form.html | 2 +- .../lingo/templates/lingo/regie_list.html | 5 ++ .../templates/lingo/transaction_list.html | 74 +++++++++++++++++++ combo/apps/lingo/urls.py | 6 +- 8 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 combo/apps/lingo/templates/lingo/manager_home.html create mode 100644 combo/apps/lingo/templates/lingo/transaction_list.html diff --git a/combo/apps/lingo/manager_views.py b/combo/apps/lingo/manager_views.py index baaefb85..984f794c 100644 --- a/combo/apps/lingo/manager_views.py +++ b/combo/apps/lingo/manager_views.py @@ -15,9 +15,13 @@ # along with this program. If not, see . from django.core.urlresolvers import reverse_lazy -from django.views.generic import CreateView, UpdateView, ListView, DeleteView +from django.http import HttpResponseRedirect +from django.views.generic import (CreateView, UpdateView, ListView, + DeleteView, TemplateView) -from .models import Regie +import eopayment + +from .models import Regie, Transaction class RegieListView(ListView): model = Regie @@ -25,14 +29,26 @@ class RegieListView(ListView): class RegieCreateView(CreateView): model = Regie - success_url = reverse_lazy('lingo-manager-homepage') + success_url = reverse_lazy('lingo-manager-regie-list') class RegieUpdateView(UpdateView): model = Regie - success_url = reverse_lazy('lingo-manager-homepage') + success_url = reverse_lazy('lingo-manager-regie-list') class RegieDeleteView(DeleteView): model = Regie - success_url = reverse_lazy('lingo-manager-homepage') + success_url = reverse_lazy('lingo-manager-regie-list') + + +class TransactionListView(ListView): + model = Transaction + paginate_by = 10 + + def get_queryset(self): + return Transaction.objects.filter(status=eopayment.PAID).order_by('-start_date') + + +class ManagerHomeView(TemplateView): + template_name = 'lingo/manager_home.html' diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 47e4fb74..55794e59 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -220,7 +220,6 @@ class Transaction(models.Model): eopayment.CANCELLED: _('Cancelled'), }.get(self.status) or _('Unknown') - @register_cell_class class LingoBasketCell(CellBase): diff --git a/combo/apps/lingo/templates/lingo/manager_base.html b/combo/apps/lingo/templates/lingo/manager_base.html index 0792d470..c59e0267 100644 --- a/combo/apps/lingo/templates/lingo/manager_base.html +++ b/combo/apps/lingo/templates/lingo/manager_base.html @@ -2,7 +2,7 @@ {% load i18n %} {% block appbar %} -

{% trans 'Regies' %}

+

{% trans 'Online Payment' %}

{% endblock %} {% block breadcrumb %} diff --git a/combo/apps/lingo/templates/lingo/manager_home.html b/combo/apps/lingo/templates/lingo/manager_home.html new file mode 100644 index 00000000..d4671253 --- /dev/null +++ b/combo/apps/lingo/templates/lingo/manager_home.html @@ -0,0 +1,9 @@ +{% extends "lingo/manager_base.html" %} +{% load i18n %} + +{% block content %} + +{% endblock %} diff --git a/combo/apps/lingo/templates/lingo/regie_form.html b/combo/apps/lingo/templates/lingo/regie_form.html index 60b5fb21..5bb04c13 100644 --- a/combo/apps/lingo/templates/lingo/regie_form.html +++ b/combo/apps/lingo/templates/lingo/regie_form.html @@ -1,4 +1,4 @@ -{% extends "lingo/manager_base.html" %} +{% extends "lingo/regie_list.html" %} {% load i18n %} {% block appbar %} diff --git a/combo/apps/lingo/templates/lingo/regie_list.html b/combo/apps/lingo/templates/lingo/regie_list.html index 9a3e7205..11f9f963 100644 --- a/combo/apps/lingo/templates/lingo/regie_list.html +++ b/combo/apps/lingo/templates/lingo/regie_list.html @@ -6,6 +6,11 @@ {% trans 'New' %} {% endblock %} +{% block breadcrumb %} +{{ block.super }} +{% trans 'Regies' %} +{% endblock %} + {% block content %} {% if object_list %} diff --git a/combo/apps/lingo/templates/lingo/transaction_list.html b/combo/apps/lingo/templates/lingo/transaction_list.html new file mode 100644 index 00000000..f09adb8a --- /dev/null +++ b/combo/apps/lingo/templates/lingo/transaction_list.html @@ -0,0 +1,74 @@ +{% extends "lingo/manager_base.html" %} +{% load i18n %} + +{% block appbar %} +

{% trans 'Transactions' %}

+{% endblock %} + +{% block breadcrumb %} +{{ block.super }} +{% trans 'Transactions' %} +{% endblock %} + +{% block content %} + +{% if object_list %} + + + + + + + + + + + +{% for object in object_list %} + + + + + + {% for item in object.items.all %} + {% if not forloop.first %}{% endif %} + + {% endfor %} + {% if not object.items.all %}{% endif %} + {% endfor %} + +
{% trans 'Transaction Identifier' %}{% trans 'Date' %}{% trans 'User' %}{% trans 'Amount' %}{% trans 'Items' %}
{{object.order_id}}{{object.start_date}}{{object.user.first_name}} {{object.user.last_name}}{{object.amount}} €
{{item.subject}} {{item.amount}} €
+ +{% if is_paginated %} +

+ {% if page_obj.has_previous %} + << + {% else %} + << + {% endif %} + +   + + {{ page_obj.number }} / {{ page_obj.paginator.num_pages }} + +   + + {% if page_obj.has_next %} + >> + {% else %} + >> + {% endif %} + +{% endif %} + + + +{% else %} +

+ {% blocktrans %} + This site doesn't have any transaction yet. + {% endblocktrans %} +
+{% endif %} + +{% endblock %} diff --git a/combo/apps/lingo/urls.py b/combo/apps/lingo/urls.py index 82e89f6d..877c042f 100644 --- a/combo/apps/lingo/urls.py +++ b/combo/apps/lingo/urls.py @@ -21,10 +21,12 @@ from combo.urls_utils import decorated_includes, manager_required from .views import (RegiesApiView, AddBasketItemApiView, PayView, CallbackView, ReturnView, ItemDownloadView, ItemView) from .manager_views import (RegieListView, RegieCreateView, RegieUpdateView, - RegieDeleteView) + RegieDeleteView, TransactionListView, ManagerHomeView) lingo_manager_urls = patterns('lingo.manager_views', - url('^$', RegieListView.as_view(), name='lingo-manager-homepage'), + url('^$', ManagerHomeView.as_view(), name='lingo-manager-homepage'), + url('^transactions/$', TransactionListView.as_view(), name='lingo-manager-transactions-list'), + url('^regies/$', RegieListView.as_view(), name='lingo-manager-regie-list'), url('^regies/add/$', RegieCreateView.as_view(), name='lingo-manager-regie-add'), url('^regies/(?P\w+)/edit$', RegieUpdateView.as_view(), name='lingo-manager-regie-edit'),