|
@ -11,11 +11,50 @@ def prirad_deadliny(apps, schema_editor): |
|
|
Deadline = apps.get_model('seminar', 'Deadline') |
|
|
Deadline = apps.get_model('seminar', 'Deadline') |
|
|
|
|
|
|
|
|
for h in Hodnoceni.objects.all(): |
|
|
for h in Hodnoceni.objects.all(): |
|
|
|
|
|
p = h.problem |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
u = p.uloha |
|
|
|
|
|
if u.cislo_zadani is not None: |
|
|
|
|
|
d = Deadline.objects.filter(cislo=u.cislo_zadani, deadline__gte=h.reseni.cas_doruceni).first() |
|
|
|
|
|
h.deadline_body = d |
|
|
|
|
|
h.save() |
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
except Exception: |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
c = p.clanek |
|
|
|
|
|
if c.cislo is not None: |
|
|
|
|
|
d = Deadline.objects.filter(cislo=c.cislo, deadline__gte=h.reseni.cas_doruceni).first() |
|
|
|
|
|
h.deadline_body = d |
|
|
|
|
|
h.save() |
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
except Exception: |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
t = p.tema |
|
|
|
|
|
d = Deadline.objects.filter(cislo__rocnik=t.rocnik, deadline__gte=h.reseni.cas_doruceni).first() |
|
|
|
|
|
|
|
|
|
|
|
if d is None: |
|
|
|
|
|
d = Deadline.objects.filter(cislo__rocnik=t.rocnik).last() |
|
|
|
|
|
|
|
|
|
|
|
h.deadline_body = d |
|
|
|
|
|
h.save() |
|
|
|
|
|
|
|
|
|
|
|
except Exception: |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
log.warning(f"Deadline hodnocení {h.id} se nepodařil určit exaktnějším způsobem. Zkouším další.") |
|
|
|
|
|
|
|
|
d = Deadline.objects.filter(deadline__gte=h.reseni.cas_doruceni).first() |
|
|
d = Deadline.objects.filter(deadline__gte=h.reseni.cas_doruceni).first() |
|
|
h.deadline_body = d |
|
|
h.deadline_body = d |
|
|
h.save() |
|
|
h.save() |
|
|
|
|
|
|
|
|
if h.cislo_body and (int(h.deadline_body.cislo.poradi) + 2 < int(h.cislo_body.poradi[0]) or int(h.deadline_body.cislo.poradi) > int(h.cislo_body.poradi[0])): |
|
|
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])): |
|
|
log.error(f"Hodnocení {h.id} se špatně změnilo číslo z {h.cislo_body} na {h.deadline_body.cislo}") |
|
|
log.error(f"Hodnocení {h.id} se špatně změnilo číslo z {h.cislo_body} na {h.deadline_body.cislo}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|