|
|
@ -3,6 +3,7 @@ |
|
|
|
import datetime |
|
|
|
from django.db import migrations, models |
|
|
|
import django.db.models.deletion |
|
|
|
from django.db.models import F |
|
|
|
from django.utils import timezone |
|
|
|
|
|
|
|
import seminar.models as m |
|
|
@ -11,13 +12,19 @@ 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(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.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.max)) |
|
|
|
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.save() |
|
|
|
else: |
|
|
@ -25,14 +32,14 @@ def vytvor_deadliny(apps, schema_editor): |
|
|
|
d = Deadline() |
|
|
|
d.cislo = cislo |
|
|
|
d.typ = m.Deadline.TYP_SOUS |
|
|
|
d.deadline = timezone.make_aware(datetime.datetime.combine(cislo.datum_deadline_soustredeni, datetime.time.max)) |
|
|
|
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.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.max)) |
|
|
|
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.save() |
|
|
|
|
|
|
@ -40,7 +47,7 @@ def vytvor_deadliny(apps, schema_editor): |
|
|
|
d = Deadline() |
|
|
|
d.cislo = cislo |
|
|
|
d.typ = m.Deadline.TYP_CISLA |
|
|
|
d.deadline = timezone.make_aware(datetime.datetime.combine(cislo.datum_deadline, datetime.time.max)) |
|
|
|
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.save() |
|
|
|
|
|
|
|