Assiduites : fin issue #712

This commit is contained in:
iziram 2023-09-12 09:37:03 +02:00
parent 306edaf63d
commit 1ec07a9329
10 changed files with 93 additions and 13 deletions

View File

@ -1035,6 +1035,15 @@ def _filter_manager(requested, assiduites_query: Query) -> Query:
if order is not None:
assiduites_query: Query = assiduites_query.order_by(Assiduite.date_debut.desc())
courant = requested.args.get("courant", None)
if courant is not None:
annee: int = scu.annee_scolaire()
assiduites_query: Query = assiduites_query.filter(
Assiduite.date_debut >= scu.date_debut_anne_scolaire(annee),
Assiduite.date_fin <= scu.date_fin_anne_scolaire(annee),
)
return assiduites_query

View File

@ -702,4 +702,13 @@ def _filter_manager(requested, justificatifs_query):
Justificatif.date_debut.desc()
)
courant = requested.args.get("courant", None)
if courant is not None:
annee: int = scu.annee_scolaire()
justificatifs_query: Query = justificatifs_query.filter(
Justificatif.date_debut >= scu.date_debut_anne_scolaire(annee),
Justificatif.date_fin <= scu.date_fin_anne_scolaire(annee),
)
return justificatifs_query

View File

@ -610,6 +610,17 @@ class BasePreferences:
},
),
# Assiduités
(
"assi_limit_annee",
{
"initvalue": 1,
"title": "Ne lister que les assiduités de l'année",
"explanation": "Limite l'affichage des listes d'assiduités et de justificatifs à l'année en cours",
"input_type": "boolcheckbox",
"labels": ["non", "oui"],
"category": "assi",
},
),
(
"forcer_module",
{

View File

@ -1069,12 +1069,17 @@ function getAllAssiduitesFromEtud(
etudid,
action,
order = false,
justifs = false
justifs = false,
courant = false
) {
const url_api =
getUrl() +
`/api/assiduites/${etudid}${
order ? "/query?order%".replace("%", justifs ? "&with_justifs" : "") : ""
order
? "/query?order%°"
.replace("%", justifs ? "&with_justifs" : "")
.replace("°", courant ? "&courant" : "")
: ""
}`;
$.ajax({
@ -1639,9 +1644,17 @@ function createJustificatif(justif, success = () => {}) {
});
}
function getAllJustificatifsFromEtud(etudid, action, order = false) {
function getAllJustificatifsFromEtud(
etudid,
action,
order = false,
courant = false
) {
const url_api =
getUrl() + `/api/justificatifs/${etudid}${order ? "/query?order" : ""}`;
getUrl() +
`/api/justificatifs/${etudid}${
order ? "/query?order°".replace("°", courant ? "&courant" : "") : ""
}`;
$.ajax({
async: true,
type: "GET",

View File

@ -221,6 +221,9 @@
const etudid = {{ sco.etud.id }};
const assi_limit_annee = "{{ assi_limit_annee }}" == "True" ? true : false;
window.onload = () => {
loadAll();
}

View File

@ -29,6 +29,7 @@
</div>
<script>
function loadAll() {
generate(defAnnee)
}
@ -57,7 +58,7 @@
}
bornes = {
deb: `${annee}-09-01T00:00`,
fin: `${annee + 1}-06-30T23:59`
fin: `${annee + 1}-08-31T23:59`
}
defAnnee = annee;
@ -75,10 +76,14 @@
let defAnnee = {{ annee }};
let bornes = {
deb: `${defAnnee}-09-01T00:00`,
fin: `${defAnnee + 1}-06-30T23:59`
fin: `${defAnnee + 1}-08-31T23:59`
}
const dept_id = {{ dept_id }};
let annees = {{ annees | safe}}
annees = annees.filter((x, i) => annees.indexOf(x) === i)
window.addEventListener('load', () => {
filterJustificatifs = {
@ -99,15 +104,16 @@
}
}
const select = document.querySelector('#annee');
for (let i = defAnnee + 1; i > defAnnee - 6; i--) {
annees.forEach((a) => {
const opt = document.createElement("option");
opt.value = i + "",
opt.textContent = i + "";
if (i === defAnnee) {
opt.value = a + "",
opt.textContent = `${a} - ${a + 1}`;
if (a === defAnnee) {
opt.selected = true;
}
select.appendChild(opt)
}
})
setterAnnee(defAnnee)
})

View File

@ -266,6 +266,9 @@
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', () => {
filterAssiduites = {
"columns": [

View File

@ -51,6 +51,9 @@
const assiduite_unique_id = {{ assi_id }};
const assi_limit_annee = "{{ assi_limit_annee }}" == "True" ? true : false;
function wayForFilter() {
if (typeof assiduites[etudid] !== "undefined") {
console.log("Done")

View File

@ -242,8 +242,8 @@
}
function loadAll() {
try { getAllAssiduitesFromEtud(etudid, assiduiteCallBack, true, true) } catch (_) { }
try { getAllJustificatifsFromEtud(etudid, justificatifCallBack, true, true) } catch (_) { }
try { getAllAssiduitesFromEtud(etudid, assiduiteCallBack, true, true, assi_limit_annee) } catch (_) { }
try { getAllJustificatifsFromEtud(etudid, justificatifCallBack, true, assi_limit_annee) } catch (_) { }
}
function order(keyword, callback = () => { }, el, assi = true) {

View File

@ -174,12 +174,23 @@ def index_html():
</li></ul>
"""
)
dept : Departement = Departement.query.filter_by(id=g.scodoc_dept_id).first()
annees: list[int] = sorted(
[f.date_debut.year for f in dept.formsemestres],
reverse=True,
)
annees_str: str = "["
for ann in annees:
annees_str += f"{ann},"
annees_str += "]"
H.append(
render_template(
"assiduites/pages/bilan_dept.j2",
dept_id=g.scodoc_dept_id,
annee=scu.annee_scolaire(),
annees=annees_str,
),
)
H.append(html_sco_header.sco_footer())
@ -322,6 +333,10 @@ def liste_assiduites_etud():
sco=ScoData(etud),
date=datetime.date.today().isoformat(),
assi_id=assiduite_id,
assi_limit_annee=sco_preferences.get_preference(
"assi_limit_annee",
dept_id=g.scodoc_dept_id,
),
),
).build()
@ -374,6 +389,10 @@ def bilan_etud():
date_fin=date_fin,
assi_metric=assi_metric,
assi_seuil=_get_seuil(),
assi_limit_annee=sco_preferences.get_preference(
"assi_limit_annee",
dept_id=g.scodoc_dept_id,
),
),
).build()
@ -415,6 +434,10 @@ def ajout_justificatif_etud():
render_template(
"assiduites/pages/ajout_justificatif.j2",
sco=ScoData(etud),
assi_limit_annee=sco_preferences.get_preference(
"assi_limit_annee",
dept_id=g.scodoc_dept_id,
),
),
).build()