add view for editing slots
This commit is contained in:
		
							parent
							
								
									39d0faac7c
								
							
						
					
					
						commit
						db908372ff
					
				
					 2 changed files with 17 additions and 2 deletions
				
			
		|  | @ -6,4 +6,5 @@ urlpatterns = patterns("symposion.schedule.views", | ||||||
|     url(r"^edit/$", "schedule_edit", name="schedule_edit_singleton"), |     url(r"^edit/$", "schedule_edit", name="schedule_edit_singleton"), | ||||||
|     url(r"^(\w+)/edit/$", "schedule_detail", name="schedule_detail"), |     url(r"^(\w+)/edit/$", "schedule_detail", name="schedule_detail"), | ||||||
|     url(r"^(\w+)/edit/$", "schedule_edit", name="schedule_edit"), |     url(r"^(\w+)/edit/$", "schedule_edit", name="schedule_edit"), | ||||||
|  |     url(r"^edit/slot/(?P<slot_pk>\d+)/", "schedule_slot_edit", name="schedule_slot_edit"), | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -1,7 +1,8 @@ | ||||||
| from django.http import Http404 | from django.http import Http404 | ||||||
| from django.shortcuts import render, get_object_or_404 | from django.shortcuts import render, get_object_or_404, redirect | ||||||
| 
 | 
 | ||||||
| from symposion.schedule.models import Schedule, Day | from symposion.schedule.forms import SlotEditForm | ||||||
|  | from symposion.schedule.models import Schedule, Day, Slot | ||||||
| from symposion.schedule.timetable import TimeTable | from symposion.schedule.timetable import TimeTable | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -29,8 +30,21 @@ def schedule_edit(request, slug=None): | ||||||
|         schedule = get_object_or_404(qs, slug=slug) |         schedule = get_object_or_404(qs, slug=slug) | ||||||
|     days_qs = Day.objects.filter(schedule=schedule) |     days_qs = Day.objects.filter(schedule=schedule) | ||||||
|     days = [TimeTable(day) for day in days_qs] |     days = [TimeTable(day) for day in days_qs] | ||||||
|  |     form = SlotEditForm() | ||||||
|     ctx = { |     ctx = { | ||||||
|         "schedule": schedule, |         "schedule": schedule, | ||||||
|         "days": days, |         "days": days, | ||||||
|  |         "form": form, | ||||||
|     } |     } | ||||||
|     return render(request, "schedule/schedule_edit.html", ctx) |     return render(request, "schedule/schedule_edit.html", ctx) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def schedule_slot_edit(request, slot_pk): | ||||||
|  |     slot = get_object_or_404(Slot, pk=slot_pk) | ||||||
|  |     form = SlotEditForm(request.POST) | ||||||
|  |      | ||||||
|  |     if form.is_valid(): | ||||||
|  |         presentation = form.presentation | ||||||
|  |         presentation.slot = slot | ||||||
|  |         presentation.save() | ||||||
|  |     return redirect("schedule_edit") | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Luke Hatcher
						Luke Hatcher