diff --git a/registrasion/reporting/reports.py b/registrasion/reporting/reports.py index d533ecf1..9ba63f06 100644 --- a/registrasion/reporting/reports.py +++ b/registrasion/reporting/reports.py @@ -118,11 +118,20 @@ class ListReport(BasicReport): class QuerysetReport(BasicReport): - def __init__(self, title, headings, attributes, queryset, link_view=None): + def __init__(self, title, attributes, queryset, headings=None, + link_view=None): super(QuerysetReport, self).__init__(title, headings, link_view=link_view) self._attributes = attributes self._queryset = queryset + def headings(self): + if self._headings is not None: + return self._headings + + return [ + " ".join(i.split("_")).capitalize() for i in self._attributes + ] + def rows(self, content_type): def rgetattr(item, attr): diff --git a/registrasion/reporting/views.py b/registrasion/reporting/views.py index 0149c987..bb89ae1a 100644 --- a/registrasion/reporting/views.py +++ b/registrasion/reporting/views.py @@ -290,9 +290,9 @@ def attendee(request, form, user_id=None): ) reports.append(QuerysetReport( "Invoices", - ["Invoice ID", "Status", "Value"], ["id", "get_status_display", "value"], invoices, + headings=["Invoice ID", "Status", "Value"], link_view=views.invoice, )) @@ -302,7 +302,6 @@ def attendee(request, form, user_id=None): ) reports.append(QuerysetReport( "Credit Notes", - ["Note ID", "Status", "Value"], ["id", "status", "value"], credit_notes, link_view=views.credit_note, @@ -314,7 +313,6 @@ def attendee(request, form, user_id=None): ) reports.append(QuerysetReport( "Payments", - ["To Invoice", "Payment ID", "Reference", "Amount"], ["invoice__id", "id", "reference", "amount"], payments, link_view=views.invoice,