From: Jan Szejko Date: Wed, 29 Nov 2017 15:47:15 +0000 (+0100) Subject: update for new curriculi X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/bab0a9769a853e7b7d6368e293838be1bef4a8f6 update for new curriculi --- diff --git a/curriculum/migrations/0015_auto__chg_field_curriculum_title.py b/curriculum/migrations/0015_auto__chg_field_curriculum_title.py new file mode 100644 index 0000000..3100293 --- /dev/null +++ b/curriculum/migrations/0015_auto__chg_field_curriculum_title.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Changing field 'Curriculum.title' + db.alter_column(u'curriculum_curriculum', 'title', self.gf('django.db.models.fields.CharField')(max_length=1024)) + + def backwards(self, orm): + + # Changing field 'Curriculum.title' + db.alter_column(u'curriculum_curriculum', 'title', self.gf('django.db.models.fields.CharField')(max_length=255)) + + models = { + u'curriculum.competence': { + 'Meta': {'ordering': "['section', 'order']", 'object_name': 'Competence'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name_en': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), + 'name_pl': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), + 'order': ('django.db.models.fields.IntegerField', [], {}), + 'section': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['curriculum.Section']"}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}) + }, + u'curriculum.competencelevel': { + 'Meta': {'ordering': "['competence', 'level']", 'object_name': 'CompetenceLevel'}, + 'competence': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['curriculum.Competence']"}), + 'description_en': ('django.db.models.fields.TextField', [], {'default': "''"}), + 'description_pl': ('django.db.models.fields.TextField', [], {'default': "''"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'level': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['curriculum.Level']"}) + }, + u'curriculum.curriculum': { + 'Meta': {'ordering': "['identifier']", 'object_name': 'Curriculum'}, + 'course': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['curriculum.CurriculumCourse']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'identifier': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}), + 'level': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['curriculum.CurriculumLevel']"}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024'}), + 'type': ('django.db.models.fields.CharField', [], {'max_length': '16'}) + }, + u'curriculum.curriculumcourse': { + 'Meta': {'ordering': "['slug']", 'object_name': 'CurriculumCourse'}, + 'accusative': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'curriculum.curriculumlevel': { + 'Meta': {'object_name': 'CurriculumLevel'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_index': 'True'}) + }, + u'curriculum.level': { + 'Meta': {'ordering': "['order']", 'object_name': 'Level'}, + 'group_en': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), + 'group_pl': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'meta_name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + 'name_en': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), + 'name_pl': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), + 'order': ('django.db.models.fields.IntegerField', [], {}), + 'package': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'slug': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + 'student_package': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}) + }, + u'curriculum.section': { + 'Meta': {'ordering': "['order']", 'object_name': 'Section'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name_en': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), + 'name_pl': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), + 'order': ('django.db.models.fields.IntegerField', [], {}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}) + } + } + + complete_apps = ['curriculum'] \ No newline at end of file diff --git a/curriculum/models.py b/curriculum/models.py index 314fa1f..3a069dd 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() @@ -190,10 +191,10 @@ 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, unique=True) - title = models.CharField(max_length=255) + title = models.CharField(max_length=1024) course = models.ForeignKey(CurriculumCourse) level = models.ForeignKey(CurriculumLevel) type = models.CharField(max_length=16, choices=TYPES.items()) @@ -213,9 +214,9 @@ 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() + 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,