Changeset - 12b665acb8c7
[Not reviewed]
0 2 0
Christopher Neugebauer - 8 years ago 2016-09-13 08:47:51
chrisjrn@gmail.com
DRYs QuerysetReport’s headers
2 files changed with 11 insertions and 4 deletions:
0 comments (0 inline, 0 general)
registrasion/reporting/reports.py
Show inline comments
...
 
@@ -119,9 +119,18 @@ 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):
 

	
registrasion/reporting/views.py
Show inline comments
...
 
@@ -291,7 +291,7 @@ 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,
 
    ))
...
 
@@ -303,5 +303,4 @@ def attendee(request, form, user_id=None):
 
    reports.append(QuerysetReport(
 
        "Credit Notes",
 
        ["Note ID", "Status", "Value"],
 
        ["id", "status", "value"],
 
        credit_notes,
...
 
@@ -315,5 +314,4 @@ def attendee(request, form, user_id=None):
 
    reports.append(QuerysetReport(
 
        "Payments",
 
        ["To Invoice", "Payment ID", "Reference", "Amount"],
 
        ["invoice__id", "id", "reference", "amount"],
 
        payments,
0 comments (0 inline, 0 general)