2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2022-01-01 14:49:42 +01:00
|
|
|
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
|
2020-09-26 16:19:37 +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-06-19 23:21:37 +02:00
|
|
|
"""Pages HTML gestion absences
|
2020-09-26 16:19:37 +02:00
|
|
|
(la plupart portées du DTML)
|
|
|
|
"""
|
2021-01-17 09:37:11 +01:00
|
|
|
import datetime
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-12-21 23:05:49 +01:00
|
|
|
from flask import url_for, g, request, abort
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-12-26 19:15:47 +01:00
|
|
|
from app import log
|
2022-02-13 23:53:11 +01:00
|
|
|
from app.comp import res_sem
|
2022-03-27 22:25:00 +02:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2022-02-13 23:53:11 +01:00
|
|
|
from app.models import Identite, FormSemestre
|
2021-06-19 23:21:37 +02:00
|
|
|
import app.scodoc.sco_utils as scu
|
|
|
|
from app.scodoc import notesdb as ndb
|
|
|
|
from app.scodoc.scolog import logdb
|
|
|
|
from app.scodoc.gen_tables import GenTable
|
|
|
|
from app.scodoc import html_sco_header
|
|
|
|
from app.scodoc import sco_abs
|
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_etud
|
|
|
|
from app.scodoc import sco_find_etud
|
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_groups
|
|
|
|
from app.scodoc import sco_moduleimpl
|
|
|
|
from app.scodoc import sco_photos
|
|
|
|
from app.scodoc import sco_preferences
|
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
def doSignaleAbsence(
|
|
|
|
datedebut,
|
|
|
|
datefin,
|
|
|
|
moduleimpl_id=None,
|
|
|
|
demijournee=2,
|
|
|
|
estjust=False,
|
|
|
|
description=None,
|
2021-02-04 23:16:18 +01:00
|
|
|
etudid=False,
|
2020-09-26 16:19:37 +02:00
|
|
|
): # etudid implied
|
2021-02-04 23:16:18 +01:00
|
|
|
"""Signalement d'une absence.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
datedebut: dd/mm/yyyy
|
|
|
|
datefin: dd/mm/yyyy (non incluse)
|
|
|
|
moduleimpl_id: module auquel imputer les absences
|
|
|
|
demijournee: 2 si journée complète, 1 matin, 0 après-midi
|
|
|
|
estjust: absence justifiée
|
|
|
|
description: str
|
2021-09-24 12:10:53 +02:00
|
|
|
etudid: etudiant concerné. Si non spécifié, cherche dans
|
|
|
|
les paramètres de la requête courante.
|
2021-02-04 23:16:18 +01:00
|
|
|
"""
|
2021-12-26 19:15:47 +01:00
|
|
|
etud = Identite.from_request(etudid)
|
|
|
|
|
2021-08-16 22:41:09 +02:00
|
|
|
if not moduleimpl_id:
|
|
|
|
moduleimpl_id = None
|
2020-09-26 16:19:37 +02:00
|
|
|
description_abs = description
|
2021-08-21 00:24:51 +02:00
|
|
|
dates = sco_abs.DateRangeISO(datedebut, datefin)
|
2020-09-26 16:19:37 +02:00
|
|
|
nbadded = 0
|
2021-05-03 11:56:41 +02:00
|
|
|
demijournee = int(demijournee)
|
2020-09-26 16:19:37 +02:00
|
|
|
for jour in dates:
|
2021-05-03 11:56:41 +02:00
|
|
|
if demijournee == 2:
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_absence(
|
2021-12-26 19:15:47 +01:00
|
|
|
etud.id,
|
2021-06-19 23:21:37 +02:00
|
|
|
jour,
|
|
|
|
False,
|
|
|
|
estjust,
|
|
|
|
description_abs,
|
|
|
|
moduleimpl_id,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_absence(
|
2021-12-26 19:15:47 +01:00
|
|
|
etud.id,
|
2021-06-19 23:21:37 +02:00
|
|
|
jour,
|
|
|
|
True,
|
|
|
|
estjust,
|
|
|
|
description_abs,
|
|
|
|
moduleimpl_id,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
nbadded += 2
|
|
|
|
else:
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_absence(
|
2021-12-26 19:15:47 +01:00
|
|
|
etud.id,
|
2021-06-12 22:43:22 +02:00
|
|
|
jour,
|
|
|
|
demijournee,
|
|
|
|
estjust,
|
|
|
|
description_abs,
|
|
|
|
moduleimpl_id,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
nbadded += 1
|
|
|
|
#
|
|
|
|
if estjust:
|
|
|
|
J = ""
|
|
|
|
else:
|
|
|
|
J = "NON "
|
2021-12-26 19:15:47 +01:00
|
|
|
indication_module = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
if moduleimpl_id and moduleimpl_id != "NULL":
|
2021-10-15 14:00:51 +02:00
|
|
|
mod = sco_moduleimpl.moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
formsemestre_id = mod["formsemestre_id"]
|
2022-02-13 23:53:11 +01:00
|
|
|
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2021-12-24 00:08:25 +01:00
|
|
|
ues = nt.get_ues_stat_dict()
|
2020-09-26 16:19:37 +02:00
|
|
|
for ue in ues:
|
2021-12-26 19:15:47 +01:00
|
|
|
modimpls = nt.get_modimpls_dict(ue_id=ue["ue_id"])
|
2020-09-26 16:19:37 +02:00
|
|
|
for modimpl in modimpls:
|
|
|
|
if modimpl["moduleimpl_id"] == moduleimpl_id:
|
2022-02-14 10:05:55 +01:00
|
|
|
indication_module = "dans le module %s" % (
|
|
|
|
modimpl["module"]["code"] or "(pas de code)"
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.sco_header(
|
2021-12-26 19:15:47 +01:00
|
|
|
page_title=f"Signalement d'une absence pour {etud.nomprenom}",
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""<h2>Signalement d'absences</h2>""",
|
|
|
|
]
|
|
|
|
if dates:
|
|
|
|
H.append(
|
|
|
|
"""<p>Ajout de %d absences <b>%sjustifiées</b> du %s au %s %s</p>"""
|
2021-12-26 19:15:47 +01:00
|
|
|
% (nbadded, J, datedebut, datefin, indication_module)
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
"""<p class="warning">Aucune date ouvrable entre le %s et le %s !</p>"""
|
|
|
|
% (datedebut, datefin)
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append(
|
2021-12-26 19:15:47 +01:00
|
|
|
f"""<ul>
|
|
|
|
<li><a href="{url_for("absences.SignaleAbsenceEtud",
|
|
|
|
scodoc_dept=g.scodoc_dept, etudid=etud.id
|
|
|
|
)}">Autre absence pour <b>{etud.nomprenom}</b></a>
|
|
|
|
</li>
|
|
|
|
<li><a href="{url_for("absences.CalAbs",
|
|
|
|
scodoc_dept=g.scodoc_dept, etudid=etud.id
|
|
|
|
)}">Calendrier de ses absences</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<hr>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-08-22 13:24:36 +02:00
|
|
|
H.append(sco_find_etud.form_search_etud())
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2020-09-26 16:19:37 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-09-24 12:10:53 +02:00
|
|
|
def SignaleAbsenceEtud(): # etudid implied
|
2020-12-28 22:59:59 +01:00
|
|
|
"""Formulaire individuel simple de signalement d'une absence"""
|
2020-09-26 16:19:37 +02:00
|
|
|
# brute-force portage from very old dtml code ...
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid = etud["etudid"]
|
2020-12-30 19:21:03 +01:00
|
|
|
disabled = False
|
2020-09-26 16:19:37 +02:00
|
|
|
if not etud["cursem"]:
|
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"
|
2020-12-30 19:21:03 +01:00
|
|
|
) # on utilise la pref globale car pas de sem courant
|
|
|
|
if require_module:
|
|
|
|
menu_module = """<div class="ue_warning">Pas inscrit dans un semestre courant,
|
|
|
|
et l'indication du module est requise. Donc pas de saisie d'absence possible !</div>"""
|
|
|
|
disabled = True
|
|
|
|
else:
|
|
|
|
menu_module = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
formsemestre_id = etud["cursem"]["formsemestre_id"]
|
2022-02-13 23:53:11 +01:00
|
|
|
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
|
|
|
ues = nt.get_ues_stat_dict()
|
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
|
|
|
)
|
2020-12-30 19:21:03 +01:00
|
|
|
if require_module:
|
|
|
|
menu_module = """
|
|
|
|
<script type="text/javascript">
|
|
|
|
function form_enable_disable() {
|
2021-08-16 22:41:09 +02:00
|
|
|
if ( $("select#sel_moduleimpl_id").val() == "" ) {
|
2020-12-30 19:21:03 +01:00
|
|
|
$("#butsubmit").prop("disabled", true);
|
|
|
|
} else {
|
|
|
|
$("#butsubmit").prop("disabled", false);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
|
|
form_enable_disable();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<p>Module:
|
|
|
|
<select id="sel_moduleimpl_id" name="moduleimpl_id"
|
|
|
|
onChange="form_enable_disable();">"""
|
|
|
|
else:
|
|
|
|
menu_module = (
|
|
|
|
"""<p>Module: <select id="sel_moduleimpl_id" name="moduleimpl_id">"""
|
|
|
|
)
|
2021-08-16 22:41:09 +02:00
|
|
|
menu_module += """<option value="" selected>(Module)</option>"""
|
2020-12-30 19:21:03 +01:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
for ue in ues:
|
2021-12-26 19:15:47 +01:00
|
|
|
modimpls = nt.get_modimpls_dict(ue_id=ue["ue_id"])
|
2020-09-26 16:19:37 +02:00
|
|
|
for modimpl in modimpls:
|
|
|
|
menu_module += (
|
|
|
|
"""<option value="%(modimpl_id)s">%(modname)s</option>\n"""
|
|
|
|
% {
|
|
|
|
"modimpl_id": modimpl["moduleimpl_id"],
|
2022-02-14 10:05:55 +01:00
|
|
|
"modname": modimpl["module"]["code"] or "",
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
menu_module += """</select></p>"""
|
|
|
|
|
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title="Signalement d'une absence pour %(nomprenom)s" % etud,
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""<table><tr><td>
|
|
|
|
<h2>Signalement d'une absence pour %(nomprenom)s</h2>
|
|
|
|
</td><td>
|
|
|
|
"""
|
|
|
|
% etud,
|
2021-07-11 17:37:12 +02:00
|
|
|
"""<a href="%s">"""
|
|
|
|
% url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etud["etudid"]),
|
2020-09-26 16:19:37 +02:00
|
|
|
sco_photos.etud_photo_html(
|
2020-12-28 22:59:59 +01:00
|
|
|
etudid=etudid,
|
|
|
|
title="fiche de " + etud["nomprenom"],
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""</a></td></tr></table>""",
|
|
|
|
"""
|
|
|
|
<form action="doSignaleAbsence" method="get">
|
|
|
|
<input type="hidden" name="etudid" value="%(etudid)s">
|
|
|
|
<p>
|
|
|
|
<table><tr>
|
2020-12-30 19:21:03 +01:00
|
|
|
<td>Date début : </td>
|
2020-09-26 16:19:37 +02:00
|
|
|
<td><input type="text" name="datedebut" size="10" class="datepicker"/> <em>j/m/a</em></td>
|
2020-12-30 19:21:03 +01:00
|
|
|
<td> Date fin (optionnelle):</td>
|
2020-09-26 16:19:37 +02:00
|
|
|
<td><input type="text" name="datefin" size="10" class="datepicker"/> <em>j/m/a</em></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<br/>
|
2020-12-30 19:21:03 +01:00
|
|
|
<input type="radio" name="demijournee" value="2" checked>Journée(s)
|
2020-09-26 16:19:37 +02:00
|
|
|
<input type="radio" name="demijournee" value="1">Matin(s)
|
2020-12-30 19:21:03 +01:00
|
|
|
<input type="radio" name="demijournee" value="0">Après-midi
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
%(menu_module)s
|
|
|
|
|
|
|
|
<p>
|
2020-12-30 19:21:03 +01:00
|
|
|
<input type="checkbox" name="estjust"/>Absence justifiée.
|
2020-09-26 16:19:37 +02:00
|
|
|
<br/>
|
|
|
|
Raison: <input type="text" name="description" size="42"/> (optionnel)
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>
|
2020-12-30 19:21:03 +01:00
|
|
|
<input id="butsubmit" type="submit" value="Envoyer" disable="%(disabled)s"/>
|
2020-09-26 16:19:37 +02:00
|
|
|
<em>
|
2020-12-30 19:21:03 +01:00
|
|
|
<p>Seuls les modules du semestre en cours apparaissent.</p>
|
|
|
|
<p>Évitez de saisir une absence pour un module qui n'est pas en place à cette date.</p>
|
|
|
|
<p>Toutes les dates sont au format jour/mois/annee.</p>
|
2020-09-26 16:19:37 +02:00
|
|
|
</em>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
"""
|
2020-12-30 19:21:03 +01:00
|
|
|
% {
|
|
|
|
"etudid": etud["etudid"],
|
|
|
|
"menu_module": menu_module,
|
|
|
|
"disabled": "disabled" if disabled else "",
|
|
|
|
},
|
2021-07-29 10:19:00 +02:00
|
|
|
html_sco_header.sco_footer(),
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
|
|
|
def doJustifAbsence(
|
2021-02-04 23:16:18 +01:00
|
|
|
datedebut,
|
|
|
|
datefin,
|
|
|
|
demijournee,
|
|
|
|
description=None,
|
|
|
|
etudid=False,
|
2020-09-26 16:19:37 +02:00
|
|
|
): # etudid implied
|
2021-02-04 23:16:18 +01:00
|
|
|
"""Justification d'une absence
|
|
|
|
|
|
|
|
Args:
|
|
|
|
datedebut: dd/mm/yyyy
|
|
|
|
datefin: dd/mm/yyyy (non incluse)
|
|
|
|
demijournee: 2 si journée complète, 1 matin, 0 après-midi
|
|
|
|
estjust: absence justifiée
|
|
|
|
description: str
|
2021-09-24 12:10:53 +02:00
|
|
|
etudid: etudiant concerné. Si non spécifié, cherche dans les
|
|
|
|
paramètres de la requête.
|
2021-02-04 23:16:18 +01:00
|
|
|
"""
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid = etud["etudid"]
|
|
|
|
description_abs = description
|
2021-08-21 00:24:51 +02:00
|
|
|
dates = sco_abs.DateRangeISO(datedebut, datefin)
|
2020-09-26 16:19:37 +02:00
|
|
|
nbadded = 0
|
2021-05-03 11:56:41 +02:00
|
|
|
demijournee = int(demijournee)
|
2020-09-26 16:19:37 +02:00
|
|
|
for jour in dates:
|
2021-05-03 11:56:41 +02:00
|
|
|
if demijournee == 2:
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_justif(
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid=etudid,
|
|
|
|
jour=jour,
|
|
|
|
matin=False,
|
|
|
|
description=description_abs,
|
|
|
|
)
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_justif(
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid=etudid,
|
|
|
|
jour=jour,
|
|
|
|
matin=True,
|
|
|
|
description=description_abs,
|
|
|
|
)
|
|
|
|
nbadded += 2
|
|
|
|
else:
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_abs.add_justif(
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid=etudid,
|
|
|
|
jour=jour,
|
2021-05-03 11:56:41 +02:00
|
|
|
matin=demijournee,
|
2020-09-26 16:19:37 +02:00
|
|
|
description=description_abs,
|
|
|
|
)
|
|
|
|
nbadded += 1
|
|
|
|
#
|
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title="Justification d'une absence pour %(nomprenom)s" % etud,
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""<h2>Justification d'absences</h2>""",
|
|
|
|
]
|
|
|
|
if dates:
|
|
|
|
H.append(
|
|
|
|
"""<p>Ajout de %d <b>justifications</b> du %s au %s</p>"""
|
|
|
|
% (nbadded, datedebut, datefin)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
"""<p class="warning">Aucune date ouvrable entre le %s et le %s !</p>"""
|
|
|
|
% (datedebut, datefin)
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append(
|
|
|
|
"""<ul><li><a href="JustifAbsenceEtud?etudid=%(etudid)s">Autre justification pour <b>%(nomprenom)s</b></a></li>
|
|
|
|
<li><a href="SignaleAbsenceEtud?etudid=%(etudid)s">Signaler une absence</a></li>
|
|
|
|
<li><a href="CalAbs?etudid=%(etudid)s">Calendrier de ses absences</a></li>
|
|
|
|
<li><a href="ListeAbsEtud?etudid=%(etudid)s">Liste de ses absences</a></li>
|
|
|
|
</ul>
|
|
|
|
<hr>"""
|
|
|
|
% etud
|
|
|
|
)
|
2021-08-22 13:24:36 +02:00
|
|
|
H.append(sco_find_etud.form_search_etud())
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2020-09-26 16:19:37 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-09-24 12:10:53 +02:00
|
|
|
def JustifAbsenceEtud(): # etudid implied
|
2020-12-28 22:59:59 +01:00
|
|
|
"""Formulaire individuel simple de justification d'une absence"""
|
2020-09-26 16:19:37 +02:00
|
|
|
# brute-force portage from very old dtml code ...
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid = etud["etudid"]
|
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title="Justification d'une absence pour %(nomprenom)s" % etud,
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""<table><tr><td>
|
|
|
|
<h2>Justification d'une absence pour %(nomprenom)s</h2>
|
|
|
|
</td><td>
|
|
|
|
"""
|
|
|
|
% etud,
|
2021-07-11 17:37:12 +02:00
|
|
|
"""<a href="%s">"""
|
|
|
|
% url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
|
2020-09-26 16:19:37 +02:00
|
|
|
sco_photos.etud_photo_html(
|
2020-12-28 22:59:59 +01:00
|
|
|
etudid=etudid,
|
|
|
|
title="fiche de " + etud["nomprenom"],
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""</a></td></tr></table>""",
|
|
|
|
"""
|
|
|
|
<form action="doJustifAbsence" method="get">
|
|
|
|
<input type="hidden" name="etudid" value="%(etudid)s">
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<table><tr>
|
|
|
|
<td>Date début : </td>
|
|
|
|
<td>
|
|
|
|
<input type="text" name="datedebut" size="10" class="datepicker"/>
|
|
|
|
</td>
|
|
|
|
<td> Date Fin (optionnel):</td>
|
|
|
|
<td><input type="text" name="datefin" size="10" class="datepicker"/></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<br/>
|
|
|
|
|
2020-12-30 19:21:03 +01:00
|
|
|
<input type="radio" name="demijournee" value="2" checked>Journée(s)
|
2020-09-26 16:19:37 +02:00
|
|
|
<input type="radio" name="demijournee" value="1">Matin(s)
|
|
|
|
<input type="radio" name="demijournee" value="0">Après midi
|
|
|
|
|
|
|
|
<br/><br/>
|
|
|
|
Raison: <input type="text" name="description" size="42"/> (optionnel)
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<input type="submit" value="Envoyer">
|
|
|
|
|
|
|
|
</form> """
|
|
|
|
% etud,
|
2021-07-29 10:19:00 +02:00
|
|
|
html_sco_header.sco_footer(),
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-09-24 12:10:53 +02:00
|
|
|
def doAnnuleAbsence(datedebut, datefin, demijournee, etudid=False): # etudid implied
|
2020-12-28 22:59:59 +01:00
|
|
|
"""Annulation des absences pour une demi journée"""
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid = etud["etudid"]
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
dates = sco_abs.DateRangeISO(datedebut, datefin)
|
2020-09-26 16:19:37 +02:00
|
|
|
nbadded = 0
|
2021-05-03 11:56:41 +02:00
|
|
|
demijournee = int(demijournee)
|
2020-09-26 16:19:37 +02:00
|
|
|
for jour in dates:
|
2021-05-03 11:56:41 +02:00
|
|
|
if demijournee == 2:
|
2021-08-21 00:24:51 +02:00
|
|
|
sco_abs.annule_absence(etudid, jour, False)
|
|
|
|
sco_abs.annule_absence(etudid, jour, True)
|
2020-09-26 16:19:37 +02:00
|
|
|
nbadded += 2
|
|
|
|
else:
|
2021-08-21 00:24:51 +02:00
|
|
|
sco_abs.annule_absence(etudid, jour, demijournee)
|
2020-09-26 16:19:37 +02:00
|
|
|
nbadded += 1
|
|
|
|
#
|
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title="Annulation d'une absence pour %(nomprenom)s" % etud,
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""<h2>Annulation d'absences pour %(nomprenom)s</h2>""" % etud,
|
|
|
|
]
|
|
|
|
if dates:
|
|
|
|
H.append(
|
|
|
|
"<p>Annulation sur %d demi-journées du %s au %s"
|
|
|
|
% (nbadded, datedebut, datefin)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
"""<p class="warning">Aucune date ouvrable entre le %s et le %s !</p>"""
|
|
|
|
% (datedebut, datefin)
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append(
|
|
|
|
"""<ul><li><a href="AnnuleAbsenceEtud?etudid=%(etudid)s">Annulation d'une
|
|
|
|
autre absence pour <b>%(nomprenom)s</b></a></li>
|
|
|
|
<li><a href="SignaleAbsenceEtud?etudid=%(etudid)s">Ajout d'une absence</a></li>
|
|
|
|
<li><a href="CalAbs?etudid=%(etudid)s">Calendrier de ses absences</a></li>
|
|
|
|
</ul>
|
|
|
|
<hr>"""
|
|
|
|
% etud
|
|
|
|
)
|
2021-08-22 13:24:36 +02:00
|
|
|
H.append(sco_find_etud.form_search_etud())
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2020-09-26 16:19:37 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-09-24 12:10:53 +02:00
|
|
|
def AnnuleAbsenceEtud(): # etudid implied
|
2020-12-28 22:59:59 +01:00
|
|
|
"""Formulaire individuel simple d'annulation d'une absence"""
|
2020-09-26 16:19:37 +02:00
|
|
|
# brute-force portage from very old dtml code ...
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid = etud["etudid"]
|
|
|
|
|
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title="Annulation d'une absence pour %(nomprenom)s" % etud,
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""<table><tr><td>
|
|
|
|
<h2><font color="#FF0000">Annulation</font> d'une absence pour %(nomprenom)s</h2>
|
|
|
|
</td><td>
|
|
|
|
"""
|
|
|
|
% etud, # "
|
2021-07-11 17:37:12 +02:00
|
|
|
"""<a href="%s">"""
|
|
|
|
% url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
|
2020-09-26 16:19:37 +02:00
|
|
|
sco_photos.etud_photo_html(
|
2020-12-28 22:59:59 +01:00
|
|
|
etudid=etudid,
|
|
|
|
title="fiche de " + etud["nomprenom"],
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
"""</a></td></tr></table>""",
|
|
|
|
"""<p>A n'utiliser que suite à une erreur de saisie ou lorsqu'il s'avère que l'étudiant était en fait présent. </p>
|
|
|
|
<p><font color="#FF0000">Si plusieurs modules sont affectés, les absences seront toutes effacées. </font></p>
|
|
|
|
"""
|
|
|
|
% etud,
|
|
|
|
"""<table frame="border" border="1"><tr><td>
|
|
|
|
<form action="doAnnuleAbsence" method="get">
|
|
|
|
<input type="hidden" name="etudid" value="%(etudid)s">
|
|
|
|
<p>
|
|
|
|
<table><tr>
|
|
|
|
<td>Date début : </td>
|
|
|
|
<td>
|
|
|
|
<input type="text" name="datedebut" size="10" class="datepicker"/> <em>j/m/a</em>
|
|
|
|
</td>
|
|
|
|
<td> Date Fin (optionnel):</td>
|
|
|
|
<td>
|
|
|
|
<input type="text" name="datefin" size="10" class="datepicker"/> <em>j/m/a</em>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<input type="radio" name="demijournee" value="2" checked>journée(s)
|
|
|
|
<input type="radio" name="demijournee" value="1">Matin(s)
|
|
|
|
<input type="radio" name="demijournee" value="0">Après midi
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<input type="submit" value="Supprimer les absences">
|
|
|
|
</form>
|
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
<tr><td>
|
|
|
|
<form action="doAnnuleJustif" method="get">
|
|
|
|
<input type="hidden" name="etudid" value="%(etudid)s">
|
|
|
|
<p>
|
|
|
|
<table><tr>
|
|
|
|
<td>Date début : </td>
|
|
|
|
<td>
|
|
|
|
<input type="text" name="datedebut0" size="10" class="datepicker"/> <em>j/m/a</em>
|
|
|
|
</td>
|
|
|
|
<td> Date Fin (optionnel):</td>
|
|
|
|
<td>
|
|
|
|
<input type="text" name="datefin0" size="10" class="datepicker"/> <em>j/m/a</em>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<p>
|
|
|
|
|
|
|
|
<input type="radio" name="demijournee" value="2" checked>journée(s)
|
|
|
|
<input type="radio" name="demijournee" value="1">Matin(s)
|
|
|
|
<input type="radio" name="demijournee" value="0">Après midi
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<input type="submit" value="Supprimer les justificatifs">
|
|
|
|
<i>(utiliser ceci en cas de justificatif erroné saisi indépendemment d'une absence)</i>
|
|
|
|
</form>
|
|
|
|
</td></tr></table>"""
|
|
|
|
% etud,
|
2021-07-29 10:19:00 +02:00
|
|
|
html_sco_header.sco_footer(),
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-09-24 12:10:53 +02:00
|
|
|
def doAnnuleJustif(datedebut0, datefin0, demijournee): # etudid implied
|
2020-12-28 22:59:59 +01:00
|
|
|
"""Annulation d'une justification"""
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid = etud["etudid"]
|
2021-08-21 00:24:51 +02:00
|
|
|
dates = sco_abs.DateRangeISO(datedebut0, datefin0)
|
2020-09-26 16:19:37 +02:00
|
|
|
nbadded = 0
|
2021-05-03 11:56:41 +02:00
|
|
|
demijournee = int(demijournee)
|
2020-09-26 16:19:37 +02:00
|
|
|
for jour in dates:
|
2020-12-30 19:21:03 +01:00
|
|
|
# Attention: supprime matin et après-midi
|
2021-05-03 11:56:41 +02:00
|
|
|
if demijournee == 2:
|
2021-09-24 12:10:53 +02:00
|
|
|
sco_abs.annule_justif(etudid, jour, False)
|
|
|
|
sco_abs.annule_justif(etudid, jour, True)
|
2020-09-26 16:19:37 +02:00
|
|
|
nbadded += 2
|
|
|
|
else:
|
2021-09-24 12:10:53 +02:00
|
|
|
sco_abs.annule_justif(etudid, jour, demijournee)
|
2020-09-26 16:19:37 +02:00
|
|
|
nbadded += 1
|
|
|
|
#
|
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.sco_header(
|
2020-09-26 16:19:37 +02:00
|
|
|
page_title="Annulation d'une justification pour %(nomprenom)s" % etud,
|
|
|
|
),
|
|
|
|
"""<h2>Annulation de justifications pour %(nomprenom)s</h2>""" % etud,
|
|
|
|
]
|
|
|
|
|
|
|
|
if dates:
|
|
|
|
H.append(
|
|
|
|
"<p>Annulation sur %d demi-journées du %s au %s"
|
|
|
|
% (nbadded, datedebut0, datefin0)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
"""<p class="warning">Aucune date ouvrable entre le %s et le %s !</p>"""
|
|
|
|
% (datedebut0, datefin0)
|
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
"""<ul><li><a href="AnnuleAbsenceEtud?etudid=%(etudid)s">Annulation d'une
|
|
|
|
autre absence pour <b>%(nomprenom)s</b></a></li>
|
|
|
|
<li><a href="SignaleAbsenceEtud?etudid=%(etudid)s">Ajout d'une absence</a></li>
|
|
|
|
<li><a href="CalAbs?etudid=%(etudid)s">Calendrier de ses absences</a></li>
|
|
|
|
</ul>
|
|
|
|
<hr>"""
|
|
|
|
% etud
|
|
|
|
)
|
2021-08-22 13:24:36 +02:00
|
|
|
H.append(sco_find_etud.form_search_etud())
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2020-09-26 16:19:37 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def AnnuleAbsencesDatesNoJust(etudid, dates, moduleimpl_id=None):
|
2021-07-31 23:05:53 +02:00
|
|
|
"""Supprime les absences non justifiées aux dates indiquées
|
|
|
|
Ne supprime pas les justificatifs éventuels.
|
|
|
|
Args:
|
|
|
|
etudid: l'étudiant
|
|
|
|
dates: liste de dates iso, eg [ "2000-01-15", "2000-01-16" ]
|
|
|
|
moduleimpl_id: si spécifié, n'affecte que les absences de ce module
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
None
|
2021-06-19 23:21:37 +02:00
|
|
|
"""
|
|
|
|
# log('AnnuleAbsencesDatesNoJust: moduleimpl_id=%s' % moduleimpl_id)
|
|
|
|
if not dates:
|
|
|
|
return
|
|
|
|
date0 = dates[0]
|
|
|
|
if len(date0.split(":")) == 2:
|
|
|
|
# am/pm is present
|
|
|
|
for date in dates:
|
|
|
|
jour, ampm = date.split(":")
|
|
|
|
if ampm == "am":
|
|
|
|
matin = 1
|
|
|
|
elif ampm == "pm":
|
|
|
|
matin = 0
|
|
|
|
else:
|
|
|
|
raise ValueError("invalid ampm !")
|
2021-08-21 00:24:51 +02:00
|
|
|
sco_abs.annule_absence(etudid, jour, matin, moduleimpl_id)
|
2021-06-19 23:21:37 +02:00
|
|
|
return
|
|
|
|
cnx = ndb.GetDBConnexion()
|
|
|
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
|
|
|
# supr les absences non justifiees
|
|
|
|
for date in dates:
|
|
|
|
cursor.execute(
|
2021-09-13 22:10:01 +02:00
|
|
|
"""DELETE FROM absences
|
|
|
|
WHERE etudid=%(etudid)s and (not estjust) and jour=%(date)s and moduleimpl_id=%(moduleimpl_id)s
|
|
|
|
""",
|
2021-06-19 23:21:37 +02:00
|
|
|
vars(),
|
|
|
|
)
|
2021-07-19 19:53:01 +02:00
|
|
|
sco_abs.invalidate_abs_etud_date(etudid, date)
|
2021-06-19 23:21:37 +02:00
|
|
|
# s'assure que les justificatifs ne sont pas "absents"
|
|
|
|
for date in dates:
|
|
|
|
cursor.execute(
|
2021-09-13 22:10:01 +02:00
|
|
|
"""UPDATE absences SET estabs=FALSE
|
|
|
|
WHERE etudid=%(etudid)s AND jour=%(date)s AND moduleimpl_id=%(moduleimpl_id)s
|
|
|
|
""",
|
2021-06-19 23:21:37 +02:00
|
|
|
vars(),
|
|
|
|
)
|
|
|
|
if dates:
|
|
|
|
date0 = dates[0]
|
|
|
|
else:
|
|
|
|
date0 = None
|
|
|
|
if len(dates) > 1:
|
|
|
|
date1 = dates[1]
|
|
|
|
else:
|
|
|
|
date1 = None
|
|
|
|
logdb(
|
|
|
|
cnx,
|
|
|
|
"AnnuleAbsencesDatesNoJust",
|
|
|
|
etudid=etudid,
|
|
|
|
msg="%s - %s - %s" % (date0, date1, moduleimpl_id),
|
|
|
|
)
|
|
|
|
cnx.commit()
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def EtatAbsences():
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Etat des absences: choix du groupe"""
|
|
|
|
# crude portage from 1999 DTML
|
|
|
|
H = [
|
2021-07-29 16:31:15 +02:00
|
|
|
html_sco_header.sco_header(page_title="Etat des absences"),
|
2021-08-24 09:22:14 +02:00
|
|
|
"""<h2>État des absences pour un groupe</h2>
|
2020-09-26 16:19:37 +02:00
|
|
|
<form action="EtatAbsencesGr" method="GET">""",
|
2021-08-21 00:24:51 +02:00
|
|
|
formChoixSemestreGroupe(),
|
2020-09-26 16:19:37 +02:00
|
|
|
"""<input type="submit" name="" value=" OK " width=100>
|
|
|
|
|
|
|
|
<table><tr><td>Date de début (j/m/a) : </td><td>
|
|
|
|
|
|
|
|
<input type="text" name="debut" size="10" value="01/09/%s" class="datepicker"/>
|
|
|
|
|
|
|
|
</td></tr><tr><td>Date de fin : </td><td>
|
|
|
|
|
|
|
|
<input type="text" name="fin" size="10" value="%s" class="datepicker"/>
|
|
|
|
|
|
|
|
</td></tr></table>
|
|
|
|
</form>"""
|
2021-08-01 16:13:47 +02:00
|
|
|
% (scu.AnneeScolaire(), datetime.datetime.now().strftime("%d/%m/%Y")),
|
2021-07-29 10:19:00 +02:00
|
|
|
html_sco_header.sco_footer(),
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def formChoixSemestreGroupe(all=False):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""partie de formulaire pour le choix d'un semestre et d'un groupe.
|
|
|
|
Si all, donne tous les semestres (même ceux verrouillés).
|
|
|
|
"""
|
|
|
|
# XXX assez primitif, à ameliorer TOTALEMENT OBSOLETE !
|
|
|
|
if all:
|
2021-08-19 10:28:35 +02:00
|
|
|
sems = sco_formsemestre.do_formsemestre_list()
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2021-08-19 10:28:35 +02:00
|
|
|
sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"})
|
2020-09-26 16:19:37 +02:00
|
|
|
if not sems:
|
|
|
|
raise ScoValueError("aucun semestre !")
|
|
|
|
H = ['<select name="group_ids">']
|
|
|
|
for sem in sems:
|
2021-08-19 10:28:35 +02:00
|
|
|
for p in sco_groups.get_partitions_list(sem["formsemestre_id"]):
|
|
|
|
for group in sco_groups.get_partition_groups(p):
|
2020-09-26 16:19:37 +02:00
|
|
|
if group["group_name"]:
|
|
|
|
group_tit = "%s %s" % (p["partition_name"], group["group_name"])
|
|
|
|
else:
|
|
|
|
group_tit = "tous"
|
|
|
|
H.append(
|
|
|
|
'<option value="%s">%s: %s</option>'
|
|
|
|
% (group["group_id"], sem["titremois"], group_tit)
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append("</select>")
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def CalAbs(etudid, sco_year=None):
|
2021-06-19 23:21:37 +02:00
|
|
|
"""Calendrier des absences d'un etudiant"""
|
2020-09-26 16:19:37 +02:00
|
|
|
# crude portage from 1999 DTML
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid = etud["etudid"]
|
2021-08-01 16:13:47 +02:00
|
|
|
anneescolaire = int(scu.AnneeScolaire(sco_year))
|
2021-08-16 22:41:09 +02:00
|
|
|
datedebut = str(anneescolaire) + "-08-01"
|
2020-09-26 16:19:37 +02:00
|
|
|
datefin = str(anneescolaire + 1) + "-07-31"
|
2022-03-15 22:32:03 +01:00
|
|
|
annee_courante = scu.AnneeScolaire()
|
2021-07-19 19:53:01 +02:00
|
|
|
nbabs = sco_abs.count_abs(etudid=etudid, debut=datedebut, fin=datefin)
|
|
|
|
nbabsjust = sco_abs.count_abs_just(etudid=etudid, debut=datedebut, fin=datefin)
|
2020-09-26 16:19:37 +02:00
|
|
|
events = []
|
2021-07-19 19:53:01 +02:00
|
|
|
for a in sco_abs.list_abs_just(etudid=etudid, datedebut=datedebut):
|
2020-09-26 16:19:37 +02:00
|
|
|
events.append(
|
|
|
|
(str(a["jour"]), "a", "#F8B7B0", "", a["matin"], a["description"])
|
|
|
|
)
|
2021-07-19 19:53:01 +02:00
|
|
|
for a in sco_abs.list_abs_non_just(etudid=etudid, datedebut=datedebut):
|
2020-09-26 16:19:37 +02:00
|
|
|
events.append(
|
|
|
|
(str(a["jour"]), "A", "#EE0000", "", a["matin"], a["description"])
|
|
|
|
)
|
2021-07-19 19:53:01 +02:00
|
|
|
justifs_noabs = sco_abs.list_abs_justifs(
|
|
|
|
etudid=etudid, datedebut=datedebut, only_no_abs=True
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
for a in justifs_noabs:
|
|
|
|
events.append(
|
|
|
|
(str(a["jour"]), "X", "#8EA2C6", "", a["matin"], a["description"])
|
|
|
|
)
|
2021-08-21 00:24:51 +02:00
|
|
|
CalHTML = sco_abs.YearTable(anneescolaire, events=events, halfday=1)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.sco_header(
|
2020-09-26 16:19:37 +02:00
|
|
|
page_title="Calendrier des absences de %(nomprenom)s" % etud,
|
|
|
|
cssstyles=["css/calabs.css"],
|
|
|
|
),
|
|
|
|
"""<table><tr><td><h2>Absences de %(nomprenom)s (%(inscription)s)</h2><p>"""
|
|
|
|
% etud,
|
|
|
|
"""<b><font color="#EE0000">A : absence NON justifiée</font><br/>
|
|
|
|
<font color="#F8B7B0">a : absence justifiée</font><br/>
|
|
|
|
<font color="#8EA2C6">X : justification sans absence</font><br/>
|
|
|
|
%d absences sur l'année, dont %d justifiées (soit %d non justifiées)</b> <em>(%d justificatifs inutilisés)</em>
|
|
|
|
</p>
|
|
|
|
"""
|
|
|
|
% (nbabs, nbabsjust, nbabs - nbabsjust, len(justifs_noabs)),
|
|
|
|
"""</td>
|
2021-07-11 17:37:12 +02:00
|
|
|
<td><a href="%s">%s</a></td>
|
2020-09-26 16:19:37 +02:00
|
|
|
</tr>
|
|
|
|
</table>"""
|
|
|
|
% (
|
2021-07-11 17:37:12 +02:00
|
|
|
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
|
2020-09-26 16:19:37 +02:00
|
|
|
sco_photos.etud_photo_html(
|
2020-12-28 22:59:59 +01:00
|
|
|
etudid=etudid,
|
|
|
|
title="fiche de " + etud["nomprenom"],
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
CalHTML,
|
|
|
|
"""<form method="GET" action="CalAbs" name="f">""",
|
|
|
|
"""<input type="hidden" name="etudid" value="%s"/>""" % etudid,
|
|
|
|
"""Année scolaire %s-%s""" % (anneescolaire, anneescolaire + 1),
|
|
|
|
""" Changer année: <select name="sco_year" onchange="document.f.submit()">""",
|
|
|
|
]
|
2022-03-15 22:32:03 +01:00
|
|
|
for y in range(annee_courante, min(annee_courante - 6, anneescolaire - 6), -1):
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("""<option value="%s" """ % y)
|
|
|
|
if y == anneescolaire:
|
|
|
|
H.append("selected")
|
|
|
|
H.append(""">%s</option>""" % y)
|
|
|
|
H.append("""</select></form>""")
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2020-09-26 16:19:37 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
|
|
|
def ListeAbsEtud(
|
2021-12-21 23:05:49 +01:00
|
|
|
etudid=None,
|
|
|
|
code_nip=None,
|
2021-08-01 16:13:47 +02:00
|
|
|
with_evals=True,
|
2020-09-26 16:19:37 +02:00
|
|
|
format="html",
|
2021-08-01 16:13:47 +02:00
|
|
|
absjust_only=0,
|
|
|
|
sco_year=None,
|
2020-09-26 16:19:37 +02:00
|
|
|
):
|
|
|
|
"""Liste des absences d'un étudiant sur l'année en cours
|
|
|
|
En format 'html': page avec deux tableaux (non justifiées et justifiées).
|
2021-05-03 11:56:41 +02:00
|
|
|
En format json, xml, xls ou pdf: l'un ou l'autre des table, suivant absjust_only.
|
2020-09-26 16:19:37 +02:00
|
|
|
En format 'text': texte avec liste d'absences (pour mails).
|
2021-08-01 16:13:47 +02:00
|
|
|
|
|
|
|
Args:
|
|
|
|
etudid:
|
|
|
|
with_evals: indique les evaluations aux dates d'absences
|
|
|
|
absjust_only: si vrai, renvoie table absences justifiées
|
|
|
|
sco_year: année scolaire à utiliser. Si non spécifier, utilie l'année en cours. e.g. "2005"
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2021-11-03 14:12:27 +01:00
|
|
|
# si absjust_only, table absjust seule (export xls ou pdf)
|
|
|
|
absjust_only = ndb.bool_or_str(absjust_only)
|
2021-08-16 22:41:09 +02:00
|
|
|
datedebut = "%s-08-01" % scu.AnneeScolaire(sco_year=sco_year)
|
2021-12-21 23:05:49 +01:00
|
|
|
etudid = etudid or False
|
|
|
|
etuds = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=True)
|
|
|
|
if not etuds:
|
|
|
|
log(f"ListeAbsEtud: no etuds with etudid={etudid} or nip={code_nip}")
|
|
|
|
abort(404)
|
|
|
|
etud = etuds[0]
|
|
|
|
etudid = etud["etudid"]
|
2020-09-26 16:19:37 +02:00
|
|
|
# Liste des absences et titres colonnes tables:
|
2021-09-24 12:10:53 +02:00
|
|
|
titles, columns_ids, absnonjust, absjust = _tables_abs_etud(
|
2021-08-21 00:24:51 +02:00
|
|
|
etudid, datedebut, with_evals=with_evals, format=format
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-09-24 12:10:53 +02:00
|
|
|
if request.base_url:
|
2021-09-18 10:10:02 +02:00
|
|
|
base_url_nj = "%s?etudid=%s&absjust_only=0" % (request.base_url, etudid)
|
|
|
|
base_url_j = "%s?etudid=%s&absjust_only=1" % (request.base_url, etudid)
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
base_url_nj = base_url_j = ""
|
|
|
|
tab_absnonjust = GenTable(
|
|
|
|
titles=titles,
|
|
|
|
columns_ids=columns_ids,
|
|
|
|
rows=absnonjust,
|
|
|
|
html_class="table_leftalign",
|
|
|
|
table_id="tab_absnonjust",
|
|
|
|
base_url=base_url_nj,
|
2021-01-17 09:37:11 +01:00
|
|
|
filename="abs_" + scu.make_filename(etud["nomprenom"]),
|
2020-09-26 16:19:37 +02:00
|
|
|
caption="Absences non justifiées de %(nomprenom)s" % etud,
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(),
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
tab_absjust = GenTable(
|
|
|
|
titles=titles,
|
|
|
|
columns_ids=columns_ids,
|
|
|
|
rows=absjust,
|
|
|
|
html_class="table_leftalign",
|
|
|
|
table_id="tab_absjust",
|
|
|
|
base_url=base_url_j,
|
2021-01-17 09:37:11 +01:00
|
|
|
filename="absjust_" + scu.make_filename(etud["nomprenom"]),
|
2020-09-26 16:19:37 +02:00
|
|
|
caption="Absences justifiées de %(nomprenom)s" % etud,
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(),
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Formats non HTML et demande d'une seule table:
|
|
|
|
if format != "html" and format != "text":
|
|
|
|
if absjust_only == 1:
|
2021-09-16 00:15:10 +02:00
|
|
|
return tab_absjust.make_page(format=format)
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2021-09-16 00:15:10 +02:00
|
|
|
return tab_absnonjust.make_page(format=format)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if format == "html":
|
|
|
|
# Mise en forme HTML:
|
|
|
|
H = []
|
|
|
|
H.append(
|
2021-07-29 16:31:15 +02:00
|
|
|
html_sco_header.sco_header(page_title="Absences de %s" % etud["nomprenom"])
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
"""<h2>Absences de %s (à partir du %s)</h2>"""
|
2021-06-19 23:21:37 +02:00
|
|
|
% (etud["nomprenom"], ndb.DateISOtoDMY(datedebut))
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if len(absnonjust):
|
|
|
|
H.append("<h3>%d absences non justifiées:</h3>" % len(absnonjust))
|
|
|
|
H.append(tab_absnonjust.html())
|
|
|
|
else:
|
|
|
|
H.append("""<h3>Pas d'absences non justifiées</h3>""")
|
|
|
|
|
|
|
|
if len(absjust):
|
|
|
|
H.append("""<h3>%d absences justifiées:</h3>""" % len(absjust))
|
|
|
|
H.append(tab_absjust.html())
|
|
|
|
else:
|
|
|
|
H.append("""<h3>Pas d'absences justifiées</h3>""")
|
2021-07-29 10:19:00 +02:00
|
|
|
return "\n".join(H) + html_sco_header.sco_footer()
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
elif format == "text":
|
|
|
|
T = []
|
|
|
|
if not len(absnonjust) and not len(absjust):
|
|
|
|
T.append(
|
|
|
|
"""--- Pas d'absences enregistrées depuis le %s"""
|
2021-06-19 23:21:37 +02:00
|
|
|
% ndb.DateISOtoDMY(datedebut)
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
T.append(
|
|
|
|
"""--- Absences enregistrées à partir du %s:"""
|
2021-06-19 23:21:37 +02:00
|
|
|
% ndb.DateISOtoDMY(datedebut)
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
T.append("\n")
|
|
|
|
if len(absnonjust):
|
|
|
|
T.append("* %d absences non justifiées:" % len(absnonjust))
|
|
|
|
T.append(tab_absnonjust.text())
|
|
|
|
if len(absjust):
|
|
|
|
T.append("* %d absences justifiées:" % len(absjust))
|
|
|
|
T.append(tab_absjust.text())
|
|
|
|
return "\n".join(T)
|
|
|
|
else:
|
|
|
|
raise ValueError("Invalid format !")
|
|
|
|
|
|
|
|
|
2021-09-24 12:10:53 +02:00
|
|
|
def _tables_abs_etud(
|
2021-06-19 23:21:37 +02:00
|
|
|
etudid,
|
|
|
|
datedebut,
|
|
|
|
with_evals=True,
|
|
|
|
format="html",
|
|
|
|
absjust_only=0,
|
|
|
|
):
|
2021-08-16 22:41:09 +02:00
|
|
|
"""Tables des absences justifiees et non justifiees d'un étudiant
|
|
|
|
sur l'année en cours
|
|
|
|
"""
|
2021-07-19 19:53:01 +02:00
|
|
|
absjust = sco_abs.list_abs_just(etudid=etudid, datedebut=datedebut)
|
|
|
|
absnonjust = sco_abs.list_abs_non_just(etudid=etudid, datedebut=datedebut)
|
2021-06-19 23:21:37 +02:00
|
|
|
# examens ces jours là ?
|
|
|
|
if with_evals:
|
|
|
|
cnx = ndb.GetDBConnexion()
|
|
|
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
|
|
|
for a in absnonjust + absjust:
|
|
|
|
cursor.execute(
|
2021-08-10 13:44:30 +02:00
|
|
|
"""SELECT eval.*
|
|
|
|
FROM notes_evaluation eval, notes_moduleimpl_inscription mi, notes_moduleimpl m
|
|
|
|
WHERE eval.jour = %(jour)s
|
|
|
|
and eval.moduleimpl_id = m.id
|
|
|
|
and mi.moduleimpl_id = m.id
|
|
|
|
and mi.etudid = %(etudid)s
|
|
|
|
""",
|
2021-06-19 23:21:37 +02:00
|
|
|
{"jour": a["jour"].strftime("%Y-%m-%d"), "etudid": etudid},
|
|
|
|
)
|
|
|
|
a["evals"] = cursor.dictfetchall()
|
|
|
|
cursor.execute(
|
|
|
|
"""SELECT mi.moduleimpl_id
|
2021-08-10 13:44:30 +02:00
|
|
|
FROM absences abs, notes_moduleimpl_inscription mi, notes_moduleimpl m
|
2021-09-24 00:11:56 +02:00
|
|
|
WHERE abs.matin = %(matin)s
|
|
|
|
and abs.jour = %(jour)s
|
|
|
|
and abs.etudid = %(etudid)s
|
|
|
|
and abs.moduleimpl_id = mi.moduleimpl_id
|
|
|
|
and mi.moduleimpl_id = m.id
|
2021-08-10 13:44:30 +02:00
|
|
|
and mi.etudid = %(etudid)s
|
|
|
|
""",
|
2021-06-19 23:21:37 +02:00
|
|
|
{
|
|
|
|
"matin": bool(a["matin"]),
|
|
|
|
"jour": a["jour"].strftime("%Y-%m-%d"),
|
|
|
|
"etudid": etudid,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
a["absent"] = cursor.dictfetchall()
|
|
|
|
|
|
|
|
def matin(x):
|
|
|
|
if x:
|
|
|
|
return "matin"
|
|
|
|
else:
|
|
|
|
return "après-midi"
|
|
|
|
|
|
|
|
def descr_exams(a):
|
2021-07-09 17:47:06 +02:00
|
|
|
if "evals" not in a:
|
2021-06-19 23:21:37 +02:00
|
|
|
return ""
|
|
|
|
ex = []
|
|
|
|
for ev in a["evals"]:
|
2021-10-15 14:00:51 +02:00
|
|
|
mod = sco_moduleimpl.moduleimpl_withmodule_list(
|
2021-08-20 01:09:55 +02:00
|
|
|
moduleimpl_id=ev["moduleimpl_id"]
|
2021-06-19 23:21:37 +02:00
|
|
|
)[0]
|
|
|
|
if format == "html":
|
|
|
|
ex.append(
|
2022-05-06 01:06:58 +02:00
|
|
|
f"""<a title="{mod['module']['titre']}" href="{url_for('notes.moduleimpl_status',
|
2021-09-24 00:11:56 +02:00
|
|
|
scodoc_dept=g.scodoc_dept, moduleimpl_id=mod["moduleimpl_id"])}
|
2022-02-14 10:05:55 +01:00
|
|
|
">{mod["module"]["code"] or "(module sans code)"}</a>"""
|
2021-06-19 23:21:37 +02:00
|
|
|
)
|
|
|
|
else:
|
2022-02-14 10:05:55 +01:00
|
|
|
ex.append(mod["module"]["code"] or "(module sans code)")
|
2021-06-19 23:21:37 +02:00
|
|
|
if ex:
|
|
|
|
return ", ".join(ex)
|
|
|
|
return ""
|
|
|
|
|
|
|
|
def descr_abs(a):
|
|
|
|
ex = []
|
|
|
|
for ev in a.get("absent", []):
|
2021-10-15 14:00:51 +02:00
|
|
|
mod = sco_moduleimpl.moduleimpl_withmodule_list(
|
2021-08-20 01:09:55 +02:00
|
|
|
moduleimpl_id=ev["moduleimpl_id"]
|
2021-06-19 23:21:37 +02:00
|
|
|
)[0]
|
|
|
|
if format == "html":
|
|
|
|
ex.append(
|
2022-05-10 18:03:33 +02:00
|
|
|
f"""<a title="{mod['module']['titre']}"
|
|
|
|
href="{url_for('notes.moduleimpl_status',
|
2021-09-24 00:11:56 +02:00
|
|
|
scodoc_dept=g.scodoc_dept, moduleimpl_id=mod["moduleimpl_id"])}
|
2022-02-14 10:05:55 +01:00
|
|
|
">{mod["module"]["code"] or '(module sans code)'}</a>"""
|
2021-06-19 23:21:37 +02:00
|
|
|
)
|
|
|
|
else:
|
2022-02-14 10:05:55 +01:00
|
|
|
ex.append(mod["module"]["code"] or "(module sans code)")
|
2021-06-19 23:21:37 +02:00
|
|
|
if ex:
|
|
|
|
return ", ".join(ex)
|
|
|
|
return ""
|
|
|
|
|
|
|
|
# ajoute date formatée et évaluations
|
|
|
|
for L in (absnonjust, absjust):
|
|
|
|
for a in L:
|
|
|
|
if with_evals:
|
|
|
|
a["exams"] = descr_exams(a)
|
|
|
|
a["datedmy"] = a["jour"].strftime("%d/%m/%Y")
|
|
|
|
a["ampm"] = int(a["matin"])
|
|
|
|
a["matin"] = matin(a["matin"])
|
|
|
|
index = a["description"].find(")")
|
|
|
|
if index != -1:
|
|
|
|
a["motif"] = a["description"][1:index]
|
|
|
|
else:
|
|
|
|
a["motif"] = ""
|
|
|
|
a["description"] = descr_abs(a) or ""
|
|
|
|
|
|
|
|
# ajoute lien pour justifier
|
|
|
|
if format == "html":
|
|
|
|
for a in absnonjust:
|
|
|
|
a["justlink"] = "<em>justifier</em>"
|
|
|
|
a[
|
|
|
|
"_justlink_target"
|
|
|
|
] = "doJustifAbsence?etudid=%s&datedebut=%s&datefin=%s&demijournee=%s" % (
|
|
|
|
etudid,
|
|
|
|
a["datedmy"],
|
|
|
|
a["datedmy"],
|
|
|
|
a["ampm"],
|
|
|
|
)
|
|
|
|
#
|
|
|
|
titles = {
|
|
|
|
"datedmy": "Date",
|
|
|
|
"matin": "",
|
|
|
|
"exams": "Examens ce jour",
|
|
|
|
"justlink": "",
|
|
|
|
"description": "Modules",
|
|
|
|
"motif": "Motif",
|
|
|
|
}
|
|
|
|
columns_ids = ["datedmy", "matin"]
|
|
|
|
if format in ("json", "xml"):
|
|
|
|
columns_ids += ["jour", "ampm"]
|
|
|
|
if with_evals:
|
|
|
|
columns_ids.append("exams")
|
|
|
|
|
|
|
|
columns_ids.append("description")
|
|
|
|
columns_ids.append("motif")
|
|
|
|
if format == "html":
|
|
|
|
columns_ids.append("justlink")
|
|
|
|
|
|
|
|
return titles, columns_ids, absnonjust, absjust
|