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
3 changed files with 53 additions and 13 deletions
Showing only changes of commit 44cb59053a - Show all commits

View File

@ -114,9 +114,18 @@ class RowAssi(tb.Row):
compte_justificatifs = scass.filter_by_date( compte_justificatifs = scass.filter_by_date(
etud.justificatifs, Justificatif, self.dates[0], self.dates[1] 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]]: def _get_etud_stats(self, etud: Identite) -> dict[str, list[str, float, float]]:
retour: dict[str, tuple[str, float, float]] = { retour: dict[str, tuple[str, float, float]] = {

View File

@ -19,8 +19,9 @@
<div class="justi-label"> <div class="justi-label">
<legend for="justi_date_debut" required>Date de début</legend> <legend for="justi_date_debut" required>Date de début</legend>
<input type="datetime-local" name="justi_date_debut" id="justi_date_debut"> <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>
<div class="justi-label"> <div class="justi-label" id="date_fin">
<legend for="justi_date_fin" required>Date de fin</legend> <legend for="justi_date_fin" required>Date de fin</legend>
<input type="datetime-local" name="justi_date_fin" id="justi_date_fin"> <input type="datetime-local" name="justi_date_fin" id="justi_date_fin">
</div> </div>
@ -110,16 +111,15 @@
function validateFields() { function validateFields() {
const field = document.querySelector('.justi-form') const field = document.querySelector('.justi-form')
const in_date_debut = field.querySelector('#justi_date_debut'); const { deb, fin } = getDates()
const in_date_fin = field.querySelector('#justi_date_fin');
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"); 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; return false;
} }
const date_debut = moment.tz(in_date_debut.value, TIMEZONE); const date_debut = moment.tz(deb.value, TIMEZONE);
const date_fin = moment.tz(in_date_fin.value, TIMEZONE); const date_fin = moment.tz(fin.value, TIMEZONE);
if (date_fin.isBefore(date_debut)) { 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"); 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() { function fieldsToJustificatif() {
const field = document.querySelector('.justi-form') const field = document.querySelector('.justi-form')
const date_debut = field.querySelector('#justi_date_debut').value; const { deb, fin } = getDates()
const date_fin = field.querySelector('#justi_date_fin').value;
const etat = field.querySelector('#justi_etat').value; const etat = field.querySelector('#justi_etat').value;
const raison = field.querySelector('#justi_raison').value; const raison = field.querySelector('#justi_raison').value;
return { return {
date_debut: date_debut, date_debut: deb,
date_fin: date_fin, date_fin: fin,
etat: etat, etat: etat,
raison: raison, 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 etudid = {{ sco.etud.id }};
const assi_limit_annee = "{{ assi_limit_annee }}" == "True" ? true : false; const assi_limit_annee = "{{ assi_limit_annee }}" == "True" ? true : false;
const assi_morning = '{{assi_morning}}';
const assi_evening = '{{assi_evening}}';
window.onload = () => { window.onload = () => {
loadAll(); loadAll();
document.getElementById('justi_journee').addEventListener('click', () => { dayOnly() });
dayOnly()
} }
</script> </script>
{% endblock pageContent %} {% endblock pageContent %}

View File

@ -174,7 +174,7 @@ def index_html():
</li></ul> </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( annees: list[int] = sorted(
[f.date_debut.year for f in dept.formsemestres], [f.date_debut.year for f in dept.formsemestres],
reverse=True, reverse=True,
@ -438,6 +438,8 @@ def ajout_justificatif_etud():
"assi_limit_annee", "assi_limit_annee",
dept_id=g.scodoc_dept_id, 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() ).build()