-def document_text(request, name):
- storage = getstorage()
- document = storage.get_or_404(name)
-
- if request.method == 'POST':
- form = DocumentTextSaveForm(request.POST)
-
- if form.is_valid():
- revision = form.cleaned_data['parent_revision']
- document.text = form.cleaned_data['text']
-
- storage.put(document,
- author = form.cleaned_data['author'] or request.user.username,
- comment = form.cleaned_data['comment'],
- parent = revision
- )
-
+@decorator_from_middleware(GZipMiddleware)
+def text(request, doc_id):
+ doc = get_object_or_404(Document, pk=doc_id, deleted=False)
+ # if not doc.book.accessible(request):
+ # return HttpResponseForbidden("Not authorized.")
+
+ if request.method == 'POST':
+ form = forms.DocumentTextSaveForm(request.POST, user=request.user, prefix="textsave")
+ if form.is_valid():
+ if request.user.is_authenticated():
+ author = request.user
+ else:
+ author = None
+ text = form.cleaned_data['text']
+ # parent_revision = form.cleaned_data['parent_revision']
+ # if parent_revision is not None:
+ # parent = doc.at_revision(parent_revision)
+ # else:
+ # parent = None
+ stage = form.cleaned_data['stage']
+ # tags = [stage] if stage else []
+ # publishable = (form.cleaned_data['publishable'] and
+ # request.user.has_perm('catalogue.can_pubmark'))
+ try:
+ doc.commit(
+ author=author,
+ text=text,
+ description=form.cleaned_data['comment'],
+ author_name=form.cleaned_data['author_name'],
+ author_email=form.cleaned_data['author_email'],
+ )
+ doc.set_stage(stage)
+ except:
+ from traceback import print_exc
+ print_exc()
+ raise
+ # revision = doc.revision()