diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 928dd609..a55188b6 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -8,6 +8,7 @@ from functools import cached_property import flask_sqlalchemy from app import db +from app import log from app.models import APO_CODE_STR_LEN from app.models import SHORT_STR_LEN from app.models import CODE_STR_LEN @@ -158,6 +159,24 @@ class FormSemestre(db.Model): """ return (self.date_debut <= date_debut) and (date_fin <= self.date_fin) + def est_sur_une_annee(self): + """Test si sem est entièrement sur la même année scolaire. + (ce n'est pas obligatoire mais si ce n'est pas le + cas les exports Apogée risquent de mal fonctionner) + Pivot au 1er août. + """ + if self.date_debut > self.date_fin: + log(f"Warning: semestre {self.id} begins after ending !") + annee_debut = self.date_debut.year + if self.date_debut.month < 8: # août + # considere que debut sur l'anne scolaire precedente + annee_debut -= 1 + annee_fin = self.date_fin.year + if self.date_fin.month < 9: + # 9 (sept) pour autoriser un début en sept et une fin en aout + annee_fin -= 1 + return annee_debut == annee_fin + def est_decale(self): """Vrai si semestre "décalé" c'est à dire semestres impairs commençant entre janvier et juin diff --git a/app/scodoc/html_sco_header.py b/app/scodoc/html_sco_header.py index e2b4d0bd..23a8b834 100644 --- a/app/scodoc/html_sco_header.py +++ b/app/scodoc/html_sco_header.py @@ -313,7 +313,7 @@ def sco_footer(): def html_sem_header( - title, sem=None, with_page_header=True, with_h2=True, page_title=None, **args + title, with_page_header=True, with_h2=True, page_title=None, **args ): "Titre d'une page semestre avec lien vers tableau de bord" # sem now unused and thus optional... diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index b7cdc1f1..159d3305 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -405,7 +405,6 @@ def formsemestre_archive(formsemestre_id, group_ids=[]): H = [ html_sco_header.html_sem_header( "Archiver les PV et résultats du semestre", - sem=sem, javascripts=sco_groups_view.JAVASCRIPTS, cssstyles=sco_groups_view.CSSSTYLES, init_qtip=True, @@ -524,7 +523,7 @@ def formsemestre_list_archives(formsemestre_id): } L.append(a) - H = [html_sco_header.html_sem_header("Archive des PV et résultats ", sem)] + H = [html_sco_header.html_sem_header("Archive des PV et résultats ")] if not L: H.append("

aucune archive enregistrée

") else: diff --git a/app/scodoc/sco_evaluation_check_abs.py b/app/scodoc/sco_evaluation_check_abs.py index 78c18045..5f52ad5e 100644 --- a/app/scodoc/sco_evaluation_check_abs.py +++ b/app/scodoc/sco_evaluation_check_abs.py @@ -222,7 +222,6 @@ def formsemestre_check_absences_html(formsemestre_id): H = [ html_sco_header.html_sem_header( "Vérification absences aux évaluations de ce semestre", - sem, ), """

Vérification de la cohérence entre les notes saisies et les absences signalées. Sont listés tous les modules avec des évaluations.
Aucune action n'est effectuée: diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index 82f5d13a..15b690a3 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -467,7 +467,6 @@ def formsemestre_evaluations_cal(formsemestre_id): H = [ html_sco_header.html_sem_header( "Evaluations du semestre", - sem, cssstyles=["css/calabs.css"], ), '

', diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index 272c5c38..629da145 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -450,7 +450,7 @@ def sem_in_annee_scolaire(sem, year=False): ) -def sem_une_annee(sem): +def sem_une_annee(sem): # XXX deprecated: use FormSemestre.est_sur_une_annee() """Test si sem est entièrement sur la même année scolaire. (ce n'est pas obligatoire mais si ce n'est pas le cas les exports Apogée ne vont pas fonctionner) pivot au 1er août. diff --git a/app/scodoc/sco_formsemestre_custommenu.py b/app/scodoc/sco_formsemestre_custommenu.py index ee18a8ec..e879d622 100644 --- a/app/scodoc/sco_formsemestre_custommenu.py +++ b/app/scodoc/sco_formsemestre_custommenu.py @@ -84,7 +84,7 @@ def formsemestre_custommenu_edit(formsemestre_id): scu.NotesURL() + "/formsemestre_status?formsemestre_id=%s" % formsemestre_id ) H = [ - html_sco_header.html_sem_header("Modification du menu du semestre ", sem), + html_sco_header.html_sem_header("Modification du menu du semestre "), """

Ce menu, spécifique à chaque semestre, peut être utilisé pour placer des liens vers vos applications préférées.

Procédez en plusieurs fois si vous voulez ajouter plusieurs items.

""", ] diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 060289e9..59e6d924 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -96,7 +96,6 @@ def formsemestre_editwithmodules(formsemestre_id): H = [ html_sco_header.html_sem_header( "Modification du semestre", - sem, javascripts=["libjs/AutoSuggest.js"], cssstyles=["css/autosuggest_inquisitor.css"], bodyOnLoad="init_tf_form('')", @@ -900,7 +899,6 @@ def formsemestre_clone(formsemestre_id): H = [ html_sco_header.html_sem_header( "Copie du semestre", - sem, javascripts=["libjs/AutoSuggest.js"], cssstyles=["css/autosuggest_inquisitor.css"], bodyOnLoad="init_tf_form('')", @@ -1240,7 +1238,7 @@ def formsemestre_delete(formsemestre_id): sem = sco_formsemestre.get_formsemestre(formsemestre_id) F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0] H = [ - html_sco_header.html_sem_header("Suppression du semestre", sem), + html_sco_header.html_sem_header("Suppression du semestre"), """
Attention !

