Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
5 changed files with 41 additions and 33 deletions
Showing only changes of commit 85ad7b5f29 - Show all commits

View File

@ -600,17 +600,6 @@ class BasePreferences:
}, },
), ),
# Assiduité # 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", "forcer_module",
{ {

View File

@ -24,7 +24,6 @@ from app.scodoc.sco_utils import (
from app.tables import table_builder as tb from app.tables import table_builder as tb
from app.scodoc.sco_cache import RequeteTableauAssiduiteCache from app.scodoc.sco_cache import RequeteTableauAssiduiteCache
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_preferences import get_preference
class Pagination: class Pagination:
@ -212,10 +211,16 @@ class ListeAssiJusti(tb.Table):
r = query_finale.all() r = query_finale.all()
RequeteTableauAssiduiteCache.set(cle_cache, r) RequeteTableauAssiduiteCache.set(cle_cache, r)
# Filtrer Si préférence "Limiter les assiduités à l'année courante" # Filtrage des objets en fonction de self.options.annee
if get_preference("assi_limit_annee"): # Si None -> année courante
annee_debut = localize_datetime(date_debut_annee_scolaire()) # Sinon -> année donnée
annee_fin = localize_datetime(date_fin_annee_scolaire()) # 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 = [ r = [
obj obj
for obj in r for obj in r
@ -767,6 +772,7 @@ class AssiDisplayOptions:
show_actions: str | bool = True, show_actions: str | bool = True,
show_module: str | bool = False, show_module: str | bool = False,
order: tuple[str, str | bool] = None, order: tuple[str, str | bool] = None,
annee_sco: int = None,
): ):
self.page: int = page self.page: int = page
self.nb_ligne_page: int = nb_ligne_page self.nb_ligne_page: int = nb_ligne_page
@ -780,6 +786,8 @@ class AssiDisplayOptions:
self.show_actions = to_bool(show_actions) self.show_actions = to_bool(show_actions)
self.show_module = to_bool(show_module) self.show_module = to_bool(show_module)
self.annee_sco: int | None = annee_sco
self.order = ( self.order = (
("date_debut", False) if order is None else (order[0], to_bool(order[1])) ("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(): for k, v in kwargs.items():
if k.startswith("show_"): if k.startswith("show_"):
setattr(self, k, to_bool(v)) 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)) setattr(self, k, int(v))
if k == "nb_ligne_page": if k == "nb_ligne_page":
self.nb_ligne_page = min( self.nb_ligne_page = min(
@ -801,6 +809,8 @@ class AssiDisplayOptions:
k, k,
("date_debut", False) if v is None else (v[0], to_bool(v[1])), ("date_debut", False) if v is None else (v[0], to_bool(v[1])),
) )
else:
setattr(self, k, v)
class AssiJustifData: class AssiJustifData:

View File

@ -218,9 +218,6 @@ Bilan assiduité de {{sco.etud.nomprenom}}
const assi_date_debut = "{{date_debut}}"; const assi_date_debut = "{{date_debut}}";
const assi_date_fin = "{{date_fin}}"; const assi_date_fin = "{{date_fin}}";
const assi_limit_annee = "{{ assi_limit_annee }}" == "True" ? true : false;
window.addEventListener('load', () => { window.addEventListener('load', () => {
document.getElementById('stats_date_fin').value = assi_date_fin; document.getElementById('stats_date_fin').value = assi_date_fin;
document.getElementById('stats_date_debut').value = assi_date_debut; document.getElementById('stats_date_debut').value = assi_date_debut;

View File

@ -27,9 +27,23 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </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> <br>
</div> </div>
<div class="div-tableau"> <div class="div-tableau">
<div class="options-tableau"> <div class="options-tableau">

View File

@ -607,10 +607,6 @@ def bilan_etud():
# Génération de la page HTML # Génération de la page HTML
return render_template( return render_template(
"assiduites/pages/bilan_etud.j2", "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_metric=assi_metric,
assi_seuil=_get_seuil(), assi_seuil=_get_seuil(),
date_debut=date_debut, date_debut=date_debut,
@ -672,10 +668,6 @@ def edit_justificatif_etud(justif_id: int):
return render_template( return render_template(
"assiduites/pages/ajout_justificatif_etud.j2", "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) can_view_justif_detail=current_user.has_permission(Permission.AbsJustifView)
or current_user.id == justif.user_id, or current_user.id == justif.user_id,
etud=justif.etudiant, etud=justif.etudiant,
@ -732,10 +724,6 @@ def ajout_justificatif_etud():
return render_template( return render_template(
"assiduites/pages/ajout_justificatif_etud.j2", "assiduites/pages/ajout_justificatif_etud.j2",
assi_limit_annee=sco_preferences.get_preference(
"assi_limit_annee",
dept_id=g.scodoc_dept_id,
),
etud=etud, etud=etud,
form=form, form=form,
title=f"Ajout justificatif absence pour {etud.html_link_fiche()}", title=f"Ajout justificatif absence pour {etud.html_link_fiche()}",
@ -1543,6 +1531,15 @@ def _prepare_tableau(
fmt = request.args.get("fmt", "html") 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
ordre: tuple[str, str | bool] = None ordre: tuple[str, str | bool] = None
ordre_col: str = request.args.get("order_col", None) ordre_col: str = request.args.get("order_col", None)
@ -1561,6 +1558,7 @@ def _prepare_tableau(
show_desc=show_desc, show_desc=show_desc,
show_etu=afficher_etu, show_etu=afficher_etu,
order=ordre, order=ordre,
annee_sco=annee_sco,
) )
if force_options is not None: if force_options is not None: