From 261f2447e3303649d1164cfab0b2e09feff2f79c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Sat, 1 Oct 2022 14:11:29 +0200 Subject: [PATCH] =?UTF-8?q?J=C3=A1=20u=C5=BE=20nev=C3=ADm,=20jak=20ur?= =?UTF-8?q?=C4=8Dovat=20deadliny=20=C5=99e=C5=A1en=C3=AD=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0104_hodnoceni_deadline_body.py | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/seminar/migrations/0104_hodnoceni_deadline_body.py b/seminar/migrations/0104_hodnoceni_deadline_body.py index 66d8e61f..74992fb8 100644 --- a/seminar/migrations/0104_hodnoceni_deadline_body.py +++ b/seminar/migrations/0104_hodnoceni_deadline_body.py @@ -14,39 +14,44 @@ def prirad_deadliny(apps, schema_editor): 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 + 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 + + cislo = None + + try: + u = p.uloha + cislo = u.cislo_zadani + 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 - + cislo = c.cislo except Exception: pass - try: - t = p.tema - d = Deadline.objects.filter(cislo__rocnik=t.rocnik, deadline__gte=h.reseni.cas_doruceni).first() + if cislo is None: + cislo = h.cislo_body + if cislo is not None: + d = Deadline.objects.filter(cislo=cislo, deadline__gte=h.reseni.cas_doruceni).first() if d is None: - d = Deadline.objects.filter(cislo__rocnik=t.rocnik).last() - + d = Deadline.objects.filter(cislo=cislo).last() h.deadline_body = d h.save() - - except Exception: - pass + continue log.warning(f"Deadline hodnocení {h.id} se nepodařil určit exaktnějším způsobem. Zkouším další.")