Adds a tag to take the CSV version of a report
This commit is contained in:
		
							parent
							
								
									517da70536
								
							
						
					
					
						commit
						67ac01e599
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		|  | @ -4,6 +4,7 @@ from registrasion.controllers.item import ItemController | |||
| 
 | ||||
| from django import template | ||||
| from django.db.models import Sum | ||||
| from urllib import urlencode | ||||
| 
 | ||||
| register = template.Library() | ||||
| 
 | ||||
|  | @ -74,3 +75,14 @@ def items_purchased(context, category=None): | |||
|     return ItemController(context.request.user).items_purchased( | ||||
|         category=category | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| @register.assignment_tag(takes_context=True) | ||||
| def report_as_csv(context, section): | ||||
| 
 | ||||
|     query = dict(context.request.GET) | ||||
|     query["section"] = section | ||||
|     query["content_type"] = "text/csv" | ||||
|     querystring = urlencode(query) | ||||
| 
 | ||||
|     return context.request.path + "?" + querystring | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer