|
|
@ -12,25 +12,23 @@ import seminar.models as m |
|
|
|
def vytvor_deadliny(apps, schema_editor): |
|
|
|
Cislo = apps.get_model('seminar', 'Cislo') |
|
|
|
Deadline = apps.get_model('seminar', 'Deadline') |
|
|
|
Hodnoceni = apps.get_model('seminar', 'Hodnoceni') |
|
|
|
|
|
|
|
for cislo in Cislo.objects.all(): |
|
|
|
if not (cislo.datum_deadline or cislo.datum_deadline_soustredeni or cislo.datum_preddeadline): |
|
|
|
h = Hodnoceni.objects.filter(problem__uloha__cislo_zadani=cislo).order_by(F("reseni__cas_doruceni")).last() |
|
|
|
|
|
|
|
if h is None: |
|
|
|
h = Hodnoceni.objects.filter(cislo_body=cislo).order_by(F("reseni__cas_doruceni")).last() |
|
|
|
|
|
|
|
if h is not None: |
|
|
|
cislo.datum_deadline = h.reseni.cas_doruceni.date() |
|
|
|
cislo.save() |
|
|
|
if cislo.rocnik.rocnik < 26: |
|
|
|
d = Deadline() |
|
|
|
d.cislo = cislo |
|
|
|
d.typ = m.Deadline.TYP_CISLA |
|
|
|
d.deadline = timezone.make_aware(datetime.datetime.combine(datetime.date(1994 + cislo.rocnik.rocnik, 6, int(cislo.poradi[0])), datetime.time.min)) |
|
|
|
d.verejna_vysledkovka = cislo.verejna_vysledkovka |
|
|
|
d.save() |
|
|
|
continue |
|
|
|
|
|
|
|
if cislo.datum_deadline_soustredeni and cislo.datum_deadline_soustredeni == cislo.datum_preddeadline: |
|
|
|
d = Deadline() |
|
|
|
d.cislo = cislo |
|
|
|
d.typ = m.Deadline.TYP_PRVNI_A_SOUS |
|
|
|
d.deadline = timezone.make_aware(datetime.datetime.combine(cislo.datum_deadline_soustredeni, datetime.time.min)) + datetime.timedelta(days=1) |
|
|
|
d.verejna_vysledkovka = cislo.verejna_vysledkovka |
|
|
|
d.verejna_vysledkovka = True |
|
|
|
d.save() |
|
|
|
else: |
|
|
|
if cislo.datum_deadline_soustredeni: |
|
|
@ -38,14 +36,14 @@ def vytvor_deadliny(apps, schema_editor): |
|
|
|
d.cislo = cislo |
|
|
|
d.typ = m.Deadline.TYP_SOUS |
|
|
|
d.deadline = timezone.make_aware(datetime.datetime.combine(cislo.datum_deadline_soustredeni, datetime.time.min)) + datetime.timedelta(days=1) |
|
|
|
d.verejna_vysledkovka = cislo.verejna_vysledkovka |
|
|
|
d.verejna_vysledkovka = True |
|
|
|
d.save() |
|
|
|
if cislo.datum_preddeadline: |
|
|
|
d = Deadline() |
|
|
|
d.cislo = cislo |
|
|
|
d.typ = m.Deadline.TYP_PRVNI |
|
|
|
d.deadline = timezone.make_aware(datetime.datetime.combine(cislo.datum_preddeadline, datetime.time.min)) + datetime.timedelta(days=1) |
|
|
|
d.verejna_vysledkovka = cislo.verejna_vysledkovka |
|
|
|
d.verejna_vysledkovka = True |
|
|
|
d.save() |
|
|
|
|
|
|
|
if cislo.datum_deadline: |
|
|
@ -53,7 +51,7 @@ def vytvor_deadliny(apps, schema_editor): |
|
|
|
d.cislo = cislo |
|
|
|
d.typ = m.Deadline.TYP_CISLA |
|
|
|
d.deadline = timezone.make_aware(datetime.datetime.combine(cislo.datum_deadline, datetime.time.min)) + datetime.timedelta(days=1) |
|
|
|
d.verejna_vysledkovka = cislo.verejna_vysledkovka |
|
|
|
d.verejna_vysledkovka = True |
|
|
|
d.save() |
|
|
|
|
|
|
|
|
|
|
|