csv schedule export
This commit is contained in:
		
							parent
							
								
									7a8c560a1b
								
							
						
					
					
						commit
						b48d66fd9d
					
				
					 2 changed files with 24 additions and 1 deletions
				
			
		|  | @ -5,9 +5,11 @@ urlpatterns = patterns("symposion.schedule.views", | |||
|     url(r"^$", "schedule_detail", name="schedule_detail"), | ||||
|     url(r"^edit/$", "schedule_edit", name="schedule_edit"), | ||||
|     url(r"^list/$", "schedule_list", name="schedule_list"), | ||||
|     url(r"^presentations.csv$", "schedule_list_csv", name="schedule_list_csv"), | ||||
|     url(r"^presentation/(\d+)/$", "schedule_presentation_detail", name="schedule_presentation_detail"), | ||||
|     url(r"^(\w+)/$", "schedule_detail", name="schedule_detail"), | ||||
|     url(r"^(\w+)/edit/$", "schedule_edit", name="schedule_edit"), | ||||
|     url(r"^(\w+)/list/$", "schedule_list", name="schedule_list"), | ||||
|     url(r"^(\w+)/presentations.csv$", "schedule_list_csv", name="schedule_list_csv"), | ||||
|     url(r"^(\w+)/edit/slot/(\d+)/", "schedule_slot_edit", name="schedule_slot_edit"), | ||||
| ) | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| from django.core.exceptions import ObjectDoesNotExist | ||||
| from django.http import Http404 | ||||
| from django.http import Http404, HttpResponse | ||||
| from django.shortcuts import render, get_object_or_404, redirect | ||||
| from django.template import loader, Context | ||||
| 
 | ||||
| from django.contrib.auth.decorators import login_required | ||||
| 
 | ||||
|  | @ -50,6 +51,26 @@ def schedule_list(request, slug=None): | |||
|     return render(request, "schedule/schedule_list.html", ctx) | ||||
| 
 | ||||
| 
 | ||||
| def schedule_list_csv(request, slug=None): | ||||
|     schedule = fetch_schedule(slug) | ||||
|      | ||||
|     presentations = Presentation.objects.filter(section=schedule.section) | ||||
|     presentations = presentations.exclude(cancelled=True).order_by("id") | ||||
|      | ||||
|     response = HttpResponse(mimetype="text/csv") | ||||
|     if slug: | ||||
|         file_slug = slug | ||||
|     else: | ||||
|         file_slug = "presentations" | ||||
|     response["Content-Disposition"] = 'attachment; filename="%s.csv"' % file_slug | ||||
|      | ||||
|     response.write(loader.get_template("schedule/schedule_list.csv").render(Context({ | ||||
|         "presentations": presentations, | ||||
|          | ||||
|     }))) | ||||
|     return response | ||||
| 
 | ||||
| 
 | ||||
| @login_required | ||||
| def schedule_edit(request, slug=None): | ||||
|      | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 James Tauber
						James Tauber