Makes form_type *properly* optional
This commit is contained in:
		
							parent
							
								
									f1c8e90b77
								
							
						
					
					
						commit
						499c4209cf
					
				
					 2 changed files with 6 additions and 6 deletions
				
			
		|  | @ -43,16 +43,16 @@ class Report(object): | |||
|         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 | ||||
|     displays a Report. | ||||
| 
 | ||||
|     Arguments: | ||||
|         title (str): | ||||
|             The title of the report. | ||||
|         form_type (forms.Form or None): | ||||
|             A form class that can make this report display things. If None, | ||||
|             no form will be displayed. | ||||
|         form_type (Optional[forms.Form]): | ||||
|             A form class that can make this report display things. If not | ||||
|             supplied, no form will be displayed. | ||||
| 
 | ||||
|     ''' | ||||
| 
 | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ def reports_list(request): | |||
| # Report functions | ||||
| 
 | ||||
| 
 | ||||
| @report_view("Paid items", forms.ProductAndCategoryForm) | ||||
| @report_view("Paid items", form_type=forms.ProductAndCategoryForm) | ||||
| def items_sold(request, form): | ||||
|     ''' Summarises the items sold and discounts granted for a given set of | ||||
|     products, or products from categories. ''' | ||||
|  | @ -92,7 +92,7 @@ def items_sold(request, form): | |||
|     return Report("Paid items", headings, data) | ||||
| 
 | ||||
| 
 | ||||
| @report_view("Inventory", forms.ProductAndCategoryForm) | ||||
| @report_view("Inventory", form_type=forms.ProductAndCategoryForm) | ||||
| def inventory(request, form): | ||||
|     ''' Summarises the inventory status of the given items, grouping by | ||||
|     invoice status. ''' | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer