Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
Showing only changes of commit ae0971229e - Show all commits

View File

@ -354,6 +354,7 @@ def _get_dates_from_assi_form(
try: try:
date_debut = datetime.datetime.strptime(form.date_debut.data, "%d/%m/%Y") date_debut = datetime.datetime.strptime(form.date_debut.data, "%d/%m/%Y")
except ValueError: except ValueError:
date_debut = None
form.date_debut.errors.append("date début invalide") form.date_debut.errors.append("date début invalide")
ok = False ok = False
try: try:
@ -363,6 +364,7 @@ def _get_dates_from_assi_form(
else None else None
) )
except ValueError: except ValueError:
date_fin = None
form.date_fin.errors.append("date fin invalide") form.date_fin.errors.append("date fin invalide")
ok = False ok = False
@ -384,11 +386,17 @@ def _get_dates_from_assi_form(
form.heure_fin.errors.append("heure fin invalide") form.heure_fin.errors.append("heure fin invalide")
ok = False ok = False
# Vérifie cohérence des dates/heures # Vérifie cohérence des dates/heures
dt_debut = datetime.datetime.combine(date_debut, heure_debut) dt_debut = (
dt_fin = datetime.datetime.combine(date_fin or date_debut, heure_fin) datetime.datetime.combine(date_debut, heure_debut) if date_debut else None
if dt_fin <= dt_debut: )
dt_fin = (
datetime.datetime.combine(date_fin or date_debut, heure_fin)
if (date_fin or date_debut)
else None
)
if ok and dt_fin <= dt_debut:
form.errors["general_errors"] = ["Erreur: dates début/fin incohérentes"] form.errors["general_errors"] = ["Erreur: dates début/fin incohérentes"]
return False ok = False
# La date de dépot (si vide, la date actuelle) # La date de dépot (si vide, la date actuelle)
dt_entry_date = ( dt_entry_date = (
datetime.datetime.strptime(form.entry_date.data, "%d/%m/%Y") datetime.datetime.strptime(form.entry_date.data, "%d/%m/%Y")
@ -396,8 +404,8 @@ def _get_dates_from_assi_form(
else None else None
) )
# Ajoute time zone serveur # Ajoute time zone serveur
dt_debut_tz_server = scu.TIME_ZONE.localize(dt_debut) dt_debut_tz_server = scu.TIME_ZONE.localize(dt_debut) if dt_debut else None
dt_fin_tz_server = scu.TIME_ZONE.localize(dt_fin) dt_fin_tz_server = scu.TIME_ZONE.localize(dt_fin) if dt_fin else None
dt_entry_date_tz_server = ( dt_entry_date_tz_server = (
scu.TIME_ZONE.localize(dt_entry_date) if dt_entry_date else None scu.TIME_ZONE.localize(dt_entry_date) if dt_entry_date else None
) )