A n'utiliser qu'en cas d'erreur lors de la saisie d'une formation. Normalement, un semestre ne doit jamais être supprimé (on perd la mémoire des notes et de tous les événements liés à ce semestre !).

@@ -1519,7 +1517,7 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None):

""" H = [ - html_sco_header.html_sem_header("Coefficients des UE du semestre", sem), + html_sco_header.html_sem_header("Coefficients des UE du semestre"), help, ] # @@ -1631,7 +1629,7 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None): formsemestre_id=formsemestre_id ) # > modif coef UE cap (modifs notes de _certains_ etudiants) - header = html_sco_header.html_sem_header("Coefficients des UE du semestre", sem) + header = html_sco_header.html_sem_header("Coefficients des UE du semestre") return ( header + "\n".join(z) diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index 94d7539c..48d24f51 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -374,7 +374,6 @@ def formsemestre_inscription_with_modules( H = [ html_sco_header.html_sem_header( "Inscription de %s dans ce semestre" % etud["nomprenom"], - sem, ) ] F = html_sco_header.sco_footer() @@ -802,7 +801,6 @@ def formsemestre_inscrits_ailleurs(formsemestre_id): H = [ html_sco_header.html_sem_header( "Inscriptions multiples parmi les étudiants du semestre ", - sem, ) ] insd = list_inscrits_ailleurs(formsemestre_id) diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 7ca52926..303cb200 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -36,6 +36,7 @@ from flask_login import current_user from app import log from app.models import Module +from app.models.formsemestre import FormSemestre import app.scodoc.sco_utils as scu from app.scodoc.sco_utils import ModuleType import app.scodoc.notesdb as ndb @@ -722,7 +723,7 @@ def formsemestre_description_table(formsemestre_id, with_evals=False): % (request.base_url, formsemestre_id, with_evals), page_title=title, html_title=html_sco_header.html_sem_header( - "Description du semestre", sem, with_page_header=False + "Description du semestre", with_page_header=False ), pdf_title=title, preferences=sco_preferences.SemPreferences(formsemestre_id), @@ -915,34 +916,35 @@ def html_expr_diagnostic(diagnostics): def formsemestre_status_head(formsemestre_id=None, page_title=None): """En-tête HTML des pages "semestre" """ - semlist = sco_formsemestre.do_formsemestre_list( - args={"formsemestre_id": formsemestre_id} - ) - if not semlist: - raise ScoValueError("Session inexistante (elle a peut être été supprimée ?)") - sem = semlist[0] - F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0] - parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"]) + sem = FormSemestre.query.get(formsemestre_id) + if not sem: + raise ScoValueError("Semestre inexistant (il a peut être été supprimé ?)") + formation = sem.formation + parcours = formation.get_parcours() page_title = page_title or "Modules de " H = [ html_sco_header.html_sem_header( - page_title, sem, with_page_header=False, with_h2=False + page_title, with_page_header=False, with_h2=False ), f"""") @@ -965,18 +967,16 @@ Il y a des notes en attente ! Le classement des étudiants n'a qu'une valeur ind ) H.append("
Formation: - {F['titre']}""", + {formation.titre} + """, ] - if sem["semestre_id"] >= 0: - H.append(", %s %s" % (parcours.SESSION_NAME, sem["semestre_id"])) - if sem["modalite"]: - H.append(" en %(modalite)s" % sem) - if sem["etapes"]: + if sem.semestre_id >= 0: + H.append(", %s %s" % (parcours.SESSION_NAME, sem.semestre_id)) + if sem.modalite: + H.append(f" en {sem.modalite}") + if sem.etapes: H.append( - "   (étape %s)" - % (sem["etapes_apo_str"] or "-") + f"""   (étape { + sem.etapes_apo_str() or "-" + })""" ) H.append("
") sem_warning = "" - if sem["bul_hide_xml"]: + if sem.bul_hide_xml: sem_warning += "Bulletins non publiés sur le portail. " - if sem["block_moyennes"]: + if sem.block_moyennes: sem_warning += "Calcul des moyennes bloqué !" if sem_warning: H.append('

' + sem_warning + "

") - if sem["semestre_id"] >= 0 and not sco_formsemestre.sem_une_annee(sem): + if sem.semestre_id >= 0 and not sem.est_sur_une_annee(): H.append( '

Attention: ce semestre couvre plusieurs années scolaires !

' ) - # elif sco_preferences.get_preference( 'bul_display_publication', formsemestre_id): - # H.append('

Bulletins publiés sur le portail

') return "".join(H) diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py index 9b40f780..36549bb3 100644 --- a/app/scodoc/sco_formsemestre_validation.py +++ b/app/scodoc/sco_formsemestre_validation.py @@ -847,9 +847,7 @@ def formsemestre_validation_auto(formsemestre_id): "Formulaire saisie automatisee des decisions d'un semestre" sem = sco_formsemestre.get_formsemestre(formsemestre_id) H = [ - html_sco_header.html_sem_header( - "Saisie automatique des décisions du semestre", sem - ), + html_sco_header.html_sem_header("Saisie automatique des décisions du semestre"), """