+ doc = storage.create_document(
+ name=form.cleaned_data['id'],
+ text=form.cleaned_data['text'],
+ )
+
+ return http.HttpResponseRedirect(reverse("wiki_editor", 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']
+
+ author = "%s <%s>" % (form.cleaned_data['author_name'], form.cleaned_data['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,
+ })