forked from ScoDoc/ScoDoc
Assiduité : suppr pref limite_annee + closes #766
This commit is contained in:
parent
6bfd461bf2
commit
85ad7b5f29
@ -600,17 +600,6 @@ class BasePreferences:
|
||||
},
|
||||
),
|
||||
# Assiduité
|
||||
(
|
||||
"assi_limit_annee",
|
||||
{
|
||||
"initvalue": 1,
|
||||
"title": "Ne lister que l'assiduité de l'année",
|
||||
"explanation": "Limite l'affichage des listes d'assiduité et de justificatifs à l'année en cours",
|
||||
"input_type": "boolcheckbox",
|
||||
"labels": ["non", "oui"],
|
||||
"category": "assi",
|
||||
},
|
||||
),
|
||||
(
|
||||
"forcer_module",
|
||||
{
|
||||
|
@ -24,7 +24,6 @@ from app.scodoc.sco_utils import (
|
||||
from app.tables import table_builder as tb
|
||||
from app.scodoc.sco_cache import RequeteTableauAssiduiteCache
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
from app.scodoc.sco_preferences import get_preference
|
||||
|
||||
|
||||
class Pagination:
|
||||
@ -212,10 +211,16 @@ class ListeAssiJusti(tb.Table):
|
||||
r = query_finale.all()
|
||||
RequeteTableauAssiduiteCache.set(cle_cache, r)
|
||||
|
||||
# Filtrer Si préférence "Limiter les assiduités à l'année courante"
|
||||
if get_preference("assi_limit_annee"):
|
||||
annee_debut = localize_datetime(date_debut_annee_scolaire())
|
||||
annee_fin = localize_datetime(date_fin_annee_scolaire())
|
||||
# Filtrage des objets en fonction de self.options.annee
|
||||
# Si None -> année courante
|
||||
# Sinon -> année donnée
|
||||
# Si err (non int) -> année courante
|
||||
# Si -1 -> afficher tout
|
||||
|
||||
annee: int | None = self.options.annee_sco
|
||||
if annee != -1:
|
||||
annee_debut = localize_datetime(date_debut_annee_scolaire(annee_sco=annee))
|
||||
annee_fin = localize_datetime(date_fin_annee_scolaire(annee_sco=annee))
|
||||
r = [
|
||||
obj
|
||||
for obj in r
|
||||
@ -767,6 +772,7 @@ class AssiDisplayOptions:
|
||||
show_actions: str | bool = True,
|
||||
show_module: str | bool = False,
|
||||
order: tuple[str, str | bool] = None,
|
||||
annee_sco: int = None,
|
||||
):
|
||||
self.page: int = page
|
||||
self.nb_ligne_page: int = nb_ligne_page
|
||||
@ -780,6 +786,8 @@ class AssiDisplayOptions:
|
||||
self.show_actions = to_bool(show_actions)
|
||||
self.show_module = to_bool(show_module)
|
||||
|
||||
self.annee_sco: int | None = annee_sco
|
||||
|
||||
self.order = (
|
||||
("date_debut", False) if order is None else (order[0], to_bool(order[1]))
|
||||
)
|
||||
@ -789,7 +797,7 @@ class AssiDisplayOptions:
|
||||
for k, v in kwargs.items():
|
||||
if k.startswith("show_"):
|
||||
setattr(self, k, to_bool(v))
|
||||
elif k in ["page", "nb_ligne_page"]:
|
||||
elif k in ("page", "nb_ligne_page"):
|
||||
setattr(self, k, int(v))
|
||||
if k == "nb_ligne_page":
|
||||
self.nb_ligne_page = min(
|
||||
@ -801,6 +809,8 @@ class AssiDisplayOptions:
|
||||
k,
|
||||
("date_debut", False) if v is None else (v[0], to_bool(v[1])),
|
||||
)
|
||||
else:
|
||||
setattr(self, k, v)
|
||||
|
||||
|
||||
class AssiJustifData:
|
||||
|
@ -218,9 +218,6 @@ Bilan assiduité de {{sco.etud.nomprenom}}
|
||||
const assi_date_debut = "{{date_debut}}";
|
||||
const assi_date_fin = "{{date_fin}}";
|
||||
|
||||
const assi_limit_annee = "{{ assi_limit_annee }}" == "True" ? true : false;
|
||||
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
document.getElementById('stats_date_fin').value = assi_date_fin;
|
||||
document.getElementById('stats_date_debut').value = assi_date_debut;
|
||||
|
@ -27,9 +27,23 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="annee_sco">Année scolaire :</label>
|
||||
<select name="annee_sco" id="annee_sco" onchange="updateTableau()">
|
||||
<option value="-1">Tout afficher</option>
|
||||
{% for annee in range(scu.annee_scolaire(), scu.annee_scolaire()-6, -1) %}
|
||||
{% if annee == options.annee_sco or (options.annee_sco == None and annee == scu.annee_scolaire()) %}
|
||||
<option value="{{annee}}" selected>
|
||||
{{annee}} - {{annee + 1}}
|
||||
</option>
|
||||
{% else %}
|
||||
<option value="{{annee}}">
|
||||
{{annee}} - {{annee + 1}}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<br>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="div-tableau">
|
||||
<div class="options-tableau">
|
||||
|
@ -607,10 +607,6 @@ def bilan_etud():
|
||||
# Génération de la page HTML
|
||||
return render_template(
|
||||
"assiduites/pages/bilan_etud.j2",
|
||||
assi_limit_annee=sco_preferences.get_preference(
|
||||
"assi_limit_annee",
|
||||
dept_id=g.scodoc_dept_id,
|
||||
),
|
||||
assi_metric=assi_metric,
|
||||
assi_seuil=_get_seuil(),
|
||||
date_debut=date_debut,
|
||||
@ -672,10 +668,6 @@ def edit_justificatif_etud(justif_id: int):
|
||||
|
||||
return render_template(
|
||||
"assiduites/pages/ajout_justificatif_etud.j2",
|
||||
assi_limit_annee=sco_preferences.get_preference(
|
||||
"assi_limit_annee",
|
||||
dept_id=g.scodoc_dept_id,
|
||||
),
|
||||
can_view_justif_detail=current_user.has_permission(Permission.AbsJustifView)
|
||||
or current_user.id == justif.user_id,
|
||||
etud=justif.etudiant,
|
||||
@ -732,10 +724,6 @@ def ajout_justificatif_etud():
|
||||
|
||||
return render_template(
|
||||
"assiduites/pages/ajout_justificatif_etud.j2",
|
||||
assi_limit_annee=sco_preferences.get_preference(
|
||||
"assi_limit_annee",
|
||||
dept_id=g.scodoc_dept_id,
|
||||
),
|
||||
etud=etud,
|
||||
form=form,
|
||||
title=f"Ajout justificatif absence pour {etud.html_link_fiche()}",
|
||||
@ -1543,6 +1531,15 @@ def _prepare_tableau(
|
||||
|
||||
fmt = request.args.get("fmt", "html")
|
||||
|
||||
annee_sco: str | None = request.args.get("annee_sco", None)
|
||||
|
||||
# Vérification de l'année scolaire
|
||||
if annee_sco is not None:
|
||||
try:
|
||||
annee_sco = int(annee_sco)
|
||||
except (ValueError, TypeError):
|
||||
annee_sco = None
|
||||
|
||||
# Ordre
|
||||
ordre: tuple[str, str | bool] = None
|
||||
ordre_col: str = request.args.get("order_col", None)
|
||||
@ -1561,6 +1558,7 @@ def _prepare_tableau(
|
||||
show_desc=show_desc,
|
||||
show_etu=afficher_etu,
|
||||
order=ordre,
|
||||
annee_sco=annee_sco,
|
||||
)
|
||||
|
||||
if force_options is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user