forked from ScoDoc/ScoDoc
Merge branch 'main96' of https://scodoc.org/git/iziram/ScoDoc into iziram-main96
This commit is contained in:
commit
b6940e4882
@ -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:
|
||||
@ -1632,23 +1630,29 @@ def recup_assiduites_plage():
|
||||
etuds = dept.etudiants
|
||||
name = dept.acronym
|
||||
|
||||
# Récupération des assiduités
|
||||
assiduites: Query = Assiduite.query.filter(
|
||||
Assiduite.etudid.in_([etud.id for etud in etuds])
|
||||
)
|
||||
# Récupération des assiduités/justificatifs
|
||||
etudids: list[int] = [etud.id for etud in etuds]
|
||||
assiduites: Query = Assiduite.query.filter(Assiduite.etudid.in_(etudids))
|
||||
justificatifs: Query = Justificatif.query.filter(Justificatif.etudid.in_(etudids))
|
||||
|
||||
# Filtrage des assiduités en fonction des dates données
|
||||
# Filtrage des assiduités/justificatifs en fonction des dates données
|
||||
assiduites = scass.filter_by_date(assiduites, Assiduite, date_deb, date_fin)
|
||||
justificatifs = scass.filter_by_date(
|
||||
justificatifs, Justificatif, date_deb, date_fin
|
||||
)
|
||||
|
||||
table_data: liste_assi.AssiJustifData = liste_assi.AssiJustifData(
|
||||
assiduites_query=assiduites,
|
||||
justificatifs_query=justificatifs,
|
||||
)
|
||||
|
||||
options: liste_assi.AssiDisplayOptions = liste_assi.AssiDisplayOptions(
|
||||
show_pres=True,
|
||||
show_reta=True,
|
||||
show_module=True,
|
||||
show_desc=True,
|
||||
show_etu=True,
|
||||
annee_sco=-1,
|
||||
)
|
||||
|
||||
date_deb_str: str = date_deb.strftime("%d-%m-%Y")
|
||||
|
Loading…
Reference in New Issue
Block a user