1
0
forked from ScoDoc/ScoDoc

Revert "Assiduites : metrique interne externe"

Changement non compatible avec les préférences en production.

This reverts commit afe2caac2d.
This commit is contained in:
Emmanuel Viennet 2023-08-19 16:17:21 +02:00
parent afe2caac2d
commit 94db71280f
10 changed files with 47 additions and 29 deletions

View File

@ -387,9 +387,11 @@ class BulletinBUT:
semestre_infos["absences"] = {
"injustifie": nbabs - nbabsjust,
"total": nbabs,
"metrique": sco_preferences.ASSIDUITES_METRIC_LABEL_LONG.get(
sco_preferences.get_preference("assi_metrique")
),
"metrique": {
"H.": "Heure(s)",
"J.": "Journée(s)",
"1/2 J.": "1/2 Jour.",
}.get(sco_preferences.get_preference("assi_metrique")),
}
decisions_ues = self.res.get_etud_decisions_ue(etud.id) or {}
if self.prefs["bul_show_ects"]:

View File

@ -39,9 +39,11 @@ from app.models.validations import ScolarFormSemestreValidation
from app.scodoc import codes_cursus, sco_preferences
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_utils import MONTH_NAMES_ABBREV
from app.scodoc.sco_utils import MONTH_NAMES_ABBREV, translate_assiduites_metric
from app.scodoc.sco_vdi import ApoEtapeVDI
from app.scodoc.sco_utils import translate_assiduites_metric
GROUPS_AUTO_ASSIGNMENT_DATA_MAX = 1024 * 1024 # bytes
@ -716,7 +718,10 @@ class FormSemestre(db.Model):
metrique = sco_preferences.get_preference("assi_metrique", self.id)
return sco_assiduites.get_assiduites_count_in_interval(
etudid, self.date_debut.isoformat(), self.date_fin.isoformat(), metrique
etudid,
self.date_debut.isoformat(),
self.date_fin.isoformat(),
translate_assiduites_metric(metrique),
)
def get_codes_apogee(self, category=None) -> set[str]:

View File

