From 7be5331da576671f52f62c36a2ec153177fe0362 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 8 Mar 2019 12:50:25 +0100 Subject: [PATCH] Show ticket code in check-in list --- .../pretixcontrol/checkin/index.html | 4 +++ .../templates/pretixcontrol/orders/index.html | 26 ++++++++++++++++++- src/pretix/control/views/orders.py | 11 +++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/pretix/control/templates/pretixcontrol/checkin/index.html b/src/pretix/control/templates/pretixcontrol/checkin/index.html index 3daa4b0106..bbe96c09ef 100644 --- a/src/pretix/control/templates/pretixcontrol/checkin/index.html +++ b/src/pretix/control/templates/pretixcontrol/checkin/index.html @@ -70,6 +70,7 @@ {% trans "Name" %} + {% trans "Ticket code" %} {% trans "Status" %} {% trans "Timestamp" %} @@ -102,6 +103,9 @@ {{ e.attendee_name }} {% endif %} + + {{ e.secret|slice:":10" }}… + {% if not e.last_checked_in %} {% trans "Not checked in" %} diff --git a/src/pretix/control/templates/pretixcontrol/orders/index.html b/src/pretix/control/templates/pretixcontrol/orders/index.html index b481ad983b..1807c6d4c1 100644 --- a/src/pretix/control/templates/pretixcontrol/orders/index.html +++ b/src/pretix/control/templates/pretixcontrol/orders/index.html @@ -85,7 +85,7 @@

{% endif %}
- +
{% endfor %} + {% if sums %} + + + + + + + + + + + {% endif %}
{% trans "Order code" %} @@ -147,6 +147,30 @@
{% trans "Sum over all pages" %} + {% blocktrans trimmed count s=sums.c %} + 1 order + {% plural %} + {{ s }} orders + {% endblocktrans %} + + {{ sums.s|money:request.event.currency }} + + {% if sums.pc %} + {{ sums.pc }} + {% endif %} +
{% include "pretixcontrol/pagination.html" %} diff --git a/src/pretix/control/views/orders.py b/src/pretix/control/views/orders.py index 111fabf868..1b133cab47 100644 --- a/src/pretix/control/views/orders.py +++ b/src/pretix/control/views/orders.py @@ -13,7 +13,7 @@ from django.core.files import File from django.db import transaction from django.db.models import ( Count, IntegerField, OuterRef, ProtectedError, Q, Subquery, -) + Sum) from django.http import ( FileResponse, Http404, HttpResponseNotAllowed, JsonResponse, ) @@ -126,6 +126,15 @@ class OrderList(EventPermissionRequiredMixin, PaginationMixin, ListView): o.has_external_refund = annotated.get(o.pk)['has_external_refund'] o.has_pending_refund = annotated.get(o.pk)['has_pending_refund'] + if ctx['page_obj'].paginator.count < 1000: + # Performance safeguard: Only count positions if the data set is small + ctx['sums'] = self.get_queryset().annotate( + pcnt=Subquery(s, output_field=IntegerField()) + ).aggregate( + s=Sum('total'), pc=Sum('pcnt'), c=Count('id') + ) + else: + ctx['sums'] = self.get_queryset().aggregate(s=Sum('total'), c=Count('id')) return ctx @cached_property