Started detail and edit views with slug field to Schedule

This commit is contained in:
Brian Rosner 2012-08-30 00:21:48 -06:00
parent 77dc781e0d
commit 0a4e626dfe
3 changed files with 41 additions and 0 deletions

View file

@ -7,6 +7,7 @@ from symposion.schedule.utils import InlineSet
class Schedule(models.Model):
section = models.OneToOneField(Section)
slug = models.SlugField(unique=True)
class Day(models.Model):

View file

@ -0,0 +1,9 @@
from django.conf.urls.defaults import url, patterns
urlpatterns = patterns("symposion.schedule.views",
url(r"^$", "schedule_detail", name="schedule_detail_singleton"),
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"),
)

View file

@ -0,0 +1,31 @@
from django.shortcuts import render, get_object_or_404
from symposion.schedule.models import Schedule
def schedule_detail(request, slug=None):
qs = Schedule.objects.all()
if pk is None:
schedule = next(iter(qs), None)
if schedule is None:
raise Http404()
else:
schedule = get_object_or_404(qs, slug=slug)
ctx = {
"schedule": schedule,
}
return render(request, "schedule/schedule_detail.html")
def schedule_edit(request, slug=None):
qs = Schedule.objects.all()
if pk is None:
schedule = next(iter(qs), None)
if schedule is None:
raise Http404()
else:
schedule = get_object_or_404(qs, slug=slug)
ctx = {
"schedule": schedule,
}
return render(request, "schedule/schedule_edit.html")