translate stage name in document summary
authorJan Szejko <janek37@gmail.com>
Fri, 10 Mar 2017 11:42:09 +0000 (12:42 +0100)
committerJan Szejko <janek37@gmail.com>
Fri, 10 Mar 2017 11:42:09 +0000 (12:42 +0100)
apps/catalogue/models/document.py
apps/wiki/templates/wiki/bootstrap.html
apps/wiki/views.py

index 6d9cb73..21eb777 100755 (executable)
@@ -10,6 +10,7 @@ from django.conf import settings
 from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
 from django.db import models
 from django.template.loader import render_to_string
+from django.utils.encoding import force_unicode
 from django.utils.translation import ugettext_lazy as _
 from dvcs.models import Ref
 from organizations.models import Organization
@@ -86,6 +87,9 @@ class Document(Ref):
             self.assigned_to = None
         self.save()
 
+    def stage_name(self):
+        return force_unicode(dict(STAGES)[self.stage]) if self.stage else None
+
     def get_plan(self):
         try:
             plan = self.plan_set.get(stage=self.stage)
index afc38dc..24cf2e3 100644 (file)
@@ -69,7 +69,7 @@
                     title: '{% trans 'Informations about lesson' %}',
                     properties: [
                         {name: 'version', label: '{% trans 'Version' %}'},
-                        {name: 'stage', label: '{% trans 'Stage' %}'},
+                        {name: 'stage_name', label: '{% trans 'Stage' %}'},
                         {name: 'assignment', label: '{% trans 'Assignment' %}'},
                     ]
                 },
index 5128b56..e32d975 100644 (file)
@@ -69,6 +69,7 @@ def editor(request, pk, template_name='wiki/bootstrap.html'):
             'version': len(history),
             'revision': revision.pk,
             'stage': doc.stage,
+            'stage_name': doc.stage_name(),
             'assignment': str(doc.assigned_to),
         }),
         'serialized_templates': json.dumps([
@@ -124,7 +125,8 @@ def text(request, doc_id):
             return JSONResponse({
                 'text': None,  # doc.materialize() if parent_revision != revision else None,
                 # 'version': revision,
-                # 'stage': doc.stage.name if doc.stage else None,
+                'stage': doc.stage,
+                'stage_name': doc.stage_name(),
                 'assignment': doc.assigned_to.username if doc.assigned_to else None
             })
         else: