forked from ScoDoc/ScoDoc
Conversion date naissance étudiant. complète #593.
This commit is contained in:
parent
161f8476ca
commit
203f3a5342
@ -480,7 +480,7 @@ def DateDMYtoISO(dmy: str, null_is_empty=False) -> str | None:
|
||||
try:
|
||||
dt = datetime.datetime.fromisoformat(dmy)
|
||||
except ValueError as exc:
|
||||
raise ValueError(f'Date (j/m/a or iso) invalide: "{dmy}"') from exc
|
||||
raise ScoValueError(f'Date (j/m/a or iso) invalide: "{dmy}"') from exc
|
||||
return dt.date().isoformat()
|
||||
|
||||
|
||||
|
@ -1365,6 +1365,15 @@ def etudident_edit_form():
|
||||
return _etudident_create_or_edit_form(edit=True)
|
||||
|
||||
|
||||
def _validate_date_naissance(val: str, field) -> bool:
|
||||
"vrai si date saisie valide"
|
||||
try:
|
||||
date_naissance = scu.convert_fr_date(val)
|
||||
except ScoValueError:
|
||||
return False
|
||||
return date_naissance < datetime.datetime.now()
|
||||
|
||||
|
||||
def _etudident_create_or_edit_form(edit):
|
||||
"Le formulaire HTML"
|
||||
H = [html_sco_header.sco_header()]
|
||||
@ -1506,8 +1515,7 @@ def _etudident_create_or_edit_form(edit):
|
||||
"title": "Date de naissance",
|
||||
"input_type": "date",
|
||||
"explanation": "j/m/a",
|
||||
"validator": lambda val, _: DMY_REGEXP.match(val)
|
||||
and (ndb.DateDMYtoISO(val) < datetime.date.today().isoformat()),
|
||||
"validator": _validate_date_naissance,
|
||||
},
|
||||
),
|
||||
("lieu_naissance", {"title": "Lieu de naissance", "size": 32}),
|
||||
@ -1779,7 +1787,7 @@ def _etudident_create_or_edit_form(edit):
|
||||
+ homonyms_html
|
||||
+ F
|
||||
)
|
||||
|
||||
tf[2]["date_naissance"] = scu.convert_fr_date(tf[2]["date_naissance"])
|
||||
if not edit:
|
||||
etud = sco_etud.create_etud(cnx, args=tf[2])
|
||||
etudid = etud["etudid"]
|
||||
|
Loading…
Reference in New Issue
Block a user