@ -122,7 +122,7 @@ def sidebar(etudid: int = None):
nbabs, nbabsjust = sco_assiduites.get_assiduites_count(etudid, cur_sem)
nbabsnj = nbabs - nbabsjust
H.append(
f"""<span title="absences du { cur_sem["date_debut"] } au { cur_sem["date_fin"] }">({sco_preferences.ASSIDUITES_METRIC_LABEL_SHORT.get(sco_preferences.get_preference("assi_metrique", "demi"))})
f"""<span title="absences du { cur_sem["date_debut"] } au { cur_sem["date_fin"] }">({sco_preferences.get_preference("assi_metrique", None)})
<br>{ nbabsjust } J., { nbabsnj } N.J.</span>"""
)
H.append("<ul>")

View File

@ -66,7 +66,11 @@ def abs_notify(etudid, date):
etudid,
formsemestre.date_debut.isoformat(),
formsemestre.date_fin.isoformat(),
sco_preferences.get_preference("assi_metrique", formsemestre.formsemestre_id),
scu.translate_assiduites_metric(
sco_preferences.get_preference(
"assi_metrique", formsemestre.formsemestre_id
)
),
)
do_abs_notify(formsemestre, etudid, date, nbabs, nbabsjust)

View File

@ -373,7 +373,7 @@ def get_assiduites_count(etudid, sem):
etudid,
sem["date_debut_iso"],
sem["date_fin_iso"],
metrique,
scu.translate_assiduites_metric(metrique),
)
@ -427,7 +427,7 @@ def invalidate_assiduites_count(etudid, sem):
"""Invalidate (clear) cached counts"""
date_debut = sem["date_debut_iso"]
date_fin = sem["date_fin_iso"]
for met in sco_preferences.ASSIDUITES_METRIC_LABEL_SHORT.values():
for met in sco_preferences.ASSIDUITES_METRIC_LABEL.values():
key = str(etudid) + "_" + date_debut + "_" + date_fin + f"{met}_assiduites"
sco_cache.AbsSemEtudCache.delete(key)

View File

@ -198,17 +198,11 @@ def _get_pref_default_value_from_config(name, pref_spec):
_INSTALLED_FONTS = ", ".join(sco_pdf.get_available_font_names())
ASSIDUITES_METRIC_LABEL_LONG = {
ASSIDUITES_METRIC_LABEL = {
# l'ordre est important, c'est celui-du menu. Le defaut en 1er donc.
"demi": "Demi-Journée",
"journee": "Journée",
"heure": "Heure",
}
ASSIDUITES_METRIC_LABEL_SHORT = {
# l'ordre est important, c'est celui-du menu. Le defaut en 1er donc.
"demi": "1/2 J.",
"journee": "J.",
"heure": "H.",
"1/2 J.": "demi",
"J.": "journee",
"H.": "heure",
}
PREF_CATEGORIES = (
@ -670,10 +664,10 @@ class BasePreferences(object):
(
"assi_metrique",
{
"initvalue": "demi",
"initvalue": "1/2 J.",
"input_type": "menu",
"labels": list(ASSIDUITES_METRIC_LABEL_LONG.values()),
"allowed_values": list(ASSIDUITES_METRIC_LABEL_LONG.keys()),
"labels": list(ASSIDUITES_METRIC_LABEL.keys()),
"allowed_values": list(ASSIDUITES_METRIC_LABEL.keys()),
"title": "Métrique de l'assiduité",
"explanation": "Unité utilisée dans la fiche étudiante, les bilans et les calculs",
"category": "assi",

View File

@ -251,6 +251,17 @@ def is_period_overlapping(
return p_deb < i_fin and p_fin > i_deb
def translate_assiduites_metric(hr_metric) -> str:
if hr_metric == "1/2 J.":
return "demi"
if hr_metric == "J.":
return "journee"
if hr_metric == "N.":
return "compte"
if hr_metric == "H.":
return "heure"
# Types de modules
class ModuleType(IntEnum):
"""Code des types de module."""

View File

@ -125,8 +125,8 @@ class RowAssi(tb.Row):
"absent": ["Absences", 0.0, 0.0],
}
assi_metric = sco_preferences.get_preference(
"assi_metrique", dept_id=g.scodoc_dept_id
assi_metric = sco_preferences.ASSIDUITES_METRIC_LABEL.get(
sco_preferences.get_preference("assi_metrique", dept_id=g.scodoc_dept_id)
)
for etat, valeur in retour.items():

View File

@ -79,7 +79,9 @@ class ScoData:
etud.id,
self.etud_cur_sem.date_debut.isoformat(),
self.etud_cur_sem.date_fin.isoformat(),
sco_preferences.get_preference("assi_metrique"),
scu.translate_assiduites_metric(
sco_preferences.get_preference("assi_metrique")
),
)
self.nbabsnj = self.nbabs - self.nbabsjust
else:

View File

@ -327,8 +327,8 @@ def bilan_etud():
date_debut: str = f"{scu.annee_scolaire()}-09-01"
date_fin: str = f"{scu.annee_scolaire()+1}-06-30"
assi_metric = sco_preferences.get_preference(
"assi_metrique", dept_id=g.scodoc_dept_id
assi_metric = sco_preferences.ASSIDUITES_METRIC_LABEL.get(
sco_preferences.get_preference("assi_metrique", dept_id=g.scodoc_dept_id)
)
return HTMLBuilder(
@ -840,8 +840,8 @@ def visu_assi_group():
return render_template(
"assiduites/pages/visu_assi.j2",
assi_metric=sco_preferences.get_preference(
"assi_metrique", dept_id=g.scodoc_dept_id
assi_metric=sco_preferences.ASSIDUITES_METRIC_LABEL.get(
sco_preferences.get_preference("assi_metrique", dept_id=g.scodoc_dept_id)
),
date_debut=dates["debut"],
date_fin=dates["fin"],