1 from content.models import Document, Folder
2 from django.http import Http404, HttpResponse
3 from django.template import RequestContext, loader
5 def document_view(request, slug=None, folders=None):
6 if folders == None and slug == None:
12 folders = folders.split('/')
14 for folder in folders:
17 resfolder = Folder.objects.get(slug__exact=folder, parent__exact=resfolder)
19 resfolder = Folder.objects.get(slug__exact=folder, parent__isnull=True)
20 resfolder = resfolder.id
24 folder = Folder.objects.get(pk=resfolder)
30 doc = Document.objects.get(slug__exact=slug, islive__exact=True, folder__exact=folder)
33 folder = Folder.objects.get(slug__exact=slug, parent__exact=folder)
34 doc = Document.objects.get(slug__exact='index', islive__exact=True, folder__exact=folder)
39 doc = Document.objects.get(slug__exact=slug, islive__exact=True, folder__isnull=True)
42 folder = Folder.objects.get(slug__exact=slug, parent__isnull=True)
43 doc = Document.objects.get(slug__exact='index', islive__exact=True, folder__exact=folder)
46 template_name = "%s.html" %(doc.format,)
47 t = loader.get_template(template_name)
48 c = RequestContext(request,
50 "content" : doc.content,
53 return HttpResponse(t.render(c))