update document summary on save/revert
authorJan Szejko <janek37@gmail.com>
Fri, 10 Mar 2017 12:38:05 +0000 (13:38 +0100)
committerJan Szejko <janek37@gmail.com>
Fri, 10 Mar 2017 12:38:05 +0000 (13:38 +0100)
apps/wiki/static/wiki/editor
apps/wiki/views.py

index 091b7b5..ab1445a 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 091b7b516be2b5c2053e2a9103f8a910efbad68a
+Subproject commit ab1445aee3c066a08d0602dd8b2e6996646d986f
index e32d975..461f110 100644 (file)
@@ -70,7 +70,7 @@ def editor(request, pk, template_name='wiki/bootstrap.html'):
             'revision': revision.pk,
             'stage': doc.stage,
             'stage_name': doc.stage_name(),
-            'assignment': str(doc.assigned_to),
+            'assignment': doc.assigned_to.username if doc.assigned_to else None,
         }),
         'serialized_templates': json.dumps([
             {'id': t.id, 'name': t.name, 'content': t.content} for t in Template.objects.filter(is_partial=True)
@@ -121,10 +121,9 @@ def text(request, doc_id):
                 from traceback import print_exc
                 print_exc()
                 raise
-            # revision = doc.revision()
             return JSONResponse({
                 'text': None,  # doc.materialize() if parent_revision != revision else None,
-                # 'version': revision,
+                'version': len(get_history(doc)),
                 'stage': doc.stage,
                 'stage_name': doc.stage_name(),
                 'assignment': doc.assigned_to.username if doc.assigned_to else None
@@ -179,8 +178,11 @@ def revert(request, doc_id):
         )
 
         return JSONResponse({
-            # 'document': None, #doc.materialize() if before != doc.revision else None,
-            # 'version': doc.revision(),
+            'document': doc.materialize(),
+            'version': len(get_history(doc)),
+            'stage': doc.stage,
+            'stage_name': doc.stage_name(),
+            'assignment': doc.assigned_to.username if doc.assigned_to else None,
         })
     else:
         return JSONFormInvalid(form)