From 10cfee815de7079c7120bc7101ab66b251a97f87 Mon Sep 17 00:00:00 2001 From: Tomas Gavenciak Date: Thu, 14 May 2015 16:02:00 +0200 Subject: [PATCH] Update modelu (poznamky, ...) a reset migraci (seminar) --- seminar/migrations/0001_initial.py | 55 +++++++++++++- seminar/migrations/0003_auto_20150511_0947.py | 71 ------------------- seminar/migrations/0004_auto_20150511_1215.py | 38 ---------- seminar/models.py | 22 ++++++ 4 files changed, 75 insertions(+), 111 deletions(-) delete mode 100644 seminar/migrations/0003_auto_20150511_0947.py delete mode 100644 seminar/migrations/0004_auto_20150511_1215.py diff --git a/seminar/migrations/0001_initial.py b/seminar/migrations/0001_initial.py index 5a78fa02..12a6b605 100644 --- a/seminar/migrations/0001_initial.py +++ b/seminar/migrations/0001_initial.py @@ -15,13 +15,41 @@ class Migration(migrations.Migration): ] operations = [ + migrations.CreateModel( + name='VysledkyKCislu', + fields=[ + ('dummy_id', models.CharField(max_length=32, serialize=False, verbose_name='dummy ID pro view', primary_key=True, db_column=b'id')), + ('body', models.IntegerField(verbose_name='body za \u010d\xedslo', db_column=b'body')), + ('body_celkem', models.IntegerField(verbose_name='body celkem do \u010d\xedsla', db_column=b'body_celkem')), + ], + options={ + 'abstract': False, + 'db_table': 'seminar_body_k_cislu', + 'managed': False, + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='VysledkyZaCislo', + fields=[ + ('dummy_id', models.CharField(max_length=32, serialize=False, verbose_name='dummy ID pro view', primary_key=True, db_column=b'id')), + ('body', models.IntegerField(verbose_name='body za \u010d\xedslo', db_column=b'body')), + ], + options={ + 'abstract': False, + 'db_table': 'seminar_body_za_cislo', + 'managed': False, + }, + bases=(models.Model,), + ), migrations.CreateModel( name='Cislo', fields=[ ('id', models.AutoField(serialize=False, primary_key=True)), - ('cislo', models.CharField(help_text='V\u011bt\u0161inou jen "1", vyj\xedme\u010dn\u011b "7-8"', max_length=32, verbose_name='n\xe1zev \u010d\xedsla')), + ('cislo', models.CharField(help_text='V\u011bt\u0161inou jen "1", vyj\xedme\u010dn\u011b "7-8", lexikograficky ur\u010dije po\u0159ad\xed v ro\u010dn\xedku!', max_length=32, verbose_name='n\xe1zev \u010d\xedsla')), ('datum_vydani', models.DateField(help_text='Datum vyd\xe1n\xed fin\xe1ln\xed verze', null=True, verbose_name='datum vyd\xe1n\xed', blank=True)), ('datum_deadline', models.DateField(help_text='Datum pro p\u0159\xedjem \u0159e\u0161en\xed \xfaloh zadan\xfdch v tomto \u010d\xedsle', null=True, verbose_name='datum deadline', blank=True)), + ('verejne_db', models.BooleanField(default=False, verbose_name='\u010d\xedslo zve\u0159ejn\u011bno', db_column=b'verejne')), ], options={ 'ordering': ['rocnik__rocnik', 'cislo'], @@ -49,6 +77,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(serialize=False, primary_key=True)), ('timestamp', models.DateTimeField(auto_now=True, verbose_name='vytvo\u0159eno')), ('soubor', models.FileField(upload_to=seminar.models.generate_filename, verbose_name='soubor')), + ('poznamka', models.TextField(help_text='Neve\u0159ejn\xe1 pozn\xe1mka k p\u0159\xedloze \u0159e\u0161en\xed (plain text), nap\u0159. o p\u016fvodu', verbose_name='neve\u0159ejn\xe1 pozn\xe1mka', blank=True)), ], options={ 'ordering': ['reseni', 'timestamp'], @@ -87,6 +116,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(serialize=False, primary_key=True)), ('body', models.IntegerField(null=True, verbose_name='body', blank=True)), ('timestamp', models.DateTimeField(auto_now=True, verbose_name='vytvo\u0159eno')), + ('poznamka', models.TextField(help_text='Neve\u0159ejn\xe1 pozn\xe1mka k \u0159e\u0161en\xed (plain text)', verbose_name='neve\u0159ejn\xe1 pozn\xe1mka', blank=True)), ('cislo_body', models.ForeignKey(related_name='bodovana_reseni', verbose_name='\u010d\xedslo pro body', blank=True, to='seminar.Cislo', null=True)), ('problem', models.ForeignKey(related_name='reseni', verbose_name='probl\xe9m', to='seminar.Problem')), ], @@ -117,6 +147,7 @@ class Migration(migrations.Migration): ('mesto', models.CharField(default=b'', max_length=256, verbose_name='m\u011bsto', blank=True)), ('psc', models.CharField(default=b'', max_length=32, verbose_name='PS\u010c', blank=True)), ('stat', django_countries.fields.CountryField(default=b'CZ', help_text='ISO 3166-1 k\xf3d zem\u011b velk\xfdmi p\xedsmeny (CZ, SK, ...)', max_length=2, verbose_name='st\xe1t')), + ('poznamka', models.TextField(help_text='Neve\u0159ejn\xe1 pozn\xe1mka k \u0159e\u0161iteli (plain text)', verbose_name='neve\u0159ejn\xe1 pozn\xe1mka', blank=True)), ], options={ 'ordering': ['prijmeni', 'jmeno'], @@ -153,6 +184,7 @@ class Migration(migrations.Migration): ('mesto', models.CharField(max_length=256, verbose_name='m\u011bsto')), ('psc', models.CharField(max_length=32, verbose_name='PS\u010c')), ('stat', django_countries.fields.CountryField(default=b'CZ', help_text='ISO 3166-1 k\xf3d zeme velk\xfdmi p\xedsmeny (CZ, SK, ...)', max_length=2, verbose_name='st\xe1t')), + ('poznamka', models.TextField(help_text='Neve\u0159ejn\xe1 pozn\xe1mka ke \u0161kole (plain text)', verbose_name='neve\u0159ejn\xe1 pozn\xe1mka', blank=True)), ], options={ 'db_table': 'seminar_skoly', @@ -161,6 +193,25 @@ class Migration(migrations.Migration): }, bases=(models.Model,), ), + migrations.CreateModel( + name='Soustredeni', + fields=[ + ('id', models.AutoField(serialize=False, primary_key=True)), + ('datum_zacatku', models.DateField(help_text='Prvn\xed den soust\u0159ed\u011bn\xed', null=True, verbose_name='datum za\u010d\xe1tku', blank=True)), + ('datum_konce', models.DateField(help_text='Posledn\xed den soust\u0159ed\u011bn\xed', null=True, verbose_name='datum konce', blank=True)), + ('verejne_db', models.BooleanField(default=False, verbose_name='soust\u0159ed\u011bn\xed zve\u0159ejn\u011bno', db_column=b'verejne')), + ('misto', models.CharField(default=b'', help_text='M\xedsto (n\xe1zev obce, voliteln\u011b t\xe9\u017e objektu', max_length=256, verbose_name='m\xedsto soust\u0159ed\u011bn\xed', blank=True)), + ('rocnik', models.ForeignKey(related_name='soustredeni', verbose_name='ro\u010dn\xedk', to='seminar.Rocnik')), + ('ucastnici', models.ManyToManyField(help_text='Seznam \xfa\u010dastn\xedk\u016f soust\u0159ed\u011bn\xed', to='seminar.Resitel', db_table=b'seminar_soustredeni_ucastnici', verbose_name='\xfa\u010dastn\xedci soust\u0159ed\u011bn\xed')), + ], + options={ + 'ordering': ['rocnik__rocnik', 'datum_zacatku'], + 'db_table': 'seminar_soustredeni', + 'verbose_name': 'Soust\u0159ed\u011bn\xed', + 'verbose_name_plural': 'Soust\u0159ed\u011bn\xed', + }, + bases=(models.Model,), + ), migrations.AddField( model_name='resitel', name='skola', @@ -194,7 +245,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='cislo', name='rocnik', - field=models.ForeignKey(verbose_name='ro\u010dn\xedk', to='seminar.Rocnik'), + field=models.ForeignKey(related_name='cisla', verbose_name='ro\u010dn\xedk', to='seminar.Rocnik'), preserve_default=True, ), ] diff --git a/seminar/migrations/0003_auto_20150511_0947.py b/seminar/migrations/0003_auto_20150511_0947.py deleted file mode 100644 index 0c0a1aec..00000000 --- a/seminar/migrations/0003_auto_20150511_0947.py +++ /dev/null @@ -1,71 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('seminar', '0002_add_body_views'), - ] - - operations = [ - migrations.CreateModel( - name='VysledkyKCislu', - fields=[ - ('dummy_id', models.CharField(max_length=32, serialize=False, verbose_name='dummy ID pro view', primary_key=True, db_column=b'id')), - ('body', models.IntegerField(verbose_name='body za \u010d\xedslo', db_column=b'body')), - ('body_celkem', models.IntegerField(verbose_name='body celkem do \u010d\xedsla', db_column=b'body_celkem')), - ], - options={ - 'abstract': False, - 'db_table': 'seminar_body_k_cislu', - 'managed': False, - }, - bases=(models.Model,), - ), - migrations.CreateModel( - name='VysledkyZaCislo', - fields=[ - ('dummy_id', models.CharField(max_length=32, serialize=False, verbose_name='dummy ID pro view', primary_key=True, db_column=b'id')), - ('body', models.IntegerField(verbose_name='body za \u010d\xedslo', db_column=b'body')), - ], - options={ - 'abstract': False, - 'db_table': 'seminar_body_za_cislo', - 'managed': False, - }, - bases=(models.Model,), - ), - migrations.CreateModel( - name='Soustredeni', - fields=[ - ('id', models.AutoField(serialize=False, primary_key=True)), - ('datum_zacatku', models.DateField(help_text='Prvn\xed den soust\u0159ed\u011bn\xed', null=True, verbose_name='datum za\u010d\xe1tku', blank=True)), - ('datum_konce', models.DateField(help_text='Posledn\xed den soust\u0159ed\u011bn\xed', null=True, verbose_name='datum konce', blank=True)), - ('misto', models.CharField(default=b'', help_text='M\xedsto (n\xe1zev obce, voliteln\u011b t\xe9\u017e objektu', max_length=256, verbose_name='m\xedsto soust\u0159ed\u011bn\xed', blank=True)), - ('rocnik', models.ForeignKey(related_name='soustredeni', verbose_name='ro\u010dn\xedk', to='seminar.Rocnik')), - ('ucastnici', models.ManyToManyField(help_text='Seznam \xfa\u010dastn\xedk\u016f soust\u0159ed\u011bn\xed', to='seminar.Resitel', db_table=b'seminar_soustredeni_ucastnici', verbose_name='\xfa\u010dastn\xedci soust\u0159ed\u011bn\xed')), - ], - options={ - 'ordering': ['rocnik__rocnik', 'datum_zacatku'], - 'db_table': 'seminar_soustredeni', - 'verbose_name': 'Soust\u0159ed\u011bn\xed', - 'verbose_name_plural': 'Soust\u0159ed\u011bn\xed', - }, - bases=(models.Model,), - ), - migrations.AlterField( - model_name='cislo', - name='cislo', - field=models.CharField(help_text='V\u011bt\u0161inou jen "1", vyj\xedme\u010dn\u011b "7-8", lexikograficky ur\u010dije po\u0159ad\xed v ro\u010dn\xedku!', max_length=32, verbose_name='n\xe1zev \u010d\xedsla'), - preserve_default=True, - ), - migrations.AlterField( - model_name='cislo', - name='rocnik', - field=models.ForeignKey(related_name='cisla', verbose_name='ro\u010dn\xedk', to='seminar.Rocnik'), - preserve_default=True, - ), - ] diff --git a/seminar/migrations/0004_auto_20150511_1215.py b/seminar/migrations/0004_auto_20150511_1215.py deleted file mode 100644 index 36ebd9e9..00000000 --- a/seminar/migrations/0004_auto_20150511_1215.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('seminar', '0003_auto_20150511_0947'), - ] - - operations = [ - migrations.AddField( - model_name='cislo', - name='verejne_db', - field=models.BooleanField(default=False, verbose_name='\u010d\xedslo zve\u0159ejn\u011bno', db_column=b'verejne'), - preserve_default=True, - ), - migrations.AddField( - model_name='reseni', - name='poznamka', - field=models.TextField(help_text='Neve\u0159ejn\xe1 pozn\xe1mka k \u0159e\u0161en\xed (plain text)', verbose_name='neve\u0159ejn\xe1 pozn\xe1mka', blank=True), - preserve_default=True, - ), - migrations.AddField( - model_name='resitel', - name='poznamka', - field=models.TextField(help_text='Neve\u0159ejn\xe1 pozn\xe1mka k \u0159e\u0161iteli (plain text)', verbose_name='neve\u0159ejn\xe1 pozn\xe1mka', blank=True), - preserve_default=True, - ), - migrations.AddField( - model_name='soustredeni', - name='verejne_db', - field=models.BooleanField(default=False, verbose_name='soust\u0159ed\u011bn\xed zve\u0159ejn\u011bno', db_column=b'verejne'), - preserve_default=True, - ), - ] diff --git a/seminar/models.py b/seminar/models.py index 54ff0b22..811fa61c 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -15,6 +15,8 @@ from django.core.urlresolvers import reverse from django_countries.fields import CountryField from solo.models import SingletonModel +import reversion + from seminar.utils import roman # TODO společná báze (admin url, url, veřejné, ...) @@ -44,6 +46,7 @@ class SeminarModelBase(models.Model): # viz https://ovvp.mff.cuni.cz/wiki/aesop/export-skol. # +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Skola(SeminarModelBase): @@ -85,10 +88,14 @@ class Skola(SeminarModelBase): stat = CountryField(u'stát', default='CZ', help_text=u'ISO 3166-1 kód zeme velkými písmeny (CZ, SK, ...)') + poznamka = models.TextField(u'neveřejná poznámka', blank=True, + help_text=u'Neveřejná poznámka ke škole (plain text)') + def __str__(self): return force_unicode(u'%s, %s' % (self.nazev, self.mesto)) +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Resitel(SeminarModelBase): @@ -165,6 +172,7 @@ class Resitel(SeminarModelBase): return force_unicode(self.plne_jmeno()) +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Rocnik(SeminarModelBase): @@ -209,6 +217,7 @@ class Rocnik(SeminarModelBase): return reverse('seminar_rocnik', kwargs={'pk': self.id}) +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Cislo(SeminarModelBase): @@ -248,6 +257,7 @@ class Cislo(SeminarModelBase): return reverse('seminar_cislo', kwargs={'pk': self.id}) +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Problem(SeminarModelBase): @@ -322,6 +332,7 @@ class Problem(SeminarModelBase): return reverse('seminar_problem', kwargs={'pk': self.id}) +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Reseni(SeminarModelBase): @@ -361,6 +372,7 @@ def generate_filename(self, filename): return os.path.join(settings.SEMINAR_RESENI_DIRNAME, datedir, fname) +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class PrilohaReseni(SeminarModelBase): @@ -379,10 +391,14 @@ class PrilohaReseni(SeminarModelBase): soubor = models.FileField(u'soubor', upload_to = generate_filename) + poznamka = models.TextField(u'neveřejná poznámka', blank=True, + help_text=u'Neveřejná poznámka k příloze řešení (plain text), např. o původu') + def __str__(self): return force_unicode(self.soubor) +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Soustredeni(SeminarModelBase): @@ -420,6 +436,8 @@ class Soustredeni(SeminarModelBase): def verejne_url(self): return reverse('seminar_soustredeni', kwargs={'pk': self.id}) + +@python_2_unicode_compatible class VysledkyBase(SeminarModelBase): class Meta: @@ -437,6 +455,8 @@ class VysledkyBase(SeminarModelBase): body = models.IntegerField(u'body za číslo', db_column='body') + def __str__(self): + return force_unicode(u"%s: %sb (%s)" % (self.resitel.plne_jmeno(), self.body, str(self.cislo))) @python_2_unicode_compatible class VysledkyZaCislo(VysledkyBase): @@ -449,6 +469,7 @@ class VysledkyZaCislo(VysledkyBase): def __str__(self): return force_unicode(u"%s: %sb (za %s)" % (self.resitel.plne_jmeno(), self.body, str(self.cislo))) + @python_2_unicode_compatible class VysledkyKCislu(VysledkyBase): @@ -463,6 +484,7 @@ class VysledkyKCislu(VysledkyBase): return force_unicode(u"%s: %sb / %sb (do %s)" % (self.resitel.plne_jmeno(), self.body, self.body_celkem, str(self.cislo))) +@reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Nastaveni(SingletonModel):