diff --git a/src/pretix/control/templates/pretixcontrol/orders/index.html b/src/pretix/control/templates/pretixcontrol/orders/index.html
index b899a032b4..7adc418ad0 100644
--- a/src/pretix/control/templates/pretixcontrol/orders/index.html
+++ b/src/pretix/control/templates/pretixcontrol/orders/index.html
@@ -70,14 +70,17 @@
{% trans "User" %}
|
- {% trans "Order total" %}
-
- |
{% trans "Order date" %}
|
- {% trans "Status" %}
+ | {% trans "Order total" %}
+
+ |
+ {% trans "Positions" %}
+
+ |
+ {% trans "Status" %}
|
@@ -88,10 +91,16 @@
{{ o.code }} |
- {{ o.email }} |
- {{ o.total|floatformat:2 }} {{ request.event.currency }} |
+
+ {{ o.email }}
+ {% if o.invoice_address.name %}
+ {{ o.invoice_address.name }}
+ {% endif %}
+ |
{{ o.datetime|date:"SHORT_DATETIME_FORMAT" }} |
- {% include "pretixcontrol/orders/fragment_order_status.html" with order=o %} |
+ {{ o.total|floatformat:2 }} {{ request.event.currency }} |
+ {{ o.pcnt }} |
+ {% include "pretixcontrol/orders/fragment_order_status.html" with order=o %} |
{% endfor %}
diff --git a/src/pretix/control/templates/pretixcontrol/search/orders.html b/src/pretix/control/templates/pretixcontrol/search/orders.html
index 1dc7e8ef55..fb16361381 100644
--- a/src/pretix/control/templates/pretixcontrol/search/orders.html
+++ b/src/pretix/control/templates/pretixcontrol/search/orders.html
@@ -38,13 +38,16 @@
{% trans "User" %}
|
- {% trans "Order total" %}
-
- |
{% trans "Order date" %}
|
- {% trans "Status" %}
+ | {% trans "Order total" %}
+
+ |
+ {% trans "Positions" %}
+
+ |
+ {% trans "Status" %}
|
@@ -60,10 +63,16 @@
{{ o.event.name }} |
- {{ o.email }} |
- {{ o.total|floatformat:2 }} {{ o.event.currency }} |
+
+ {{ o.email }}
+ {% if o.invoice_address.name %}
+ {{ o.invoice_address.name }}
+ {% endif %}
+ |
{{ o.datetime|date:"SHORT_DATETIME_FORMAT" }} |
- {% include "pretixcontrol/orders/fragment_order_status.html" with order=o %} |
+ {{ o.total|floatformat:2 }} {{ o.event.currency }} |
+ {{ o.pcnt }} |
+ {% include "pretixcontrol/orders/fragment_order_status.html" with order=o %} |
{% empty %}
diff --git a/src/pretix/control/views/orders.py b/src/pretix/control/views/orders.py
index 419ec33b39..6fa00761f6 100644
--- a/src/pretix/control/views/orders.py
+++ b/src/pretix/control/views/orders.py
@@ -3,6 +3,7 @@ from datetime import timedelta
from django.conf import settings
from django.contrib import messages
from django.core.urlresolvers import reverse
+from django.db.models import Count
from django.http import FileResponse, Http404, HttpResponseNotAllowed
from django.shortcuts import redirect, render
from django.utils.functional import cached_property
@@ -49,13 +50,14 @@ class OrderList(EventPermissionRequiredMixin, ListView):
def get_queryset(self):
qs = Order.objects.filter(
event=self.request.event
- )
+ ).annotate(pcnt=Count('positions')).select_related('invoice_address')
if self.filter_form.is_valid():
qs = self.filter_form.filter_qs(qs)
if self.request.GET.get("ordering", "") != "":
p = self.request.GET.get("ordering", "")
- p_admissable = ('-code', 'code', '-email', 'email', '-total', 'total', '-datetime', 'datetime', '-status', 'status')
+ p_admissable = ('-code', 'code', '-email', 'email', '-total', 'total', '-datetime', 'datetime',
+ '-status', 'status', 'pcnt', '-pcnt')
if p in p_admissable:
qs = qs.order_by(p)
diff --git a/src/pretix/control/views/search.py b/src/pretix/control/views/search.py
index 1969e2da44..84b22c685b 100644
--- a/src/pretix/control/views/search.py
+++ b/src/pretix/control/views/search.py
@@ -1,4 +1,4 @@
-from django.db.models import Q
+from django.db.models import Count, Q
from django.utils.functional import cached_property
from django.views.generic import ListView
@@ -22,7 +22,7 @@ class OrderSearch(ListView):
return ctx
def get_queryset(self):
- qs = Order.objects.all()
+ qs = Order.objects.all().annotate(pcnt=Count('positions')).select_related('invoice_address')
if not self.request.user.is_superuser:
qs = qs.filter(
Q(event__organizer_id__in=self.request.user.teams.filter(
@@ -37,7 +37,7 @@ class OrderSearch(ListView):
if self.request.GET.get("ordering", "") != "":
p = self.request.GET.get("ordering", "")
p_admissable = ('event', '-event', '-code', 'code', '-email', 'email', '-total', 'total', '-datetime',
- 'datetime', '-status', 'status')
+ 'datetime', '-status', 'status', 'pcnt', '-pcnt')
if p in p_admissable:
qs = qs.order_by(p)