2021-05-31 00:14:15 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-06-02 22:40:34 +02:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
|
|
|
# Copyright (c) 1999 - 2021 Emmanuel Viennet. All rights reserved.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2021-05-31 00:14:15 +02:00
|
|
|
"""
|
|
|
|
Module absences: issu de ScoDoc7 / ZAbsences.py
|
|
|
|
|
|
|
|
Emmanuel Viennet, 2021
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
Gestion des absences (v4)
|
|
|
|
|
|
|
|
Code dérivé de la partie la plus ancienne de ScoDoc, et à revoir.
|
|
|
|
|
|
|
|
L'API de plus bas niveau est en gros:
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
AnnuleAbsencesDatesNoJust( dates)
|
2021-07-19 19:53:01 +02:00
|
|
|
count_abs(etudid, debut, fin, matin=None, moduleimpl_id=None)
|
|
|
|
count_abs_just(etudid, debut, fin, matin=None, moduleimpl_id=None)
|
|
|
|
list_abs_just(etudid, datedebut) [pas de fin ?]
|
|
|
|
list_abs_non_just(etudid, datedebut) [pas de fin ?]
|
|
|
|
list_abs_justifs(etudid, datedebut, datefin=None, only_no_abs=True)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
list_abs_jour(date, am=True, pm=True, is_abs=None, is_just=None)
|
|
|
|
list_abs_non_just_jour(date, am=True, pm=True)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-05-31 00:14:15 +02:00
|
|
|
"""
|
|
|
|
|
2021-07-11 13:03:13 +02:00
|
|
|
import calendar
|
|
|
|
import cgi
|
2021-06-02 22:40:34 +02:00
|
|
|
import datetime
|
|
|
|
import dateutil
|
|
|
|
import dateutil.parser
|
2021-07-11 13:03:13 +02:00
|
|
|
import re
|
2021-07-09 10:26:31 +02:00
|
|
|
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
|
2021-07-11 13:03:13 +02:00
|
|
|
import string
|
|
|
|
import time
|
|
|
|
from xml.etree import ElementTree
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-08-01 10:16:16 +02:00
|
|
|
import flask
|
2021-05-31 00:14:15 +02:00
|
|
|
from flask import g
|
2021-07-11 17:37:12 +02:00
|
|
|
from flask import url_for
|
2021-05-31 00:14:15 +02:00
|
|
|
from flask import current_app
|
|
|
|
|
|
|
|
from app.decorators import (
|
2021-08-13 00:34:58 +02:00
|
|
|
scodoc,
|
2021-05-31 00:14:15 +02:00
|
|
|
scodoc7func,
|
|
|
|
permission_required,
|
|
|
|
admin_required,
|
|
|
|
login_required,
|
|
|
|
)
|
|
|
|
|
|
|
|
from app.views import absences_bp as bp
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
# ---------------
|
|
|
|
from app.scodoc import sco_utils as scu
|
2021-06-15 13:59:56 +02:00
|
|
|
from app.scodoc import notesdb as ndb
|
2021-06-02 22:40:34 +02:00
|
|
|
from app.scodoc.notes_log import log
|
|
|
|
from app.scodoc.scolog import logdb
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.sco_permissions import Permission
|
2021-06-02 22:40:34 +02:00
|
|
|
from app.scodoc.sco_exceptions import ScoValueError, ScoInvalidDateError
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.TrivialFormulator import TrivialFormulator
|
2021-06-02 22:40:34 +02:00
|
|
|
from app.scodoc.gen_tables import GenTable
|
|
|
|
from app.scodoc import html_sco_header
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_abs
|
2021-06-21 10:17:16 +02:00
|
|
|
from app.scodoc import sco_abs_notification
|
|
|
|
from app.scodoc import sco_abs_views
|
2021-07-19 19:53:01 +02:00
|
|
|
from app.scodoc import sco_cache
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_compute_moy
|
|
|
|
from app.scodoc import sco_etud
|
|
|
|
from app.scodoc import sco_excel
|
2021-07-09 10:26:31 +02:00
|
|
|
from app.scodoc import sco_find_etud
|
2021-06-02 22:40:34 +02:00
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_groups
|
|
|
|
from app.scodoc import sco_groups_view
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_moduleimpl
|
|
|
|
from app.scodoc import sco_preferences
|
2021-07-11 13:03:13 +02:00
|
|
|
from app.scodoc import sco_xml
|
2021-06-19 23:21:37 +02:00
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS
|
|
|
|
|
|
|
|
|
2021-07-09 10:26:31 +02:00
|
|
|
def sco_publish(route, function, permission, methods=["GET"]):
|
2021-06-12 22:43:22 +02:00
|
|
|
"""Declare a route for a python function,
|
|
|
|
protected by permission and called following ScoDoc 7 Zope standards.
|
|
|
|
"""
|
2021-07-09 10:26:31 +02:00
|
|
|
return bp.route(route, methods=methods)(
|
2021-08-21 00:24:51 +02:00
|
|
|
scodoc(permission_required(permission)(scodoc7func(function)))
|
2021-07-09 10:26:31 +02:00
|
|
|
)
|
2021-06-12 22:43:22 +02:00
|
|
|
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
# --------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ABSENCES (/ScoDoc/<dept>/Scolarite/Absences/...)
|
|
|
|
#
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2021-07-09 10:26:31 +02:00
|
|
|
|
|
|
|
@bp.route("/")
|
|
|
|
@bp.route("/index_html")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-07-09 10:26:31 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
|
|
|
def index_html(REQUEST=None):
|
2021-07-09 10:26:31 +02:00
|
|
|
"""Gestionnaire absences, page principale"""
|
|
|
|
# crude portage from 1999 DTML
|
2021-08-19 10:28:35 +02:00
|
|
|
sems = sco_formsemestre.do_formsemestre_list()
|
2021-07-09 10:26:31 +02:00
|
|
|
authuser = REQUEST.AUTHENTICATED_USER
|
|
|
|
|
|
|
|
H = [
|
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title="Gestion des absences",
|
|
|
|
cssstyles=["css/calabs.css"],
|
|
|
|
javascripts=["js/calabs.js"],
|
|
|
|
),
|
|
|
|
"""<h2>Gestion des Absences</h2>""",
|
|
|
|
]
|
|
|
|
if not sems:
|
|
|
|
H.append(
|
|
|
|
"""<p class="warning">Aucun semestre défini (ou aucun groupe d'étudiant)</p>"""
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
"""<ul><li><a href="EtatAbsences">Afficher l'état des absences (pour tout un groupe)</a></li>"""
|
|
|
|
)
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("handle_billets_abs"):
|
2021-07-09 10:26:31 +02:00
|
|
|
H.append(
|
|
|
|
"""<li><a href="listeBillets">Traitement des billets d'absence en attente</a></li>"""
|
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
"""<p>Pour signaler, annuler ou justifier une absence, choisissez d'abord l'étudiant concerné:</p>"""
|
|
|
|
)
|
2021-08-21 00:24:51 +02:00
|
|
|
H.append(sco_find_etud.form_search_etud(REQUEST))
|
2021-07-09 10:26:31 +02:00
|
|
|
if authuser.has_permission(Permission.ScoAbsChange):
|
|
|
|
H.extend(
|
|
|
|
(
|
|
|
|
"""<hr/>
|
|
|
|
<form action="SignaleAbsenceGrHebdo" id="formw">
|
|
|
|
<input type="hidden" name="destination" value="%s"/>
|
|
|
|
<p>
|
|
|
|
<span style="font-weight: bold; font-size:120%%;">
|
|
|
|
Saisie par semaine </span> - Choix du groupe:
|
|
|
|
<input name="datelundi" type="hidden" value="x"/>
|
|
|
|
"""
|
|
|
|
% REQUEST.URL0,
|
2021-08-21 00:24:51 +02:00
|
|
|
sco_abs_views.formChoixSemestreGroupe(),
|
2021-07-09 10:26:31 +02:00
|
|
|
"</p>",
|
2021-08-21 00:24:51 +02:00
|
|
|
cal_select_week(),
|
2021-07-09 10:26:31 +02:00
|
|
|
"""<p class="help">Sélectionner le groupe d'étudiants, puis cliquez sur une semaine pour
|
|
|
|
saisir les absences de toute cette semaine.</p>
|
|
|
|
</form>""",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
"""<p class="scoinfo">Vous n'avez pas l'autorisation d'ajouter, justifier ou supprimer des absences.</p>"""
|
|
|
|
)
|
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2021-07-09 10:26:31 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def cal_select_week(year=None):
|
2021-07-09 10:26:31 +02:00
|
|
|
"display calendar allowing week selection"
|
|
|
|
if not year:
|
2021-08-01 16:13:47 +02:00
|
|
|
year = scu.AnneeScolaire()
|
2021-08-19 10:28:35 +02:00
|
|
|
sems = sco_formsemestre.do_formsemestre_list()
|
2021-07-09 10:26:31 +02:00
|
|
|
if not sems:
|
|
|
|
js = ""
|
|
|
|
else:
|
|
|
|
js = 'onmouseover="highlightweek(this);" onmouseout="deselectweeks();" onclick="wclick(this);"'
|
2021-08-21 00:24:51 +02:00
|
|
|
C = sco_abs.YearTable(int(year), dayattributes=js)
|
2021-07-09 10:26:31 +02:00
|
|
|
return C
|
|
|
|
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
sco_publish("/EtatAbsences", sco_abs_views.EtatAbsences, Permission.ScoView)
|
|
|
|
sco_publish("/CalAbs", sco_abs_views.CalAbs, Permission.ScoView)
|
|
|
|
sco_publish(
|
2021-07-09 10:26:31 +02:00
|
|
|
"/SignaleAbsenceEtud",
|
|
|
|
sco_abs_views.SignaleAbsenceEtud,
|
|
|
|
Permission.ScoAbsChange,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
|
|
|
sco_publish(
|
|
|
|
"/doSignaleAbsence",
|
|
|
|
sco_abs_views.doSignaleAbsence,
|
|
|
|
Permission.ScoAbsChange,
|
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
sco_publish(
|
2021-07-09 10:26:31 +02:00
|
|
|
"/JustifAbsenceEtud",
|
|
|
|
sco_abs_views.JustifAbsenceEtud,
|
|
|
|
Permission.ScoAbsChange,
|
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
sco_publish(
|
2021-07-09 10:26:31 +02:00
|
|
|
"/doJustifAbsence",
|
|
|
|
sco_abs_views.doJustifAbsence,
|
|
|
|
Permission.ScoAbsChange,
|
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
sco_publish(
|
2021-07-09 10:26:31 +02:00
|
|
|
"/AnnuleAbsenceEtud",
|
|
|
|
sco_abs_views.AnnuleAbsenceEtud,
|
|
|
|
Permission.ScoAbsChange,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
|
|
|
sco_publish(
|
|
|
|
"/doAnnuleAbsence",
|
|
|
|
sco_abs_views.doAnnuleAbsence,
|
|
|
|
Permission.ScoAbsChange,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
|
|
|
sco_publish(
|
|
|
|
"/doAnnuleJustif",
|
|
|
|
sco_abs_views.doAnnuleJustif,
|
|
|
|
Permission.ScoAbsChange,
|
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_publish(
|
|
|
|
"/AnnuleAbsencesDatesNoJust",
|
|
|
|
sco_abs_views.AnnuleAbsencesDatesNoJust,
|
|
|
|
Permission.ScoAbsChange,
|
2021-07-09 10:26:31 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-19 23:21:37 +02:00
|
|
|
)
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
sco_publish("/ListeAbsEtud", sco_abs_views.ListeAbsEtud, Permission.ScoView)
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SQL METHODS (xxx #sco8 not views => à déplacer)
|
|
|
|
#
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
# API backward compatibility
|
|
|
|
sco_publish("/CountAbs", sco_abs.count_abs, Permission.ScoView)
|
|
|
|
sco_publish("/CountAbsJust", sco_abs.count_abs_just, Permission.ScoView)
|
|
|
|
# TODO nouvel appel rendnat les deux valeurs et utilisant le cache
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-07-09 10:26:31 +02:00
|
|
|
@bp.route("/doSignaleAbsenceGrSemestre", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoAbsChange)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-06-02 22:40:34 +02:00
|
|
|
def doSignaleAbsenceGrSemestre(
|
|
|
|
moduleimpl_id=None,
|
|
|
|
abslist=[],
|
|
|
|
dates="",
|
|
|
|
etudids="",
|
|
|
|
destination=None,
|
|
|
|
REQUEST=None,
|
|
|
|
):
|
|
|
|
"""Enregistre absences aux dates indiquees (abslist et dates).
|
|
|
|
dates est une liste de dates ISO (séparées par des ',').
|
|
|
|
Efface les absences aux dates indiquées par dates,
|
|
|
|
ou bien ajoute celles de abslist.
|
|
|
|
"""
|
|
|
|
if etudids:
|
|
|
|
etudids = etudids.split(",")
|
|
|
|
else:
|
|
|
|
etudids = []
|
|
|
|
if dates:
|
|
|
|
dates = dates.split(",")
|
|
|
|
else:
|
|
|
|
dates = []
|
|
|
|
|
|
|
|
# 1- Efface les absences
|
|
|
|
if dates:
|
|
|
|
for etudid in etudids:
|
2021-08-21 00:24:51 +02:00
|
|
|
sco_abs_views.AnnuleAbsencesDatesNoJust(etudid, dates, moduleimpl_id)
|
2021-06-02 22:40:34 +02:00
|
|
|
return "Absences effacées"
|
|
|
|
|
|
|
|
# 2- Ajoute les absences
|
|
|
|
if abslist:
|
2021-08-21 00:24:51 +02:00
|
|
|
sco_abs._add_abslist(abslist, REQUEST, moduleimpl_id)
|
2021-06-02 22:40:34 +02:00
|
|
|
return "Absences ajoutées"
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
# ------------ HTML Interfaces
|
2021-07-09 10:26:31 +02:00
|
|
|
@bp.route("/SignaleAbsenceGrHebdo", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoAbsChange)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-06-02 22:40:34 +02:00
|
|
|
def SignaleAbsenceGrHebdo(
|
2021-08-21 00:24:51 +02:00
|
|
|
datelundi, group_ids=[], destination="", moduleimpl_id=None, REQUEST=None
|
2021-06-02 22:40:34 +02:00
|
|
|
):
|
|
|
|
"Saisie hebdomadaire des absences"
|
|
|
|
if not moduleimpl_id:
|
|
|
|
moduleimpl_id = None
|
|
|
|
|
|
|
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
2021-08-20 10:51:42 +02:00
|
|
|
group_ids, moduleimpl_id=moduleimpl_id, REQUEST=REQUEST
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
if not groups_infos.members:
|
|
|
|
return (
|
2021-07-29 16:58:18 +02:00
|
|
|
html_sco_header.sco_header(page_title="Saisie des absences")
|
2021-06-02 22:40:34 +02:00
|
|
|
+ "<h3>Aucun étudiant !</h3>"
|
2021-07-29 10:19:00 +02:00
|
|
|
+ html_sco_header.sco_footer()
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-05-31 00:14:15 +02:00
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
base_url = "SignaleAbsenceGrHebdo?datelundi=%s&%s&destination=%s" % (
|
|
|
|
datelundi,
|
|
|
|
groups_infos.groups_query_args,
|
2021-07-09 10:26:31 +02:00
|
|
|
six.moves.urllib.parse.quote(destination),
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-05-31 00:14:15 +02:00
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
formsemestre_id = groups_infos.formsemestre_id
|
2021-06-14 00:23:22 +02:00
|
|
|
require_module = sco_preferences.get_preference(
|
2021-07-28 17:03:54 +02:00
|
|
|
"abs_require_module", formsemestre_id
|
2021-06-14 00:23:22 +02:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
etuds = [
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0]
|
2021-06-02 22:40:34 +02:00
|
|
|
for m in groups_infos.members
|
|
|
|
]
|
|
|
|
# Restreint aux inscrits au module sélectionné
|
|
|
|
if moduleimpl_id:
|
|
|
|
mod_inscrits = set(
|
|
|
|
[
|
|
|
|
x["etudid"]
|
|
|
|
for x in sco_moduleimpl.do_moduleimpl_inscription_list(
|
2021-08-20 01:09:55 +02:00
|
|
|
moduleimpl_id=moduleimpl_id
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
etuds_inscrits_module = [e for e in etuds if e["etudid"] in mod_inscrits]
|
|
|
|
if etuds_inscrits_module:
|
|
|
|
etuds = etuds_inscrits_module
|
|
|
|
else:
|
|
|
|
# Si aucun etudiant n'est inscrit au module choisi...
|
|
|
|
moduleimpl_id = None
|
2021-07-19 19:53:01 +02:00
|
|
|
nt = sco_cache.NotesTableCache.get(formsemestre_id)
|
2021-08-19 10:28:35 +02:00
|
|
|
sem = sco_formsemestre.do_formsemestre_list({"formsemestre_id": formsemestre_id})[0]
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
# calcule dates jours de cette semaine
|
|
|
|
# liste de dates iso "yyyy-mm-dd"
|
2021-06-15 13:59:56 +02:00
|
|
|
datessem = [ndb.DateDMYtoISO(datelundi)]
|
2021-08-21 00:24:51 +02:00
|
|
|
for _ in sco_abs.day_names()[1:]:
|
|
|
|
datessem.append(sco_abs.next_iso_day(datessem[-1]))
|
2021-06-02 22:40:34 +02:00
|
|
|
#
|
|
|
|
if groups_infos.tous_les_etuds_du_sem:
|
|
|
|
gr_tit = "en"
|
|
|
|
else:
|
|
|
|
if len(groups_infos.group_ids) > 1:
|
|
|
|
p = "des groupes"
|
|
|
|
else:
|
|
|
|
p = "du groupe"
|
|
|
|
gr_tit = p + ' <span class="fontred">' + groups_infos.groups_titles + "</span>"
|
|
|
|
|
|
|
|
H = [
|
2021-06-13 18:29:53 +02:00
|
|
|
html_sco_header.sco_header(
|
2021-06-02 22:40:34 +02:00
|
|
|
page_title="Saisie hebdomadaire des absences",
|
|
|
|
init_qtip=True,
|
|
|
|
javascripts=html_sco_header.BOOTSTRAP_MULTISELECT_JS
|
|
|
|
+ [
|
|
|
|
"js/etud_info.js",
|
|
|
|
"js/abs_ajax.js",
|
|
|
|
"js/groups_view.js",
|
|
|
|
],
|
|
|
|
cssstyles=CSSSTYLES,
|
|
|
|
no_side_bar=1,
|
|
|
|
),
|
|
|
|
"""<table border="0" cellspacing="16"><tr><td>
|
|
|
|
<h2>Saisie des absences %s %s,
|
|
|
|
<span class="fontred">semaine du lundi %s</span></h2>
|
|
|
|
<div>
|
|
|
|
<form id="group_selector" method="get">
|
|
|
|
<input type="hidden" name="formsemestre_id" id="formsemestre_id" value="%s"/>
|
|
|
|
<input type="hidden" name="datelundi" id="datelundi" value="%s"/>
|
|
|
|
<input type="hidden" name="destination" id="destination" value="%s"/>
|
|
|
|
<input type="hidden" name="moduleimpl_id" id="moduleimpl_id_o" value="%s"/>
|
|
|
|
Groupes: %s
|
|
|
|
</form>
|
|
|
|
<form id="abs_form">
|
|
|
|
"""
|
|
|
|
% (
|
|
|
|
gr_tit,
|
|
|
|
sem["titre_num"],
|
|
|
|
datelundi,
|
|
|
|
groups_infos.formsemestre_id,
|
|
|
|
datelundi,
|
|
|
|
destination,
|
|
|
|
moduleimpl_id or "",
|
2021-08-20 10:51:42 +02:00
|
|
|
sco_groups_view.menu_groups_choice(groups_infos, submit_on_change=True),
|
2021-06-02 22:40:34 +02:00
|
|
|
),
|
|
|
|
]
|
|
|
|
#
|
|
|
|
modimpls_list = []
|
|
|
|
# Initialize with first student
|
|
|
|
ues = nt.get_ues(etudid=etuds[0]["etudid"])
|
|
|
|
for ue in ues:
|
|
|
|
modimpls_list += nt.get_modimpls(ue_id=ue["ue_id"])
|
|
|
|
|
|
|
|
# Add modules other students are subscribed to
|
|
|
|
for etud in etuds[1:]:
|
|
|
|
modimpls_etud = []
|
|
|
|
ues = nt.get_ues(etudid=etud["etudid"])
|
|
|
|
for ue in ues:
|
|
|
|
modimpls_etud += nt.get_modimpls(ue_id=ue["ue_id"])
|
|
|
|
modimpls_list += [m for m in modimpls_etud if m not in modimpls_list]
|
|
|
|
|
|
|
|
menu_module = ""
|
|
|
|
for modimpl in modimpls_list:
|
|
|
|
if modimpl["moduleimpl_id"] == moduleimpl_id:
|
|
|
|
sel = "selected"
|
|
|
|
else:
|
|
|
|
sel = ""
|
|
|
|
menu_module += (
|
|
|
|
"""<option value="%(modimpl_id)s" %(sel)s>%(modname)s</option>\n"""
|
|
|
|
% {
|
|
|
|
"modimpl_id": modimpl["moduleimpl_id"],
|
|
|
|
"modname": modimpl["module"]["code"]
|
|
|
|
+ " "
|
|
|
|
+ (modimpl["module"]["abbrev"] or modimpl["module"]["titre"]),
|
|
|
|
"sel": sel,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
if moduleimpl_id:
|
|
|
|
sel = ""
|
|
|
|
else:
|
|
|
|
sel = "selected" # aucun module specifie
|
|
|
|
|
|
|
|
H.append(
|
|
|
|
"""Module concerné:
|
|
|
|
<select id="moduleimpl_id" name="moduleimpl_id" onchange="change_moduleimpl('%(url)s')">
|
|
|
|
<option value="" %(sel)s>non spécifié</option>
|
|
|
|
%(menu_module)s
|
|
|
|
</select>
|
|
|
|
</div>"""
|
|
|
|
% {"menu_module": menu_module, "url": base_url, "sel": sel}
|
|
|
|
)
|
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
H += _gen_form_saisie_groupe(
|
2021-08-21 00:24:51 +02:00
|
|
|
etuds, datessem, destination, moduleimpl_id, require_module
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2021-06-02 22:40:34 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-07-09 10:26:31 +02:00
|
|
|
@bp.route("/SignaleAbsenceGrSemestre", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoAbsChange)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-06-02 22:40:34 +02:00
|
|
|
def SignaleAbsenceGrSemestre(
|
|
|
|
datedebut,
|
|
|
|
datefin,
|
|
|
|
destination="",
|
|
|
|
group_ids=[], # list of groups to display
|
|
|
|
nbweeks=4, # ne montre que les nbweeks dernieres semaines
|
|
|
|
moduleimpl_id=None,
|
|
|
|
REQUEST=None,
|
|
|
|
):
|
|
|
|
"""Saisie des absences sur une journée sur un semestre (ou intervalle de dates) entier"""
|
2021-08-20 10:51:42 +02:00
|
|
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids, REQUEST=REQUEST)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not groups_infos.members:
|
|
|
|
return (
|
2021-07-29 16:58:18 +02:00
|
|
|
html_sco_header.sco_header(page_title="Saisie des absences")
|
2021-06-02 22:40:34 +02:00
|
|
|
+ "<h3>Aucun étudiant !</h3>"
|
2021-07-29 10:19:00 +02:00
|
|
|
+ html_sco_header.sco_footer()
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
formsemestre_id = groups_infos.formsemestre_id
|
2021-06-14 00:23:22 +02:00
|
|
|
require_module = sco_preferences.get_preference(
|
2021-07-28 17:03:54 +02:00
|
|
|
"abs_require_module", formsemestre_id
|
2021-06-14 00:23:22 +02:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
etuds = [
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0]
|
2021-06-02 22:40:34 +02:00
|
|
|
for m in groups_infos.members
|
|
|
|
]
|
|
|
|
# Restreint aux inscrits au module sélectionné
|
|
|
|
if moduleimpl_id:
|
|
|
|
mod_inscrits = set(
|
|
|
|
[
|
|
|
|
x["etudid"]
|
|
|
|
for x in sco_moduleimpl.do_moduleimpl_inscription_list(
|
2021-08-20 01:09:55 +02:00
|
|
|
moduleimpl_id=moduleimpl_id
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
etuds = [e for e in etuds if e["etudid"] in mod_inscrits]
|
|
|
|
if not moduleimpl_id:
|
|
|
|
moduleimpl_id = None
|
|
|
|
base_url_noweeks = (
|
|
|
|
"SignaleAbsenceGrSemestre?datedebut=%s&datefin=%s&%s&destination=%s"
|
|
|
|
% (
|
|
|
|
datedebut,
|
|
|
|
datefin,
|
|
|
|
groups_infos.groups_query_args,
|
2021-07-09 10:26:31 +02:00
|
|
|
six.moves.urllib.parse.quote(destination),
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
base_url = base_url_noweeks + "&nbweeks=%s" % nbweeks # sans le moduleimpl_id
|
|
|
|
|
|
|
|
if etuds:
|
2021-07-19 19:53:01 +02:00
|
|
|
nt = sco_cache.NotesTableCache.get(formsemestre_id)
|
2021-06-02 22:40:34 +02:00
|
|
|
sem = sco_formsemestre.do_formsemestre_list(
|
2021-08-19 10:28:35 +02:00
|
|
|
{"formsemestre_id": formsemestre_id}
|
2021-06-02 22:40:34 +02:00
|
|
|
)[0]
|
2021-08-21 00:24:51 +02:00
|
|
|
work_saturday = sco_abs.is_work_saturday()
|
2021-06-19 23:21:37 +02:00
|
|
|
jourdebut = sco_abs.ddmmyyyy(datedebut, work_saturday=work_saturday)
|
|
|
|
jourfin = sco_abs.ddmmyyyy(datefin, work_saturday=work_saturday)
|
|
|
|
today = sco_abs.ddmmyyyy(
|
2021-06-02 22:40:34 +02:00
|
|
|
time.strftime("%d/%m/%Y", time.localtime()),
|
|
|
|
work_saturday=work_saturday,
|
|
|
|
)
|
2021-07-09 10:26:31 +02:00
|
|
|
today.next_day()
|
2021-06-02 22:40:34 +02:00
|
|
|
if jourfin > today: # ne propose jamais les semaines dans le futur
|
|
|
|
jourfin = today
|
|
|
|
if jourdebut > today:
|
|
|
|
raise ScoValueError("date de début dans le futur (%s) !" % jourdebut)
|
|
|
|
#
|
|
|
|
if not jourdebut.iswork() or jourdebut > jourfin:
|
|
|
|
raise ValueError(
|
|
|
|
"date debut invalide (%s, ouvrable=%d)"
|
|
|
|
% (str(jourdebut), jourdebut.iswork())
|
|
|
|
)
|
|
|
|
# calcule dates
|
2021-06-19 23:21:37 +02:00
|
|
|
dates = [] # sco_abs.ddmmyyyy instances
|
|
|
|
d = sco_abs.ddmmyyyy(datedebut, work_saturday=work_saturday)
|
2021-06-02 22:40:34 +02:00
|
|
|
while d <= jourfin:
|
|
|
|
dates.append(d)
|
2021-07-09 10:26:31 +02:00
|
|
|
d = d.next_day(7) # avance d'une semaine
|
2021-06-02 22:40:34 +02:00
|
|
|
#
|
|
|
|
msg = "Montrer seulement les 4 dernières semaines"
|
|
|
|
nwl = 4
|
|
|
|
if nbweeks:
|
|
|
|
nbweeks = int(nbweeks)
|
|
|
|
if nbweeks > 0:
|
|
|
|
dates = dates[-nbweeks:]
|
|
|
|
msg = "Montrer toutes les semaines"
|
|
|
|
nwl = 0
|
|
|
|
url_link_semaines = base_url_noweeks + "&nbweeks=%s" % nwl
|
|
|
|
if moduleimpl_id:
|
|
|
|
url_link_semaines += "&moduleimpl_id=" + moduleimpl_id
|
|
|
|
#
|
|
|
|
dates = [x.ISO() for x in dates]
|
2021-08-21 00:24:51 +02:00
|
|
|
dayname = sco_abs.day_names()[jourdebut.weekday]
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
if groups_infos.tous_les_etuds_du_sem:
|
|
|
|
gr_tit = "en"
|
|
|
|
else:
|
|
|
|
if len(groups_infos.group_ids) > 1:
|
|
|
|
p = "des groupes "
|
|
|
|
else:
|
|
|
|
p = "du groupe "
|
|
|
|
gr_tit = p + '<span class="fontred">' + groups_infos.groups_titles + "</span>"
|
|
|
|
|
|
|
|
H = [
|
2021-06-13 18:29:53 +02:00
|
|
|
html_sco_header.sco_header(
|
2021-06-02 22:40:34 +02:00
|
|
|
page_title="Saisie des absences",
|
|
|
|
init_qtip=True,
|
|
|
|
javascripts=["js/etud_info.js", "js/abs_ajax.js"],
|
|
|
|
no_side_bar=1,
|
|
|
|
),
|
|
|
|
"""<table border="0" cellspacing="16"><tr><td>
|
|
|
|
<h2>Saisie des absences %s %s,
|
|
|
|
les <span class="fontred">%s</span></h2>
|
|
|
|
<p>
|
|
|
|
<a href="%s">%s</a>
|
|
|
|
<form id="abs_form" action="doSignaleAbsenceGrSemestre" method="post">
|
|
|
|
"""
|
|
|
|
% (gr_tit, sem["titre_num"], dayname, url_link_semaines, msg),
|
|
|
|
]
|
|
|
|
#
|
|
|
|
if etuds:
|
|
|
|
modimpls_list = []
|
|
|
|
# Initialize with first student
|
|
|
|
ues = nt.get_ues(etudid=etuds[0]["etudid"])
|
|
|
|
for ue in ues:
|
|
|
|
modimpls_list += nt.get_modimpls(ue_id=ue["ue_id"])
|
|
|
|
|
|
|
|
# Add modules other students are subscribed to
|
|
|
|
for etud in etuds[1:]:
|
|
|
|
modimpls_etud = []
|
|
|
|
ues = nt.get_ues(etudid=etud["etudid"])
|
|
|
|
for ue in ues:
|
|
|
|
modimpls_etud += nt.get_modimpls(ue_id=ue["ue_id"])
|
|
|
|
modimpls_list += [m for m in modimpls_etud if m not in modimpls_list]
|
|
|
|
|
|
|
|
menu_module = ""
|
|
|
|
for modimpl in modimpls_list:
|
|
|
|
if modimpl["moduleimpl_id"] == moduleimpl_id:
|
|
|
|
sel = "selected"
|
|
|
|
else:
|
|
|
|
sel = ""
|
|
|
|
menu_module += (
|
|
|
|
"""<option value="%(modimpl_id)s" %(sel)s>%(modname)s</option>\n"""
|
|
|
|
% {
|
|
|
|
"modimpl_id": modimpl["moduleimpl_id"],
|
|
|
|
"modname": modimpl["module"]["code"]
|
|
|
|
+ " "
|
|
|
|
+ (modimpl["module"]["abbrev"] or modimpl["module"]["titre"]),
|
|
|
|
"sel": sel,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
if moduleimpl_id:
|
|
|
|
sel = ""
|
|
|
|
else:
|
|
|
|
sel = "selected" # aucun module specifie
|
|
|
|
H.append(
|
|
|
|
"""<p>
|
|
|
|
Module concerné par ces absences (%(optionel_txt)s):
|
|
|
|
<select id="moduleimpl_id" name="moduleimpl_id"
|
|
|
|
onchange="document.location='%(url)s&moduleimpl_id='+document.getElementById('moduleimpl_id').value">
|
|
|
|
<option value="" %(sel)s>non spécifié</option>
|
|
|
|
%(menu_module)s
|
|
|
|
</select>
|
|
|
|
</p>"""
|
|
|
|
% {
|
|
|
|
"menu_module": menu_module,
|
|
|
|
"url": base_url,
|
|
|
|
"sel": sel,
|
|
|
|
"optionel_txt": '<span class="redboldtext">requis</span>'
|
|
|
|
if require_module
|
|
|
|
else "optionnel",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
H += _gen_form_saisie_groupe(
|
2021-08-21 00:24:51 +02:00
|
|
|
etuds, dates, destination, moduleimpl_id, require_module
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2021-06-02 22:40:34 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
|
|
|
def _gen_form_saisie_groupe(
|
2021-08-21 00:24:51 +02:00
|
|
|
etuds, dates, destination="", moduleimpl_id=None, require_module=False
|
2021-06-02 22:40:34 +02:00
|
|
|
):
|
|
|
|
"""Formulaire saisie absences
|
|
|
|
|
|
|
|
Args:
|
|
|
|
etuds: liste des étudiants
|
|
|
|
dates: liste ordonnée de dates iso, par exemple: [ '2020-12-24', ... ]
|
|
|
|
moduleimpl_id: optionnel, module concerné.
|
|
|
|
"""
|
|
|
|
H = [
|
|
|
|
"""
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(function() {
|
|
|
|
$(".abs_form_table input").prop( "disabled", %s );
|
|
|
|
});
|
|
|
|
function colorize(obj) {
|
|
|
|
if (obj.checked) {
|
|
|
|
obj.parentNode.className = 'absent';
|
|
|
|
} else {
|
|
|
|
obj.parentNode.className = 'present';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function on_toggled(obj, etudid, dat) {
|
|
|
|
colorize(obj);
|
|
|
|
if (obj.checked) {
|
|
|
|
ajaxFunction('add', etudid, dat);
|
|
|
|
} else {
|
|
|
|
ajaxFunction('remove', etudid, dat);
|
|
|
|
}
|
2021-05-31 00:14:15 +02:00
|
|
|
}
|
2021-06-02 22:40:34 +02:00
|
|
|
</script>
|
|
|
|
<div id="AjaxDiv"></div>
|
|
|
|
<br/>
|
|
|
|
<table rules="cols" frame="box" class="abs_form_table">
|
|
|
|
<tr><th class="formabs_contetud">%d étudiants</th>
|
|
|
|
"""
|
|
|
|
% (
|
|
|
|
"true" if (require_module and not moduleimpl_id) else "false",
|
|
|
|
len(etuds),
|
|
|
|
)
|
|
|
|
]
|
|
|
|
# Dates
|
|
|
|
odates = [datetime.date(*[int(x) for x in d.split("-")]) for d in dates]
|
|
|
|
begin = dates[0]
|
|
|
|
end = dates[-1]
|
|
|
|
# Titres colonnes
|
|
|
|
noms_jours = [] # eg [ "Lundi", "mardi", "Samedi", ... ]
|
2021-08-21 00:24:51 +02:00
|
|
|
jn = sco_abs.day_names()
|
2021-06-02 22:40:34 +02:00
|
|
|
for d in odates:
|
|
|
|
idx_jour = d.weekday()
|
|
|
|
noms_jours.append(jn[idx_jour])
|
|
|
|
for jour in noms_jours:
|
|
|
|
H.append(
|
|
|
|
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
|
|
|
|
+ jour
|
|
|
|
+ "</th>"
|
|
|
|
)
|
|
|
|
H.append("</tr><tr><td> </td>")
|
|
|
|
for d in odates:
|
|
|
|
H.append(
|
|
|
|
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
|
|
|
|
+ d.strftime("%d/%m/%Y")
|
|
|
|
+ "</th>"
|
|
|
|
)
|
|
|
|
H.append("</tr><tr><td> </td>")
|
|
|
|
H.append("<th>AM</th><th>PM</th>" * len(dates))
|
|
|
|
H.append("</tr>")
|
|
|
|
#
|
|
|
|
if not etuds:
|
|
|
|
H.append(
|
|
|
|
'<tr><td><span class="redboldtext">Aucun étudiant inscrit !</span></td></tr>'
|
|
|
|
)
|
|
|
|
i = 1
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
|
|
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
2021-06-02 22:40:34 +02:00
|
|
|
for etud in etuds:
|
|
|
|
i += 1
|
|
|
|
etudid = etud["etudid"]
|
|
|
|
# UE capitalisee dans semestre courant ?
|
|
|
|
cap = []
|
|
|
|
if etud["cursem"]:
|
2021-07-19 19:53:01 +02:00
|
|
|
nt = sco_cache.NotesTableCache.get(
|
|
|
|
etud["cursem"]["formsemestre_id"]
|
2021-06-02 22:40:34 +02:00
|
|
|
) # > get_ues, get_etud_ue_status
|
|
|
|
for ue in nt.get_ues():
|
|
|
|
status = nt.get_etud_ue_status(etudid, ue["ue_id"])
|
|
|
|
if status["is_capitalized"]:
|
|
|
|
cap.append(ue["acronyme"])
|
|
|
|
if cap:
|
|
|
|
capstr = ' <span class="capstr">(%s cap.)</span>' % ", ".join(cap)
|
|
|
|
else:
|
|
|
|
capstr = ""
|
|
|
|
|
|
|
|
tr_class = ("row_1", "row_2", "row_3")[i % 3]
|
|
|
|
td_matin_class = ("matin_1", "matin_2", "matin_3")[i % 3]
|
|
|
|
|
|
|
|
H.append(
|
2021-07-11 17:37:12 +02:00
|
|
|
'<tr class="%s"><td><b class="etudinfo" id="%s"><a class="discretelink" href="%s" target="new">%s</a></b>%s</td>'
|
|
|
|
% (
|
|
|
|
tr_class,
|
|
|
|
etudid,
|
|
|
|
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
|
|
|
|
etud["nomprenom"],
|
|
|
|
capstr,
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-06-19 23:21:37 +02:00
|
|
|
etud_abs = sco_abs.list_abs_in_range(
|
2021-07-19 19:53:01 +02:00
|
|
|
etudid, begin, end, moduleimpl_id=moduleimpl_id, cursor=cursor
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
for d in odates:
|
|
|
|
date = d.strftime("%Y-%m-%d")
|
|
|
|
# matin
|
|
|
|
is_abs = {"jour": d, "matin": True} in etud_abs
|
|
|
|
if is_abs:
|
|
|
|
checked = "checked"
|
|
|
|
else:
|
|
|
|
checked = ""
|
|
|
|
# bulle lors du passage souris
|
|
|
|
coljour = sco_abs.DAYNAMES[(calendar.weekday(d.year, d.month, d.day))]
|
|
|
|
datecol = coljour + " " + d.strftime("%d/%m/%Y")
|
|
|
|
bulle_am = '"' + etud["nomprenom"] + " - " + datecol + ' (matin)"'
|
|
|
|
bulle_pm = '"' + etud["nomprenom"] + " - " + datecol + ' (ap.midi)"'
|
|
|
|
|
|
|
|
H.append(
|
|
|
|
'<td class="%s"><a title=%s><input type="checkbox" name="abslist:list" value="%s" %s onclick="on_toggled(this, \'%s\', \'%s\')"/></a></td>'
|
|
|
|
% (
|
|
|
|
td_matin_class,
|
|
|
|
bulle_am,
|
2021-08-15 15:09:09 +02:00
|
|
|
str(etudid) + ":" + date + ":" + "am",
|
2021-06-02 22:40:34 +02:00
|
|
|
checked,
|
|
|
|
etudid,
|
|
|
|
date + ":am",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
# après-midi
|
|
|
|
is_abs = {"jour": d, "matin": False} in etud_abs
|
|
|
|
if is_abs:
|
|
|
|
checked = "checked"
|
|
|
|
else:
|
|
|
|
checked = ""
|
|
|
|
H.append(
|
|
|
|
'<td><a title=%s><input type="checkbox" name="abslist:list" value="%s" %s onclick="on_toggled(this, \'%s\', \'%s\')"/></a></td>'
|
|
|
|
% (
|
|
|
|
bulle_pm,
|
2021-08-16 08:33:12 +02:00
|
|
|
str(etudid) + ":" + date + ":" + "pm",
|
2021-06-02 22:40:34 +02:00
|
|
|
checked,
|
|
|
|
etudid,
|
|
|
|
date + ":pm",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
H.append("</tr>")
|
|
|
|
H.append("</table>")
|
|
|
|
# place la liste des etudiants et les dates pour pouvoir effacer les absences
|
|
|
|
H.append(
|
|
|
|
'<input type="hidden" name="etudids" value="%s"/>'
|
2021-08-16 08:33:12 +02:00
|
|
|
% ",".join([str(etud["etudid"]) for etud in etuds])
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
H.append('<input type="hidden" name="datedebut" value="%s"/>' % dates[0])
|
|
|
|
H.append('<input type="hidden" name="datefin" value="%s"/>' % dates[-1])
|
|
|
|
H.append('<input type="hidden" name="dates" value="%s"/>' % ",".join(dates))
|
|
|
|
H.append(
|
|
|
|
'<input type="hidden" name="destination" value="%s"/>'
|
2021-07-09 10:26:31 +02:00
|
|
|
% six.moves.urllib.parse.quote(destination)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
#
|
|
|
|
# version pour formulaire avec AJAX (Yann LB)
|
|
|
|
H.append(
|
|
|
|
"""
|
|
|
|
<p><input type="button" value="Retour" onClick="window.location='%s'"/>
|
|
|
|
</p>
|
|
|
|
</form>
|
|
|
|
</p>
|
|
|
|
</td></tr></table>
|
|
|
|
<p class="help">Les cases cochées correspondent à des absences.
|
|
|
|
Les absences saisies ne sont pas justifiées (sauf si un justificatif a été entré
|
|
|
|
par ailleurs).
|
|
|
|
</p><p class="help">Si vous "décochez" une case, l'absence correspondante sera supprimée.
|
|
|
|
Attention, les modifications sont automatiquement entregistrées au fur et à mesure.
|
|
|
|
</p>
|
|
|
|
"""
|
|
|
|
% destination
|
|
|
|
)
|
|
|
|
return H
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/EtatAbsencesGr")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func # ported from dtml
|
2021-06-02 22:40:34 +02:00
|
|
|
def EtatAbsencesGr(
|
|
|
|
group_ids=[], # list of groups to display
|
|
|
|
debut="",
|
|
|
|
fin="",
|
|
|
|
with_boursier=True, # colonne boursier
|
|
|
|
format="html",
|
|
|
|
REQUEST=None,
|
|
|
|
):
|
|
|
|
"""Liste les absences de groupes"""
|
2021-06-15 13:59:56 +02:00
|
|
|
datedebut = ndb.DateDMYtoISO(debut)
|
|
|
|
datefin = ndb.DateDMYtoISO(fin)
|
2021-06-02 22:40:34 +02:00
|
|
|
# Informations sur les groupes à afficher:
|
2021-08-20 10:51:42 +02:00
|
|
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids, REQUEST=REQUEST)
|
2021-06-02 22:40:34 +02:00
|
|
|
formsemestre_id = groups_infos.formsemestre_id
|
|
|
|
sem = groups_infos.formsemestre
|
|
|
|
|
|
|
|
# Construit tableau (etudid, statut, nomprenom, nbJust, nbNonJust, NbTotal)
|
|
|
|
T = []
|
|
|
|
for m in groups_infos.members:
|
2021-06-19 23:21:37 +02:00
|
|
|
etud = sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0]
|
2021-07-19 19:53:01 +02:00
|
|
|
nbabs = sco_abs.count_abs(etudid=etud["etudid"], debut=datedebut, fin=datefin)
|
|
|
|
nbabsjust = sco_abs.count_abs_just(
|
|
|
|
etudid=etud["etudid"], debut=datedebut, fin=datefin
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
nbjustifs_noabs = len(
|
2021-07-19 19:53:01 +02:00
|
|
|
sco_abs.list_abs_justifs(
|
|
|
|
etudid=etud["etudid"], datedebut=datedebut, only_no_abs=True
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
# retrouve sem dans etud['sems']
|
|
|
|
s = None
|
|
|
|
for s in etud["sems"]:
|
|
|
|
if s["formsemestre_id"] == formsemestre_id:
|
|
|
|
break
|
|
|
|
if not s or s["formsemestre_id"] != formsemestre_id:
|
|
|
|
raise ValueError(
|
|
|
|
"EtatAbsencesGr: can't retreive sem"
|
|
|
|
) # bug or malicious arg
|
|
|
|
T.append(
|
|
|
|
{
|
|
|
|
"etudid": etud["etudid"],
|
|
|
|
"etatincursem": s["ins"]["etat"],
|
|
|
|
"nomprenom": etud["nomprenom"],
|
|
|
|
"nbabsjust": nbabsjust,
|
|
|
|
"nbabsnonjust": nbabs - nbabsjust,
|
|
|
|
"nbabs": nbabs,
|
|
|
|
"nbjustifs_noabs": nbjustifs_noabs,
|
|
|
|
"_nomprenom_target": "CalAbs?etudid=%s" % etud["etudid"],
|
|
|
|
"_nomprenom_td_attrs": 'id="%s" class="etudinfo"' % etud["etudid"],
|
|
|
|
"boursier": etud["boursier"],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
if s["ins"]["etat"] == "D":
|
|
|
|
T[-1]["_css_row_class"] = "etuddem"
|
|
|
|
T[-1]["nomprenom"] += " (dem)"
|
|
|
|
columns_ids = [
|
|
|
|
"nomprenom",
|
|
|
|
"nbjustifs_noabs",
|
|
|
|
"nbabsjust",
|
|
|
|
"nbabsnonjust",
|
|
|
|
"nbabs",
|
|
|
|
]
|
|
|
|
if with_boursier:
|
|
|
|
columns_ids[1:1] = ["boursier"]
|
|
|
|
if groups_infos.tous_les_etuds_du_sem:
|
|
|
|
gr_tit = ""
|
|
|
|
else:
|
|
|
|
if len(groups_infos.group_ids) > 1:
|
|
|
|
p = "des groupes"
|
|
|
|
else:
|
|
|
|
p = "du groupe"
|
|
|
|
if format == "html":
|
|
|
|
h = ' <span class="fontred">' + groups_infos.groups_titles + "</span>"
|
|
|
|
else:
|
|
|
|
h = groups_infos.groups_titles
|
|
|
|
gr_tit = p + h
|
|
|
|
|
|
|
|
title = "Etat des absences %s" % gr_tit
|
|
|
|
if format == "xls" or format == "xml" or format == "json":
|
|
|
|
columns_ids = ["etudid"] + columns_ids
|
|
|
|
tab = GenTable(
|
|
|
|
columns_ids=columns_ids,
|
|
|
|
rows=T,
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(formsemestre_id),
|
2021-06-02 22:40:34 +02:00
|
|
|
titles={
|
|
|
|
"etatincursem": "Etat",
|
|
|
|
"nomprenom": "Nom",
|
|
|
|
"nbabsjust": "Justifiées",
|
|
|
|
"nbabsnonjust": "Non justifiées",
|
|
|
|
"nbabs": "Total",
|
|
|
|
"nbjustifs_noabs": "Justifs non utilisés",
|
|
|
|
"boursier": "Bourse",
|
|
|
|
},
|
|
|
|
html_sortable=True,
|
|
|
|
html_class="table_leftalign",
|
2021-06-13 18:29:53 +02:00
|
|
|
html_header=html_sco_header.sco_header(
|
2021-06-02 22:40:34 +02:00
|
|
|
page_title=title,
|
|
|
|
init_qtip=True,
|
|
|
|
javascripts=["js/etud_info.js"],
|
|
|
|
),
|
2021-06-21 11:22:55 +02:00
|
|
|
html_title=html_sco_header.html_sem_header(
|
2021-08-20 10:51:42 +02:00
|
|
|
REQUEST, "%s" % title, sem, with_page_header=False
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
+ "<p>Période du %s au %s (nombre de <b>demi-journées</b>)<br/>" % (debut, fin),
|
|
|
|
base_url="%s&formsemestre_id=%s&debut=%s&fin=%s"
|
|
|
|
% (groups_infos.base_url, formsemestre_id, debut, fin),
|
|
|
|
filename="etat_abs_"
|
|
|
|
+ scu.make_filename(
|
|
|
|
"%s de %s" % (groups_infos.groups_filename, sem["titreannee"])
|
|
|
|
),
|
|
|
|
caption=title,
|
|
|
|
html_next_section="""</table>
|
|
|
|
<p class="help">
|
|
|
|
Justifs non utilisés: nombre de demi-journées avec justificatif mais sans absences relevées.
|
|
|
|
</p>
|
|
|
|
<p class="help">
|
|
|
|
Cliquez sur un nom pour afficher le calendrier des absences<br/>
|
|
|
|
ou entrez une date pour visualiser les absents un jour donné :
|
|
|
|
</p>
|
|
|
|
<div style="margin-bottom: 10px;">
|
|
|
|
<form action="EtatAbsencesDate" method="get" action="%s">
|
|
|
|
<input type="hidden" name="formsemestre_id" value="%s">
|
|
|
|
%s
|
|
|
|
<input type="text" name="date" size="10" class="datepicker"/>
|
|
|
|
<input type="submit" name="" value="visualiser les absences">
|
|
|
|
</form></div>
|
|
|
|
"""
|
|
|
|
% (REQUEST.URL0, formsemestre_id, groups_infos.get_form_elem()),
|
|
|
|
)
|
2021-08-19 10:28:35 +02:00
|
|
|
return tab.make_page(format=format, REQUEST=REQUEST)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/EtatAbsencesDate")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-06-02 22:40:34 +02:00
|
|
|
def EtatAbsencesDate(
|
2021-08-21 00:24:51 +02:00
|
|
|
group_ids=[], date=None, REQUEST=None # list of groups to display
|
2021-06-02 22:40:34 +02:00
|
|
|
):
|
|
|
|
# ported from dtml
|
|
|
|
"""Etat des absences pour un groupe à une date donnée"""
|
|
|
|
# Informations sur les groupes à afficher:
|
2021-08-20 10:51:42 +02:00
|
|
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids, REQUEST=REQUEST)
|
2021-07-29 16:58:18 +02:00
|
|
|
H = [html_sco_header.sco_header(page_title="Etat des absences")]
|
2021-06-02 22:40:34 +02:00
|
|
|
if date:
|
2021-06-15 13:59:56 +02:00
|
|
|
dateiso = ndb.DateDMYtoISO(date)
|
2021-06-02 22:40:34 +02:00
|
|
|
nbetud = 0
|
|
|
|
t_nbabsjustam = 0
|
|
|
|
t_nbabsam = 0
|
|
|
|
t_nbabsjustpm = 0
|
|
|
|
t_nbabspm = 0
|
|
|
|
H.append("<h2>État des absences le %s</h2>" % date)
|
|
|
|
H.append(
|
|
|
|
"""<table border="0" cellspacing="4" cellpadding="0">
|
|
|
|
<tr><th> </th>
|
|
|
|
<th style="width: 10em;">Matin</th><th style="width: 10em;">Après-midi</th></tr>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
for etud in groups_infos.members:
|
2021-07-19 19:53:01 +02:00
|
|
|
nbabsam = sco_abs.count_abs(
|
|
|
|
etudid=etud["etudid"], debut=dateiso, fin=dateiso, matin=1
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-07-19 19:53:01 +02:00
|
|
|
nbabspm = sco_abs.count_abs(
|
|
|
|
etudid=etud["etudid"], debut=dateiso, fin=dateiso, matin=0
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
if (nbabsam != 0) or (nbabspm != 0):
|
|
|
|
nbetud += 1
|
2021-07-19 19:53:01 +02:00
|
|
|
nbabsjustam = sco_abs.count_abs_just(
|
|
|
|
etudid=etud["etudid"], debut=dateiso, fin=dateiso, matin=1
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-07-19 19:53:01 +02:00
|
|
|
nbabsjustpm = sco_abs.count_abs_just(
|
|
|
|
etudid=etud["etudid"], debut=dateiso, fin=dateiso, matin=0
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
"""<tr bgcolor="#FFFFFF"><td>
|
|
|
|
<a href="CalAbs?etudid=%(etudid)s"><font color="#A00000">%(nomprenom)s</font></a></td><td align="center">"""
|
|
|
|
% etud
|
|
|
|
) # """
|
|
|
|
if nbabsam != 0:
|
|
|
|
if nbabsjustam:
|
|
|
|
H.append("Just.")
|
|
|
|
t_nbabsjustam += 1
|
|
|
|
else:
|
|
|
|
H.append("Abs.")
|
|
|
|
t_nbabsam += 1
|
|
|
|
else:
|
|
|
|
H.append("")
|
|
|
|
H.append('</td><td align="center">')
|
|
|
|
if nbabspm != 0:
|
|
|
|
if nbabsjustpm:
|
|
|
|
H.append("Just.")
|
|
|
|
t_nbabsjustam += 1
|
|
|
|
else:
|
|
|
|
H.append("Abs.")
|
|
|
|
t_nbabspm += 1
|
|
|
|
else:
|
|
|
|
H.append("")
|
|
|
|
H.append("</td></tr>")
|
|
|
|
H.append(
|
|
|
|
"""<tr bgcolor="#FFFFFF"><td></td><td>%d abs, %d just.</td><td>%d abs, %d just.</td></tr>"""
|
|
|
|
% (t_nbabsam, t_nbabsjustam, t_nbabspm, t_nbabsjustpm)
|
|
|
|
)
|
|
|
|
H.append("</table>")
|
|
|
|
if nbetud == 0:
|
|
|
|
H.append("<p>Aucune absence !</p>")
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
"""<h2>Erreur: vous n'avez pas choisi de date !</h2>
|
2021-06-21 23:13:57 +02:00
|
|
|
"""
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
return "\n".join(H) + html_sco_header.sco_footer()
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
# ----- Gestion des "billets d'absence": signalement par les etudiants eux mêmes (à travers le portail)
|
|
|
|
@bp.route("/AddBilletAbsence")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoAbsAddBillet)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-06-02 22:40:34 +02:00
|
|
|
def AddBilletAbsence(
|
|
|
|
begin,
|
|
|
|
end,
|
|
|
|
description,
|
|
|
|
etudid=False,
|
|
|
|
code_nip=None,
|
|
|
|
code_ine=None,
|
|
|
|
justified=True,
|
|
|
|
REQUEST=None,
|
|
|
|
xml_reply=True,
|
|
|
|
):
|
|
|
|
"""Memorise un "billet"
|
|
|
|
begin et end sont au format ISO (eg "1999-01-08 04:05:06")
|
|
|
|
"""
|
|
|
|
t0 = time.time()
|
|
|
|
# check etudid
|
2021-06-19 23:21:37 +02:00
|
|
|
etuds = sco_etud.get_etud_info(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True
|
|
|
|
)
|
|
|
|
if not etuds:
|
2021-07-28 17:03:54 +02:00
|
|
|
return scu.log_unknown_etud(REQUEST=REQUEST)
|
2021-06-02 22:40:34 +02:00
|
|
|
etud = etuds[0]
|
|
|
|
# check dates
|
|
|
|
begin_date = dateutil.parser.isoparse(begin) # may raises ValueError
|
|
|
|
end_date = dateutil.parser.isoparse(end)
|
|
|
|
if begin_date > end_date:
|
|
|
|
raise ValueError("invalid dates")
|
|
|
|
#
|
2021-08-10 13:44:30 +02:00
|
|
|
justified = bool(justified)
|
2021-06-02 22:40:34 +02:00
|
|
|
#
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-02 22:40:34 +02:00
|
|
|
billet_id = sco_abs.billet_absence_create(
|
|
|
|
cnx,
|
|
|
|
{
|
|
|
|
"etudid": etud["etudid"],
|
|
|
|
"abs_begin": begin,
|
|
|
|
"abs_end": end,
|
|
|
|
"description": description,
|
2021-08-10 13:44:30 +02:00
|
|
|
"etat": False,
|
2021-06-02 22:40:34 +02:00
|
|
|
"justified": justified,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
if xml_reply:
|
|
|
|
# Renvoie le nouveau billet en XML
|
|
|
|
if REQUEST:
|
|
|
|
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
|
|
|
|
|
|
|
|
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
|
2021-08-21 00:24:51 +02:00
|
|
|
tab = _tableBillets(billets, etud=etud)
|
2021-06-02 22:40:34 +02:00
|
|
|
log("AddBilletAbsence: new billet_id=%s (%gs)" % (billet_id, time.time() - t0))
|
2021-08-19 10:28:35 +02:00
|
|
|
return tab.make_page(REQUEST=REQUEST, format="xml")
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
|
|
|
return billet_id
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/AddBilletAbsenceForm")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoAbsAddBillet)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
|
|
|
def AddBilletAbsenceForm(etudid, REQUEST=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Formulaire ajout billet (pour tests seulement, le vrai formulaire accessible aux etudiants
|
|
|
|
étant sur le portail étudiant).
|
|
|
|
"""
|
2021-06-19 23:21:37 +02:00
|
|
|
etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
|
2021-06-02 22:40:34 +02:00
|
|
|
H = [
|
2021-06-13 18:29:53 +02:00
|
|
|
html_sco_header.sco_header(
|
2021-07-29 16:31:15 +02:00
|
|
|
page_title="Billet d'absence de %s" % etud["nomprenom"]
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
]
|
|
|
|
tf = TrivialFormulator(
|
|
|
|
REQUEST.URL0,
|
|
|
|
REQUEST.form,
|
|
|
|
(
|
|
|
|
("etudid", {"input_type": "hidden"}),
|
|
|
|
("begin", {"input_type": "date"}),
|
|
|
|
("end", {"input_type": "date"}),
|
|
|
|
(
|
|
|
|
"justified",
|
|
|
|
{"input_type": "boolcheckbox", "default": 0, "title": "Justifiée"},
|
|
|
|
),
|
|
|
|
("description", {"input_type": "textarea"}),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
if tf[0] == 0:
|
2021-07-29 10:19:00 +02:00
|
|
|
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
2021-06-02 22:40:34 +02:00
|
|
|
elif tf[0] == -1:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(scu.ScoURL())
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
|
|
|
e = tf[2]["begin"].split("/")
|
|
|
|
begin = e[2] + "-" + e[1] + "-" + e[0] + " 00:00:00"
|
|
|
|
e = tf[2]["end"].split("/")
|
|
|
|
end = e[2] + "-" + e[1] + "-" + e[0] + " 00:00:00"
|
|
|
|
log(
|
2021-06-19 23:21:37 +02:00
|
|
|
AddBilletAbsence(
|
2021-06-02 22:40:34 +02:00
|
|
|
begin,
|
|
|
|
end,
|
|
|
|
tf[2]["description"],
|
|
|
|
etudid=etudid,
|
|
|
|
xml_reply=True,
|
|
|
|
justified=tf[2]["justified"],
|
|
|
|
)
|
|
|
|
)
|
2021-08-10 17:12:10 +02:00
|
|
|
return flask.redirect("listeBilletsEtud?etudid=" + str(etudid))
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def _tableBillets(billets, etud=None, title=""):
|
2021-06-02 22:40:34 +02:00
|
|
|
for b in billets:
|
|
|
|
if b["abs_begin"].hour < 12:
|
|
|
|
m = " matin"
|
|
|
|
else:
|
|
|
|
m = " après-midi"
|
|
|
|
b["abs_begin_str"] = b["abs_begin"].strftime("%d/%m/%Y") + m
|
|
|
|
if b["abs_end"].hour < 12:
|
|
|
|
m = " matin"
|
|
|
|
else:
|
|
|
|
m = " après-midi"
|
|
|
|
b["abs_end_str"] = b["abs_end"].strftime("%d/%m/%Y") + m
|
|
|
|
if b["etat"] == 0:
|
2021-08-11 00:36:07 +02:00
|
|
|
if b["justified"]:
|
2021-06-02 22:40:34 +02:00
|
|
|
b["etat_str"] = "à traiter"
|
|
|
|
else:
|
|
|
|
b["etat_str"] = "à justifier"
|
|
|
|
b["_etat_str_target"] = (
|
|
|
|
"ProcessBilletAbsenceForm?billet_id=%s" % b["billet_id"]
|
|
|
|
)
|
|
|
|
if etud:
|
|
|
|
b["_etat_str_target"] += "&etudid=%s" % etud["etudid"]
|
|
|
|
b["_billet_id_target"] = b["_etat_str_target"]
|
|
|
|
else:
|
|
|
|
b["etat_str"] = "ok"
|
|
|
|
if not etud:
|
|
|
|
# ajoute info etudiant
|
2021-06-19 23:21:37 +02:00
|
|
|
e = sco_etud.get_etud_info(etudid=b["etudid"], filled=1)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not e:
|
|
|
|
b["nomprenom"] = "???" # should not occur
|
|
|
|
else:
|
|
|
|
b["nomprenom"] = e[0]["nomprenom"]
|
2021-07-11 17:37:12 +02:00
|
|
|
b["_nomprenom_target"] = url_for(
|
|
|
|
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=b["etudid"]
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
if etud and not title:
|
|
|
|
title = "Billets d'absence déclarés par %(nomprenom)s" % etud
|
|
|
|
else:
|
|
|
|
title = title
|
|
|
|
columns_ids = ["billet_id"]
|
|
|
|
if not etud:
|
|
|
|
columns_ids += ["nomprenom"]
|
|
|
|
columns_ids += ["abs_begin_str", "abs_end_str", "description", "etat_str"]
|
|
|
|
|
|
|
|
tab = GenTable(
|
|
|
|
titles={
|
|
|
|
"billet_id": "Numéro",
|
|
|
|
"abs_begin_str": "Début",
|
|
|
|
"abs_end_str": "Fin",
|
|
|
|
"description": "Raison de l'absence",
|
|
|
|
"etat_str": "Etat",
|
|
|
|
},
|
|
|
|
columns_ids=columns_ids,
|
|
|
|
page_title=title,
|
|
|
|
html_title="<h2>%s</h2>" % title,
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(),
|
2021-06-02 22:40:34 +02:00
|
|
|
rows=billets,
|
|
|
|
html_sortable=True,
|
|
|
|
)
|
|
|
|
return tab
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/listeBilletsEtud")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
|
|
|
def listeBilletsEtud(etudid=False, REQUEST=None, format="html"):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Liste billets pour un etudiant"""
|
2021-06-19 23:21:37 +02:00
|
|
|
etuds = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not etuds:
|
2021-07-28 17:03:54 +02:00
|
|
|
return scu.log_unknown_etud(format=format, REQUEST=REQUEST)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
etud = etuds[0]
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-02 22:40:34 +02:00
|
|
|
billets = sco_abs.billet_absence_list(cnx, {"etudid": etud["etudid"]})
|
2021-08-21 00:24:51 +02:00
|
|
|
tab = _tableBillets(billets, etud=etud)
|
2021-08-19 10:28:35 +02:00
|
|
|
return tab.make_page(REQUEST=REQUEST, format=format)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/XMLgetBilletsEtud")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
|
|
|
def XMLgetBilletsEtud(etudid=False, REQUEST=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Liste billets pour un etudiant"""
|
2021-07-28 17:03:54 +02:00
|
|
|
if not sco_preferences.get_preference("handle_billets_abs"):
|
2021-06-02 22:40:34 +02:00
|
|
|
return ""
|
|
|
|
t0 = time.time()
|
2021-08-21 00:24:51 +02:00
|
|
|
r = listeBilletsEtud(etudid, REQUEST=REQUEST, format="xml")
|
2021-06-02 22:40:34 +02:00
|
|
|
log("XMLgetBilletsEtud (%gs)" % (time.time() - t0))
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/listeBillets")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
|
|
|
def listeBillets(REQUEST=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Page liste des billets non traités et formulaire recherche d'un billet"""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-02 22:40:34 +02:00
|
|
|
billets = sco_abs.billet_absence_list(cnx, {"etat": 0})
|
2021-08-21 00:24:51 +02:00
|
|
|
tab = _tableBillets(billets)
|
2021-06-02 22:40:34 +02:00
|
|
|
T = tab.html()
|
|
|
|
H = [
|
2021-07-29 16:31:15 +02:00
|
|
|
html_sco_header.sco_header(page_title="Billet d'absence non traités"),
|
2021-06-02 22:40:34 +02:00
|
|
|
"<h2>Billets d'absence en attente de traitement (%d)</h2>" % len(billets),
|
|
|
|
]
|
|
|
|
|
|
|
|
tf = TrivialFormulator(
|
|
|
|
REQUEST.URL0,
|
|
|
|
REQUEST.form,
|
|
|
|
(("billet_id", {"input_type": "text", "title": "Numéro du billet"}),),
|
|
|
|
submitbutton=False,
|
|
|
|
)
|
|
|
|
if tf[0] == 0:
|
2021-07-29 10:19:00 +02:00
|
|
|
return "\n".join(H) + tf[1] + T + html_sco_header.sco_footer()
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2021-06-02 22:40:34 +02:00
|
|
|
"ProcessBilletAbsenceForm?billet_id=" + tf[2]["billet_id"]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/deleteBilletAbsence")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoAbsChange)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
|
|
|
def deleteBilletAbsence(billet_id, REQUEST=None, dialog_confirmed=False):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Supprime un billet."""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-02 22:40:34 +02:00
|
|
|
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
|
|
|
|
if not billets:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2021-06-02 22:40:34 +02:00
|
|
|
"listeBillets?head_message=Billet%%20%s%%20inexistant !" % billet_id
|
|
|
|
)
|
|
|
|
if not dialog_confirmed:
|
2021-08-21 00:24:51 +02:00
|
|
|
tab = _tableBillets(billets)
|
2021-06-21 12:13:25 +02:00
|
|
|
return scu.confirm_dialog(
|
2021-06-02 22:40:34 +02:00
|
|
|
"""<h2>Supprimer ce billet ?</h2>""" + tab.html(),
|
|
|
|
dest_url="",
|
|
|
|
cancel_url="listeBillets",
|
|
|
|
parameters={"billet_id": billet_id},
|
|
|
|
)
|
|
|
|
|
|
|
|
sco_abs.billet_absence_delete(cnx, billet_id)
|
|
|
|
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect("listeBillets?head_message=Billet%20supprimé")
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def _ProcessBilletAbsence(billet, estjust, description, REQUEST):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Traite un billet: ajoute absence(s) et éventuellement justificatifs,
|
|
|
|
et change l'état du billet à 1.
|
|
|
|
NB: actuellement, les heures ne sont utilisées que pour déterminer si matin et/ou après-midi.
|
|
|
|
"""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-02 22:40:34 +02:00
|
|
|
if billet["etat"] != 0:
|
|
|
|
log("billet=%s" % billet)
|
|
|
|
log("billet deja traité !")
|
|
|
|
return -1
|
|
|
|
n = 0 # nombre de demi-journées d'absence ajoutées
|
|
|
|
# 1-- ajout des absences (et justifs)
|
|
|
|
datedebut = billet["abs_begin"].strftime("%d/%m/%Y")
|
|
|
|
datefin = billet["abs_end"].strftime("%d/%m/%Y")
|
2021-08-21 00:24:51 +02:00
|
|
|
dates = sco_abs.DateRangeISO(datedebut, datefin)
|
2021-06-02 22:40:34 +02:00
|
|
|
# commence après-midi ?
|
|
|
|
if dates and billet["abs_begin"].hour > 11:
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_absence(
|
|
|
|
billet["etudid"],
|
|
|
|
dates[0],
|
|
|
|
0,
|
|
|
|
estjust,
|
|
|
|
REQUEST,
|
|
|
|
description=description,
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
n += 1
|
|
|
|
dates = dates[1:]
|
|
|
|
# termine matin ?
|
|
|
|
if dates and billet["abs_end"].hour < 12:
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_absence(
|
2021-06-02 22:40:34 +02:00
|
|
|
billet["etudid"],
|
|
|
|
dates[-1],
|
|
|
|
1,
|
|
|
|
estjust,
|
|
|
|
REQUEST,
|
|
|
|
description=description,
|
|
|
|
)
|
|
|
|
n += 1
|
|
|
|
dates = dates[:-1]
|
|
|
|
|
|
|
|
for jour in dates:
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_absence(
|
|
|
|
billet["etudid"],
|
|
|
|
jour,
|
|
|
|
0,
|
|
|
|
estjust,
|
|
|
|
REQUEST,
|
|
|
|
description=description,
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_absence(
|
|
|
|
billet["etudid"],
|
|
|
|
jour,
|
|
|
|
1,
|
|
|
|
estjust,
|
|
|
|
REQUEST,
|
|
|
|
description=description,
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
n += 2
|
|
|
|
|
|
|
|
# 2- change etat du billet
|
|
|
|
sco_abs.billet_absence_edit(cnx, {"billet_id": billet["billet_id"], "etat": 1})
|
|
|
|
|
|
|
|
return n
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/ProcessBilletAbsenceForm")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoAbsChange)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
|
|
|
def ProcessBilletAbsenceForm(billet_id, REQUEST=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Formulaire traitement d'un billet"""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-02 22:40:34 +02:00
|
|
|
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
|
|
|
|
if not billets:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2021-06-02 22:40:34 +02:00
|
|
|
"listeBillets?head_message=Billet%%20%s%%20inexistant !" % billet_id
|
|
|
|
)
|
|
|
|
billet = billets[0]
|
|
|
|
etudid = billet["etudid"]
|
2021-06-19 23:21:37 +02:00
|
|
|
etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
H = [
|
2021-06-13 18:29:53 +02:00
|
|
|
html_sco_header.sco_header(
|
2021-06-02 22:40:34 +02:00
|
|
|
page_title="Traitement billet d'absence de %s" % etud["nomprenom"],
|
|
|
|
),
|
2021-07-11 17:37:12 +02:00
|
|
|
'<h2>Traitement du billet %s : <a class="discretelink" href="%s">%s</a></h2>'
|
|
|
|
% (
|
|
|
|
billet_id,
|
|
|
|
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
|
|
|
|
etud["nomprenom"],
|
|
|
|
),
|
2021-06-02 22:40:34 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
tf = TrivialFormulator(
|
|
|
|
REQUEST.URL0,
|
|
|
|
REQUEST.form,
|
|
|
|
(
|
|
|
|
("billet_id", {"input_type": "hidden"}),
|
|
|
|
(
|
|
|
|
"etudid",
|
|
|
|
{"input_type": "hidden"},
|
|
|
|
), # pour centrer l'UI sur l'étudiant
|
|
|
|
(
|
|
|
|
"estjust",
|
|
|
|
{"input_type": "boolcheckbox", "title": "Absences justifiées"},
|
|
|
|
),
|
|
|
|
("description", {"input_type": "text", "size": 42, "title": "Raison"}),
|
|
|
|
),
|
|
|
|
initvalues={
|
|
|
|
"description": billet["description"],
|
|
|
|
"estjust": billet["justified"],
|
|
|
|
"etudid": etudid,
|
|
|
|
},
|
|
|
|
submitlabel="Enregistrer ces absences",
|
|
|
|
)
|
|
|
|
if tf[0] == 0:
|
2021-08-21 00:24:51 +02:00
|
|
|
tab = _tableBillets([billet], etud=etud)
|
2021-06-02 22:40:34 +02:00
|
|
|
H.append(tab.html())
|
2021-08-11 00:36:07 +02:00
|
|
|
if billet["justified"]:
|
2021-06-02 22:40:34 +02:00
|
|
|
H.append(
|
|
|
|
"""<p>L'étudiant pense pouvoir justifier cette absence.<br/><em>Vérifiez le justificatif avant d'enregistrer.</em></p>"""
|
|
|
|
)
|
|
|
|
F = (
|
|
|
|
"""<p><a class="stdlink" href="deleteBilletAbsence?billet_id=%s">Supprimer ce billet</a> (utiliser en cas d'erreur, par ex. billet en double)</p>"""
|
|
|
|
% billet_id
|
|
|
|
)
|
|
|
|
F += '<p><a class="stdlink" href="listeBillets">Liste de tous les billets en attente</a></p>'
|
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
return "\n".join(H) + "<br/>" + tf[1] + F + html_sco_header.sco_footer()
|
2021-06-02 22:40:34 +02:00
|
|
|
elif tf[0] == -1:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(scu.ScoURL())
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
2021-06-19 23:21:37 +02:00
|
|
|
n = _ProcessBilletAbsence(
|
2021-08-21 00:24:51 +02:00
|
|
|
billet, tf[2]["estjust"], tf[2]["description"], REQUEST
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
if tf[2]["estjust"]:
|
|
|
|
j = "justifiées"
|
|
|
|
else:
|
|
|
|
j = "non justifiées"
|
|
|
|
H.append('<div class="head_message">')
|
|
|
|
if n > 0:
|
|
|
|
H.append("%d absences (1/2 journées) %s ajoutées" % (n, j))
|
|
|
|
elif n == 0:
|
|
|
|
H.append("Aucun jour d'absence dans les dates indiquées !")
|
|
|
|
elif n < 0:
|
|
|
|
H.append("Ce billet avait déjà été traité !")
|
|
|
|
H.append(
|
|
|
|
'</div><p><a class="stdlink" href="listeBillets">Autre billets en attente</a></p><h4>Billets déclarés par %s</h4>'
|
|
|
|
% (etud["nomprenom"])
|
|
|
|
)
|
|
|
|
billets = sco_abs.billet_absence_list(cnx, {"etudid": etud["etudid"]})
|
2021-08-21 00:24:51 +02:00
|
|
|
tab = _tableBillets(billets, etud=etud)
|
2021-06-02 22:40:34 +02:00
|
|
|
H.append(tab.html())
|
2021-07-29 10:19:00 +02:00
|
|
|
return "\n".join(H) + html_sco_header.sco_footer()
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/XMLgetAbsEtud")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
|
|
|
def XMLgetAbsEtud(beg_date="", end_date="", REQUEST=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""returns list of absences in date interval"""
|
|
|
|
t0 = time.time()
|
2021-06-19 23:21:37 +02:00
|
|
|
etud = sco_etud.get_etud_info(REQUEST=REQUEST)[0]
|
2021-06-02 22:40:34 +02:00
|
|
|
exp = re.compile(r"^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$")
|
|
|
|
if not exp.match(beg_date):
|
|
|
|
raise ScoValueError("invalid date: %s" % beg_date)
|
|
|
|
if not exp.match(end_date):
|
|
|
|
raise ScoValueError("invalid date: %s" % end_date)
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
Abs = sco_abs.list_abs_date(etud["etudid"], beg_date, end_date)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
|
2021-07-11 13:03:13 +02:00
|
|
|
doc = ElementTree.Element(
|
|
|
|
"absences", etudid=etud["etudid"], beg_date=beg_date, end_date=end_date
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
for a in Abs:
|
|
|
|
if a["estabs"]: # ne donne pas les justifications si pas d'absence
|
2021-07-11 13:03:13 +02:00
|
|
|
doc.append(
|
|
|
|
ElementTree.Element(
|
|
|
|
"abs",
|
|
|
|
begin=a["begin"],
|
|
|
|
end=a["end"],
|
|
|
|
description=a["description"],
|
|
|
|
justified=a["estjust"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
log("XMLgetAbsEtud (%gs)" % (time.time() - t0))
|
2021-07-12 23:34:18 +02:00
|
|
|
return sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
|