Doplnění deadlinů, větší rozptyl kontroly
This commit is contained in:
parent
e33a80b16d
commit
d9912671ff
2 changed files with 12 additions and 5 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ def prirad_deadliny(apps, schema_editor):
|
|||
h.deadline_body = d
|
||||
h.save()
|
||||
|
||||
if h.cislo_body and int(h.deadline_body.cislo.poradi) + 1 != int(h.cislo_body.poradi[0]):
|
||||
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])):
|
||||
log.error(f"Hodnocení {h.id} se špatně změnilo číslo z {h.cislo_body} na {h.deadline_body.cislo}")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue