Show roll totals in individual order headings

This commit is contained in:
Mikei386 committed 2026-11-26 22:33:58 +01:00
1 parent b281f0f188
commit cdc953e9ae
3 files changed
+12 -10

No files matched your search

+6 -4
View File
@@ -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
View File
@@ -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",