Browse Source

Zmena jmena rocniku na integer

remotes/origin/feincms
Tomas Gavenciak 10 years ago
parent
commit
ff532b2f59
  1. 32
      seminar/migrations/0019_rocnik_ciselne.py
  2. 7
      seminar/models.py

32
seminar/migrations/0019_rocnik_ciselne.py

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('seminar', '0018_problemnavrh_problemzadany'),
]
operations = [
migrations.AddField(
model_name='rocnik',
name='rocnik_n',
field=models.IntegerField(default=0, verbose_name='\u010d\xedslo ro\u010dn\xedku'),
preserve_default=False,
),
migrations.RunSQL(
sql="update seminar_rocniky set rocnik_n = cast (rocnik as integer)"
),
migrations.RemoveField(
model_name='rocnik',
name='rocnik',
),
migrations.RenameField(
model_name='rocnik',
old_name='rocnik_n',
new_name='rocnik',
),
]

7
seminar/models.py

@ -204,16 +204,13 @@ class Rocnik(SeminarModelBase):
prvni_rok = models.IntegerField(u'první rok')
rocnik = models.CharField(u'číslo ročníku', max_length=16)
rocnik = models.IntegerField(u'číslo ročníku')
def __str__(self):
return force_unicode(u'%s (%d/%d)' % (self.rocnik, self.prvni_rok, self.prvni_rok+1))
def roman(self):
if self.rocnik.isdigit():
return force_unicode(roman(int(self.rocnik)))
else:
return force_unicode(self.rocnik)
return force_unicode(roman(int(self.rocnik)))
def verejne(self):
return len(self.verejna_cisla()) > 0

Loading…
Cancel
Save