X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/739f5e011528ab0651f67be7e40daf8e48cb3764..3e1298ac6e8a17d42dfa56acc7e2e6e1d57d7a7e:/curriculum/models.py?ds=sidebyside diff --git a/curriculum/models.py b/curriculum/models.py index 1d77d4f..0c3acb2 100644 --- a/curriculum/models.py +++ b/curriculum/models.py @@ -5,6 +5,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _, get_language from fnpdjango.storage import BofhFileSystemStorage from fnpdjango.utils.models.translation import add_translatable +from fnpdjango.utils.text.slughifi import slughifi as slugify bofh_storage = BofhFileSystemStorage() @@ -118,6 +119,13 @@ class Level(models.Model): lesson.add_to_zip(zipf, student, prefix) # Add all appendix lessons, from all levels. for lesson in Lesson.objects.filter(type='appendix'): + # ugly fix + if self.slug in ('przedszkole', 'sp1-3', 'sp4-6'): + if lesson.slug == 'slowniczek': + continue + else: + if lesson.slug == 'slowniczek-sp': + continue prefix = '%s/' % lesson.slug lesson.add_to_zip(zipf, student, prefix) zipf.close() @@ -158,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") @@ -183,15 +192,16 @@ class CurriculumCourse(models.Model): class Curriculum(models.Model): """Official curriculum.""" - TYPES = {'c': u'Cele kształcenia', 't': u'Treści nauczania'} + TYPES = {'c': u'Cele kształcenia', 't': u'Treści nauczania', 'o': u'Osiągnięcia'} - identifier = models.CharField(max_length=255, db_index=True) - title = models.CharField(max_length=255) + identifier = models.CharField(max_length=255, db_index=True, unique=True) + title = models.CharField(max_length=1024) course = models.ForeignKey(CurriculumCourse) level = models.ForeignKey(CurriculumLevel) type = models.CharField(max_length=16, choices=TYPES.items()) class Meta: + ordering = ['identifier'] verbose_name = _("curriculum item") verbose_name_plural = _("curriculum items") @@ -205,13 +215,17 @@ 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')) - def_title = m.group('course').title() + if created: + print 'created level:', m.group('level') + def_title = m.group('course').capitalize() course, created = CurriculumCourse.objects.get_or_create( - slug=m.group('course').lower(), + slug=slugify(m.group('course')), defaults={ '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)"