some book merging automation
[redakcja.git] / apps / dvcs / views.py
1 # Create your views here.
2 from django.views.generic.simple import direct_to_template
3 from django import http
4 from dvcs.models import Document
5
6 def document_list(request, template_name="dvcs/document_list.html"):
7     return direct_to_template(request, template_name, {
8         "documents": Document.objects.all(),
9     })
10
11 def document_data(request, document_id, version=None):
12     doc = Document.objects.get(pk=document_id)
13     return http.HttpResponse(doc.materialize(version or None), content_type="text/plain")
14
15 def document_history(request, docid, template_name="dvcs/document_history.html"):
16     document = Document.objects.get(pk=docid)
17     return direct_to_template(request, template_name, {
18         "document": document,
19         "changes": document.history(),
20     })
21