Show roll totals in individual order headings
This commit is contained in:
1 parent
b281f0f188
commit
cdc953e9ae
3 files changed
+12
-10
No files matched your search
@@ -141,14 +141,16 @@ class SharedOrderTests(CatalogTestCase):
|
||||
self.client.post("/bestellung/hinzufuegen/", self.selection(self.refill, 4))
|
||||
response = self.client.get("/bestellung/")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
groups = dict(response.context["groups"])
|
||||
self.assertEqual(
|
||||
{name: {e.variant_id: e.quantity for e in entries} for name, entries in groups.items()},
|
||||
{
|
||||
username: {entry.variant_id: entry.quantity for entry in entries}
|
||||
for username, entries, _ in response.context["groups"]
|
||||
},
|
||||
{"michael": {self.spool.pk: 2}, "person-zwei": {self.spool.pk: 1, self.refill.pk: 4}},
|
||||
)
|
||||
self.assertContains(response, 'class="order-table"', count=2)
|
||||
self.assertContains(response, "Bestellwunsch · michael")
|
||||
self.assertContains(response, "Bestellwunsch · person-zwei")
|
||||
self.assertContains(response, "Bestellwunsch · michael · ×2")
|
||||
self.assertContains(response, "Bestellwunsch · person-zwei · ×5")
|
||||
self.assertContains(response, "Mit Spule")
|
||||
self.assertContains(response, "Refill (ohne Spule)")
|
||||
self.assertEqual(response.context["total"], 7)
|
||||
|
||||
+4
-4
@@ -924,10 +924,10 @@ def orders(request):
|
||||
"pk",
|
||||
)
|
||||
)
|
||||
groups = [
|
||||
(username, list(items))
|
||||
for username, items in groupby(entries, key=lambda e: e.owner.username)
|
||||
]
|
||||
groups = []
|
||||
for username, items in groupby(entries, key=lambda entry: entry.owner.username):
|
||||
positions = list(items)
|
||||
groups.append((username, positions, sum(position.quantity for position in positions)))
|
||||
return render(
|
||||
request,
|
||||
"filament/orders.html",
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<section class="stat"><span>Verschiedene Varianten</span><strong>{{ variant_count }}</strong></section>
|
||||
<section class="stat"><span>Personen mit Bestellwünschen</span><strong>{{ groups|length }}</strong></section>
|
||||
</div>
|
||||
{% for username, entries in groups %}
|
||||
{% for username, entries, roll_count in groups %}
|
||||
<section class="panel">
|
||||
<div class="panel-heading"><h2 id="order-person-{{ forloop.counter }}">Bestellwunsch · {{ username }}</h2></div>
|
||||
<div class="panel-heading"><h2 id="order-person-{{ forloop.counter }}">Bestellwunsch · {{ username }} · ×{{ roll_count }}</h2></div>
|
||||
<div class="table-wrap">
|
||||
<table class="order-table" aria-labelledby="order-person-{{ forloop.counter }}">
|
||||
<thead>
|
||||
|
||||
Reference in new issue
Block a user