Polymorfismus v migraci lépe.
This commit is contained in:
parent
d582c43de5
commit
e6842af2a8
1 changed files with 6 additions and 12 deletions
|
@ -11,7 +11,7 @@ def prirad_deadliny(apps, schema_editor):
|
|||
Deadline = apps.get_model('seminar', 'Deadline')
|
||||
|
||||
for h in Hodnoceni.objects.all():
|
||||
if h.cislo_body is not None and h.cislo_body.rocnik.rocnik < 26:
|
||||
if h.cislo_body is not None and h.cislo_body.rocnik.rocnik < -1:
|
||||
# Deadline připravený v minulé migraci
|
||||
h.deadline_body = h.cislo_body.deadline_v_cisle.get()
|
||||
h.save()
|
||||
|
@ -19,7 +19,7 @@ def prirad_deadliny(apps, schema_editor):
|
|||
|
||||
p = h.problem
|
||||
|
||||
try:
|
||||
if p.polymorphic_ctype.model == 'tema':
|
||||
t = p.tema
|
||||
d = Deadline.objects.filter(cislo__rocnik=t.rocnik, deadline__gte=h.reseni.cas_doruceni).first()
|
||||
|
||||
|
@ -31,24 +31,16 @@ def prirad_deadliny(apps, schema_editor):
|
|||
h.save()
|
||||
continue
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
cislo = None
|
||||
|
||||
try:
|
||||
if p.polymorphic_ctype.model == 'uloha':
|
||||
u = p.uloha
|
||||
cislo = u.cislo_zadani
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
if p.polymorphic_ctype.model == 'clanek':
|
||||
c = p.clanek
|
||||
if c.cislo is not None:
|
||||
cislo = c.cislo
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if cislo is None:
|
||||
cislo = h.cislo_body
|
||||
|
@ -68,6 +60,8 @@ def prirad_deadliny(apps, schema_editor):
|
|||
h.deadline_body = d
|
||||
h.save()
|
||||
|
||||
# Zběžná kontrola. Předpokládá, že M&M má méně než 10 čísel v ročníku
|
||||
# a že první znak pořadí je int určující dané pořadí (schroustání 7-8).
|
||||
if h.cislo_body and (
|
||||
int(h.deadline_body.cislo.poradi[0]) + 2 < int(h.cislo_body.poradi[0])
|
||||
or int(h.deadline_body.cislo.poradi[0]) > int(h.cislo_body.poradi[0])
|
||||
|
|
Loading…
Reference in a new issue