From 94e3d1b327655f92b3ea314cc581c707728e1acd Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 7 Jun 2018 15:54:35 +0200 Subject: [PATCH 1/1] verbose curriculum levels in model --- curriculum/models.py | 5 +++++ curriculum/templates/curriculum/snippets/curriculum.html | 2 +- curriculum/templatetags/curriculum_tags.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/curriculum/models.py b/curriculum/models.py index 3a069dd..0c3acb2 100644 --- a/curriculum/models.py +++ b/curriculum/models.py @@ -166,6 +166,7 @@ add_translatable(CompetenceLevel, { class CurriculumLevel(models.Model): title = models.CharField(max_length=16, db_index=True) + verbose = models.CharField(max_length=32) class Meta: verbose_name = _("curriculum level") @@ -214,6 +215,8 @@ class Curriculum(models.Model): assert m is not None, "Curriculum identifier doesn't match template." level, created = CurriculumLevel.objects.get_or_create( title=m.group('level')) + if created: + print 'created level:', m.group('level') def_title = m.group('course').capitalize() course, created = CurriculumCourse.objects.get_or_create( slug=slugify(m.group('course')), @@ -221,6 +224,8 @@ class Curriculum(models.Model): 'title': def_title, 'accusative': def_title, }) + if created: + print 'created course:', slugify(m.group('course')), def_title type_ = m.group('type') if m.group('roz'): title += " (zakres rozszerzony)" diff --git a/curriculum/templates/curriculum/snippets/curriculum.html b/curriculum/templates/curriculum/snippets/curriculum.html index 467c3f3..a499a88 100755 --- a/curriculum/templates/curriculum/snippets/curriculum.html +++ b/curriculum/templates/curriculum/snippets/curriculum.html @@ -1,7 +1,7 @@ {% if currset %} {% for what, types in currset.items %}
  • - {{ what.0 }}, {{ what.1 }} {% if new %}klasa{% else %}poziom edukacyjny{% endif %}
    + {{ what.0 }}, {{ what.1 }}
    {% for type, currs in types.items %} {{ type }}:
    {% for curr in currs %} diff --git a/curriculum/templatetags/curriculum_tags.py b/curriculum/templatetags/curriculum_tags.py index f3e9279..9525aec 100755 --- a/curriculum/templatetags/curriculum_tags.py +++ b/curriculum/templatetags/curriculum_tags.py @@ -32,7 +32,7 @@ def curriculum(identifiers, new=False): currset = SortedDict() for curr in currs: - k = curr.course, curr.level + k = curr.course, curr.level.verbose if k not in currset: currset[k] = SortedDict() typename = Curriculum.TYPES[curr.type] -- 2.20.1