author = None
text = form.cleaned_data['text']
parent_revision = form.cleaned_data['parent_revision']
- parent = doc.at_revision(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 []
doc.commit(author=author,
try:
revision = int(revision)
except (ValueError, TypeError):
- revision = None
+ revision = doc.revision()
+
+ if revision is not None:
+ text = doc.at_revision(revision).materialize()
+ else:
+ text = ''
return JSONResponse({
- 'text': doc.at_revision(revision).materialize(),
+ 'text': text,
'meta': {},
- 'revision': revision if revision else doc.revision(),
+ 'revision': revision,
})
doc = Chunk.get(slug, chunk)
except (Chunk.MultipleObjectsReturned, Chunk.DoesNotExist):
raise Http404
- docA = doc.at_revision(revA).materialize()
+ # allow diff from the beginning
+ if revA:
+ docA = doc.at_revision(revA).materialize()
+ else:
+ docA = ""
docB = doc.at_revision(revB).materialize()
return http.HttpResponse(nice_diff.html_diff_table(docA.splitlines(),
publishable = form.cleaned_data['publishable']
change = doc.at_revision(revision)
if publishable != change.publishable:
- change.publishable = publishable
- change.save()
+ change.set_publishable(publishable)
return JSONResponse({"message": _("Revision marked")})
else:
return JSONResponse({"message": _("Nothing changed")})