Makes form_type *properly* optional

This commit is contained in:
Christopher Neugebauer 2016-09-02 10:30:12 +10:00
parent f1c8e90b77
commit 499c4209cf
2 changed files with 6 additions and 6 deletions

View file

@ -43,16 +43,16 @@ class Report(object):
return self._data return self._data
def report_view(title, form_type): def report_view(title, form_type=None):
''' Decorator that converts a report view function into something that ''' Decorator that converts a report view function into something that
displays a Report. displays a Report.
Arguments: Arguments:
title (str): title (str):
The title of the report. The title of the report.
form_type (forms.Form or None): form_type (Optional[forms.Form]):
A form class that can make this report display things. If None, A form class that can make this report display things. If not
no form will be displayed. supplied, no form will be displayed.
''' '''

View file

@ -46,7 +46,7 @@ def reports_list(request):
# Report functions # Report functions
@report_view("Paid items", forms.ProductAndCategoryForm) @report_view("Paid items", form_type=forms.ProductAndCategoryForm)
def items_sold(request, form): def items_sold(request, form):
''' Summarises the items sold and discounts granted for a given set of ''' Summarises the items sold and discounts granted for a given set of
products, or products from categories. ''' products, or products from categories. '''
@ -92,7 +92,7 @@ def items_sold(request, form):
return Report("Paid items", headings, data) return Report("Paid items", headings, data)
@report_view("Inventory", forms.ProductAndCategoryForm) @report_view("Inventory", form_type=forms.ProductAndCategoryForm)
def inventory(request, form): def inventory(request, form):
''' Summarises the inventory status of the given items, grouping by ''' Summarises the inventory status of the given items, grouping by
invoice status. ''' invoice status. '''