Spravna timezone pri kontrole dat organizace

This commit is contained in:
Pavel Turinsky (DebianVM @ Zr) 2021-06-22 20:53:23 +00:00
parent 42ccaa47b0
commit 0012e47334

View file

@ -174,13 +174,16 @@ def check_organizator():
for o,n in res: for o,n in res:
check_same(o,n,old_fields, new_fields) check_same(o,n,old_fields, new_fields)
# organizuje od, do: # organizuje od, do:
# Migrace prirazuje aktualni casovou zonu, takze chceme tady rucne vynutit CET.
from datetime import timedelta, timezone
cet = timezone(timedelta(hours=1))
if o['organizuje_do_roku'] is None and n['organizuje_do'] is None: if o['organizuje_do_roku'] is None and n['organizuje_do'] is None:
pass pass
elif o['organizuje_od_roku'] != n['organizuje_od'].year: elif o['organizuje_od_roku'] != n['organizuje_od'].astimezone(cet).year:
raise ValueError(f'Not matching organizuje_od for org id={o["id"]}: old {o["organizuje_od_roku"]}, new {n["organizuje_od"]}') raise ValueError(f'Not matching organizuje_od for org id={o["id"]}: old {o["organizuje_od_roku"]}, new {n["organizuje_od"]}')
if o['organizuje_do_roku'] is None and n['organizuje_do'] is None: if o['organizuje_do_roku'] is None and n['organizuje_do'] is None:
pass pass
elif o['organizuje_do_roku'] != n['organizuje_do'].year: elif o['organizuje_do_roku'] != n['organizuje_do'].astimezone(cet).year:
raise ValueError(f'Not matching organizuje_do for org id={o["id"]}: old {o["organizuje_do_roku"]}, new {n["organizuje_do"]}') raise ValueError(f'Not matching organizuje_do for org id={o["id"]}: old {o["organizuje_do_roku"]}, new {n["organizuje_do"]}')
if o['prezdivka'] == n['o_prezdivka']: if o['prezdivka'] == n['o_prezdivka']:
continue continue