Allows for callable attributes to be specified in QuerysetReports.
This commit is contained in:
parent
4c9f426a47
commit
bbce369a38
2 changed files with 14 additions and 13 deletions
|
@ -128,6 +128,13 @@ class QuerysetReport(BasicReport):
|
||||||
def rgetattr(item, attr):
|
def rgetattr(item, attr):
|
||||||
for i in attr.split("__"):
|
for i in attr.split("__"):
|
||||||
item = getattr(item, i)
|
item = getattr(item, i)
|
||||||
|
|
||||||
|
if callable(item):
|
||||||
|
try:
|
||||||
|
return item()
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
return item
|
return item
|
||||||
|
|
||||||
for row in self._queryset:
|
for row in self._queryset:
|
||||||
|
|
|
@ -285,21 +285,16 @@ def attendee(request, form, user_id=None):
|
||||||
))
|
))
|
||||||
|
|
||||||
# Invoices
|
# Invoices
|
||||||
# TODO make this a querysetreport
|
|
||||||
headings = ["Invoice ID", "Status", "Value"]
|
|
||||||
data = []
|
|
||||||
|
|
||||||
invoices = commerce.Invoice.objects.filter(
|
invoices = commerce.Invoice.objects.filter(
|
||||||
user=attendee.user,
|
user=attendee.user,
|
||||||
)
|
)
|
||||||
for invoice in invoices:
|
reports.append(QuerysetReport(
|
||||||
data.append([
|
"Invoices",
|
||||||
invoice.id, invoice.get_status_display(), invoice.value,
|
["Invoice ID", "Status", "Value"],
|
||||||
])
|
["id", "get_status_display", "value"],
|
||||||
|
invoices,
|
||||||
reports.append(
|
link_view=views.invoice,
|
||||||
ListReport("Invoices", headings, data, link_view=views.invoice)
|
))
|
||||||
)
|
|
||||||
|
|
||||||
# Credit Notes
|
# Credit Notes
|
||||||
credit_notes = commerce.CreditNote.objects.filter(
|
credit_notes = commerce.CreditNote.objects.filter(
|
||||||
|
@ -325,7 +320,6 @@ def attendee(request, form, user_id=None):
|
||||||
link_view=views.invoice,
|
link_view=views.invoice,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
return reports
|
return reports
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue