diff --git a/app/but/bulletin_but_court_pdf.py b/app/but/bulletin_but_court_pdf.py index e8a6563df..62bba9988 100644 --- a/app/but/bulletin_but_court_pdf.py +++ b/app/but/bulletin_but_court_pdf.py @@ -31,6 +31,7 @@ from app.scodoc.sco_bulletins_standard import BulletinGeneratorStandard from app.scodoc.sco_logos import Logo from app.scodoc.sco_pdf import PDFLOCK, SU from app.scodoc.sco_preferences import SemPreferences +from app.scodoc import sco_utils as scu def make_bulletin_but_court_pdf( @@ -343,9 +344,11 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard): for mod in self.bul[mod_type]: row = [mod, bul[mod_type][mod]["titre"]] row += [ - bul["ues"][ue][mod_type][mod]["moyenne"] - if mod in bul["ues"][ue][mod_type] - else "" + ( + bul["ues"][ue][mod_type][mod]["moyenne"] + if mod in bul["ues"][ue][mod_type] + else "" + ) for ue in self.ues_acronyms ] rows.append(row) @@ -523,7 +526,7 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard): if self.bul["semestre"].get("decision_annee", None): txt += f""" Décision saisie le { - datetime.datetime.fromisoformat(self.bul["semestre"]["decision_annee"]["date"]).strftime("%d/%m/%Y") + datetime.datetime.fromisoformat(self.bul["semestre"]["decision_annee"]["date"]).strftime(scu.DATE_FMT) }, année BUT{self.bul["semestre"]["decision_annee"]["ordre"]} {self.bul["semestre"]["decision_annee"]["code"]}.
diff --git a/app/but/bulletin_but_pdf.py b/app/but/bulletin_but_pdf.py index 999846f77..ef1f1e41f 100644 --- a/app/but/bulletin_but_pdf.py +++ b/app/but/bulletin_but_pdf.py @@ -269,7 +269,7 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard): date_capitalisation = ue.get("date_capitalisation") if date_capitalisation: fields_bmr.append( - f"""Capitalisée le {date_capitalisation.strftime("%d/%m/%Y")}""" + f"""Capitalisée le {date_capitalisation.strftime(scu.DATE_FMT)}""" ) t = { "titre": " - ".join(fields_bmr), diff --git a/app/but/jury_but_view.py b/app/but/jury_but_view.py index 1f2a8a170..2abbeb1d8 100644 --- a/app/but/jury_but_view.py +++ b/app/but/jury_but_view.py @@ -21,8 +21,6 @@ from app.but.jury_but import ( DecisionsProposeesRCUE, DecisionsProposeesUE, ) -from app.comp import res_sem -from app.comp.res_but import ResultatsSemestreBUT from app.models import ( ApcNiveau, FormSemestre, @@ -33,11 +31,8 @@ from app.models import ( ScolarFormSemestreValidation, ScolarNews, ) -from app.models.config import ScoDocSiteConfig -from app.scodoc import html_sco_header from app.scodoc import codes_cursus as sco_codes from app.scodoc.sco_exceptions import ScoValueError -from app.scodoc import sco_preferences from app.scodoc import sco_utils as scu @@ -217,7 +212,7 @@ def _gen_but_niveau_ue( scoplement = f"""
UE {ue.acronyme} capitalisée - le {dec_ue.ue_status["event_date"].strftime("%d/%m/%Y")} + le {dec_ue.ue_status["event_date"].strftime(scu.DATE_FMT)}
@@ -233,7 +228,7 @@ def _gen_but_niveau_ue(
UE {ue.acronyme} antérieure validée {dec_ue.validation.code} - le {dec_ue.validation.event_date.strftime("%d/%m/%Y")} + le {dec_ue.validation.event_date.strftime(scu.DATE_FMT)}
Non reprise dans l'année en cours
@@ -251,9 +246,7 @@ def _gen_but_niveau_ue( moy_ue_str = f"""{scu.fmt_note(dec_ue.moy_ue)}""" if dec_ue.code_valide: date_str = ( - f"""enregistré le {dec_ue.validation.event_date.strftime("%d/%m/%Y")} - à {dec_ue.validation.event_date.strftime("%Hh%M")} - """ + f"""enregistré le {dec_ue.validation.event_date.strftime(scu.DATEATIME_FMT)}""" if dec_ue.validation and dec_ue.validation.event_date else "" ) diff --git a/app/comp/jury.py b/app/comp/jury.py index 1a4c87687..6e701a54f 100644 --- a/app/comp/jury.py +++ b/app/comp/jury.py @@ -23,6 +23,7 @@ from app.models import ( ) from app.scodoc import sco_cache from app.scodoc import codes_cursus +from app.scodoc import sco_utils as scu class ValidationsSemestre(ResultatsCache): @@ -84,7 +85,7 @@ class ValidationsSemestre(ResultatsCache): "code": decision.code, "assidu": decision.assidu, "compense_formsemestre_id": decision.compense_formsemestre_id, - "event_date": decision.event_date.strftime("%d/%m/%Y"), + "event_date": decision.event_date.strftime(scu.DATE_FMT), } self.decisions_jury = decisions_jury @@ -107,7 +108,7 @@ class ValidationsSemestre(ResultatsCache): decisions_jury_ues[decision.etudid][decision.ue.id] = { "code": decision.code, "ects": ects, # 0. si UE non validée - "event_date": decision.event_date.strftime("%d/%m/%Y"), + "event_date": decision.event_date.strftime(scu.DATE_FMT), } self.decisions_jury_ues = decisions_jury_ues diff --git a/app/models/assiduites.py b/app/models/assiduites.py index 2b8742874..f645f5c5a 100644 --- a/app/models/assiduites.py +++ b/app/models/assiduites.py @@ -21,6 +21,7 @@ from app.scodoc import sco_abs_notification from app.scodoc.sco_archives_justificatifs import JustificatifArchiver from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_permissions import Permission +from app.scodoc import sco_utils as scu from app.scodoc.sco_utils import ( EtatAssiduite, EtatJustificatif, @@ -113,9 +114,9 @@ class Assiduite(ScoDocModel): "entry_date": self.entry_date, "user_id": None if user is None else user.id, # l'uid "user_name": None if user is None else user.user_name, # le login - "user_nom_complet": None - if user is None - else user.get_nomcomplet(), # "Marie Dupont" + "user_nom_complet": ( + None if user is None else user.get_nomcomplet() + ), # "Marie Dupont" "est_just": self.est_just, "external_data": self.external_data, } @@ -364,7 +365,7 @@ class Assiduite(ScoDocModel): retourne le texte "saisie le par " """ - date: str = self.entry_date.strftime("%d/%m/%Y à %H:%M") + date: str = self.entry_date.strftime(scu.DATEATIME_FMT) utilisateur: str = "" if self.user is not None: self.user: User diff --git a/app/models/but_validations.py b/app/models/but_validations.py index 0dc298296..8c23694d3 100644 --- a/app/models/but_validations.py +++ b/app/models/but_validations.py @@ -10,6 +10,7 @@ from app.models.etudiants import Identite from app.models.formsemestre import FormSemestre from app.models.ues import UniteEns from app.scodoc import sco_preferences +from app.scodoc import sco_utils as scu class ApcValidationRCUE(db.Model): @@ -63,14 +64,13 @@ class ApcValidationRCUE(db.Model): def __str__(self): return f"""Décision sur RCUE {self.ue1.acronyme}/{self.ue2.acronyme}: { - self.code} enregistrée le {self.date.strftime("%d/%m/%Y")}""" + self.code} enregistrée le {self.date.strftime(scu.DATE_FMT)}""" def html(self) -> str: "description en HTML" return f"""Décision sur RCUE {self.ue1.acronyme}/{self.ue2.acronyme}: {self.code} - enregistrée le {self.date.strftime("%d/%m/%Y")} - à {self.date.strftime("%Hh%M")}""" + enregistrée le {self.date.strftime(scu.DATEATIME_FMT)}""" def annee(self) -> str: """l'année BUT concernée: "BUT1", "BUT2" ou "BUT3" """ @@ -164,7 +164,7 @@ class ApcValidationAnnee(db.Model): def html(self) -> str: "Affichage html" date_str = ( - f"""le {self.date.strftime("%d/%m/%Y")} à {self.date.strftime("%Hh%M")}""" + f"""le {self.date.strftime(scu.DATEATIME_FMT)}""" if self.date else "(sans date)" ) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index 03e6093bb..f79264c55 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -481,7 +481,9 @@ class Identite(models.ScoDocModel): "code_ine": self.code_ine or "", "code_nip": self.code_nip or "", "date_naissance": ( - self.date_naissance.strftime("%d/%m/%Y") if self.date_naissance else "" + self.date_naissance.strftime(scu.DATE_FMT) + if self.date_naissance + else "" ), "dept_acronym": self.departement.acronym, "dept_id": self.dept_id, @@ -733,7 +735,7 @@ class Identite(models.ScoDocModel): """ if with_paragraph: return f"""{self.etat_civil}{line_sep}n°{self.code_nip or ""}{line_sep}né{self.e} le { - self.date_naissance.strftime("%d/%m/%Y") if self.date_naissance else ""}{ + self.date_naissance.strftime(scu.DATE_FMT) if self.date_naissance else ""}{ line_sep}à {self.lieu_naissance or ""}""" return self.etat_civil diff --git a/app/models/evaluations.py b/app/models/evaluations.py index 8a253bf58..124c3ac40 100644 --- a/app/models/evaluations.py +++ b/app/models/evaluations.py @@ -207,7 +207,9 @@ class Evaluation(models.ScoDocModel): e_dict["poids"] = self.get_ue_poids_dict() # { ue_id : poids } # Deprecated - e_dict["jour"] = self.date_debut.strftime("%d/%m/%Y") if self.date_debut else "" + e_dict["jour"] = ( + self.date_debut.strftime(scu.DATE_FMT) if self.date_debut else "" + ) return evaluation_enrich_dict(self, e_dict) @@ -315,10 +317,10 @@ class Evaluation(models.ScoDocModel): def descr_heure(self) -> str: "Description de la plage horaire pour affichages ('de 13h00 à 14h00')" if self.date_debut and (not self.date_fin or self.date_fin == self.date_debut): - return f"""à {self.date_debut.strftime("%Hh%M")}""" + return f"""à {self.date_debut.strftime(scu.TIME_FMT)}""" elif self.date_debut and self.date_fin: - return f"""de {self.date_debut.strftime("%Hh%M") - } à {self.date_fin.strftime("%Hh%M")}""" + return f"""de {self.date_debut.strftime(scu.TIME_FMT) + } à {self.date_fin.strftime(scu.TIME_FMT)}""" else: return "" @@ -345,7 +347,7 @@ class Evaluation(models.ScoDocModel): def _h(dt: datetime.datetime) -> str: if dt.minute: - return dt.strftime("%Hh%M") + return dt.strftime(scu.TIME_FMT) return f"{dt.hour}h" if self.date_fin is None: @@ -539,8 +541,8 @@ class EvaluationUEPoids(db.Model): def evaluation_enrich_dict(e: Evaluation, e_dict: dict): """add or convert some fields in an evaluation dict""" # For ScoDoc7 compat - e_dict["heure_debut"] = e.date_debut.strftime("%Hh%M") if e.date_debut else "" - e_dict["heure_fin"] = e.date_fin.strftime("%Hh%M") if e.date_fin else "" + e_dict["heure_debut"] = e.date_debut.strftime(scu.TIME_FMT) if e.date_debut else "" + e_dict["heure_fin"] = e.date_fin.strftime(scu.TIME_FMT) if e.date_fin else "" e_dict["jour_iso"] = e.date_debut.isoformat() if e.date_debut else "" # Calcule durée en minutes e_dict["descrheure"] = e.descr_heure() @@ -614,7 +616,7 @@ def check_and_convert_evaluation_args(data: dict, moduleimpl: "ModuleImpl"): ): raise ScoValueError( f"""La date de début de l'évaluation ({ - data["date_debut"].strftime("%d/%m/%Y") + data["date_debut"].strftime(scu.DATE_FMT) }) n'est pas dans le semestre !""", dest_url="javascript:history.back();", ) @@ -629,7 +631,7 @@ def check_and_convert_evaluation_args(data: dict, moduleimpl: "ModuleImpl"): ): raise ScoValueError( f"""La date de fin de l'évaluation ({ - data["date_fin"].strftime("%d/%m/%Y") + data["date_fin"].strftime(scu.DATE_FMT) }) n'est pas dans le semestre !""", dest_url="javascript:history.back();", ) diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 338b92239..1799c603f 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -224,12 +224,12 @@ class FormSemestre(models.ScoDocModel): d["formsemestre_id"] = self.id d["titre_num"] = self.titre_num() if self.date_debut: - d["date_debut"] = self.date_debut.strftime("%d/%m/%Y") + d["date_debut"] = self.date_debut.strftime(scu.DATE_FMT) d["date_debut_iso"] = self.date_debut.isoformat() else: d["date_debut"] = d["date_debut_iso"] = "" if self.date_fin: - d["date_fin"] = self.date_fin.strftime("%d/%m/%Y") + d["date_fin"] = self.date_fin.strftime(scu.DATE_FMT) d["date_fin_iso"] = self.date_fin.isoformat() else: d["date_fin"] = d["date_fin_iso"] = "" @@ -255,12 +255,12 @@ class FormSemestre(models.ScoDocModel): d["annee_scolaire"] = self.annee_scolaire() d["bul_hide_xml"] = self.bul_hide_xml if self.date_debut: - d["date_debut"] = self.date_debut.strftime("%d/%m/%Y") + d["date_debut"] = self.date_debut.strftime(scu.DATE_FMT) d["date_debut_iso"] = self.date_debut.isoformat() else: d["date_debut"] = d["date_debut_iso"] = "" if self.date_fin: - d["date_fin"] = self.date_fin.strftime("%d/%m/%Y") + d["date_fin"] = self.date_fin.strftime(scu.DATE_FMT) d["date_fin_iso"] = self.date_fin.isoformat() else: d["date_fin"] = d["date_fin_iso"] = "" diff --git a/app/models/validations.py b/app/models/validations.py index e97968768..1e19092eb 100644 --- a/app/models/validations.py +++ b/app/models/validations.py @@ -72,7 +72,7 @@ class ScolarFormSemestreValidation(db.Model): return f"""décision sur UE {self.ue.acronyme if self.ue else self.ue_id } ({self.ue_id}): {self.code}""" return f"""décision sur semestre {self.formsemestre.titre_mois()} du { - self.event_date.strftime("%d/%m/%Y")}""" + self.event_date.strftime(scu.DATE_FMT)}""" def delete(self): "Efface cette validation" @@ -113,14 +113,14 @@ class ScolarFormSemestreValidation(db.Model): if self.ue.parcours else ""} {("émise par " + link)} : {self.code}{moyenne} - le {self.event_date.strftime("%d/%m/%Y")} à {self.event_date.strftime("%Hh%M")} - """ + le {self.event_date.strftime(scu.DATEATIME_FMT)} + """ else: return f"""Validation du semestre S{ self.formsemestre.semestre_id if self.formsemestre else "?"} {self.formsemestre.html_link_status() if self.formsemestre else ""} : {self.code} - le {self.event_date.strftime("%d/%m/%Y")} à {self.event_date.strftime("%Hh%M")} + le {self.event_date.strftime(scu.DATEATIME_FMT)} """ def ects(self) -> float: @@ -175,8 +175,8 @@ class ScolarAutorisationInscription(db.Model): ) return f"""Autorisation de passage vers S{self.semestre_id} émise par {link} - le {self.date.strftime("%d/%m/%Y")} à {self.date.strftime("%Hh%M")} - """ + le {self.date.strftime(scu.DATEATIME_FMT)} + """ @classmethod def autorise_etud( diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py index 008d366b9..1b160713d 100755 --- a/app/scodoc/html_sidebar.py +++ b/app/scodoc/html_sidebar.py @@ -180,9 +180,9 @@ def sidebar(etudid: int = None): ) H.append( f"""({ sco_preferences.get_preference("assi_metrique", None)})
{nbabsjust:1g} J., {nbabsnj:1g} N.J.
""" diff --git a/app/scodoc/notesdb.py b/app/scodoc/notesdb.py index 0f72cd01e..add7d84a5 100644 --- a/app/scodoc/notesdb.py +++ b/app/scodoc/notesdb.py @@ -12,6 +12,7 @@ import psycopg2.extras from app import log from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError +from app.scodoc import sco_utils as scu quote_html = html.escape @@ -475,7 +476,7 @@ def DateDMYtoISO(dmy: str, null_is_empty=False) -> str | None: if not isinstance(dmy, str): raise ScoValueError(f'Date (j/m/a) invalide: "{dmy}"') try: - dt = datetime.datetime.strptime(dmy, "%d/%m/%Y") + dt = datetime.datetime.strptime(dmy, scu.DATE_FMT) except ValueError: try: dt = datetime.datetime.fromisoformat(dmy) diff --git a/app/scodoc/sco_abs_billets.py b/app/scodoc/sco_abs_billets.py index 330524736..e20bf1a25 100644 --- a/app/scodoc/sco_abs_billets.py +++ b/app/scodoc/sco_abs_billets.py @@ -34,6 +34,7 @@ from app.models.absences import BilletAbsence from app.models.etudiants import Identite from app.scodoc.gen_tables import GenTable from app.scodoc import sco_preferences +from app.scodoc import sco_utils as scu def query_billets_etud(etudid: int = None, etat: bool = None) -> Query: @@ -89,12 +90,12 @@ def table_billets( m = " matin" else: m = " après-midi" - billet_dict["abs_begin_str"] = billet.abs_begin.strftime("%d/%m/%Y") + m + billet_dict["abs_begin_str"] = billet.abs_begin.strftime(scu.DATE_FMT) + m if billet.abs_end.hour < 12: m = " matin" else: m = " après-midi" - billet_dict["abs_end_str"] = billet.abs_end.strftime("%d/%m/%Y") + m + billet_dict["abs_end_str"] = billet.abs_end.strftime(scu.DATE_FMT) + m if billet.etat == 0: if billet.justified: billet_dict["etat_str"] = "à traiter" diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index 965222f0b..a0bff221a 100644 --- a/app/scodoc/sco_apogee_csv.py +++ b/app/scodoc/sco_apogee_csv.py @@ -515,11 +515,13 @@ class ApoEtud(dict): # ne trouve pas de semestre impair self.validation_annee_but = None return - self.validation_annee_but: ApcValidationAnnee = ApcValidationAnnee.query.filter_by( - formsemestre_id=formsemestre.id, - etudid=self.etud["etudid"], - referentiel_competence_id=self.cur_res.formsemestre.formation.referentiel_competence_id, - ).first() + self.validation_annee_but: ApcValidationAnnee = ( + ApcValidationAnnee.query.filter_by( + formsemestre_id=formsemestre.id, + etudid=self.etud["etudid"], + referentiel_competence_id=self.cur_res.formsemestre.formation.referentiel_competence_id, + ).first() + ) self.is_nar = ( self.validation_annee_but and self.validation_annee_but.code == NAR ) @@ -1003,7 +1005,7 @@ def comp_apo_sems(etape_apogee, annee_scolaire: int) -> list[dict]: def nar_etuds_table(apo_data, nar_etuds): """Liste les NAR -> excel table""" code_etape = apo_data.etape_apogee - today = datetime.datetime.today().strftime("%d/%m/%y") + today = datetime.datetime.today().strftime(scu.DATE_FMT) rows = [] nar_etuds.sort(key=lambda k: k["nom"]) for e in nar_etuds: diff --git a/app/scodoc/sco_archives_formsemestre.py b/app/scodoc/sco_archives_formsemestre.py index 24197dd43..6a77e6506 100644 --- a/app/scodoc/sco_archives_formsemestre.py +++ b/app/scodoc/sco_archives_formsemestre.py @@ -98,7 +98,7 @@ def do_formsemestre_archive( archive_id = PV_ARCHIVER.create_obj_archive( sem_archive_id, description, formsemestre.dept_id ) - date = PV_ARCHIVER.get_archive_date(archive_id).strftime("%d/%m/%Y à %H:%M") + date = PV_ARCHIVER.get_archive_date(archive_id).strftime(scu.DATEATIME_FMT) if not group_ids: # tous les inscrits du semestre diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index d1c32795d..d87692ff7 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -126,7 +126,7 @@ def make_context_dict(formsemestre: FormSemestre, etud: dict) -> dict: # ajoute date courante t = time.localtime() - C["date_dmy"] = time.strftime("%d/%m/%Y", t) + C["date_dmy"] = time.strftime(scu.DATE_FMT, t) C["date_iso"] = time.strftime("%Y-%m-%d", t) return C diff --git a/app/scodoc/sco_bulletins_legacy.py b/app/scodoc/sco_bulletins_legacy.py index 05c462f6c..26de93813 100644 --- a/app/scodoc/sco_bulletins_legacy.py +++ b/app/scodoc/sco_bulletins_legacy.py @@ -352,7 +352,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): H.append( f"""

{ - appreciation.date.strftime("%d/%m/%y") if appreciation.date else "" + appreciation.date.strftime(scu.DATE_FMT) if appreciation.date else "" } {appreciation.comment_safe()} {mlink} diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py index f2309e941..f96730b54 100644 --- a/app/scodoc/sco_bulletins_standard.py +++ b/app/scodoc/sco_bulletins_standard.py @@ -182,7 +182,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): H.append( f"""

{ - appreciation.date.strftime("%d/%m/%Y") + appreciation.date.strftime(scu.DATE_FMT) if appreciation.date else ""} {appreciation.comment_safe()} {mlink} diff --git a/app/scodoc/sco_cal.py b/app/scodoc/sco_cal.py index 3ca918ffe..abb837403 100644 --- a/app/scodoc/sco_cal.py +++ b/app/scodoc/sco_cal.py @@ -29,7 +29,6 @@ """ import calendar -import datetime import html import time @@ -357,7 +356,7 @@ def MonthTableBody( if not halfday: for d in range(1, nbdays + 1): weeknum = time.strftime( - "%U", time.strptime("%d/%d/%d" % (d, month, year), "%d/%m/%Y") + "%U", time.strptime("%d/%d/%d" % (d, month, year), scu.DATE_FMT) ) day = DAYNAMES_ABREV[(firstday + d - 1) % 7] if day in weekend: @@ -432,7 +431,7 @@ def MonthTableBody( # Calendar with 2 cells / day for d in range(1, nbdays + 1): weeknum = time.strftime( - "%U", time.strptime("%d/%d/%d" % (d, month, year), "%d/%m/%Y") + "%U", time.strptime("%d/%d/%d" % (d, month, year), scu.DATE_FMT) ) day = DAYNAMES_ABREV[(firstday + d - 1) % 7] if day in weekend: diff --git a/app/scodoc/sco_edt_cal.py b/app/scodoc/sco_edt_cal.py index b8cdf9ac9..1fce5d269 100644 --- a/app/scodoc/sco_edt_cal.py +++ b/app/scodoc/sco_edt_cal.py @@ -478,11 +478,11 @@ def convert_ics( "heure_deb": event.decoded("dtstart") .replace(tzinfo=timezone.utc) .astimezone(tz=None) - .strftime("%H:%M"), + .strftime(scu.TIME_FMT), "heure_fin": event.decoded("dtend") .replace(tzinfo=timezone.utc) .astimezone(tz=None) - .strftime("%H:%M"), + .strftime(scu.TIME_FMT), "jour": event.decoded("dtstart").date().isoformat(), "start": event.decoded("dtstart").isoformat(), "end": event.decoded("dtend").isoformat(), diff --git a/app/scodoc/sco_etape_apogee_view.py b/app/scodoc/sco_etape_apogee_view.py index f680775c3..f6b38b37f 100644 --- a/app/scodoc/sco_etape_apogee_view.py +++ b/app/scodoc/sco_etape_apogee_view.py @@ -452,7 +452,7 @@ def table_apo_csv_list(semset): apo_data = sco_apogee_csv.ApoData(csv_data, periode=semset["sem_id"]) t["filename"] = apo_data.apo_csv.titles["apoC_Fichier_Exp"] t["nb_etuds"] = len(apo_data.etuds) - t["date_str"] = t["date"].strftime("%d/%m/%Y à %H:%M") + t["date_str"] = t["date"].strftime(scu.DATEATIME_FMT) view_link = url_for( "notes.view_apo_csv", scodoc_dept=g.scodoc_dept, diff --git a/app/scodoc/sco_evaluation_check_abs.py b/app/scodoc/sco_evaluation_check_abs.py index 0349e8f54..852309abc 100644 --- a/app/scodoc/sco_evaluation_check_abs.py +++ b/app/scodoc/sco_evaluation_check_abs.py @@ -135,7 +135,7 @@ def evaluation_check_absences_html( f"""

{ evaluation.description or "évaluation" } du { - evaluation.date_debut.strftime("%d/%m/%Y") if evaluation.date_debut else "" + evaluation.date_debut.strftime(scu.DATE_FMT) if evaluation.date_debut else "" } """ ] if ( diff --git a/app/scodoc/sco_evaluation_edit.py b/app/scodoc/sco_evaluation_edit.py index 98cc9c02a..3d78a45a4 100644 --- a/app/scodoc/sco_evaluation_edit.py +++ b/app/scodoc/sco_evaluation_edit.py @@ -90,7 +90,7 @@ def evaluation_create_form( raise ValueError("missing moduleimpl_id parameter") numeros = [(e.numero or 0) for e in modimpl.evaluations] initvalues = { - "jour": time.strftime("%d/%m/%Y", time.localtime()), + "jour": time.strftime(scu.DATE_FMT, time.localtime()), "note_max": 20, "numero": (max(numeros) + 1) if numeros else 0, "publish_incomplete": is_malus, @@ -144,7 +144,7 @@ def evaluation_create_form( if edit: initvalues["blocked"] = evaluation.is_blocked() initvalues["blocked_until"] = ( - evaluation.blocked_until.strftime("%d/%m/%Y") + evaluation.blocked_until.strftime(scu.DATE_FMT) if evaluation.blocked_until and evaluation.blocked_until < Evaluation.BLOCKED_FOREVER else "" @@ -405,7 +405,7 @@ def evaluation_create_form( if args.get("blocked_until"): try: args["blocked_until"] = datetime.datetime.strptime( - args["blocked_until"], "%d/%m/%Y" + args["blocked_until"], scu.DATE_FMT ) except ValueError as exc: raise ScoValueError("Date déblocage (j/m/a) invalide") from exc diff --git a/app/scodoc/sco_evaluation_recap.py b/app/scodoc/sco_evaluation_recap.py index 25042ecc2..514d6030e 100644 --- a/app/scodoc/sco_evaluation_recap.py +++ b/app/scodoc/sco_evaluation_recap.py @@ -126,13 +126,15 @@ def evaluations_recap_table(formsemestre: FormSemestre) -> list[dict]: evaluation_id=evaluation_id, ), "_titre_target_attrs": 'class="discretelink"', - "date": e.date_debut.strftime("%d/%m/%Y") if e.date_debut else "", + "date": e.date_debut.strftime(scu.DATE_FMT) if e.date_debut else "", "_date_order": e.date_debut.isoformat() if e.date_debut else "", "complete": "oui" if eval_etat.is_complete else "non", "_complete_target": "#", - "_complete_target_attrs": 'class="bull_link" title="prise en compte dans les moyennes"' - if eval_etat.is_complete - else 'class="bull_link incomplete" title="il manque des notes"', + "_complete_target_attrs": ( + 'class="bull_link" title="prise en compte dans les moyennes"' + if eval_etat.is_complete + else 'class="bull_link incomplete" title="il manque des notes"' + ), "manquantes": len(modimpl_results.evals_etudids_sans_note[e.id]), "inscrits": modimpl_results.nb_inscrits_module, "nb_abs": sum(modimpl_results.evals_notes[e.id] == scu.NOTES_ABSENCE), diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index 32f1992a8..06e0258d1 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -381,8 +381,10 @@ def formsemestre_evaluations_cal(formsemestre_id): if e.date_debut == e.date_fin: heure_debut_txt, heure_fin_txt = "?", "?" else: - heure_debut_txt = e.date_debut.strftime("%Hh%M") if e.date_debut else "?" - heure_fin_txt = e.date_fin.strftime("%Hh%M") if e.date_fin else "?" + heure_debut_txt = ( + e.date_debut.strftime(scu.TIME_FMT) if e.date_debut else "?" + ) + heure_fin_txt = e.date_fin.strftime(scu.TIME_FMT) if e.date_fin else "?" description = f"""{ e.moduleimpl.module.titre @@ -526,7 +528,7 @@ def formsemestre_evaluations_delai_correction(formsemestre_id, fmt="html"): "date_first_complete": date_first_complete, "delai_correction": delai_correction, "jour": ( - e.date_debut.strftime("%d/%m/%Y") if e.date_debut else "sans date" + e.date_debut.strftime(scu.DATE_FMT) if e.date_debut else "sans date" ), "_jour_target": url_for( "notes.evaluation_listenotes", diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index ea72d2b58..08f1af9f5 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -72,7 +72,7 @@ def xldate_as_datetime(xldate, datemode=0): Peut lever une ValueError """ try: - return datetime.datetime.strptime(xldate, "%d/%m/%Y") + return datetime.datetime.strptime(xldate, scu.DATE_FMT) except: return openpyxl.utils.datetime.from_ISO8601(xldate) diff --git a/app/scodoc/sco_formsemestre_exterieurs.py b/app/scodoc/sco_formsemestre_exterieurs.py index c9b329e91..4ba6a47ab 100644 --- a/app/scodoc/sco_formsemestre_exterieurs.py +++ b/app/scodoc/sco_formsemestre_exterieurs.py @@ -521,7 +521,7 @@ def _record_ue_validations_and_coefs( coef = _convert_field_to_float(coef) if coef == "" or coef is False: coef = None - now_dmy = time.strftime("%d/%m/%Y") + now_dmy = time.strftime(scu.DATE_FMT) log( f"_record_ue_validations_and_coefs: {formsemestre.id} etudid={etud.id} ue_id={ue.id} moy_ue={note} ue_coef={coef}" ) diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index f8ddc30d5..15995e11e 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -106,7 +106,7 @@ def do_formsemestre_inscription_create(args, method=None): cnx, args={ "etudid": args["etudid"], - "event_date": time.strftime("%d/%m/%Y"), + "event_date": time.strftime(scu.DATE_FMT), "formsemestre_id": args["formsemestre_id"], "event_type": "INSCRIPTION", }, diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 2563e5a72..058550127 100755 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -64,14 +64,11 @@ from app.scodoc import sco_archives_formsemestre from app.scodoc import sco_bulletins from app.scodoc import codes_cursus from app.scodoc import sco_compute_moy -from app.scodoc import sco_edit_ue from app.scodoc import sco_evaluations -from app.scodoc import sco_evaluation_db from app.scodoc import sco_formations from app.scodoc import sco_formsemestre from app.scodoc import sco_formsemestre_inscriptions from app.scodoc import sco_groups -from app.scodoc import sco_moduleimpl from app.scodoc import sco_preferences from app.scodoc import sco_users from app.scodoc.gen_tables import GenTable @@ -692,7 +689,7 @@ def formsemestre_description_table( ) e["_date_evaluation_order"] = e["jour"].isoformat() e["date_evaluation"] = ( - e["jour"].strftime("%d/%m/%Y") if e["jour"] else "" + e["jour"].strftime(scu.DATE_FMT) if e["jour"] else "" ) e["UE"] = row["UE"] e["_UE_td_attrs"] = row["_UE_td_attrs"] diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py index 16e8d5299..55ed06658 100644 --- a/app/scodoc/sco_formsemestre_validation.py +++ b/app/scodoc/sco_formsemestre_validation.py @@ -1160,7 +1160,7 @@ def formsemestre_validate_previous_ue(formsemestre: FormSemestre, etud: Identite "input_type": "date", "size": 9, "explanation": "j/m/a", - "default": time.strftime("%d/%m/%Y"), + "default": time.strftime(scu.DATE_FMT), }, ), ( diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py index 59de87215..85f2b18ba 100644 --- a/app/scodoc/sco_inscr_passage.py +++ b/app/scodoc/sco_inscr_passage.py @@ -513,7 +513,7 @@ def _build_page(
{scu.EMO_WARNING} Seuls les semestres dont la date de fin est proche de la date de début - de ce semestre ({formsemestre.date_debut.strftime("%d/%m/%Y")}) sont pris en + de ce semestre ({formsemestre.date_debut.strftime(scu.DATE_FMT)}) sont pris en compte.
{etuds_select_boxes(auth_etuds_by_sem, inscrits_ailleurs)} @@ -704,7 +704,7 @@ def etuds_select_boxes( elink += ( '' + " : inscription finalisée le " - + etud["datefinalisationinscription"].strftime("%d/%m/%Y") + + etud["datefinalisationinscription"].strftime(scu.DATE_FMT) + "" ) diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index f2ca4f571..46f28adc1 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -827,7 +827,7 @@ def _add_eval_columns( nb_notes, evaluation.description, ( - evaluation.date_debut.strftime("%d/%m/%Y") + evaluation.date_debut.strftime(scu.DATE_FMT) if evaluation.date_debut else "" ), diff --git a/app/scodoc/sco_moduleimpl_inscriptions.py b/app/scodoc/sco_moduleimpl_inscriptions.py index 20467db7d..8f79e46f7 100644 --- a/app/scodoc/sco_moduleimpl_inscriptions.py +++ b/app/scodoc/sco_moduleimpl_inscriptions.py @@ -50,8 +50,6 @@ from app.scodoc import html_sco_header from app.scodoc import htmlutils from app.scodoc import sco_cache from app.scodoc import codes_cursus -from app.scodoc import sco_edit_module -from app.scodoc import sco_edit_ue from app.scodoc import sco_etud from app.scodoc import sco_formsemestre_inscriptions from app.scodoc import sco_groups @@ -431,7 +429,7 @@ def moduleimpl_inscriptions_stats(formsemestre_id): ) if info["ue_status"]["event_date"]: H.append( - f"""(cap. le {info["ue_status"]["event_date"].strftime("%d/%m/%Y")})""" + f"""(cap. le {info["ue_status"]["event_date"].strftime(scu.DATE_FMT)})""" ) if is_apc: is_inscrit_ue = (etud.id, ue.id) not in res.dispense_ues @@ -584,7 +582,7 @@ def _list_but_ue_inscriptions(res: NotesTableCompat, read_only: bool = True) -> validation = validations_ue[-1] if validations_ue else None expl_validation = ( f"""Validée ({validation.code}) le { - validation.event_date.strftime("%d/%m/%Y")}""" + validation.event_date.strftime(scu.DATE_FMT)}""" if validation else "" ) diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index aee1c91ec..4aeae9da9 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -28,7 +28,6 @@ """Tableau de bord module""" import math -import time import datetime from flask import g, url_for @@ -48,13 +47,10 @@ from app.scodoc.sco_permissions import Permission from app.scodoc import html_sco_header from app.scodoc import htmlutils -from app.scodoc import sco_cal from app.scodoc import sco_compute_moy from app.scodoc import sco_evaluations -from app.scodoc import sco_formsemestre_status from app.scodoc import sco_groups from app.scodoc import sco_moduleimpl -from app.scodoc import sco_permissions_check from app.tables import list_etuds @@ -262,7 +258,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): # 2ieme ligne: Semestre, Coef H.append("""""") if formsemestre.semestre_id >= 0: - H.append("""Semestre: %s""" % formsemestre.semestre_id) + H.append(f"""Semestre: {formsemestre.semestre_id}""") else: H.append("""""") if sem_locked: @@ -290,7 +286,8 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): ) if current_user.has_permission(Permission.EtudInscrit): H.append( - f"""modifier""" + f"""modifier""" ) H.append("") # Ligne: règle de calcul @@ -614,7 +611,7 @@ def _ligne_evaluation( if evaluation.is_blocked(): etat_txt = f"""évaluation bloquée { - "jusqu'au " + evaluation.blocked_until.strftime("%d/%m/%Y") + "jusqu'au " + evaluation.blocked_until.strftime(scu.DATE_FMT) if evaluation.blocked_until < Evaluation.BLOCKED_FOREVER else "" } """ @@ -657,7 +654,8 @@ def _ligne_evaluation( Notes Abs N - {etat_txt} + {etat_txt} """ diff --git a/app/scodoc/sco_page_etud.py b/app/scodoc/sco_page_etud.py index ad52e8132..ba99209a8 100644 --- a/app/scodoc/sco_page_etud.py +++ b/app/scodoc/sco_page_etud.py @@ -730,7 +730,7 @@ def get_html_annotations_list(etud: Identite) -> list[str]: author = User.query.filter_by(user_name=annot.author).first() html_annotations_list.append( f"""Le { - annot.date.strftime("%d/%m/%Y") if annot.date else "?"} + annot.date.strftime(scu.DATE_FMT) if annot.date else "?"} par {author.get_prenomnom() if author else "?"} : {annot.comment or ""}{del_link} """ diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index ba87f84bf..c1dbbfad4 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -335,7 +335,7 @@ class PlacementRunner: def _production_pdf(self): pdf_title = "
".join(self.desceval) - pdf_title += f"""\nDate : {self.evaluation.date_debut.strftime("%d/%m/%Y") + pdf_title += f"""\nDate : {self.evaluation.date_debut.strftime(scu.DATE_FMT) if self.evaluation.date_debut else '-' } - Horaire : {self.evaluation.heure_debut()} à {self.evaluation.heure_fin() }""" @@ -485,7 +485,7 @@ class PlacementRunner: worksheet.append_blank_row() worksheet.append_single_cell_row(desceval, self.styles["titres"]) worksheet.append_single_cell_row( - f"""Date : {self.evaluation.date_debut.strftime("%d/%m/%Y") + f"""Date : {self.evaluation.date_debut.strftime(scu.DATE_FMT) if self.evaluation.date_debut else '-' } - Horaire : {self.evaluation.heure_debut()} à {self.evaluation.heure_fin() }""", diff --git a/app/scodoc/sco_portal_apogee.py b/app/scodoc/sco_portal_apogee.py index ec2ed1329..7081f7c9b 100644 --- a/app/scodoc/sco_portal_apogee.py +++ b/app/scodoc/sco_portal_apogee.py @@ -517,7 +517,7 @@ def _normalize_apo_fields(infolist): ) infos["datefinalisationinscription_str"] = infos[ "datefinalisationinscription" - ].strftime("%d/%m/%Y") + ].strftime(scu.DATE_FMT) else: infos["datefinalisationinscription"] = None infos["datefinalisationinscription_str"] = "" diff --git a/app/scodoc/sco_prepajury.py b/app/scodoc/sco_prepajury.py index db04bc04f..750aac162 100644 --- a/app/scodoc/sco_prepajury.py +++ b/app/scodoc/sco_prepajury.py @@ -327,7 +327,7 @@ def feuille_preparation_jury(formsemestre_id): "Préparé par %s le %s sur %s pour %s" % ( sco_version.SCONAME, - time.strftime("%d/%m/%Y"), + time.strftime(scu.DATE_FMT), request.url_root, current_user, ) diff --git a/app/scodoc/sco_report.py b/app/scodoc/sco_report.py index cc66ec071..511850915 100644 --- a/app/scodoc/sco_report.py +++ b/app/scodoc/sco_report.py @@ -670,8 +670,8 @@ def table_suivi_cohorte( L.append(l) columns_ids = [p.datedebut for p in P] - titles = dict([(p.datedebut, p.datedebut.strftime("%d/%m/%y")) for p in P]) - titles[porigin.datedebut] = porigin.datedebut.strftime("%d/%m/%y") + titles = dict([(p.datedebut, p.datedebut.strftime(scu.DATE_FMT)) for p in P]) + titles[porigin.datedebut] = porigin.datedebut.strftime(scu.DATE_FMT) if percent: pp = "(en % de la population initiale) " titles["row_title"] = "%" @@ -717,7 +717,7 @@ def table_suivi_cohorte( else: expl = ["

Semestres associés à chaque date:

    "] for p in P: - expl.append(f"""
  • {p.datedebut.strftime("%d/%m/%y")}:""") + expl.append(f"""
  • {p.datedebut.strftime(scu.DATE_FMT)}:""") ls = [] for s in p.sems: ls.append(formsemestre.html_link_status()) diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index fd5b51bfd..d8006e496 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -892,7 +892,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]): eval_name = f"{evaluation.moduleimpl.module.code}-{indication_date}" date_str = ( - f"""du {evaluation.date_debut.strftime("%d/%m/%Y")}""" + f"""du {evaluation.date_debut.strftime(scu.DATE_FMT)}""" if evaluation.date_debut else "(sans date)" ) diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 55fa10cbc..643a04165 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -117,7 +117,7 @@ def convert_fr_date(date_str: str, allow_iso=True) -> datetime.datetime: ScoValueError si date invalide. """ try: - return datetime.datetime.strptime(date_str, "%d/%m/%Y") + return datetime.datetime.strptime(date_str, DATE_FMT) except ValueError: # Try to add century ? m = re.match(r"^(\d{1,2})/(\d{1,2})/(\d\d)$", date_str) @@ -129,7 +129,7 @@ def convert_fr_date(date_str: str, allow_iso=True) -> datetime.datetime: year += 1900 try: return datetime.datetime.strptime( - f"{m.group(1)}/{m.group(2)}/{year}", "%d/%m/%Y" + f"{m.group(1)}/{m.group(2)}/{year}", DATE_FMT ) except ValueError: pass @@ -550,6 +550,11 @@ MONTH_NAMES = ( ) DAY_NAMES = ("lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche") +TIME_FMT = "%H:%M" # affichage des heures +DATE_FMT = "%d/%m/%Y" # affichage des dates +DATEATIME_FMT = DATE_FMT + " à " + DATE_FMT +DATETIME_FMT = DATE_FMT + " " + DATE_FMT + def fmt_note(val, note_max=None, keep_numeric=False): """conversion note en str pour affichage dans tables HTML ou PDF. @@ -1067,9 +1072,9 @@ def bul_filename(formsemestre, etud, prefix="bul"): def flash_errors(form): """Flashes form errors (version sommaire)""" - for field, errors in form.errors.items(): + for field, _ in form.errors.items(): flash( - "Erreur: voir le champ %s" % (getattr(form, field).label.text,), + f"Erreur: voir le champ {getattr(form, field).label.text}", "warning", ) # see https://getbootstrap.com/docs/4.0/components/alerts/ diff --git a/app/tables/liste_assiduites.py b/app/tables/liste_assiduites.py index 19316bd3f..c0c7dbbba 100644 --- a/app/tables/liste_assiduites.py +++ b/app/tables/liste_assiduites.py @@ -13,6 +13,8 @@ from sqlalchemy import desc, literal, union, asc from app import db, g from app.auth.models import User from app.models import Assiduite, Identite, Justificatif, Module +import app.scodoc.sco_utils as scu + from app.scodoc.sco_utils import ( EtatAssiduite, EtatJustificatif, @@ -401,8 +403,8 @@ class RowAssiJusti(tb.Row): ] if multi_days and self.ligne["type"] != "justificatif": - date_affichees[0] = self.ligne["date_debut"].strftime("%d/%m/%y") - date_affichees[1] = self.ligne["date_fin"].strftime("%d/%m/%y") + date_affichees[0] = self.ligne["date_debut"].strftime(scu.DATE_FMT) + date_affichees[1] = self.ligne["date_fin"].strftime(scu.DATE_FMT) self.add_cell( "date_debut", @@ -443,7 +445,7 @@ class RowAssiJusti(tb.Row): "entry_date", "Saisie le", ( - self.ligne["entry_date"].strftime("%d/%m/%y à %H:%M") + self.ligne["entry_date"].strftime(scu.DATEATIME_FMT) if self.ligne["entry_date"] else "?" ), diff --git a/app/tables/recap.py b/app/tables/recap.py index 9de571581..5b948615a 100644 --- a/app/tables/recap.py +++ b/app/tables/recap.py @@ -386,7 +386,7 @@ class TableRecap(tb.Table): for e in evals: col_id = f"eval_{e.id}" title = f"""{modimpl.module.code} {eval_index} { - e.date_debut.strftime("%d/%m/%Y") if e.date_debut else "" + e.date_debut.strftime(scu.DATE_FMT) if e.date_debut else "" }""" col_classes = [] if first_eval: diff --git a/app/templates/assiduites/pages/ajout_justificatif_etud.j2 b/app/templates/assiduites/pages/ajout_justificatif_etud.j2 index 311d25c7e..221f3b496 100644 --- a/app/templates/assiduites/pages/ajout_justificatif_etud.j2 +++ b/app/templates/assiduites/pages/ajout_justificatif_etud.j2 @@ -48,7 +48,7 @@ div.submit > input { {% if justif %}
    Saisie par {{justif.user.get_prenomnom() if justif.user else "inconnu"}} - le {{justif.entry_date.strftime("%d/%m/%Y à %H:%M") if justif.entry_date else "?"}} + le {{justif.entry_date.strftime(scu.DATEATIME_FMT) if justif.entry_date else "?"}}
    {% endif %} diff --git a/app/templates/assiduites/pages/etat_abs_date.j2 b/app/templates/assiduites/pages/etat_abs_date.j2 index 22ecb8e56..5f51b317d 100644 --- a/app/templates/assiduites/pages/etat_abs_date.j2 +++ b/app/templates/assiduites/pages/etat_abs_date.j2 @@ -10,8 +10,8 @@ {% block app_content %}
    -

    Présence du groupe {{group_title}} le {{date_debut.strftime("%d/%m/%Y")}} -de {{date_debut.strftime("%H:%M")}} à {{date_fin.strftime("%H:%M")}} +

    Présence du groupe {{group_title}} le {{date_debut.strftime(scu.DATE_FMT)}} +de {{date_debut.strftime(scu.TIME_FMT)}} à {{date_fin.strftime(scu.TIME_FMT)}}

    diff --git a/app/templates/assiduites/pages/traitement_justificatifs.j2 b/app/templates/assiduites/pages/traitement_justificatifs.j2 index 6054f5657..ea2ae094c 100644 --- a/app/templates/assiduites/pages/traitement_justificatifs.j2 +++ b/app/templates/assiduites/pages/traitement_justificatifs.j2 @@ -326,15 +326,15 @@ main();
    {% if ligne.justif.date_debut.date() == ligne.justif.date_fin.date() %} - {{ligne.justif.date_debut.strftime("%d/%m/%y")}} de {{ligne.justif.date_debut.strftime("%Hh%M")}} à - {{ligne.justif.date_fin.strftime("%Hh%M")}} + {{ligne.justif.date_debut.strftime(scu.DATE_FMT)}} de {{ligne.justif.date_debut.strftime(scu.TIME_FMT)}} à + {{ligne.justif.date_fin.strftime(scu.TIME_FMT)}} {% else %} - du {{ligne.justif.date_debut.strftime("%d/%m/%y")}} + du {{ligne.justif.date_debut.strftime(scu.DATE_FMT)}} - au {{ligne.justif.date_fin.strftime("%d/%m/%y")}} + au {{ligne.justif.date_fin.strftime(scu.DATE_FMT)}} {% endif %}
  • {{scu.EtatAssiduite(assi.etat).version_lisible()}} {% if assi.date_debut.date() == assi.date_fin.date() %} - du {{assi.date_debut.strftime("%d/%m/%y")}} de {{assi.date_debut.strftime("%Hh%M")}} à - {{assi.date_fin.strftime("%Hh%M")}} + du {{assi.date_debut.strftime(scu.DATE_FMT)}} de {{assi.date_debut.strftime(scu.TIME_FMT)}} à + {{assi.date_fin.strftime(scu.TIME_FMT)}} {% else %} du {{assi.date_debut.strftime("%d/%m/%y %Hh%M")}} au {{assi.date_fin.strftime("%d/%m/%y %Hh%M")}} diff --git a/app/templates/auth/user_info_page.j2 b/app/templates/auth/user_info_page.j2 index 315bb6251..b3957202a 100644 --- a/app/templates/auth/user_info_page.j2 +++ b/app/templates/auth/user_info_page.j2 @@ -30,15 +30,15 @@
{% if current_user.is_administrator() %}
- Dernière vue : {{user.last_seen.strftime("%d/%m/%Y à %H:%M") if user.last_seen else "-"}}
- Dernière connexion CAS : {{user.cas_last_login.strftime("%d/%m/%Y à %H:%M") if user.cas_last_login else "-"}}
+ Dernière vue : {{user.last_seen.strftime(scu.DATEATIME_FMT) if user.last_seen else "-"}}
+ Dernière connexion CAS : {{user.cas_last_login.strftime(scu.DATEATIME_FMT) if user.cas_last_login else "-"}}
{% endif %}
Dernière modif mot de passe: - {{user.date_modif_passwd.strftime("%d/%m/%Y") if user.date_modif_passwd else ""}}
+ {{user.date_modif_passwd.strftime(scu.DATE_FMT) if user.date_modif_passwd else ""}}
Date d'expiration: - {{user.date_expiration.strftime("%d/%m/%Y") if user.date_expiration else "(sans limite)"}} + {{user.date_expiration.strftime(scu.DATE_FMT) if user.date_expiration else "(sans limite)"}}
diff --git a/app/templates/but/bulletin_court_page.j2 b/app/templates/but/bulletin_court_page.j2 index a878e9f11..1faa42cfe 100644 --- a/app/templates/but/bulletin_court_page.j2 +++ b/app/templates/but/bulletin_court_page.j2 @@ -134,7 +134,7 @@
{% if bul.semestre.decision_annee %} Décision saisie le {{ - datetime.datetime.fromisoformat(bul.semestre.decision_annee.date).strftime("%d/%m/%Y") + datetime.datetime.fromisoformat(bul.semestre.decision_annee.date).strftime(scu.DATE_FMT) }}, année BUT{{bul.semestre.decision_annee.ordre}} {{bul.semestre.decision_annee.code}}. diff --git a/app/templates/but/cursus_etud.j2 b/app/templates/but/cursus_etud.j2 index 34090aa61..16361ee61 100644 --- a/app/templates/but/cursus_etud.j2 +++ b/app/templates/but/cursus_etud.j2 @@ -18,7 +18,7 @@
{{validation.ue1.acronyme}} - {{validation.ue2.acronyme}}
Jury de {{validation.formsemestre.titre_annee() if validation.formsemestre else "-"}}
enregistré le {{ - validation.date.strftime("%d/%m/%Y à %H:%M") + validation.date.strftime(scu.DATEATIME_FMT) }}
diff --git a/app/templates/but/refcomp_show.j2 b/app/templates/but/refcomp_show.j2 index 7ccc0372c..bd152aab4 100644 --- a/app/templates/but/refcomp_show.j2 +++ b/app/templates/but/refcomp_show.j2 @@ -9,7 +9,7 @@

Référentiel de compétences {{ref.type_titre}} {{ref.specialite_long}}

- Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à + Référentiel chargé le {{ref.scodoc_date_loaded.strftime(scu.DATEATIME_FMT) if ref.scodoc_date_loaded else ""}} à partir du fichier {{ref.scodoc_orig_filename or "(inconnu)"}}.
diff --git a/app/templates/but/validation_rcues.j2 b/app/templates/but/validation_rcues.j2 index 484e87cef..6dc4b39f0 100644 --- a/app/templates/but/validation_rcues.j2 +++ b/app/templates/but/validation_rcues.j2 @@ -26,7 +26,7 @@
Jury de {{validation.formsemestre.titre_annee() if validation.formsemestre else "-"}}
enregistrée le {{ - validation.event_date.strftime("%d/%m/%Y à %H:%M") + validation.event_date.strftime(scu.DATEATIME_FMT) if validation.event_date else "-" }}
{{"%g"|format(validation.ects())}} ECTS
@@ -116,7 +116,7 @@
Validation du RCUE
enregistrée le {{ - validation.date.strftime("%d/%m/%Y à %H:%M") + validation.date.strftime(scu.DATEATIME_FMT) if validation.date else "-" }}
diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 22f2d46f5..7ce10e556 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -313,13 +313,13 @@ def _get_dates_from_assi_form( date_fin = None # On commence par convertir individuellement tous les champs try: - date_debut = datetime.datetime.strptime(form.date_debut.data, "%d/%m/%Y") + date_debut = datetime.datetime.strptime(form.date_debut.data, scu.DATE_FMT) except ValueError: date_debut = None form.set_error("date début invalide", form.date_debut) try: date_fin = ( - datetime.datetime.strptime(form.date_fin.data, "%d/%m/%Y") + datetime.datetime.strptime(form.date_fin.data, scu.DATE_FMT) if form.date_fin.data else None ) @@ -358,7 +358,7 @@ def _get_dates_from_assi_form( # La date de dépôt (si vide, la date actuelle) try: dt_entry_date = ( - datetime.datetime.strptime(form.entry_date.data, "%d/%m/%Y") + datetime.datetime.strptime(form.entry_date.data, scu.DATE_FMT) if form.entry_date.data else datetime.datetime.now() # local tz ) @@ -573,8 +573,8 @@ def bilan_etud(): abort(404, "étudiant inexistant dans ce département") # Gestion des dates du bilan (par défaut l'année scolaire) - date_debut = scu.date_debut_annee_scolaire().strftime("%d/%m/%Y") - date_fin: str = scu.date_fin_annee_scolaire().strftime("%d/%m/%Y") + date_debut = scu.date_debut_annee_scolaire().strftime(scu.DATE_FMT) + date_fin: str = scu.date_fin_annee_scolaire().strftime(scu.DATE_FMT) # Récupération de la métrique d'assiduité assi_metric = scu.translate_assiduites_metric( @@ -634,18 +634,18 @@ def edit_justificatif_etud(justif_id: int): form = AjoutJustificatifEtudForm(obj=justif) # Set the default value for the etat field if request.method == "GET": - form.date_debut.data = justif.date_debut.strftime("%d/%m/%Y") - form.date_fin.data = justif.date_fin.strftime("%d/%m/%Y") + form.date_debut.data = justif.date_debut.strftime(scu.DATE_FMT) + form.date_fin.data = justif.date_fin.strftime(scu.DATE_FMT) if form.date_fin.data == form.date_debut.data: # un seul jour: pas de date de fin, indique les heures form.date_fin.data = "" - form.heure_debut.data = justif.date_debut.strftime("%H:%M") - form.heure_fin.data = justif.date_fin.strftime("%H:%M") + form.heure_debut.data = justif.date_debut.strftime(scu.TIME_FMT) + form.heure_fin.data = justif.date_fin.strftime(scu.TIME_FMT) form.entry_date.data = ( - justif.entry_date.strftime("%d/%m/%Y") if justif.entry_date else "" + justif.entry_date.strftime(scu.DATE_FMT) if justif.entry_date else "" ) form.entry_time.data = ( - justif.entry_date.strftime("%H:%M") if justif.entry_date else "" + justif.entry_date.strftime(scu.TIME_FMT) if justif.entry_date else "" ) form.etat.data = str(justif.etat) @@ -968,7 +968,7 @@ def choix_date() -> str: ok: bool = False try: date: datetime.date = datetime.datetime.strptime( - form.date.data, "%d/%m/%Y" + form.date.data, scu.DATE_FMT ).date() if date < formsemestre.date_debut or date > formsemestre.date_fin: form.set_error( @@ -999,8 +999,8 @@ def choix_date() -> str: "assiduites/pages/choix_date.j2", form=form, sco=ScoData(formsemestre=formsemestre), - deb=formsemestre.date_debut.strftime("%d/%m/%Y"), - fin=formsemestre.date_fin.strftime("%d/%m/%Y"), + deb=formsemestre.date_debut.strftime(scu.DATE_FMT), + fin=formsemestre.date_fin.strftime(scu.DATE_FMT), ) @@ -1607,11 +1607,11 @@ def recup_assiduites_plage(): # Vérification des dates try: - date_deb = datetime.datetime.strptime(date_deb, "%d/%m/%Y") + date_deb = datetime.datetime.strptime(date_deb, scu.DATE_FMT) except ValueError as exc: raise ScoValueError("date_debut invalide", dest_url=request.referrer) from exc try: - date_fin = datetime.datetime.strptime(date_fin, "%d/%m/%Y") + date_fin = datetime.datetime.strptime(date_fin, scu.DATE_FMT) except ValueError as exc: raise ScoValueError("date_fin invalide", dest_url=request.referrer) from exc @@ -1893,12 +1893,12 @@ def _preparer_objet( "filenames": filenames, } - objet_prepare["date_fin"] = objet.date_fin.strftime("%d/%m/%y à %H:%M") + objet_prepare["date_fin"] = objet.date_fin.strftime(scu.DATEATIME_FMT) objet_prepare["real_date_fin"] = objet.date_fin.isoformat() - objet_prepare["date_debut"] = objet.date_debut.strftime("%d/%m/%y à %H:%M") + objet_prepare["date_debut"] = objet.date_debut.strftime(scu.DATEATIME_FMT) objet_prepare["real_date_debut"] = objet.date_debut.isoformat() - objet_prepare["entry_date"] = objet.entry_date.strftime("%d/%m/%y à %H:%M") + objet_prepare["entry_date"] = objet.entry_date.strftime(scu.DATEATIME_FMT) objet_prepare["etud_nom"] = objet.etudiant.nomprenom @@ -2243,7 +2243,7 @@ def _get_date_str(deb: datetime.datetime, fin: datetime.datetime) -> str: "du dd/mm/yyyy hh:MM audd/mm/yyyy hh:MM" sinon """ if deb.date() == fin.date(): - temps = deb.strftime("%d/%m/%Y %H:%M").split(" ") + [fin.strftime("%H:%M")] + temps = deb.strftime("%d/%m/%Y %H:%M").split(" ") + [fin.strftime(scu.TIME_FMT)] return f"le {temps[0]} de {temps[1]} à {temps[2]}" return f'du {deb.strftime("%d/%m/%Y %H:%M")} au {fin.strftime("%d/%m/%Y %H:%M")}' @@ -2542,7 +2542,7 @@ class Jour: """ Renvoie la date du jour au format "dd/mm/yyyy" """ - return self.date.strftime("%d/%m/%Y") + return self.date.strftime(scu.DATE_FMT) def get_class(self, show_pres: bool = False, show_reta: bool = False) -> str: """ diff --git a/app/views/notes.py b/app/views/notes.py index 1bdccf864..242f9d8fc 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -2455,7 +2455,7 @@ def formsemestre_validation_but( if formsemestre.date_fin - datetime.date.today() > datetime.timedelta(days=12): # encore loin de la fin du semestre de départ de ce jury ? warning += f"""
Le semestre S{formsemestre.semestre_id} - terminera le {formsemestre.date_fin.strftime("%d/%m/%Y")} : + terminera le {formsemestre.date_fin.strftime(scu.DATE_FMT)} : êtes-vous certain de vouloir enregistrer une décision de jury ?
""" diff --git a/app/views/scolar.py b/app/views/scolar.py index 6cb7a357c..d62a2b53c 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -1162,7 +1162,7 @@ def _form_dem_of_def( ).first_or_404() if not formsemestre.etat: raise ScoValueError("Modification impossible: semestre verrouille") - nowdmy = time.strftime("%d/%m/%Y") + nowdmy = time.strftime(scu.DATE_FMT) # header = html_sco_header.sco_header( page_title=f"""{operation_name} de {etud.nomprenom} (du semestre {formsemestre.titre_mois()})""" diff --git a/app/views/users.py b/app/views/users.py index 241190111..be505bb19 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -245,7 +245,7 @@ def create_user_form(user_name=None, edit=0, all_roles=True): initvalues["roles"] = [] if "date_expiration" in initvalues: initvalues["date_expiration"] = ( - the_user.date_expiration.strftime("%d/%m/%Y") + the_user.date_expiration.strftime(scu.DATE_FMT) if the_user.date_expiration else "" ) @@ -391,9 +391,9 @@ def create_user_form(user_name=None, edit=0, all_roles=True): { "title": "e-mail", "input_type": "text", - "explanation": "requis, doit fonctionner" - if not edit_only_roles - else "", + "explanation": ( + "requis, doit fonctionner" if not edit_only_roles else "" + ), "size": 36, "allow_null": False, "readonly": edit_only_roles, @@ -448,10 +448,10 @@ def create_user_form(user_name=None, edit=0, all_roles=True): "title": "e-mail institutionnel", "input_type": "text", "explanation": ( - "requis" if require_email_institutionnel else "facultatif" - ) - if not edit_only_roles - else "", + ("requis" if require_email_institutionnel else "facultatif") + if not edit_only_roles + else "" + ), "size": 36, "allow_null": not require_email_institutionnel, "readonly": edit_only_roles, @@ -550,9 +550,11 @@ def create_user_form(user_name=None, edit=0, all_roles=True): { "title": "Date d'expiration", # j/m/a "input_type": "datedmy", - "explanation": "j/m/a, laisser vide si pas de limite" - if not edit_only_roles - else "", + "explanation": ( + "j/m/a, laisser vide si pas de limite" + if not edit_only_roles + else "" + ), "size": 9, "allow_null": True, "readonly": edit_only_roles, @@ -664,7 +666,7 @@ def create_user_form(user_name=None, edit=0, all_roles=True): try: if vals["date_expiration"]: vals["date_expiration"] = datetime.datetime.strptime( - vals["date_expiration"], "%d/%m/%Y" + vals["date_expiration"], scu.DATE_FMT ) if vals["date_expiration"] < datetime.datetime.now(): H.append(tf_error_message("date expiration passée")) diff --git a/tests/unit/sco_fake_gen.py b/tests/unit/sco_fake_gen.py index fe5b700ae..0090d53a1 100644 --- a/tests/unit/sco_fake_gen.py +++ b/tests/unit/sco_fake_gen.py @@ -414,7 +414,7 @@ class ScoFake(object): for e_idx in range(1, nb_evaluations_per_module + 1): e = self.create_evaluation( moduleimpl_id=moduleimpl_id, - date_debut=datetime.datetime.strptime(date_debut, "%d/%m/%Y"), + date_debut=datetime.datetime.strptime(date_debut, scu.DATE_FMT), description="evaluation test %s" % e_idx, coefficient=1.0, ) diff --git a/tests/unit/test_assiduites.py b/tests/unit/test_assiduites.py index 11260746b..e6e057c87 100644 --- a/tests/unit/test_assiduites.py +++ b/tests/unit/test_assiduites.py @@ -962,8 +962,8 @@ def _create_abs( date_debut, date_fin, demijournee, estjust=False, etudid=False, estabs=True ): etud = Identite.from_request(etudid) - deb: dt.date = dt.datetime.strptime(date_debut, "%d/%m/%Y").date() - fin: dt.date = dt.datetime.strptime(date_fin, "%d/%m/%Y").date() + deb: dt.date = dt.datetime.strptime(date_debut, scu.DATE_FMT).date() + fin: dt.date = dt.datetime.strptime(date_fin, scu.DATE_FMT).date() abs_list: list[Absence] = [] while deb < fin: if deb.weekday() in [5, 6]: