From 9bf9cc0f9f109e9d95a9a535de5c26693ca9d9d4 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 21 Dec 2016 18:42:14 +0100 Subject: [PATCH] Do not group positions in control view --- .../templates/pretixcontrol/order/change.html | 1 + .../templates/pretixcontrol/order/index.html | 12 +++------ src/pretix/control/views/orders.py | 25 ++++++------------- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/pretix/control/templates/pretixcontrol/order/change.html b/src/pretix/control/templates/pretixcontrol/order/change.html index 4093d31250..f4549abf92 100644 --- a/src/pretix/control/templates/pretixcontrol/order/change.html +++ b/src/pretix/control/templates/pretixcontrol/order/change.html @@ -43,6 +43,7 @@

+ #{{ position.positionid }} – {{ position.item.name }} {% if position.variation %} – {{ position.variation }} diff --git a/src/pretix/control/templates/pretixcontrol/order/index.html b/src/pretix/control/templates/pretixcontrol/order/index.html index 5de945f011..21e8be8e59 100644 --- a/src/pretix/control/templates/pretixcontrol/order/index.html +++ b/src/pretix/control/templates/pretixcontrol/order/index.html @@ -158,8 +158,8 @@
{% for line in items.positions %}
-
- {{ line.positionid }} +
+ #{{ line.positionid }} – {{ line.item.name }} {% if line.variation %} – {{ line.variation }} @@ -185,14 +185,8 @@ {% endif %}
-
- {{ line.count }} -
- {{ event.currency }} {{ line.price|floatformat:2 }} -
-
- {{ event.currency }} {{ line.total|floatformat:2 }} + {{ event.currency }} {{ line.price|floatformat:2 }} {% if line.tax_rate %}
{% blocktrans trimmed with rate=line.tax_rate %} diff --git a/src/pretix/control/views/orders.py b/src/pretix/control/views/orders.py index af2d60b8ba..5edbceab3e 100644 --- a/src/pretix/control/views/orders.py +++ b/src/pretix/control/views/orders.py @@ -1,5 +1,4 @@ from datetime import timedelta -from itertools import groupby from django.contrib import messages from django.core.urlresolvers import reverse @@ -166,24 +165,14 @@ class OrderDetail(OrderView): 'item__questions', 'answers', 'answers__question' ) - # Group items of the same variation - # We do this by list manipulations instead of a GROUP BY query, as - # Django is unable to join related models in a .values() query - def keyfunc(pos): - if (pos.item.admission and self.request.event.settings.attendee_names_asked) \ - or pos.item.questions.all(): - return pos.id, 0, 0, 0, 0, 0 - return 0, pos.item_id, pos.variation_id, pos.price, pos.tax_rate, (pos.voucher_id or 0) - positions = [] - for k, g in groupby(sorted(list(cartpos), key=keyfunc), key=keyfunc): - g = list(g) - group = g[0] - group.count = len(g) - group.total = group.count * group.price - group.has_questions = k[0] != "" - group.cache_answers() - positions.append(group) + for p in cartpos: + p.has_questions = ( + (p.item.admission and self.request.event.settings.attendee_names_asked) or + p.item.questions.all() + ) + p.cache_answers() + positions.append(p) return { 'positions': positions,