missing setting
[turniej.git] / apps / poetry / views.py
1 from django.shortcuts import render, get_object_or_404
2 from poetry.models import Poet, Poem
3
4
5 def new(request, slug=None):
6     if slug is not None:
7         poet = get_object_or_404(Poet, slug=slug)
8     else:
9         poet = Poet.objects.order_by('?')[0]
10
11     poem = poet.write()
12     return render(request, "poetry/poem.html", locals())
13
14
15 def poem(request, slug):
16     poem = get_object_or_404(Poem, slug=slug)
17     return render(request, "poetry/poem.html", locals())
18
19
20 def poet(request, slug):
21     poet = get_object_or_404(Poet, slug=slug)
22     last = poet.poem_set.order_by('-created_at')[:20]
23     return render(request, "poetry/poet.html", locals())
24
25
26 def main(request):
27     poets = Poet.objects.all().order_by('?')
28     last = Poem.objects.all().order_by('-created_at')[:20]
29     return render(request, "poetry/main.html", locals())