From f7326eedf7c1a0e1eae6df71a71573e7069bfa60 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Tue, 13 Sep 2016 16:24:50 +1000 Subject: [PATCH] Makes as many reports under attendee() as possible a QuerysetReport --- registrasion/reporting/views.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/registrasion/reporting/views.py b/registrasion/reporting/views.py index 0ea7a1f6..8e648505 100644 --- a/registrasion/reporting/views.py +++ b/registrasion/reporting/views.py @@ -303,6 +303,7 @@ def attendee(request, form, user_id=None): 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, @@ -313,32 +314,24 @@ def attendee(request, form, user_id=None): ) # Credit Notes - headings = ["Note ID", "Status", "Value"] - data = [] - credit_notes = commerce.CreditNote.objects.filter( invoice__user=attendee.user, ) - for credit_note in credit_notes: - data.append([ - credit_note.id, credit_note.status, credit_note.value, - ]) - - reports.append( - ListReport("Credit Notes", headings, data, link_view=views.credit_note) - ) + reports.append(QuerysetReport( + "Credit Notes", + ["Note ID", "Status", "Value"], + ["id", "status", "value"], + credit_notes, + link_view=views.credit_note, + )) # All payments - headings = ["To Invoice", "Payment ID", "Reference", "Amount"] - data = [] - payments = commerce.PaymentBase.objects.filter( invoice__user=attendee.user, ) - reports.append(QuerysetReport( "Payments", - headings, + ["To Invoice", "Payment ID", "Reference", "Amount"], ["invoice__id", "id", "reference", "amount"], payments, link_view=views.invoice,