2017-10-28 21:41:33 -04:00
|
|
|
from annoying.decorators import render_to
|
|
|
|
from django.shortcuts import redirect
|
2017-10-24 21:01:52 -04:00
|
|
|
from .models import Entry
|
|
|
|
|
|
|
|
|
2017-10-28 21:41:33 -04:00
|
|
|
@render_to('entries/index.html')
|
2017-10-24 21:01:52 -04:00
|
|
|
def index(request, kind):
|
|
|
|
entries = Entry.objects.filter(kind=kind.id)
|
2017-10-28 21:41:33 -04:00
|
|
|
return {'entries': entries, 'title': kind.plural}
|
2017-10-24 21:31:08 -04:00
|
|
|
|
|
|
|
|
2017-10-28 21:41:33 -04:00
|
|
|
@render_to('entries/entry.html')
|
2017-10-24 21:31:08 -04:00
|
|
|
def entry(request, id, slug=None):
|
|
|
|
entry = Entry.objects.get(pk=id)
|
2017-10-27 01:23:31 -04:00
|
|
|
if request.path != entry.url:
|
|
|
|
return redirect(entry.url, permanent=True)
|
2017-10-28 21:41:33 -04:00
|
|
|
return {
|
2017-10-24 21:31:08 -04:00
|
|
|
'entry': entry,
|
2017-10-27 02:45:38 -04:00
|
|
|
'title': entry.title,
|
2017-10-24 23:04:22 -04:00
|
|
|
'meta': entry.as_meta(request)
|
2017-10-28 21:41:33 -04:00
|
|
|
}
|