From b89e1c4384485707316dae1cd3fe6f98e84dfa73 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Fri, 10 Mar 2017 12:42:09 +0100 Subject: [PATCH] translate stage name in document summary --- apps/catalogue/models/document.py | 4 ++++ apps/wiki/templates/wiki/bootstrap.html | 2 +- apps/wiki/views.py | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/catalogue/models/document.py b/apps/catalogue/models/document.py index 6d9cb732..21eb7774 100755 --- a/apps/catalogue/models/document.py +++ b/apps/catalogue/models/document.py @@ -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) diff --git a/apps/wiki/templates/wiki/bootstrap.html b/apps/wiki/templates/wiki/bootstrap.html index afc38dcc..24cf2e3d 100644 --- a/apps/wiki/templates/wiki/bootstrap.html +++ b/apps/wiki/templates/wiki/bootstrap.html @@ -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' %}'}, ] }, diff --git a/apps/wiki/views.py b/apps/wiki/views.py index 5128b569..e32d9755 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -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: -- 2.20.1