From 280ceaa255cd26034ad643dcb356890b18a528e9 Mon Sep 17 00:00:00 2001 From: iziram Date: Thu, 22 Jun 2023 16:25:13 +0200 Subject: [PATCH] =?UTF-8?q?Assiduites=20:=20Calendrier=20des=20assiduit?= =?UTF-8?q?=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/html_sidebar.py | 2 +- app/static/js/assiduites.js | 15 + app/templates/assiduites/pages/calendrier.j2 | 338 ++++++++++++++++++ .../assiduites/widgets/minitimeline.j2 | 41 ++- .../assiduites/widgets/tableau_base.j2 | 2 +- app/templates/sidebar.j2 | 2 +- app/views/assiduites.py | 44 +++ 7 files changed, 431 insertions(+), 13 deletions(-) create mode 100644 app/templates/assiduites/pages/calendrier.j2 diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py index 3c8da9c31..cb93b15e1 100755 --- a/app/scodoc/html_sidebar.py +++ b/app/scodoc/html_sidebar.py @@ -136,7 +136,7 @@ def sidebar(etudid: int = None): ) H.append( f""" -
  • Calendrier
  • +
  • Calendrier
  • Liste
  • """ diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index 7451b84c2..de13ba26e 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -170,6 +170,21 @@ function sync_get(path, success, errors) { error: errors, }); } +/** + * Fait une requête GET de façon asynchrone + * @param {String} path adresse distante + * @param {CallableFunction} success fonction à effectuer en cas de succès + * @param {CallableFunction} errors fonction à effectuer en cas d'échec + */ +function async_get(path, success, errors) { + $.ajax({ + async: true, + type: "GET", + url: path, + success: success, + error: errors, + }); +} /** * Fait une requête POST de façon synchrone * @param {String} path adresse distante diff --git a/app/templates/assiduites/pages/calendrier.j2 b/app/templates/assiduites/pages/calendrier.j2 new file mode 100644 index 000000000..cf1ce4618 --- /dev/null +++ b/app/templates/assiduites/pages/calendrier.j2 @@ -0,0 +1,338 @@ +{% block pageContent %} +{% include "assiduites/widgets/alert.j2" %} + +
    + {{minitimeline | safe }} +

    Assiduités de {{sco.etud.nomprenom}}

    +
    + +
    +
    + Année scolaire 2022-2023 Changer année: + +
    +
    + + + + + +{% endblock pageContent %} \ No newline at end of file diff --git a/app/templates/assiduites/widgets/minitimeline.j2 b/app/templates/assiduites/widgets/minitimeline.j2 index 29c0c7c63..5c387d91a 100644 --- a/app/templates/assiduites/widgets/minitimeline.j2 +++ b/app/templates/assiduites/widgets/minitimeline.j2 @@ -11,9 +11,9 @@ * @param {Array[Assiduité]} assiduitesArray * @returns {HTMLElement} l'élément correspondant à la mini timeline */ - function createMiniTimeline(assiduitesArray) { + function createMiniTimeline(assiduitesArray, day = null) { const array = [...assiduitesArray]; - const dateiso = document.getElementById("tl_date").value; + const dateiso = day == null ? document.getElementById("tl_date").value : day; const timeline = document.createElement("div"); timeline.className = "mini-timeline"; if (isSingleEtud()) { @@ -26,15 +26,16 @@ timeline.appendChild(setMiniTick(timelineDate, dayStart, dayDuration)); - const tlTimes = getTimeLineTimes(); - const period_assi = { - date_debut: tlTimes.deb.format(), - date_fin: tlTimes.fin.format(), - etat: "CRENEAU", - }; - array.push(period_assi); + if (day == null) { + const tlTimes = getTimeLineTimes(); + array.push({ + date_debut: tlTimes.deb.format(), + date_fin: tlTimes.fin.format(), + etat: "CRENEAU", + }); + } array.forEach((assiduité) => { const startDate = moment(assiduité.date_debut); @@ -65,7 +66,7 @@ deb = Math.max(mt_start, deb); fin = Math.min(mt_end, fin); - setPeriodValues(deb, fin); + if (day == null) setPeriodValues(deb, fin); if (isSingleEtud()) { updateSelectedSelect(getCurrentAssiduiteModuleImplId()); updateJustifyBtn(); @@ -288,4 +289,24 @@ outline: 3px solid #7059FF; pointer-events: none; } + + .mini-timeline-block.absent { + background-color: #F1A69C !important; + } + + .mini-timeline-block.present { + background-color: #9CF1AF !important; + } + + .mini-timeline-block.retard { + background-color: #F1D99C !important; + } + + .mini-timeline-block.justified { + background-image: repeating-linear-gradient(135deg, transparent, transparent 4px, #7059FF 4px, #7059FF 8px); + } + + .mini-timeline-block.invalid_justified { + background-image: repeating-linear-gradient(135deg, transparent, transparent 4px, #d61616 4px, #d61616 8px); + } \ No newline at end of file diff --git a/app/templates/assiduites/widgets/tableau_base.j2 b/app/templates/assiduites/widgets/tableau_base.j2 index 9912a42ce..6e7520b21 100644 --- a/app/templates/assiduites/widgets/tableau_base.j2 +++ b/app/templates/assiduites/widgets/tableau_base.j2 @@ -478,7 +478,7 @@ const filterHead = html.querySelector('.filter-head'); filterHead.innerHTML = "" - let cols = ["entry_date", "date_debut", "date_fin", "etat", "raison"]; + let cols = ["entry_date", "date_debut", "date_fin", "etat", "raison", "fichier"]; cols.forEach((k) => { const label = document.createElement('label') diff --git a/app/templates/sidebar.j2 b/app/templates/sidebar.j2 index 5db4039d3..6a607db79 100755 --- a/app/templates/sidebar.j2 +++ b/app/templates/sidebar.j2 @@ -69,7 +69,7 @@ etudid=sco.etud.id) }}">Billets {% endif %} {% endif %} -
  • Calendrier
  • Liste
  • diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 8efad887d..464b4cc53 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -310,6 +310,50 @@ def ajout_justificatif_etud(): ).build() +@bp.route("/CalendrierAssiduitesEtud") +@scodoc +@permission_required(Permission.ScoView) +def calendrier_etud(): + """ + calendrier_etud : Affichage d'un calendrier des assiduités de l'étudiant + Args: + etudid (int): l'identifiant de l'étudiant + + Returns: + str: l'html généré + """ + + etudid = request.args.get("etudid", -1) + etud: Identite = Identite.query.get_or_404(etudid) + if etud.dept_id != g.scodoc_dept_id: + abort(404, "étudiant inexistant dans ce département") + + header: str = html_sco_header.sco_header( + page_title="Calendrier des Assiduités", + init_qtip=True, + javascripts=[ + "js/assiduites.js", + "libjs/moment.new.min.js", + "libjs/moment-timezone.js", + ], + cssstyles=CSSSTYLES + + [ + "css/assiduites.css", + ], + ) + + return HTMLBuilder( + header, + render_template( + "assiduites/pages/calendrier.j2", + sco=ScoData(etud), + annee=scu.annee_scolaire(), + nonworkdays=_non_work_days(), + minitimeline=_mini_timeline(), + ), + ).build() + + @bp.route("/SignalAssiduiteGr") @scodoc @permission_required(Permission.ScoAbsChange)