4 logger = logging.getLogger("fnp.wiki")
6 from django.views.generic.simple import direct_to_template
7 from django.core.urlresolvers import reverse
8 from wiki.helpers import JSONResponse
9 from django import http
10 from django.shortcuts import get_object_or_404
11 from django.conf import settings
13 from wiki_img.models import ImageDocument
14 from wiki_img.forms import DocumentTextSaveForm
17 # Quick hack around caching problems, TODO: use ETags
19 from django.views.decorators.cache import never_cache
23 def editor(request, slug, template_name='wiki_img/document_details.html'):
24 doc = get_object_or_404(ImageDocument, slug=slug)
26 return direct_to_template(request, template_name, extra_context={
29 "text_save": DocumentTextSaveForm(prefix="textsave"),
31 'REDMINE_URL': settings.REDMINE_URL,
36 def text(request, slug):
37 if request.method == 'POST':
38 form = DocumentTextSaveForm(request.POST, prefix="textsave")
40 document = get_object_or_404(ImageDocument, slug=slug)
41 revision = form.cleaned_data['parent_revision']
43 comment = form.cleaned_data['comment']
45 if request.user.is_authenticated():
52 text=form.cleaned_data['text'],
58 'text': document.doc.materialize(),
59 'revision': document.doc.change_set.count(),
62 return JSONFormInvalid(form)
64 doc = get_object_or_404(ImageDocument, slug=slug)
66 'text': doc.doc.materialize(),
67 'revision': doc.doc.change_set.count()