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: if order is not None:
assiduites_query: Query = assiduites_query.order_by(Assiduite.date_debut.desc()) 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 return assiduites_query

View File

@ -702,4 +702,13 @@ def _filter_manager(requested, justificatifs_query):
Justificatif.date_debut.desc() 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 return justificatifs_query

View File

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

View File

@ -1069,12 +1069,17 @@ function getAllAssiduitesFromEtud(
etudid, etudid,
action, action,
order = false, order = false,
justifs = false justifs = false,
courant = false
) { ) {
const url_api = const url_api =
getUrl() + getUrl() +
`/api/assiduites/${etudid}${ `/api/assiduites/${etudid}${
order ? "/query?order%".replace("%", justifs ? "&with_justifs" : "") : "" order
? "/query?order%°"
.replace("%", justifs ? "&with_justifs" : "")
.replace("°", courant ? "&courant" : "")
: ""
}`; }`;
$.ajax({ $.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 = const url_api =
getUrl() + `/api/justificatifs/${etudid}${order ? "/query?order" : ""}`; getUrl() +
`/api/justificatifs/${etudid}${
order ? "/query?order°".replace("°", courant ? "&courant" : "") : ""
}`;
$.ajax({ $.ajax({
async: true, async: true,
type: "GET", type: "GET",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -174,12 +174,23 @@ def index_html():
</li></ul> </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( H.append(
render_template( render_template(
"assiduites/pages/bilan_dept.j2", "assiduites/pages/bilan_dept.j2",
dept_id=g.scodoc_dept_id, dept_id=g.scodoc_dept_id,
annee=scu.annee_scolaire(), annee=scu.annee_scolaire(),
annees=annees_str,
), ),
) )
H.append(html_sco_header.sco_footer()) H.append(html_sco_header.sco_footer())
@ -322,6 +333,10 @@ def liste_assiduites_etud():
sco=ScoData(etud), sco=ScoData(etud),
date=datetime.date.today().isoformat(), date=datetime.date.today().isoformat(),
assi_id=assiduite_id, assi_id=assiduite_id,
assi_limit_annee=sco_preferences.get_preference(
"assi_limit_annee",
dept_id=g.scodoc_dept_id,
),
), ),
).build() ).build()
@ -374,6 +389,10 @@ def bilan_etud():
date_fin=date_fin, date_fin=date_fin,
assi_metric=assi_metric, assi_metric=assi_metric,
assi_seuil=_get_seuil(), assi_seuil=_get_seuil(),
assi_limit_annee=sco_preferences.get_preference(
"assi_limit_annee",
dept_id=g.scodoc_dept_id,
),
), ),
).build() ).build()
@ -415,6 +434,10 @@ def ajout_justificatif_etud():
render_template( render_template(
"assiduites/pages/ajout_justificatif.j2", "assiduites/pages/ajout_justificatif.j2",
sco=ScoData(etud), sco=ScoData(etud),
assi_limit_annee=sco_preferences.get_preference(
"assi_limit_annee",
dept_id=g.scodoc_dept_id,
),
), ),
).build() ).build()