- 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)
+ 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_completed']
+ tags = [stage] if stage else []
+ publishable = (form.cleaned_data['publishable'] and
+ request.user.has_perm('catalogue.can_pubmark'))
+ doc.commit(author=author,
+ text=text,
+ parent=parent,
+ description=form.cleaned_data['comment'],
+ tags=tags,
+ author_name=form.cleaned_data['author_name'],
+ author_email=form.cleaned_data['author_email'],
+ publishable=publishable,
+ )
+ revision = doc.revision()