diff --git a/registrasion/reporting/reports.py b/registrasion/reporting/reports.py index 1061a903..d533ecf1 100644 --- a/registrasion/reporting/reports.py +++ b/registrasion/reporting/reports.py @@ -128,6 +128,13 @@ class QuerysetReport(BasicReport): def rgetattr(item, attr): for i in attr.split("__"): item = getattr(item, i) + + if callable(item): + try: + return item() + except TypeError: + pass + return item for row in self._queryset: diff --git a/registrasion/reporting/views.py b/registrasion/reporting/views.py index 934705ce..0149c987 100644 --- a/registrasion/reporting/views.py +++ b/registrasion/reporting/views.py @@ -285,21 +285,16 @@ def attendee(request, form, user_id=None): )) # Invoices - # TODO make this a querysetreport - headings = ["Invoice ID", "Status", "Value"] - data = [] - invoices = commerce.Invoice.objects.filter( user=attendee.user, ) - for invoice in invoices: - data.append([ - invoice.id, invoice.get_status_display(), invoice.value, - ]) - - reports.append( - ListReport("Invoices", headings, data, link_view=views.invoice) - ) + reports.append(QuerysetReport( + "Invoices", + ["Invoice ID", "Status", "Value"], + ["id", "get_status_display", "value"], + invoices, + link_view=views.invoice, + )) # Credit Notes credit_notes = commerce.CreditNote.objects.filter( @@ -325,7 +320,6 @@ def attendee(request, form, user_id=None): link_view=views.invoice, )) - return reports