2021-05-31 00:14:15 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-06-02 22:40:34 +02:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-01-02 13:16:27 +01:00
|
|
|
# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
|
2021-06-02 22:40:34 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
"""
|
2023-08-27 21:49:50 +02:00
|
|
|
Module absences: remplacé par assiduité en août 2023, reste ici seulement la gestion des "billets"
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-05-31 00:14:15 +02:00
|
|
|
"""
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
import dateutil
|
|
|
|
import dateutil.parser
|
|
|
|
|
2021-08-01 10:16:16 +02:00
|
|
|
import flask
|
2021-09-18 10:10:02 +02:00
|
|
|
from flask import g, request
|
2022-09-11 09:35:47 +02:00
|
|
|
from flask import abort, flash, url_for
|
2021-09-18 13:42:19 +02:00
|
|
|
from flask_login import current_user
|
2021-05-31 00:14:15 +02:00
|
|
|
|
2022-08-01 21:42:19 +02:00
|
|
|
from app import db, log
|
|
|
|
from app import api
|
2023-08-27 21:49:50 +02:00
|
|
|
|
2021-05-31 00:14:15 +02:00
|
|
|
from app.decorators import (
|
2021-08-13 00:34:58 +02:00
|
|
|
scodoc,
|
2021-05-31 00:14:15 +02:00
|
|
|
scodoc7func,
|
|
|
|
permission_required,
|
2021-09-09 16:11:05 +02:00
|
|
|
permission_required_compat_scodoc7,
|
2021-05-31 00:14:15 +02:00
|
|
|
)
|
2022-02-13 23:53:11 +01:00
|
|
|
from app.models.absences import BilletAbsence
|
2022-08-18 15:43:14 +02:00
|
|
|
from app.models.etudiants import Identite
|
2021-05-31 00:14:15 +02:00
|
|
|
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-19 23:21:37 +02:00
|
|
|
from app.scodoc.sco_permissions import Permission
|
2023-08-27 21:49:50 +02:00
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
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 import html_sco_header
|
2023-08-27 21:49:50 +02:00
|
|
|
from app.scodoc import sco_cal
|
2023-09-06 16:41:46 +02:00
|
|
|
from app.scodoc import sco_assiduites as scass
|
2022-08-01 21:42:19 +02:00
|
|
|
from app.scodoc import sco_abs_billets
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_etud
|
|
|
|
from app.scodoc import sco_preferences
|
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
|
2021-09-24 12:10:53 +02:00
|
|
|
def index_html():
|
2021-07-09 10:26:31 +02:00
|
|
|
"""Gestionnaire absences, page principale"""
|
|
|
|
|
|
|
|
H = [
|
|
|
|
html_sco_header.sco_header(
|
2023-08-27 21:49:50 +02:00
|
|
|
page_title="Billets d'absences",
|
2021-07-09 10:26:31 +02:00
|
|
|
),
|
|
|
|
]
|
2022-04-08 16:36:56 +02:00
|
|
|
if current_user.has_permission(
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.AbsChange
|
2022-04-08 16:36:56 +02:00
|
|
|
) and sco_preferences.get_preference("handle_billets_abs"):
|
2021-07-09 10:26:31 +02:00
|
|
|
H.append(
|
2022-08-01 21:42:19 +02:00
|
|
|
f"""
|
2022-04-08 16:36:56 +02:00
|
|
|
<h2 style="margin-top: 30px;">Billets d'absence</h2>
|
2022-08-01 21:42:19 +02:00
|
|
|
<ul><li><a href="{url_for("absences.list_billets", scodoc_dept=g.scodoc_dept)
|
|
|
|
}">Traitement des billets d'absence en attente</a>
|
|
|
|
</li></ul>
|
2022-04-08 16:36:56 +02:00
|
|
|
"""
|
|
|
|
)
|
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-06-02 22:40:34 +02:00
|
|
|
# ----- Gestion des "billets d'absence": signalement par les etudiants eux mêmes (à travers le portail)
|
2021-10-24 12:01:42 +02:00
|
|
|
@bp.route("/AddBilletAbsence", methods=["GET", "POST"]) # API ScoDoc 7 compat
|
2021-10-26 00:13:42 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required_compat_scodoc7(Permission.AbsAddBillet)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-06-02 22:40:34 +02:00
|
|
|
def AddBilletAbsence(
|
|
|
|
begin,
|
|
|
|
end,
|
|
|
|
description,
|
2022-08-18 15:43:14 +02:00
|
|
|
etudid=None,
|
2021-06-02 22:40:34 +02:00
|
|
|
code_nip=None,
|
|
|
|
code_ine=None,
|
|
|
|
justified=True,
|
2023-09-21 10:20:19 +02:00
|
|
|
fmt="json",
|
2021-11-01 16:59:56 +01:00
|
|
|
xml_reply=True, # deprecated
|
2021-06-02 22:40:34 +02:00
|
|
|
):
|
2021-10-24 12:01:42 +02:00
|
|
|
"""Mémorise un "billet"
|
2021-06-02 22:40:34 +02:00
|
|
|
begin et end sont au format ISO (eg "1999-01-08 04:05:06")
|
|
|
|
"""
|
2022-08-01 21:42:19 +02:00
|
|
|
log("Warning: calling deprecated AddBilletAbsence")
|
2021-10-07 23:21:30 +02:00
|
|
|
begin = str(begin)
|
|
|
|
end = str(end)
|
|
|
|
code_nip = str(code_nip) if code_nip else None
|
|
|
|
|
2022-08-18 15:43:14 +02:00
|
|
|
etud = api.tools.get_etud(etudid=etudid, nip=code_nip, ine=code_ine)
|
2021-06-02 22:40:34 +02:00
|
|
|
# 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-11-01 16:59:56 +01:00
|
|
|
xml_reply = bool(xml_reply)
|
|
|
|
if xml_reply: # backward compat
|
2023-09-21 10:20:19 +02:00
|
|
|
fmt = "xml"
|
2022-08-01 21:42:19 +02:00
|
|
|
#
|
|
|
|
billet = BilletAbsence(
|
|
|
|
etudid=etud.id,
|
|
|
|
abs_begin=begin,
|
|
|
|
abs_end=end,
|
|
|
|
description=description,
|
|
|
|
etat=False,
|
|
|
|
justified=justified,
|
|
|
|
)
|
|
|
|
db.session.add(billet)
|
|
|
|
db.session.commit()
|
2021-11-01 16:59:56 +01:00
|
|
|
|
|
|
|
# Renvoie le nouveau billet au format demandé
|
2022-08-01 21:42:19 +02:00
|
|
|
table = sco_abs_billets.table_billets([billet], etud=etud)
|
|
|
|
log(f"AddBilletAbsence: new billet_id={billet.id}")
|
2023-09-21 10:20:19 +02:00
|
|
|
return table.make_page(fmt=fmt)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2022-08-01 21:42:19 +02:00
|
|
|
@bp.route("/add_billets_absence_form", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.AbsAddBillet)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-08-01 21:42:19 +02:00
|
|
|
def add_billets_absence_form(etudid):
|
|
|
|
"""Formulaire ajout billet (pour tests seulement, le vrai
|
|
|
|
formulaire accessible aux etudiants étant sur le portail étudiant).
|
2021-06-02 22:40:34 +02:00
|
|
|
"""
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[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(
|
2021-09-18 10:10:02 +02:00
|
|
|
request.base_url,
|
2021-09-27 16:42:14 +02:00
|
|
|
scu.get_request_args(),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
("etudid", {"input_type": "hidden"}),
|
2022-01-10 12:00:02 +01:00
|
|
|
("begin", {"input_type": "datedmy"}),
|
|
|
|
("end", {"input_type": "datedmy"}),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
"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"],
|
|
|
|
)
|
|
|
|
)
|
2022-08-01 21:42:19 +02:00
|
|
|
return flask.redirect("billets_etud?etudid=" + str(etudid))
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2022-08-01 21:42:19 +02:00
|
|
|
@bp.route("/billets_etud/<int:etudid>")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2023-09-21 10:20:19 +02:00
|
|
|
def billets_etud(etudid=False, fmt=False):
|
2022-11-13 14:55:18 +01:00
|
|
|
"""Liste billets pour un étudiant"""
|
2023-09-21 10:20:19 +02:00
|
|
|
fmt = fmt or request.args.get("fmt", "html")
|
2022-08-01 21:42:19 +02:00
|
|
|
if not fmt in {"html", "json", "xml", "xls", "xlsx"}:
|
|
|
|
return ScoValueError("Format invalide")
|
|
|
|
table = sco_abs_billets.table_billets_etud(etudid)
|
|
|
|
if table:
|
2023-09-21 10:20:19 +02:00
|
|
|
return table.make_page(fmt=fmt)
|
2022-08-01 21:42:19 +02:00
|
|
|
return ""
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2022-08-01 21:42:19 +02:00
|
|
|
# DEEPRECATED: pour compat anciens clients PHP
|
|
|
|
@bp.route("/XMLgetBilletsEtud", methods=["GET", "POST"])
|
2021-10-26 00:13:42 +02:00
|
|
|
@scodoc
|
2021-10-28 00:52:23 +02:00
|
|
|
@permission_required_compat_scodoc7(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-08-18 15:43:14 +02:00
|
|
|
def XMLgetBilletsEtud(etudid=False, code_nip=False):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Liste billets pour un etudiant"""
|
2022-08-01 21:42:19 +02:00
|
|
|
log("Warning: called deprecated XMLgetBilletsEtud")
|
2022-08-18 15:43:14 +02:00
|
|
|
if etudid is False:
|
2022-09-11 09:35:47 +02:00
|
|
|
etud = Identite.query.filter_by(
|
|
|
|
code_nip=str(code_nip), dept_id=g.scodoc_dept_id
|
|
|
|
).first_or_404()
|
2022-08-18 15:43:14 +02:00
|
|
|
etudid = etud.id
|
2022-08-01 21:42:19 +02:00
|
|
|
table = sco_abs_billets.table_billets_etud(etudid)
|
|
|
|
if table:
|
2023-09-21 10:20:19 +02:00
|
|
|
return table.make_page(fmt="xml")
|
2022-08-01 21:42:19 +02:00
|
|
|
return ""
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2023-03-19 10:26:03 +01:00
|
|
|
@bp.route("/list_billets", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-10-24 12:01:42 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-08-01 21:42:19 +02:00
|
|
|
def list_billets():
|
|
|
|
"""Page liste des billets non traités pour tous les étudiants du département
|
|
|
|
et formulaire recherche d'un billet.
|
|
|
|
"""
|
|
|
|
table = sco_abs_billets.table_billets_etud(etat=False)
|
|
|
|
T = table.html()
|
2021-06-02 22:40:34 +02:00
|
|
|
H = [
|
2022-09-22 14:58:46 +02:00
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title="Billet d'absence non traités",
|
|
|
|
javascripts=["js/etud_info.js"],
|
|
|
|
init_qtip=True,
|
|
|
|
),
|
2022-08-01 21:42:19 +02:00
|
|
|
f"<h2>Billets d'absence en attente de traitement ({table.get_nb_rows()})</h2>",
|
2021-06-02 22:40:34 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
tf = TrivialFormulator(
|
2021-09-18 10:10:02 +02:00
|
|
|
request.base_url,
|
2021-09-27 16:42:14 +02:00
|
|
|
scu.get_request_args(),
|
2022-09-11 09:35:47 +02:00
|
|
|
(("billet_id", {"input_type": "text", "title": "Numéro du billet :"}),),
|
2021-06-02 22:40:34 +02:00
|
|
|
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(
|
2022-08-01 21:42:19 +02:00
|
|
|
url_for(
|
|
|
|
"absences.process_billet_absence_form",
|
|
|
|
billet_id=tf[2]["billet_id"],
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-08-01 21:42:19 +02:00
|
|
|
@bp.route("/delete_billets_absence", methods=["POST", "GET"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.AbsChange)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-08-01 21:42:19 +02:00
|
|
|
def delete_billets_absence(billet_id, dialog_confirmed=False):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Supprime un billet."""
|
2022-09-11 09:35:47 +02:00
|
|
|
billet: BilletAbsence = (
|
|
|
|
BilletAbsence.query.filter_by(id=billet_id)
|
|
|
|
.join(Identite)
|
|
|
|
.filter_by(dept_id=g.scodoc_dept_id)
|
|
|
|
.first_or_404()
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not dialog_confirmed:
|
2022-09-11 09:35:47 +02:00
|
|
|
tab = sco_abs_billets.table_billets([billet])
|
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="",
|
2022-08-01 21:42:19 +02:00
|
|
|
cancel_url="list_billets",
|
2021-06-02 22:40:34 +02:00
|
|
|
parameters={"billet_id": billet_id},
|
|
|
|
)
|
|
|
|
|
2022-09-11 09:35:47 +02:00
|
|
|
db.session.delete(billet)
|
|
|
|
db.session.commit()
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2022-09-11 09:35:47 +02:00
|
|
|
flash("Billet supprimé")
|
|
|
|
return flask.redirect(url_for("absences.list_billets", scodoc_dept=g.scodoc_dept))
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2022-09-11 09:35:47 +02:00
|
|
|
def _ProcessBilletAbsence(
|
|
|
|
billet: BilletAbsence, estjust: bool, description: str
|
|
|
|
) -> int:
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Traite un billet: ajoute absence(s) et éventuellement justificatifs,
|
2022-09-11 09:35:47 +02:00
|
|
|
et change l'état du billet à True.
|
|
|
|
return: nombre de demi-journées d'absence ajoutées, -1 si billet déjà traité.
|
|
|
|
NB: actuellement, les heures ne sont utilisées que pour déterminer
|
|
|
|
si matin et/ou après-midi.
|
2021-06-02 22:40:34 +02:00
|
|
|
"""
|
2022-09-11 09:35:47 +02:00
|
|
|
if billet.etat:
|
|
|
|
log(f"billet deja traite: {billet} !")
|
2021-06-02 22:40:34 +02:00
|
|
|
return -1
|
|
|
|
n = 0 # nombre de demi-journées d'absence ajoutées
|
2022-09-11 09:35:47 +02:00
|
|
|
|
|
|
|
# 1-- Ajout des absences (et justifs)
|
2023-09-06 16:41:46 +02:00
|
|
|
datedebut = billet.abs_begin
|
|
|
|
datefin = billet.abs_end
|
|
|
|
log(f"Gestion du billet n°{billet.id}")
|
|
|
|
n = scass.create_absence(
|
|
|
|
date_debut=datedebut,
|
|
|
|
date_fin=datefin,
|
|
|
|
etudid=billet.etudid,
|
|
|
|
description=description,
|
|
|
|
est_just=estjust,
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2022-09-11 09:35:47 +02:00
|
|
|
# 2- Change état du billet
|
|
|
|
billet.etat = True
|
|
|
|
db.session.add(billet)
|
|
|
|
db.session.commit()
|
2021-06-02 22:40:34 +02:00
|
|
|
return n
|
|
|
|
|
|
|
|
|
2022-08-01 21:42:19 +02:00
|
|
|
@bp.route("/process_billet_absence_form", methods=["POST", "GET"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.AbsChange)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-11-13 18:36:07 +01:00
|
|
|
def process_billet_absence_form(billet_id: int):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Formulaire traitement d'un billet"""
|
2022-11-13 18:36:07 +01:00
|
|
|
if not isinstance(billet_id, int):
|
|
|
|
raise abort(404, "billet_id invalide")
|
2022-09-11 09:35:47 +02:00
|
|
|
billet: BilletAbsence = (
|
|
|
|
BilletAbsence.query.filter_by(id=billet_id)
|
|
|
|
.join(Identite)
|
|
|
|
.filter_by(dept_id=g.scodoc_dept_id)
|
|
|
|
.first()
|
|
|
|
)
|
|
|
|
if billet is None:
|
|
|
|
raise ScoValueError(
|
|
|
|
f"Aucun billet avec le numéro <tt>{billet_id}</tt> dans ce département.",
|
|
|
|
dest_url=url_for("absences.list_billets", scodoc_dept=g.scodoc_dept),
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2022-09-11 09:35:47 +02:00
|
|
|
etud = billet.etudiant
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
H = [
|
2021-06-13 18:29:53 +02:00
|
|
|
html_sco_header.sco_header(
|
2022-09-11 09:35:47 +02:00
|
|
|
page_title=f"Traitement billet d'absence de {etud.nomprenom}",
|
2021-07-11 17:37:12 +02:00
|
|
|
),
|
2022-09-11 09:35:47 +02:00
|
|
|
f"""<h2>Traitement du billet {billet.id} : <a class="discretelink" href="{
|
|
|
|
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etud.id)
|
|
|
|
}">{etud.nomprenom}</a></h2>
|
|
|
|
""",
|
2021-06-02 22:40:34 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
tf = TrivialFormulator(
|
2021-09-18 10:10:02 +02:00
|
|
|
request.base_url,
|
2021-09-27 16:42:14 +02:00
|
|
|
scu.get_request_args(),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
("billet_id", {"input_type": "hidden"}),
|
|
|
|
(
|
|
|
|
"etudid",
|
|
|
|
{"input_type": "hidden"},
|
2022-09-11 09:35:47 +02:00
|
|
|
),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
"estjust",
|
|
|
|
{"input_type": "boolcheckbox", "title": "Absences justifiées"},
|
|
|
|
),
|
|
|
|
("description", {"input_type": "text", "size": 42, "title": "Raison"}),
|
|
|
|
),
|
|
|
|
initvalues={
|
2022-09-11 09:35:47 +02:00
|
|
|
"description": billet.description or "",
|
|
|
|
"estjust": billet.justified,
|
|
|
|
"etudid": etud.id,
|
2021-06-02 22:40:34 +02:00
|
|
|
},
|
|
|
|
submitlabel="Enregistrer ces absences",
|
|
|
|
)
|
|
|
|
if tf[0] == 0:
|
2022-08-01 21:42:19 +02:00
|
|
|
tab = sco_abs_billets.table_billets([billet], etud=etud)
|
2021-06-02 22:40:34 +02:00
|
|
|
H.append(tab.html())
|
2022-09-11 09:35:47 +02:00
|
|
|
if billet.justified:
|
2021-06-02 22:40:34 +02:00
|
|
|
H.append(
|
2022-10-02 23:43:29 +02:00
|
|
|
"""<p>L'étudiant pense pouvoir justifier cette absence.<br>
|
2022-09-11 09:35:47 +02:00
|
|
|
<em>Vérifiez le justificatif avant d'enregistrer.</em></p>"""
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2022-09-11 09:35:47 +02:00
|
|
|
F = f"""<p><a class="stdlink" href="{
|
|
|
|
url_for("absences.delete_billets_absence",
|
|
|
|
scodoc_dept=g.scodoc_dept, billet_id=billet_id)
|
|
|
|
}">Supprimer ce billet</a>
|
|
|
|
(utiliser en cas d'erreur, par ex. billet en double)
|
|
|
|
</p>
|
|
|
|
<p><a class="stdlink" href="{
|
|
|
|
url_for("absences.list_billets", scodoc_dept=g.scodoc_dept)
|
|
|
|
}">Liste de tous les billets en attente</a>
|
|
|
|
</p>
|
|
|
|
"""
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2022-10-02 23:43:29 +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-09-24 01:07:00 +02:00
|
|
|
n = _ProcessBilletAbsence(billet, tf[2]["estjust"], tf[2]["description"])
|
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(
|
2022-09-11 09:35:47 +02:00
|
|
|
f"""</div><p><a class="stdlink" href="{
|
|
|
|
url_for("absences.list_billets", scodoc_dept=g.scodoc_dept)
|
|
|
|
}">Autre billets en attente</a>
|
|
|
|
</p>
|
|
|
|
<h4>Billets déclarés par {etud.nomprenom}</h4>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
billets = (
|
|
|
|
BilletAbsence.query.filter_by(etudid=etud.id)
|
|
|
|
.join(Identite)
|
|
|
|
.filter_by(dept_id=g.scodoc_dept_id)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2022-08-01 21:42:19 +02:00
|
|
|
tab = sco_abs_billets.table_billets(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()
|