add view for editing slots

This commit is contained in:
Luke Hatcher 2012-08-31 00:55:37 -04:00
parent 39d0faac7c
commit db908372ff
2 changed files with 17 additions and 2 deletions

View file

@ -6,4 +6,5 @@ urlpatterns = patterns("symposion.schedule.views",
url(r"^edit/$", "schedule_edit", name="schedule_edit_singleton"),
url(r"^(\w+)/edit/$", "schedule_detail", name="schedule_detail"),
url(r"^(\w+)/edit/$", "schedule_edit", name="schedule_edit"),
url(r"^edit/slot/(?P<slot_pk>\d+)/", "schedule_slot_edit", name="schedule_slot_edit"),
)

View file

@ -1,7 +1,8 @@
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
@ -29,8 +30,21 @@ def schedule_edit(request, slug=None):
schedule = get_object_or_404(qs, slug=slug)
days_qs = Day.objects.filter(schedule=schedule)
days = [TimeTable(day) for day in days_qs]
form = SlotEditForm()
ctx = {
"schedule": schedule,
"days": days,
"form": form,
}
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")