+ doc = storage.create_document(
+ id=form.cleaned_data['id'],
+ text=form.cleaned_data['text'],
+ )
+
+ return http.HttpResponseRedirect(reverse("wiki_details", args=[doc.name]))
+ else:
+ form = DocumentCreateForm(initial={
+ "id": name.replace(" ", "_"),
+ "title": name.title(),
+ })
+
+ return direct_to_template(request, "wiki/document_create_missing.html", extra_context={
+ "document_name": name,
+ "form": form,
+ })
+
+
+@never_cache
+@normalized_name
+def text(request, name):
+ storage = getstorage()
+
+ if request.method == 'POST':
+ form = DocumentTextSaveForm(request.POST, prefix="textsave")
+ if form.is_valid():
+ revision = form.cleaned_data['parent_revision']
+ document = storage.get_or_404(name, revision)
+ document.text = form.cleaned_data['text']
+ comment = form.cleaned_data['comment']
+ if form.cleaned_data['stage_completed']:
+ comment += '\n#stage-finished: %s\n' % form.cleaned_data['stage_completed']
+ if request.user.is_authenticated():
+ author_name = request.user
+ author_email = request.user.email
+ else:
+ author_name = form.cleaned_data['author_name']
+ author_email = form.cleaned_data['author_email']
+ author = "%s <%s>" % (author_name, author_email)
+ storage.put(document, author=author, comment=comment, parent=revision)
+ document = storage.get(name)
+ return JSONResponse({
+ 'text': document.plain_text if revision != document.revision else None,
+ 'meta': document.meta(),
+ 'revision': document.revision,
+ })