1
0
forked from ScoDoc/ScoDoc

Assiduites : oublie stash issue 712

This commit is contained in:
iziram 2023-09-12 09:41:50 +02:00
parent 1ec07a9329
commit 44cb59053a
3 changed files with 53 additions and 13 deletions

View File

@ -114,9 +114,18 @@ class RowAssi(tb.Row):
compte_justificatifs = scass.filter_by_date(
etud.justificatifs, Justificatif, self.dates[0], self.dates[1]
).count()
)
self.add_cell("justificatifs", "Justificatifs", f"{compte_justificatifs}")
compte_justificatifs_att = compte_justificatifs.filter(Justificatif.etat == 2)
self.add_cell(
"justificatifs_att",
"Justificatifs en Attente",
f"{compte_justificatifs_att.count()}",
)
self.add_cell(
"justificatifs", "Justificatifs", f"{compte_justificatifs.count()}"
)
def _get_etud_stats(self, etud: Identite) -> dict[str, list[str, float, float]]:
retour: dict[str, tuple[str, float, float]] = {

View File

@ -19,8 +19,9 @@
<div class="justi-label">
<legend for="justi_date_debut" required>Date de début</legend>
<input type="datetime-local" name="justi_date_debut" id="justi_date_debut">
<span>Journée entière</span> <input type="checkbox" name="justi_journee" id="justi_journee">
</div>
<div class="justi-label">
<div class="justi-label" id="date_fin">
<legend for="justi_date_fin" required>Date de fin</legend>
<input type="datetime-local" name="justi_date_fin" id="justi_date_fin">
</div>
@ -110,16 +111,15 @@
function validateFields() {
const field = document.querySelector('.justi-form')
const in_date_debut = field.querySelector('#justi_date_debut');
const in_date_fin = field.querySelector('#justi_date_fin');
const { deb, fin } = getDates()
if (in_date_debut.value == "" || in_date_fin.value == "") {
if (deb.value == "" || fin.value == "") {
openAlertModal("Erreur détéctée", document.createTextNode("Il faut indiquer une date de début et une date de fin."), "", color = "crimson");
return false;
}
const date_debut = moment.tz(in_date_debut.value, TIMEZONE);
const date_fin = moment.tz(in_date_fin.value, TIMEZONE);
const date_debut = moment.tz(deb.value, TIMEZONE);
const date_fin = moment.tz(fin.value, TIMEZONE);
if (date_fin.isBefore(date_debut)) {
openAlertModal("Erreur détéctée", document.createTextNode("La date de fin doit se trouver après la date de début."), "", color = "crimson");
@ -132,14 +132,14 @@
function fieldsToJustificatif() {
const field = document.querySelector('.justi-form')
const date_debut = field.querySelector('#justi_date_debut').value;
const date_fin = field.querySelector('#justi_date_fin').value;
const { deb, fin } = getDates()
const etat = field.querySelector('#justi_etat').value;
const raison = field.querySelector('#justi_raison').value;
return {
date_debut: date_debut,
date_fin: date_fin,
date_debut: deb,
date_fin: fin,
etat: etat,
raison: raison,
}
@ -218,14 +218,43 @@
}
function dayOnly() {
if (document.getElementById('justi_journee').checked) {
document.getElementById("date_fin").style.display = "none";
document.getElementById("justi_date_debut").type = "date"
} else {
document.getElementById("date_fin").style.display = "block";
document.getElementById("justi_date_debut").type = "datetime-local"
}
}
function getDates() {
if (document.getElementById('justi_journee').checked) {
const date_str = document.getElementById("justi_date_debut").value
return {
"deb": `${date_str}T${assi_morning}`,
"fin": `${date_str}T${assi_evening}`,
}
}
return {
"deb": document.getElementById("justi_date_debut").value,
"fin": document.getElementById("justi_date_fin").value,
}
}
const etudid = {{ sco.etud.id }};
const assi_limit_annee = "{{ assi_limit_annee }}" == "True" ? true : false;
const assi_morning = '{{assi_morning}}';
const assi_evening = '{{assi_evening}}';
window.onload = () => {
loadAll();
document.getElementById('justi_journee').addEventListener('click', () => { dayOnly() });
dayOnly()
}
</script>
{% endblock pageContent %}

View File

@ -174,7 +174,7 @@ def index_html():
</li></ul>
"""
)
dept : Departement = Departement.query.filter_by(id=g.scodoc_dept_id).first()
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,
@ -438,6 +438,8 @@ def ajout_justificatif_etud():
"assi_limit_annee",
dept_id=g.scodoc_dept_id,
),
assi_morning=ScoDocSiteConfig.get("assi_morning_time", "08:00"),
assi_evening=ScoDocSiteConfig.get("assi_evening_time", "18:00"),
),
).build()