From 4c9f426a472cd55e10c58ea5879c9f80eb65a921 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Tue, 13 Sep 2016 16:26:40 +1000 Subject: [PATCH] Simplifies a bunch of older reports. --- registrasion/reporting/views.py | 36 +++++++++++---------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/registrasion/reporting/views.py b/registrasion/reporting/views.py index 8e648505..934705ce 100644 --- a/registrasion/reporting/views.py +++ b/registrasion/reporting/views.py @@ -271,39 +271,27 @@ def attendee(request, form, user_id=None): )) reports.append(Links("Actions for " + name, links)) + # Paid and pending products ic = ItemController(attendee.user) - # Paid products - headings = ["Product", "Quantity"] - data = [] - - for pq in ic.items_purchased(): - data.append([ - pq.product, - pq.quantity, - ]) - - reports.append(ListReport("Paid Products", headings, data)) - - # Unpaid products - headings = ["Product", "Quantity"] - data = [] - - for pq in ic.items_pending(): - data.append([ - pq.product, - pq.quantity, - ]) - - reports.append(ListReport("Unpaid Products", headings, data)) + reports.append(ListReport( + "Paid Products", + ["Product", "Quantity"], + [(pq.product, pq.quantity) for pq in ic.items_purchased()], + )) + reports.append(ListReport( + "Unpaid Products", + ["Product", "Quantity"], + [(pq.product, pq.quantity) for pq in ic.items_pending()], + )) # Invoices + # TODO make this a querysetreport headings = ["Invoice ID", "Status", "Value"] data = [] invoices = commerce.Invoice.objects.filter( user=attendee.user, ) - # TODO make this a querysetreport for invoice in invoices: data.append([ invoice.id, invoice.get_status_display(), invoice.value,