2021-05-31 00:14:15 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-06-02 22:40:34 +02:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# ScoDoc
|
|
|
|
#
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 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
|
|
|
"""
|
2021-07-10 07:27:06 +02:00
|
|
|
Module scolar: vues de .../ScoDoc/<dept>/Scolarite
|
|
|
|
|
|
|
|
issu de ScoDoc7 / ZScolar.py
|
2021-05-31 00:14:15 +02:00
|
|
|
|
|
|
|
Emmanuel Viennet, 2021
|
|
|
|
"""
|
2022-09-03 09:29:40 +02:00
|
|
|
import datetime
|
2021-06-02 22:40:34 +02:00
|
|
|
import time
|
|
|
|
|
2023-09-25 23:51:38 +02:00
|
|
|
import requests
|
|
|
|
|
2021-08-01 10:16:16 +02:00
|
|
|
import flask
|
2023-09-25 23:51:38 +02:00
|
|
|
from flask import abort, flash, make_response, render_template, url_for
|
2022-02-12 14:59:18 +01:00
|
|
|
from flask import g, request
|
2023-04-06 16:10:32 +02:00
|
|
|
from flask_json import as_json
|
2021-08-10 17:12:10 +02:00
|
|
|
from flask_login import current_user
|
2021-09-08 23:00:01 +02:00
|
|
|
from flask_wtf import FlaskForm
|
|
|
|
from flask_wtf.file import FileField, FileAllowed
|
2023-10-26 16:15:29 +02:00
|
|
|
import sqlalchemy as sa
|
2021-11-16 18:48:56 +01:00
|
|
|
from wtforms import SubmitField
|
2021-05-31 00:14:15 +02:00
|
|
|
|
2023-09-25 23:51:38 +02:00
|
|
|
import app
|
2022-04-12 17:12:51 +02:00
|
|
|
from app import db
|
2021-12-26 19:15:47 +01:00
|
|
|
from app import log
|
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
|
|
|
)
|
2023-09-06 08:48:00 +02:00
|
|
|
from app.models import (
|
2024-08-23 04:30:53 +02:00
|
|
|
Adresse,
|
2023-10-08 10:01:23 +02:00
|
|
|
Admission,
|
2023-09-25 23:51:38 +02:00
|
|
|
Departement,
|
2023-09-06 08:48:00 +02:00
|
|
|
FormSemestre,
|
|
|
|
Identite,
|
|
|
|
Partition,
|
|
|
|
ScolarEvent,
|
|
|
|
ScolarNews,
|
|
|
|
Scolog,
|
|
|
|
)
|
2021-12-26 19:15:47 +01:00
|
|
|
from app.models.etudiants import make_etud_args
|
2021-05-31 00:14:15 +02:00
|
|
|
from app.views import scolar_bp as bp
|
2022-04-12 17:12:51 +02:00
|
|
|
from app.views import ScoData
|
2021-05-31 00:14:15 +02:00
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
import app.scodoc.sco_utils as scu
|
|
|
|
import app.scodoc.notesdb as ndb
|
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 (
|
|
|
|
AccessDenied,
|
2023-09-25 23:51:38 +02:00
|
|
|
ScoPermissionDenied,
|
2021-06-02 22:40:34 +02:00
|
|
|
ScoValueError,
|
|
|
|
)
|
2022-09-03 09:29:40 +02:00
|
|
|
|
2024-07-08 23:13:45 +02:00
|
|
|
from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message
|
2021-06-02 22:40:34 +02:00
|
|
|
from app.scodoc.gen_tables import GenTable
|
2023-12-29 04:11:37 +01:00
|
|
|
from app.scodoc import (
|
|
|
|
codes_cursus,
|
|
|
|
html_sco_header,
|
|
|
|
sco_import_etuds,
|
|
|
|
sco_archives_etud,
|
2024-05-23 00:15:32 +02:00
|
|
|
sco_bug_report,
|
2023-12-29 04:11:37 +01:00
|
|
|
sco_cache,
|
|
|
|
sco_debouche,
|
|
|
|
sco_dept,
|
|
|
|
sco_dump_db,
|
|
|
|
sco_etud,
|
|
|
|
sco_edt_cal,
|
|
|
|
sco_find_etud,
|
|
|
|
sco_formsemestre,
|
|
|
|
sco_formsemestre_inscriptions,
|
|
|
|
sco_groups,
|
|
|
|
sco_groups_edit,
|
|
|
|
sco_groups_exports,
|
|
|
|
sco_groups_view,
|
|
|
|
sco_page_etud,
|
|
|
|
sco_permissions_check,
|
|
|
|
sco_photos,
|
|
|
|
sco_portal_apogee,
|
|
|
|
sco_preferences,
|
|
|
|
sco_synchro_etuds,
|
|
|
|
sco_trombino,
|
|
|
|
sco_trombino_tours,
|
|
|
|
sco_up_to_date,
|
|
|
|
)
|
2023-11-26 18:28:56 +01:00
|
|
|
from app.tables import list_etuds
|
2024-05-24 13:01:56 +02:00
|
|
|
from app.forms.main.create_bug_report import CreateBugReport
|
2021-06-12 22:43:22 +02:00
|
|
|
|
|
|
|
|
2021-08-13 09:31:49 +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-06-25 19:24:12 +02:00
|
|
|
return bp.route(route, methods=methods)(
|
2021-08-21 00:24:51 +02:00
|
|
|
scodoc(permission_required(permission)(scodoc7func(function)))
|
2021-06-16 18:18:32 +02:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SCOLARITE (/ScoDoc/<dept>/Scolarite/...)
|
|
|
|
#
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2021-05-31 00:14:15 +02:00
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
# --------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# PREFERENCES
|
|
|
|
#
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-06-21 14:40:58 +02:00
|
|
|
@bp.route("/edit_preferences", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EditPreferences)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-09-27 10:20:10 +02:00
|
|
|
def edit_preferences():
|
2021-06-16 18:18:32 +02:00
|
|
|
"""Edit global preferences (lien "Paramétrage" département)"""
|
2021-09-27 10:20:10 +02:00
|
|
|
return sco_preferences.get_base_preferences().edit()
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-06-25 19:24:12 +02:00
|
|
|
@bp.route("/formsemestre_edit_preferences", methods=["GET", "POST"])
|
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-09-27 10:20:10 +02:00
|
|
|
def formsemestre_edit_preferences(formsemestre_id):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Edit preferences for a semestre"""
|
2021-08-19 10:28:35 +02:00
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
2021-06-02 22:40:34 +02:00
|
|
|
ok = (
|
2023-09-29 21:17:31 +02:00
|
|
|
current_user.has_permission(Permission.EditFormSemestre)
|
2021-08-22 13:24:36 +02:00
|
|
|
or ((current_user.id in sem["responsables"]) and sem["resp_can_edit"])
|
2021-08-10 12:57:38 +02:00
|
|
|
) and (sem["etat"])
|
2021-06-02 22:40:34 +02:00
|
|
|
if ok:
|
2021-09-27 10:20:10 +02:00
|
|
|
return sco_preferences.SemPreferences(formsemestre_id=formsemestre_id).edit()
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
2021-08-22 13:24:36 +02:00
|
|
|
raise AccessDenied(
|
|
|
|
"Modification impossible pour %s" % current_user.get_nomplogin()
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/doc_preferences")
|
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-09-27 10:20:10 +02:00
|
|
|
def doc_preferences():
|
2021-06-02 22:40:34 +02:00
|
|
|
"""List preferences for wiki documentation"""
|
2021-09-27 10:20:10 +02:00
|
|
|
response = make_response(sco_preferences.doc_preferences())
|
|
|
|
response.headers["Content-Type"] = "text/plain"
|
|
|
|
return response
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-11-16 18:48:56 +01:00
|
|
|
class DeptLogosConfigurationForm(FlaskForm):
|
|
|
|
"Panneau de configuration logos dept"
|
|
|
|
|
|
|
|
logo_header = FileField(
|
|
|
|
label="Modifier l'image:",
|
|
|
|
description="logo placé en haut des documents PDF",
|
|
|
|
validators=[
|
|
|
|
FileAllowed(
|
|
|
|
scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
2021-11-19 11:51:05 +01:00
|
|
|
f"n'accepte que les fichiers image <tt>{','.join(scu.LOGOS_IMAGES_ALLOWED_TYPES)}</tt>",
|
2021-11-16 18:48:56 +01:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
logo_footer = FileField(
|
|
|
|
label="Modifier l'image:",
|
|
|
|
description="logo placé en pied des documents PDF",
|
|
|
|
validators=[
|
|
|
|
FileAllowed(
|
|
|
|
scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
2021-11-19 11:51:05 +01:00
|
|
|
f"n'accepte que les fichiers image <tt>{','.join(scu.LOGOS_IMAGES_ALLOWED_TYPES)}</tt>",
|
2021-11-16 18:48:56 +01:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
submit = SubmitField("Enregistrer")
|
|
|
|
|
|
|
|
|
2021-11-19 11:51:05 +01:00
|
|
|
# @bp.route("/config_logos", methods=["GET", "POST"])
|
2023-09-29 21:17:31 +02:00
|
|
|
# @permission_required(Permission.EditPreferences)
|
2021-11-19 11:51:05 +01:00
|
|
|
# def config_logos(scodoc_dept):
|
|
|
|
# "Panneau de configuration général"
|
|
|
|
# form = DeptLogosConfigurationForm()
|
|
|
|
# if form.validate_on_submit():
|
|
|
|
# if form.logo_header.data:
|
|
|
|
# sco_logos.store_image(
|
|
|
|
# form.logo_header.data,
|
|
|
|
# os.path.join(
|
|
|
|
# scu.SCODOC_LOGOS_DIR, "logos_" + scodoc_dept, "logo_header"
|
|
|
|
# ),
|
|
|
|
# )
|
|
|
|
# if form.logo_footer.data:
|
|
|
|
# sco_logos.store_image(
|
|
|
|
# form.logo_footer.data,
|
|
|
|
# os.path.join(
|
|
|
|
# scu.SCODOC_LOGOS_DIR, "logos_" + scodoc_dept, "logo_footer"
|
|
|
|
# ),
|
|
|
|
# )
|
|
|
|
# app.clear_scodoc_cache()
|
|
|
|
# flash(f"Logos enregistrés")
|
|
|
|
# return flask.redirect(url_for("scolar.index_html", scodoc_dept=scodoc_dept))
|
|
|
|
#
|
|
|
|
# return render_template(
|
2023-01-30 22:25:17 +01:00
|
|
|
# "configuration.j2",
|
2021-11-19 11:51:05 +01:00
|
|
|
# title="Configuration Logos du département",
|
|
|
|
# form=form,
|
|
|
|
# scodoc_dept=scodoc_dept,
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# class DeptLogosConfigurationForm(FlaskForm):
|
|
|
|
# "Panneau de configuration logos dept"
|
|
|
|
#
|
|
|
|
# logo_header = FileField(
|
|
|
|
# label="Modifier l'image:",
|
|
|
|
# description="logo placé en haut des documents PDF",
|
|
|
|
# validators=[
|
|
|
|
# FileAllowed(
|
|
|
|
# scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
|
|
|
# f"n'accepte que les fichiers image <tt>{','.join([e for e in scu.LOGOS_IMAGES_ALLOWED_TYPES])}</tt>",
|
|
|
|
# )
|
|
|
|
# ],
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
# logo_footer = FileField(
|
|
|
|
# label="Modifier l'image:",
|
|
|
|
# description="logo placé en pied des documents PDF",
|
|
|
|
# validators=[
|
|
|
|
# FileAllowed(
|
|
|
|
# scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
|
|
|
# f"n'accepte que les fichiers image <tt>{','.join([e for e in scu.LOGOS_IMAGES_ALLOWED_TYPES])}</tt>",
|
|
|
|
# )
|
|
|
|
# ],
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
# submit = SubmitField("Enregistrer")
|
|
|
|
|
|
|
|
|
|
|
|
# @bp.route("/config_logos", methods=["GET", "POST"])
|
2023-09-29 21:17:31 +02:00
|
|
|
# @permission_required(Permission.EditPreferences)
|
2021-11-19 11:51:05 +01:00
|
|
|
# def config_logos(scodoc_dept):
|
|
|
|
# "Panneau de configuration général"
|
|
|
|
# form = DeptLogosConfigurationForm()
|
|
|
|
# if form.validate_on_submit():
|
|
|
|
# if form.logo_header.data:
|
|
|
|
# sco_logos.store_image(
|
|
|
|
# form.logo_header.data,
|
|
|
|
# os.path.join(
|
|
|
|
# scu.SCODOC_LOGOS_DIR, "logos_" + scodoc_dept, "logo_header"
|
|
|
|
# ),
|
|
|
|
# )
|
|
|
|
# if form.logo_footer.data:
|
|
|
|
# sco_logos.store_image(
|
|
|
|
# form.logo_footer.data,
|
|
|
|
# os.path.join(
|
|
|
|
# scu.SCODOC_LOGOS_DIR, "logos_" + scodoc_dept, "logo_footer"
|
|
|
|
# ),
|
|
|
|
# )
|
|
|
|
# app.clear_scodoc_cache()
|
|
|
|
# flash(f"Logos enregistrés")
|
|
|
|
# return flask.redirect(url_for("scolar.index_html", scodoc_dept=scodoc_dept))
|
|
|
|
#
|
|
|
|
# return render_template(
|
2023-01-30 22:25:17 +01:00
|
|
|
# "configuration.j2",
|
2021-11-19 11:51:05 +01:00
|
|
|
# title="Configuration Logos du département",
|
|
|
|
# form=form,
|
|
|
|
# scodoc_dept=scodoc_dept,
|
|
|
|
# )
|
2021-11-16 18:48:56 +01:00
|
|
|
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
# --------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ETUDIANTS
|
|
|
|
#
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2024-07-08 23:13:45 +02:00
|
|
|
@bp.route("/show_etud_log")
|
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
|
2024-07-08 23:13:45 +02:00
|
|
|
def show_etud_log(etudid, fmt="html"):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Display log of operations on this student"""
|
2024-07-08 23:13:45 +02:00
|
|
|
etud = Identite.get_etud(etudid)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2024-07-08 23:13:45 +02:00
|
|
|
operations = Scolog.query.filter_by(etudid=etud.id).order_by(Scolog.date.desc())
|
2021-06-02 22:40:34 +02:00
|
|
|
tab = GenTable(
|
|
|
|
titles={
|
|
|
|
"date": "Date",
|
|
|
|
"authenticated_user": "Utilisateur",
|
|
|
|
"method": "Opération",
|
|
|
|
"msg": "Message",
|
|
|
|
},
|
2024-07-08 23:13:45 +02:00
|
|
|
columns_ids=("date", "authenticated_user", "method", "msg"),
|
|
|
|
rows=[op.to_dict(convert_date=True) for op in operations],
|
2021-06-02 22:40:34 +02:00
|
|
|
html_sortable=True,
|
|
|
|
html_class="table_leftalign",
|
2024-07-08 23:13:45 +02:00
|
|
|
base_url="%s?etudid=%s" % (request.base_url, etud.id),
|
|
|
|
page_title=f"Opérations sur {etud.nom_prenom()}",
|
|
|
|
html_title=f"""<h2>Opérations effectuées sur l'étudiant{etud.e} {
|
|
|
|
etud.html_link_fiche()}</h2>""",
|
|
|
|
filename="log_" + scu.make_filename(etud.nom_prenom()),
|
2021-07-19 19:53:01 +02:00
|
|
|
html_next_section=f"""
|
2024-07-08 23:13:45 +02:00
|
|
|
<ul>
|
|
|
|
<li>Fiche de {etud.html_link_fiche()}</li>
|
2021-07-19 19:53:01 +02:00
|
|
|
</ul>""",
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(),
|
2024-07-08 23:13:45 +02:00
|
|
|
table_id="show_etud_log",
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
2023-09-21 10:20:19 +02:00
|
|
|
return tab.make_page(fmt=fmt)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
# ---------- PAGE ACCUEIL (listes) --------------
|
2021-08-13 00:34:58 +02:00
|
|
|
|
|
|
|
|
2024-04-08 18:56:43 +02:00
|
|
|
@bp.route("/")
|
|
|
|
@bp.route("/index_html", alias=True)
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-25 19:24:12 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-09-27 10:20:10 +02:00
|
|
|
def index_html(showcodes=0, showsemtable=0):
|
2024-07-22 16:53:50 +02:00
|
|
|
"La page d'accueil département (ScoDoc/<dept>/Scolarite)"
|
2021-09-27 10:20:10 +02:00
|
|
|
return sco_dept.index_html(showcodes=showcodes, showsemtable=showsemtable)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2024-03-21 13:21:16 +01:00
|
|
|
@bp.route("/export_table_dept_formsemestres")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def export_table_dept_formsemestres():
|
|
|
|
"""La table de tous les semestres non EXt du département, en excel"""
|
|
|
|
table = sco_dept.index_html(showcodes=True, export_table_formsemestres=True)
|
|
|
|
return scu.send_file(
|
|
|
|
table.excel(),
|
|
|
|
f"semestres_{g.scodoc_dept}",
|
|
|
|
suffix=scu.XLSX_SUFFIX,
|
|
|
|
mime=scu.XLSX_MIMETYPE,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-03-19 22:00:31 +01:00
|
|
|
@bp.route("/install_info")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def install_info():
|
|
|
|
"""Information on install status (html str)"""
|
|
|
|
return sco_up_to_date.is_up_to_date()
|
|
|
|
|
|
|
|
|
2022-04-12 17:12:51 +02:00
|
|
|
@bp.route("/dept_news")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def dept_news():
|
|
|
|
"Affiche table des dernières opérations"
|
|
|
|
return render_template(
|
2023-01-30 22:25:17 +01:00
|
|
|
"dept_news.j2", title=f"Opérations {g.scodoc_dept}", sco=ScoData()
|
2022-04-12 17:12:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/dept_news_json")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def dept_news_json():
|
|
|
|
"Table des news du département"
|
|
|
|
start = request.args.get("start", type=int)
|
|
|
|
length = request.args.get("length", type=int)
|
|
|
|
|
|
|
|
log(f"dept_news_json( start={start}, length={length})")
|
|
|
|
query = ScolarNews.query.filter_by(dept_id=g.scodoc_dept_id)
|
|
|
|
# search
|
|
|
|
search = request.args.get("search[value]")
|
|
|
|
if search:
|
|
|
|
query = query.filter(
|
|
|
|
db.or_(
|
|
|
|
ScolarNews.authenticated_user.like(f"%{search}%"),
|
|
|
|
ScolarNews.text.like(f"%{search}%"),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
total_filtered = query.count()
|
|
|
|
# sorting
|
|
|
|
order = []
|
|
|
|
i = 0
|
|
|
|
while True:
|
|
|
|
col_index = request.args.get(f"order[{i}][column]")
|
|
|
|
if col_index is None:
|
|
|
|
break
|
|
|
|
col_name = request.args.get(f"columns[{col_index}][data]")
|
|
|
|
if col_name not in ["date", "type", "authenticated_user"]:
|
|
|
|
col_name = "date"
|
|
|
|
descending = request.args.get(f"order[{i}][dir]") == "desc"
|
|
|
|
col = getattr(ScolarNews, col_name)
|
|
|
|
if descending:
|
|
|
|
col = col.desc()
|
|
|
|
order.append(col)
|
|
|
|
i += 1
|
|
|
|
if order:
|
|
|
|
query = query.order_by(*order)
|
|
|
|
|
|
|
|
# pagination
|
|
|
|
query = query.offset(start).limit(length)
|
|
|
|
data = [news.to_dict() for news in query]
|
|
|
|
# response
|
|
|
|
return {
|
|
|
|
"data": data,
|
|
|
|
"recordsFiltered": total_filtered,
|
|
|
|
"recordsTotal": ScolarNews.query.count(),
|
|
|
|
"draw": request.args.get("draw", type=int),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-02 09:16:57 +02:00
|
|
|
sco_publish(
|
|
|
|
"/trombino", sco_trombino.trombino, Permission.ScoView, methods=["GET", "POST"]
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/pdf_trombino_tours", sco_trombino_tours.pdf_trombino_tours, Permission.ScoView
|
|
|
|
)
|
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/pdf_feuille_releve_absences",
|
|
|
|
sco_trombino_tours.pdf_feuille_releve_absences,
|
|
|
|
Permission.ScoView,
|
|
|
|
)
|
|
|
|
|
|
|
|
sco_publish(
|
2021-09-08 00:34:45 +02:00
|
|
|
"/trombino_copy_photos",
|
|
|
|
sco_trombino.trombino_copy_photos,
|
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
2022-03-02 23:14:04 +01:00
|
|
|
sco_publish(
|
|
|
|
"/groups_export_annotations",
|
|
|
|
sco_groups_exports.groups_export_annotations,
|
2024-01-20 17:37:24 +01:00
|
|
|
Permission.ViewEtudData,
|
2022-03-02 23:14:04 +01:00
|
|
|
)
|
|
|
|
|
2021-11-01 16:59:56 +01:00
|
|
|
|
2024-08-22 22:02:34 +02:00
|
|
|
@bp.route("/groups_lists")
|
2021-11-01 16:59:56 +01:00
|
|
|
@scodoc
|
2024-08-22 22:02:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2021-11-01 16:59:56 +01:00
|
|
|
@scodoc7func
|
2024-08-22 22:02:34 +02:00
|
|
|
def groups_lists(
|
2021-11-01 16:59:56 +01:00
|
|
|
group_ids=(),
|
2023-09-21 10:20:19 +02:00
|
|
|
fmt="html",
|
2021-11-01 16:59:56 +01:00
|
|
|
# Options pour listes:
|
|
|
|
with_codes=0,
|
|
|
|
etat=None,
|
|
|
|
with_paiement=0, # si vrai, ajoute colonnes infos paiement droits et finalisation inscription (lent car interrogation portail)
|
|
|
|
with_archives=0, # ajoute colonne avec noms fichiers archivés
|
|
|
|
with_annotations=0,
|
2022-12-07 15:52:50 +01:00
|
|
|
with_bourse=0,
|
2021-11-01 16:59:56 +01:00
|
|
|
formsemestre_id=None,
|
|
|
|
):
|
2024-08-22 22:02:34 +02:00
|
|
|
"Listes des étudiants des groupes"
|
|
|
|
return sco_groups_view.groups_lists(
|
2021-11-03 00:27:50 +01:00
|
|
|
group_ids=group_ids,
|
2023-09-21 10:20:19 +02:00
|
|
|
fmt=fmt,
|
2021-11-01 16:59:56 +01:00
|
|
|
with_codes=with_codes,
|
|
|
|
etat=etat,
|
2022-12-07 15:52:50 +01:00
|
|
|
with_paiement=with_paiement,
|
|
|
|
with_archives=with_archives,
|
2021-11-01 16:59:56 +01:00
|
|
|
with_annotations=with_annotations,
|
2022-12-07 15:52:50 +01:00
|
|
|
with_bourse=with_bourse,
|
2021-11-01 16:59:56 +01:00
|
|
|
formsemestre_id=formsemestre_id,
|
|
|
|
)
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2024-08-22 22:02:34 +02:00
|
|
|
@bp.route("/groups_photos")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
@scodoc7func
|
|
|
|
def groups_photos(
|
|
|
|
group_ids=(),
|
|
|
|
etat=None,
|
|
|
|
formsemestre_id=None,
|
|
|
|
):
|
|
|
|
"trombi HTML"
|
|
|
|
return sco_groups_view.groups_photos(
|
|
|
|
group_ids=group_ids,
|
|
|
|
etat=etat,
|
|
|
|
formsemestre_id=formsemestre_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/groups_feuilles")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
@scodoc7func
|
|
|
|
def groups_feuilles(
|
|
|
|
group_ids=(),
|
|
|
|
etat=None,
|
|
|
|
formsemestre_id=None,
|
|
|
|
):
|
|
|
|
"Feuilles appel, liens assiduité, etc."
|
|
|
|
return sco_groups_view.groups_feuilles(
|
|
|
|
group_ids=group_ids,
|
|
|
|
etat=etat,
|
|
|
|
formsemestre_id=formsemestre_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
sco_publish(
|
|
|
|
"/export_groups_as_moodle_csv",
|
|
|
|
sco_groups_view.export_groups_as_moodle_csv,
|
|
|
|
Permission.ScoView,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# -------------------------- INFOS SUR ETUDIANTS --------------------------
|
|
|
|
@bp.route("/getEtudInfo")
|
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
|
2023-09-21 10:20:19 +02:00
|
|
|
def getEtudInfo(etudid=False, code_nip=False, filled=False, fmt=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""infos sur un etudiant (API)
|
2021-06-14 00:23:22 +02:00
|
|
|
On peut specifier etudid ou code_nip
|
2021-09-27 10:20:10 +02:00
|
|
|
ou bien cherche dans les arguments de la requête: etudid, code_nip, code_ine
|
2021-06-02 22:40:34 +02:00
|
|
|
(dans cet ordre).
|
|
|
|
"""
|
2021-08-22 13:24:36 +02:00
|
|
|
etud = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=filled)
|
2023-09-21 10:20:19 +02:00
|
|
|
if fmt is None:
|
2021-06-02 22:40:34 +02:00
|
|
|
return etud
|
2023-09-21 10:20:19 +02:00
|
|
|
return scu.sendResult(etud, name="etud", fmt=fmt)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
sco_publish(
|
2021-07-13 14:53:14 +02:00
|
|
|
"/search_etud_in_dept",
|
|
|
|
sco_find_etud.search_etud_in_dept,
|
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
2021-08-31 08:21:30 +02:00
|
|
|
|
|
|
|
@bp.route("/search_etud_by_name")
|
|
|
|
@bp.route("/Notes/search_etud_by_name") # for JS apis
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
2023-04-06 16:10:32 +02:00
|
|
|
@as_json
|
2021-08-31 08:21:30 +02:00
|
|
|
def search_etud_by_name():
|
2024-07-03 21:32:33 +02:00
|
|
|
"""Recherche étudiants par nom ou NIP
|
|
|
|
utilisé par autocomplete formulaire recherche
|
|
|
|
"""
|
2021-08-31 08:21:30 +02:00
|
|
|
term = request.args["term"]
|
|
|
|
data = sco_find_etud.search_etud_by_name(term)
|
2023-04-06 16:10:32 +02:00
|
|
|
return data
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
# XMLgetEtudInfos était le nom dans l'ancienne API ScoDoc 6
|
2021-09-10 22:03:52 +02:00
|
|
|
@bp.route("/etud_info", methods=["GET", "POST"]) # pour compat anciens clients PHP)
|
|
|
|
@bp.route(
|
|
|
|
"/XMLgetEtudInfos", methods=["GET", "POST"]
|
|
|
|
) # pour compat anciens clients PHP)
|
|
|
|
@bp.route(
|
|
|
|
"/Absences/XMLgetEtudInfos", methods=["GET", "POST"]
|
|
|
|
) # pour compat anciens clients PHP
|
|
|
|
@bp.route(
|
|
|
|
"/Notes/XMLgetEtudInfos", methods=["GET", "POST"]
|
|
|
|
) # pour compat anciens clients PHP
|
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
|
2023-09-21 10:20:19 +02:00
|
|
|
def etud_info(etudid=None, fmt="xml"):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Donne les informations sur un etudiant"
|
2023-09-21 10:20:19 +02:00
|
|
|
if not fmt in ("xml", "json"):
|
2021-10-20 22:34:06 +02:00
|
|
|
raise ScoValueError("format demandé non supporté par cette fonction.")
|
2021-06-02 22:40:34 +02:00
|
|
|
t0 = time.time()
|
2021-12-26 19:15:47 +01:00
|
|
|
args = make_etud_args(etudid=etudid)
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-19 23:21:37 +02:00
|
|
|
etuds = sco_etud.etudident_list(cnx, args)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not etuds:
|
|
|
|
# etudiant non trouvé: message d'erreur
|
|
|
|
d = {
|
|
|
|
"etudid": etudid,
|
|
|
|
"nom": "?",
|
|
|
|
"nom_usuel": "",
|
|
|
|
"prenom": "?",
|
|
|
|
"civilite": "?",
|
|
|
|
"sexe": "?", # for backward compat
|
|
|
|
"email": "?",
|
|
|
|
"emailperso": "",
|
|
|
|
"error": "code etudiant inconnu",
|
|
|
|
}
|
2023-09-21 10:20:19 +02:00
|
|
|
return scu.sendResult(d, name="etudiant", fmt=fmt, force_outer_xml_tag=False)
|
2021-06-02 22:40:34 +02:00
|
|
|
d = {}
|
|
|
|
etud = etuds[0]
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_etud.fill_etuds_info([etud])
|
2021-06-02 22:40:34 +02:00
|
|
|
etud["date_naissance_iso"] = ndb.DateDMYtoISO(etud["date_naissance"])
|
|
|
|
for a in (
|
|
|
|
"etudid",
|
|
|
|
"code_nip",
|
|
|
|
"code_ine",
|
|
|
|
"nom",
|
|
|
|
"nom_usuel",
|
|
|
|
"prenom",
|
|
|
|
"nomprenom",
|
2023-03-13 06:39:36 +01:00
|
|
|
"prenom_etat_civil",
|
2021-06-02 22:40:34 +02:00
|
|
|
"email",
|
|
|
|
"emailperso",
|
|
|
|
"domicile",
|
|
|
|
"codepostaldomicile",
|
|
|
|
"villedomicile",
|
|
|
|
"paysdomicile",
|
|
|
|
"telephone",
|
|
|
|
"telephonemobile",
|
|
|
|
"fax",
|
|
|
|
"bac",
|
|
|
|
"specialite",
|
|
|
|
"annee_bac",
|
|
|
|
"nomlycee",
|
|
|
|
"villelycee",
|
|
|
|
"codepostallycee",
|
|
|
|
"codelycee",
|
|
|
|
"date_naissance_iso",
|
|
|
|
):
|
2021-10-20 23:18:00 +02:00
|
|
|
d[a] = etud[a] # ne pas quoter car ElementTree.tostring quote déjà
|
2023-10-16 22:51:31 +02:00
|
|
|
d["civilite"] = etud["civilite_str"] # exception: ne sort pas les civilités brutes
|
|
|
|
d["civilite_etat_civil"] = etud["civilite_etat_civil_str"]
|
2021-06-02 22:40:34 +02:00
|
|
|
d["sexe"] = d["civilite"] # backward compat pour anciens clients
|
2021-10-20 23:18:00 +02:00
|
|
|
d["photo_url"] = sco_photos.etud_photo_url(etud)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
sem = etud["cursem"]
|
|
|
|
if sem:
|
2022-03-05 12:47:08 +01:00
|
|
|
sco_groups.etud_add_group_infos(etud, sem["formsemestre_id"] if sem else None)
|
2021-06-02 22:40:34 +02:00
|
|
|
d["insemestre"] = [
|
|
|
|
{
|
|
|
|
"current": "1",
|
|
|
|
"formsemestre_id": sem["formsemestre_id"],
|
|
|
|
"date_debut": ndb.DateDMYtoISO(sem["date_debut"]),
|
|
|
|
"date_fin": ndb.DateDMYtoISO(sem["date_fin"]),
|
2021-10-20 23:18:00 +02:00
|
|
|
"etat": sem["ins"]["etat"],
|
|
|
|
"groupes": etud["groupes"], # slt pour semestre courant
|
2021-06-02 22:40:34 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
d["insemestre"] = []
|
|
|
|
for sem in etud["sems"]:
|
|
|
|
if sem != etud["cursem"]:
|
|
|
|
d["insemestre"].append(
|
|
|
|
{
|
|
|
|
"formsemestre_id": sem["formsemestre_id"],
|
|
|
|
"date_debut": ndb.DateDMYtoISO(sem["date_debut"]),
|
|
|
|
"date_fin": ndb.DateDMYtoISO(sem["date_fin"]),
|
2021-10-20 23:18:00 +02:00
|
|
|
"etat": sem["ins"]["etat"],
|
2021-06-02 22:40:34 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
log("etud_info (%gs)" % (time.time() - t0))
|
2021-10-20 22:34:06 +02:00
|
|
|
return scu.sendResult(
|
2023-09-21 10:20:19 +02:00
|
|
|
d, name="etudiant", fmt=fmt, force_outer_xml_tag=False, quote_xml=False
|
2021-10-20 22:34:06 +02:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
# -------------------------- FICHE ETUDIANT --------------------------
|
2024-01-20 14:49:36 +01:00
|
|
|
sco_publish("/fiche_etud", sco_page_etud.fiche_etud, Permission.ScoView)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/etud_upload_file_form",
|
|
|
|
sco_archives_etud.etud_upload_file_form,
|
2024-01-20 17:37:24 +01:00
|
|
|
Permission.ViewEtudData,
|
2021-06-25 19:24:12 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
sco_publish(
|
2021-07-13 14:53:14 +02:00
|
|
|
"/etud_delete_archive",
|
|
|
|
sco_archives_etud.etud_delete_archive,
|
2024-01-20 17:37:24 +01:00
|
|
|
Permission.ViewEtudData,
|
2021-07-13 14:53:14 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/etud_get_archived_file",
|
|
|
|
sco_archives_etud.etud_get_archived_file,
|
2024-01-20 17:37:24 +01:00
|
|
|
Permission.ViewEtudData,
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/etudarchive_import_files_form",
|
|
|
|
sco_archives_etud.etudarchive_import_files_form,
|
2024-01-20 17:37:24 +01:00
|
|
|
Permission.ViewEtudData,
|
2021-06-25 19:24:12 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/etudarchive_generate_excel_sample",
|
|
|
|
sco_archives_etud.etudarchive_generate_excel_sample,
|
|
|
|
Permission.ScoView,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Debouche / devenir etudiant
|
|
|
|
sco_publish(
|
2021-08-10 17:12:10 +02:00
|
|
|
"/itemsuivi_suppress",
|
|
|
|
sco_debouche.itemsuivi_suppress,
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.EtudChangeAdr,
|
2021-08-10 17:12:10 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
sco_publish(
|
2021-08-10 17:12:10 +02:00
|
|
|
"/itemsuivi_create",
|
|
|
|
sco_debouche.itemsuivi_create,
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.EtudChangeAdr,
|
2021-08-10 17:12:10 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
sco_publish(
|
2021-08-10 17:12:10 +02:00
|
|
|
"/itemsuivi_set_date",
|
|
|
|
sco_debouche.itemsuivi_set_date,
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.EtudChangeAdr,
|
2021-08-10 17:12:10 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
sco_publish(
|
|
|
|
"/itemsuivi_set_situation",
|
|
|
|
sco_debouche.itemsuivi_set_situation,
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.EtudChangeAdr,
|
2021-08-10 17:12:10 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
sco_publish(
|
|
|
|
"/itemsuivi_list_etud", sco_debouche.itemsuivi_list_etud, Permission.ScoView
|
|
|
|
)
|
|
|
|
sco_publish("/itemsuivi_tag_list", sco_debouche.itemsuivi_tag_list, Permission.ScoView)
|
|
|
|
sco_publish(
|
|
|
|
"/itemsuivi_tag_search", sco_debouche.itemsuivi_tag_search, Permission.ScoView
|
|
|
|
)
|
|
|
|
sco_publish(
|
2021-08-10 17:12:10 +02:00
|
|
|
"/itemsuivi_tag_set",
|
|
|
|
sco_debouche.itemsuivi_tag_set,
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.EtudChangeAdr,
|
2021-08-10 17:12:10 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
@bp.route("/doAddAnnotation", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudAddAnnotations)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-08-10 17:12:10 +02:00
|
|
|
def doAddAnnotation(etudid, comment):
|
2021-06-02 22:40:34 +02:00
|
|
|
"ajoute annotation sur etudiant"
|
2023-03-20 11:17:38 +01:00
|
|
|
_ = Identite.get_etud(etudid) # check existence
|
2022-08-25 18:48:48 +02:00
|
|
|
if comment:
|
|
|
|
cnx = ndb.GetDBConnexion()
|
|
|
|
sco_etud.etud_annotations_create(
|
|
|
|
cnx,
|
|
|
|
args={
|
|
|
|
"etudid": etudid,
|
|
|
|
"comment": comment,
|
|
|
|
"author": current_user.user_name,
|
|
|
|
},
|
|
|
|
)
|
2024-07-08 23:13:45 +02:00
|
|
|
Scolog.logdb(method="addAnnotation", etudid=etudid, commit=True)
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2024-01-20 14:49:36 +01:00
|
|
|
url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
2021-07-11 17:37:12 +02:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
@bp.route("/doSuppressAnnotation", methods=["GET", "POST"])
|
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-09-27 10:20:10 +02:00
|
|
|
def doSuppressAnnotation(etudid, annotation_id):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Suppression annotation."""
|
2021-07-29 16:31:15 +02:00
|
|
|
if not sco_permissions_check.can_suppress_annotation(annotation_id):
|
2021-06-02 22:40:34 +02:00
|
|
|
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
|
|
|
|
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-19 23:21:37 +02:00
|
|
|
annos = sco_etud.etud_annotations_list(cnx, args={"id": annotation_id})
|
2021-06-02 22:40:34 +02:00
|
|
|
if len(annos) != 1:
|
|
|
|
raise ScoValueError("annotation inexistante !")
|
|
|
|
anno = annos[0]
|
2024-07-08 23:13:45 +02:00
|
|
|
log(f"suppress annotation: {anno}")
|
|
|
|
Scolog.logdb(method="SuppressAnnotation", etudid=etudid)
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_etud.etud_annotations_delete(cnx, annotation_id)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2023-04-15 10:50:20 +02:00
|
|
|
flash("Annotation supprimée")
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2021-07-11 17:37:12 +02:00
|
|
|
url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud",
|
2021-07-11 17:37:12 +02:00
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
etudid=etudid,
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-09-27 12:21:19 +02:00
|
|
|
@bp.route("/form_change_coordonnees", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudChangeAdr)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-27 12:21:19 +02:00
|
|
|
def form_change_coordonnees(etudid):
|
2021-06-02 22:40:34 +02:00
|
|
|
"edit coordonnees etudiant"
|
2024-01-20 17:37:24 +01:00
|
|
|
if not current_user.has_permission(Permission.ViewEtudData):
|
|
|
|
raise ScoPermissionDenied()
|
2023-03-20 11:17:38 +01:00
|
|
|
etud = Identite.get_etud(etudid)
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-19 23:21:37 +02:00
|
|
|
adrs = sco_etud.adresse_list(cnx, {"etudid": etudid})
|
2021-06-02 22:40:34 +02:00
|
|
|
if adrs:
|
|
|
|
adr = adrs[0]
|
|
|
|
else:
|
|
|
|
adr = {} # no data for this student
|
|
|
|
H = [
|
2022-09-27 12:21:19 +02:00
|
|
|
f"""{html_sco_header.sco_header(
|
|
|
|
page_title=f"Changement coordonnées de {etud.nomprenom}"
|
|
|
|
)}
|
|
|
|
<h2>Changement des coordonnées de {etud.nomprenom}</h2>
|
|
|
|
<p>"""
|
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
|
|
|
(
|
|
|
|
("adresse_id", {"input_type": "hidden"}),
|
|
|
|
("etudid", {"input_type": "hidden"}),
|
|
|
|
(
|
|
|
|
"email",
|
|
|
|
{
|
|
|
|
"size": 40,
|
|
|
|
"title": "e-mail",
|
|
|
|
"explanation": "adresse institutionnelle",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"emailperso",
|
|
|
|
{
|
|
|
|
"size": 40,
|
|
|
|
"title": "e-mail",
|
|
|
|
"explanation": "adresse personnelle",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"domicile",
|
|
|
|
{"size": 65, "explanation": "numéro, rue", "title": "Adresse"},
|
|
|
|
),
|
|
|
|
("codepostaldomicile", {"size": 6, "title": "Code postal"}),
|
|
|
|
("villedomicile", {"size": 20, "title": "Ville"}),
|
|
|
|
("paysdomicile", {"size": 20, "title": "Pays"}),
|
|
|
|
("", {"input_type": "separator", "default": " "}),
|
|
|
|
("telephone", {"size": 13, "title": "Téléphone"}),
|
|
|
|
("telephonemobile", {"size": 13, "title": "Mobile"}),
|
|
|
|
),
|
|
|
|
initvalues=adr,
|
2024-04-06 12:16:53 +02:00
|
|
|
submitlabel="Enregistrer",
|
|
|
|
cancelbutton="Annuler",
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2024-01-20 14:49:36 +01:00
|
|
|
dest_url = url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
2021-06-02 22:40:34 +02:00
|
|
|
if tf[0] == 0:
|
2022-09-27 12:21:19 +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(dest_url)
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
|
|
|
if adrs:
|
2021-08-21 00:24:51 +02:00
|
|
|
sco_etud.adresse_edit(cnx, args=tf[2])
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_etud.adresse_create(cnx, args=tf[2])
|
2024-07-08 23:13:45 +02:00
|
|
|
Scolog.logdb(method="changeCoordonnees", etudid=etudid, commit=True)
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(dest_url)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
# --- Gestion des groupes:
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
2021-10-04 22:05:05 +02:00
|
|
|
"/affect_groups",
|
|
|
|
sco_groups_edit.affect_groups,
|
2021-07-13 14:53:14 +02:00
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/XMLgetGroupsInPartition", sco_groups.XMLgetGroupsInPartition, Permission.ScoView
|
|
|
|
)
|
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/formsemestre_partition_list",
|
|
|
|
sco_groups.formsemestre_partition_list,
|
|
|
|
Permission.ScoView,
|
|
|
|
)
|
|
|
|
|
2022-09-02 15:07:59 +02:00
|
|
|
sco_publish("/setGroups", sco_groups.setGroups, Permission.ScoView, methods=["POST"])
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
|
|
|
"/group_rename",
|
2023-11-06 22:05:38 +01:00
|
|
|
sco_groups_edit.group_rename,
|
2021-07-13 14:53:14 +02:00
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2023-09-06 08:48:00 +02:00
|
|
|
|
|
|
|
@bp.route("/groups_auto_repartition/<int:partition_id>", methods=["GET", "POST"])
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def groups_auto_repartition(partition_id: int):
|
|
|
|
"Réparti les etudiants dans des groupes dans une partition"
|
|
|
|
partition: Partition = Partition.query.get_or_404(partition_id)
|
|
|
|
return sco_groups.groups_auto_repartition(partition)
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
2022-05-22 05:01:25 +02:00
|
|
|
"/edit_partition_form",
|
|
|
|
sco_groups.edit_partition_form,
|
2021-07-13 14:53:14 +02:00
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
|
|
|
"/partition_delete",
|
|
|
|
sco_groups.partition_delete,
|
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
|
|
|
"/partition_set_attr",
|
|
|
|
sco_groups.partition_set_attr,
|
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
|
|
|
"/partition_move",
|
|
|
|
sco_groups.partition_move,
|
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
|
|
|
"/partition_set_name",
|
|
|
|
sco_groups.partition_set_name,
|
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
|
|
|
"/partition_rename",
|
|
|
|
sco_groups.partition_rename,
|
|
|
|
Permission.ScoView,
|
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-13 14:53:14 +02:00
|
|
|
sco_publish(
|
|
|
|
"/partition_create",
|
|
|
|
sco_groups.partition_create,
|
2022-05-22 05:01:25 +02:00
|
|
|
Permission.ScoView, # controle d'access ad-hoc
|
2021-07-13 14:53:14 +02:00
|
|
|
methods=["GET", "POST"],
|
|
|
|
)
|
2022-05-22 05:01:25 +02:00
|
|
|
|
2023-04-06 16:10:32 +02:00
|
|
|
|
2022-07-22 17:37:01 +02:00
|
|
|
# Nouvel éditeur de partitions et groupe, @SebL Jul 2022
|
|
|
|
@bp.route("/partition_editor", methods=["GET", "POST"])
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
@scodoc7func
|
2023-07-21 09:25:39 +02:00
|
|
|
def partition_editor(formsemestre_id: int, edit_partition=False):
|
|
|
|
"""Page édition groupes et partitions
|
|
|
|
Si edit_partition, se met en mode édition des partitions.
|
|
|
|
"""
|
2022-07-22 17:37:01 +02:00
|
|
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
2023-07-21 09:25:39 +02:00
|
|
|
edit_partition = bool(int(edit_partition)) if edit_partition else False
|
2022-12-17 13:43:47 +01:00
|
|
|
formsemestre.setup_parcours_groups()
|
2024-08-15 00:04:35 +02:00
|
|
|
return render_template(
|
|
|
|
"scolar/partition_editor.j2",
|
|
|
|
formsemestre=formsemestre,
|
|
|
|
read_only=not formsemestre.can_change_groups(),
|
|
|
|
edit_partition=edit_partition,
|
|
|
|
is_edt_configured=sco_edt_cal.is_edt_configured(),
|
|
|
|
sco=ScoData(formsemestre=formsemestre),
|
|
|
|
scu=scu,
|
|
|
|
)
|
2022-07-22 17:37:01 +02:00
|
|
|
|
2022-05-22 05:01:25 +02:00
|
|
|
|
2023-03-02 23:29:25 +01:00
|
|
|
@bp.route("/students_groups_auto_assignment", methods=["GET", "POST"])
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
@scodoc7func
|
|
|
|
def students_groups_auto_assignment(formsemestre_id: int):
|
2024-07-17 14:58:49 +02:00
|
|
|
"""Répartition auto des groupes"""
|
2023-03-02 23:29:25 +01:00
|
|
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
|
|
|
H = [
|
|
|
|
html_sco_header.sco_header(
|
2024-07-17 14:58:49 +02:00
|
|
|
page_title="Répartition des groupes",
|
2023-03-02 23:29:25 +01:00
|
|
|
),
|
|
|
|
render_template(
|
|
|
|
"scolar/students_groups_auto_assignment.j2",
|
|
|
|
formsemestre=formsemestre,
|
|
|
|
),
|
|
|
|
html_sco_header.sco_footer(),
|
|
|
|
]
|
|
|
|
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2022-05-22 05:01:25 +02:00
|
|
|
@bp.route("/create_partition_parcours", methods=["GET", "POST"])
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
@scodoc7func
|
|
|
|
def create_partition_parcours(formsemestre_id):
|
2022-05-26 03:55:03 +02:00
|
|
|
"""Création d'une partitions nommée "Parcours" (PARTITION_PARCOURS)
|
|
|
|
avec un groupe par parcours."""
|
2023-01-24 00:35:15 +01:00
|
|
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
2022-05-28 11:38:22 +02:00
|
|
|
formsemestre.setup_parcours_groups()
|
2022-05-22 05:01:25 +02:00
|
|
|
return flask.redirect(
|
|
|
|
url_for(
|
|
|
|
"scolar.edit_partition_form",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=formsemestre_id,
|
|
|
|
)
|
|
|
|
)
|
2021-08-11 00:36:07 +02:00
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
sco_publish("/etud_info_html", sco_page_etud.etud_info_html, Permission.ScoView)
|
|
|
|
|
|
|
|
# --- Gestion des photos:
|
|
|
|
sco_publish("/get_photo_image", sco_photos.get_photo_image, Permission.ScoView)
|
|
|
|
|
|
|
|
sco_publish("/etud_photo_html", sco_photos.etud_photo_html, Permission.ScoView)
|
|
|
|
|
|
|
|
|
2024-06-21 19:13:53 +02:00
|
|
|
@bp.route("/etud_photo_orig_page/<int:etudid>")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2021-06-02 22:40:34 +02:00
|
|
|
@permission_required(Permission.ScoView)
|
2024-06-21 19:13:53 +02:00
|
|
|
def etud_photo_orig_page(etudid):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Page with photo in orig. size"
|
2024-06-21 19:13:53 +02:00
|
|
|
etud = Identite.get_etud(etudid)
|
|
|
|
return f"""{
|
|
|
|
html_sco_header.sco_header(etudid=etud.id, page_title=etud.nomprenom)
|
|
|
|
}
|
|
|
|
<h2>{etud.nomprenom}</h2>
|
|
|
|
<div>
|
|
|
|
<a href="{etud.url_fiche()}">{etud.photo_html(size='orig')}</a>
|
|
|
|
</div>
|
|
|
|
{html_sco_header.sco_footer()}
|
|
|
|
"""
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
@bp.route("/form_change_photo", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudChangeAdr)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-30 22:43:39 +02:00
|
|
|
def form_change_photo(etudid=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Formulaire changement photo étudiant"""
|
2023-08-11 23:15:17 +02:00
|
|
|
etud = Identite.get_etud(etudid)
|
|
|
|
if sco_photos.etud_photo_is_local(etud.photo_filename):
|
|
|
|
photo_loc = "dans ScoDoc"
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
2023-08-11 23:15:17 +02:00
|
|
|
photo_loc = "externe"
|
2021-06-02 22:40:34 +02:00
|
|
|
H = [
|
2021-07-29 16:31:15 +02:00
|
|
|
html_sco_header.sco_header(page_title="Changement de photo"),
|
2023-08-11 23:15:17 +02:00
|
|
|
f"""<h2>Changement de la photo de {etud.nomprenom}</h2>
|
|
|
|
<p>Photo actuelle ({photo_loc}):
|
|
|
|
{sco_photos.etud_photo_html(etudid=etud.id, title="photo actuelle")}
|
|
|
|
</p>
|
|
|
|
<p>Le fichier ne doit pas dépasser {sco_photos.MAX_FILE_SIZE//1024}Ko
|
|
|
|
(recadrer l'image, format "portrait" de préférence).
|
|
|
|
</p>
|
|
|
|
<p>L'image sera automagiquement réduite pour obtenir une hauteur de 90 pixels.</p>
|
|
|
|
""",
|
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
|
|
|
(
|
2023-08-11 23:15:17 +02:00
|
|
|
("etudid", {"default": etud.id, "input_type": "hidden"}),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
"photofile",
|
|
|
|
{"input_type": "file", "title": "Fichier image", "size": 20},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
submitlabel="Valider",
|
|
|
|
cancelbutton="Annuler",
|
|
|
|
)
|
2024-01-20 14:49:36 +01:00
|
|
|
dest_url = url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etud.id)
|
2021-06-02 22:40:34 +02:00
|
|
|
if tf[0] == 0:
|
|
|
|
return (
|
|
|
|
"\n".join(H)
|
2023-08-11 23:15:17 +02:00
|
|
|
+ f"""
|
|
|
|
{tf[1]}
|
|
|
|
<p><a class="stdlink" href="{
|
|
|
|
url_for("scolar.form_suppress_photo",
|
|
|
|
scodoc_dept=g.scodoc_dept, etudid=etud.id)
|
|
|
|
}">Supprimer cette photo</a></p>
|
|
|
|
{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(dest_url)
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
2021-07-26 15:23:07 +02:00
|
|
|
data = tf[2]["photofile"].read()
|
2022-09-02 20:56:55 +02:00
|
|
|
status, err_msg = sco_photos.store_photo(
|
|
|
|
etud, data, tf[2]["photofile"].filename
|
|
|
|
)
|
|
|
|
if status:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(dest_url)
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
2022-09-02 20:56:55 +02:00
|
|
|
H.append(f"""<p class="warning">Erreur: {err_msg}</p>""")
|
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
|
|
|
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
@bp.route("/form_suppress_photo", methods=["POST", "GET"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudChangeAdr)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-30 22:43:39 +02:00
|
|
|
def form_suppress_photo(etudid=None, dialog_confirmed=False):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Formulaire suppression photo étudiant"""
|
2023-03-20 11:17:38 +01:00
|
|
|
etud = Identite.get_etud(etudid)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not dialog_confirmed:
|
|
|
|
return scu.confirm_dialog(
|
2021-12-20 22:53:09 +01:00
|
|
|
f"<p>Confirmer la suppression de la photo de {etud.nom_disp()} ?</p>",
|
2021-06-02 22:40:34 +02:00
|
|
|
dest_url="",
|
2021-07-11 17:37:12 +02:00
|
|
|
cancel_url=url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etud.id
|
2021-07-11 17:37:12 +02:00
|
|
|
),
|
2021-12-20 22:53:09 +01:00
|
|
|
parameters={"etudid": etud.id},
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
2021-09-27 10:20:10 +02:00
|
|
|
sco_photos.suppress_photo(etud)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2024-01-20 14:49:36 +01:00
|
|
|
url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etud.id)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
2022-09-30 22:43:39 +02:00
|
|
|
@bp.route("/form_dem")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-30 22:43:39 +02:00
|
|
|
def form_dem(etudid, formsemestre_id):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Formulaire Démission Etudiant"
|
2022-09-30 22:43:39 +02:00
|
|
|
return _form_dem_of_def(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
operation_name="Démission",
|
2022-09-30 22:43:39 +02:00
|
|
|
operation_method="do_dem_etudiant",
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
@bp.route("/form_def")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-30 22:43:39 +02:00
|
|
|
def form_def(etudid, formsemestre_id):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Formulaire Défaillance Etudiant"
|
2022-09-30 22:43:39 +02:00
|
|
|
return _form_dem_of_def(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
operation_name="Défaillance",
|
2022-09-30 22:43:39 +02:00
|
|
|
operation_method="do_def_etudiant",
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
def _form_dem_of_def(
|
|
|
|
etudid: int,
|
|
|
|
formsemestre_id: int,
|
|
|
|
operation_name: str = "",
|
|
|
|
operation_method: str = "",
|
2021-06-02 22:40:34 +02:00
|
|
|
):
|
|
|
|
"Formulaire démission ou défaillance Etudiant"
|
2023-03-20 11:17:38 +01:00
|
|
|
etud = Identite.get_etud(etudid)
|
2022-09-30 22:43:39 +02:00
|
|
|
formsemestre: FormSemestre = FormSemestre.query.filter_by(
|
|
|
|
id=formsemestre_id, dept_id=g.scodoc_dept_id
|
|
|
|
).first_or_404()
|
|
|
|
if not formsemestre.etat:
|
2021-06-02 22:40:34 +02:00
|
|
|
raise ScoValueError("Modification impossible: semestre verrouille")
|
2024-04-02 23:37:23 +02:00
|
|
|
nowdmy = time.strftime(scu.DATE_FMT)
|
2021-06-02 22:40:34 +02:00
|
|
|
#
|
2021-06-13 18:29:53 +02:00
|
|
|
header = html_sco_header.sco_header(
|
2022-09-30 22:43:39 +02:00
|
|
|
page_title=f"""{operation_name} de {etud.nomprenom} (du semestre {formsemestre.titre_mois()})"""
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2022-10-01 10:39:46 +02:00
|
|
|
validations_descr = formsemestre.etud_validations_description_html(etudid)
|
2022-09-30 22:43:39 +02:00
|
|
|
return f"""
|
|
|
|
{header}
|
|
|
|
<h2><font color="#FF0000">{operation_name} de</font> {etud.nomprenom} ({formsemestre.titre_mois()})</h2>
|
2023-10-25 23:07:34 +02:00
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
<form action="{operation_method}" method="get">
|
|
|
|
<div><b>Date de la {operation_name.lower()} (J/M/AAAA): </b>
|
|
|
|
<input type="text" name="event_date" width=20 value="{nowdmy}">
|
|
|
|
</div>
|
|
|
|
<input type="hidden" name="etudid" value="{etudid}">
|
|
|
|
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}">
|
|
|
|
<div class="vertical_spacing_but"><input type="submit" value="Confirmer"></div>
|
|
|
|
</form>
|
2022-10-01 10:39:46 +02:00
|
|
|
|
|
|
|
<div class="rappel_decisions">
|
|
|
|
{'<p class="warning">Attention: il y a des décisions de jury déjà prises !</p>' if validations_descr else ""}
|
|
|
|
{validations_descr}
|
2023-10-25 23:07:34 +02:00
|
|
|
{('<p><a class="stdlink" href="'
|
|
|
|
+ url_for("notes.formsemestre_validation_but", scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=formsemestre_id, etudid=etudid)
|
2022-10-01 10:39:46 +02:00
|
|
|
+ '">modifier ces décisions</a></p>') if validations_descr else ""}
|
|
|
|
</div>
|
2022-09-30 22:43:39 +02:00
|
|
|
{html_sco_header.sco_footer()}
|
2021-06-02 22:40:34 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
@bp.route("/do_dem_etudiant")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-30 22:43:39 +02:00
|
|
|
def do_dem_etudiant(etudid, formsemestre_id, event_date=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Déclare la démission d'un etudiant dans le semestre"
|
2021-06-21 12:13:25 +02:00
|
|
|
return _do_dem_or_def_etud(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
event_date=event_date,
|
2022-09-30 22:43:39 +02:00
|
|
|
etat_new=scu.DEMISSION,
|
|
|
|
operation_method="dem_etudiant",
|
2021-06-02 22:40:34 +02:00
|
|
|
event_type="DEMISSION",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
@bp.route("/do_def_etudiant")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-30 22:43:39 +02:00
|
|
|
def do_def_etudiant(etudid, formsemestre_id, event_date=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Déclare la défaillance d'un etudiant dans le semestre"
|
2021-06-21 12:13:25 +02:00
|
|
|
return _do_dem_or_def_etud(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
event_date=event_date,
|
2023-02-12 13:36:47 +01:00
|
|
|
etat_new=codes_cursus.DEF,
|
2021-06-02 22:40:34 +02:00
|
|
|
operation_method="defailleEtudiant",
|
|
|
|
event_type="DEFAILLANCE",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-06-21 12:13:25 +02:00
|
|
|
def _do_dem_or_def_etud(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
event_date=None,
|
2022-09-30 22:43:39 +02:00
|
|
|
etat_new=scu.DEMISSION, # DEMISSION or DEF
|
2021-06-02 22:40:34 +02:00
|
|
|
operation_method="demEtudiant",
|
|
|
|
event_type="DEMISSION",
|
2021-09-27 10:20:10 +02:00
|
|
|
redirect=True,
|
2021-06-02 22:40:34 +02:00
|
|
|
):
|
|
|
|
"Démission ou défaillance d'un étudiant"
|
2021-11-03 16:15:39 +01:00
|
|
|
sco_formsemestre_inscriptions.do_formsemestre_demission(
|
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
event_date=event_date,
|
2022-09-30 22:43:39 +02:00
|
|
|
etat_new=etat_new, # DEMISSION or DEF
|
2021-11-03 16:15:39 +01:00
|
|
|
operation_method=operation_method,
|
|
|
|
event_type=event_type,
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-09-27 10:20:10 +02:00
|
|
|
if redirect:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2024-01-20 14:49:36 +01:00
|
|
|
url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
2021-07-11 17:37:12 +02:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
@bp.route("/do_cancel_dem", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-30 22:43:39 +02:00
|
|
|
def do_cancel_dem(etudid, formsemestre_id, dialog_confirmed=False, args=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Annule une démission"
|
2021-06-21 12:13:25 +02:00
|
|
|
return _do_cancel_dem_or_def(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
dialog_confirmed=dialog_confirmed,
|
|
|
|
args=args,
|
|
|
|
operation_name="démission",
|
2022-09-30 22:43:39 +02:00
|
|
|
etat_current=scu.DEMISSION,
|
|
|
|
etat_new=scu.INSCRIT,
|
2021-06-02 22:40:34 +02:00
|
|
|
operation_method="cancelDem",
|
|
|
|
event_type="DEMISSION",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
@bp.route("/do_cancel_def", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2022-09-30 22:43:39 +02:00
|
|
|
def do_cancel_def(etudid, formsemestre_id, dialog_confirmed=False, args=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Annule la défaillance de l'étudiant"
|
2021-06-21 12:13:25 +02:00
|
|
|
return _do_cancel_dem_or_def(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
dialog_confirmed=dialog_confirmed,
|
|
|
|
args=args,
|
|
|
|
operation_name="défaillance",
|
2023-02-12 13:36:47 +01:00
|
|
|
etat_current=codes_cursus.DEF,
|
2022-09-30 22:43:39 +02:00
|
|
|
etat_new=scu.INSCRIT,
|
|
|
|
operation_method="cancel_def",
|
2021-06-02 22:40:34 +02:00
|
|
|
event_type="DEFAILLANCE",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-06-21 12:13:25 +02:00
|
|
|
def _do_cancel_dem_or_def(
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
dialog_confirmed=False,
|
|
|
|
args=None,
|
|
|
|
operation_name="", # "démission" ou "défaillance"
|
2022-09-30 22:43:39 +02:00
|
|
|
etat_current=scu.DEMISSION,
|
|
|
|
etat_new=scu.INSCRIT,
|
|
|
|
operation_method="cancel_dem",
|
2021-06-02 22:40:34 +02:00
|
|
|
event_type="DEMISSION",
|
|
|
|
):
|
2022-09-30 22:43:39 +02:00
|
|
|
"Annule une démission ou une défaillance"
|
2023-03-20 11:17:38 +01:00
|
|
|
etud = Identite.get_etud(etudid)
|
2022-09-30 22:43:39 +02:00
|
|
|
formsemestre: FormSemestre = FormSemestre.query.filter_by(
|
|
|
|
id=formsemestre_id, dept_id=g.scodoc_dept_id
|
|
|
|
).first_or_404()
|
2021-06-02 22:40:34 +02:00
|
|
|
# check lock
|
2022-09-30 22:43:39 +02:00
|
|
|
if not formsemestre.etat:
|
2021-06-02 22:40:34 +02:00
|
|
|
raise ScoValueError("Modification impossible: semestre verrouille")
|
|
|
|
# verif
|
2022-09-30 22:43:39 +02:00
|
|
|
if formsemestre_id not in (inscr.formsemestre_id for inscr in etud.inscriptions()):
|
|
|
|
raise ScoValueError("étudiant non inscrit dans ce semestre !")
|
|
|
|
if etud.inscription_etat(formsemestre_id) != etat_current:
|
|
|
|
raise ScoValueError(f"etudiant non {operation_name} !")
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
if not dialog_confirmed:
|
|
|
|
return scu.confirm_dialog(
|
2022-09-30 22:43:39 +02:00
|
|
|
f"<p>Confirmer l'annulation de la {operation_name} ?</p>",
|
2021-06-02 22:40:34 +02:00
|
|
|
dest_url="",
|
2021-07-11 17:37:12 +02:00
|
|
|
cancel_url=url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid
|
2021-07-11 17:37:12 +02:00
|
|
|
),
|
2021-06-02 22:40:34 +02:00
|
|
|
parameters={"etudid": etudid, "formsemestre_id": formsemestre_id},
|
|
|
|
)
|
|
|
|
#
|
2022-09-30 22:43:39 +02:00
|
|
|
inscr = next(
|
|
|
|
inscr
|
|
|
|
for inscr in etud.inscriptions()
|
|
|
|
if inscr.formsemestre_id == formsemestre_id
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2022-09-30 22:43:39 +02:00
|
|
|
inscr.etat = etat_new
|
|
|
|
db.session.add(inscr)
|
|
|
|
Scolog.logdb(method=operation_method, etudid=etudid)
|
|
|
|
# Efface les évènements
|
|
|
|
for event in ScolarEvent.query.filter_by(
|
|
|
|
etudid=etudid, formsemestre_id=formsemestre_id, event_type=event_type
|
|
|
|
):
|
|
|
|
db.session.delete(event)
|
|
|
|
|
|
|
|
db.session.commit()
|
2023-06-01 19:48:52 +02:00
|
|
|
sco_cache.invalidate_formsemestre(formsemestre_id=formsemestre_id)
|
|
|
|
|
2022-09-30 22:43:39 +02:00
|
|
|
flash(f"{operation_name} annulée.")
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2024-01-20 14:49:36 +01:00
|
|
|
url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
2021-07-11 17:37:12 +02:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-06-25 18:25:46 +02:00
|
|
|
@bp.route("/etudident_create_form", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-09-27 10:20:10 +02:00
|
|
|
def etudident_create_form():
|
2021-06-02 22:40:34 +02:00
|
|
|
"formulaire creation individuelle etudiant"
|
2021-09-27 10:20:10 +02:00
|
|
|
return _etudident_create_or_edit_form(edit=False)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2021-06-25 18:25:46 +02:00
|
|
|
@bp.route("/etudident_edit_form", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-09-27 10:20:10 +02:00
|
|
|
def etudident_edit_form():
|
2021-06-02 22:40:34 +02:00
|
|
|
"formulaire edition individuelle etudiant"
|
2024-01-20 17:37:24 +01:00
|
|
|
if not current_user.has_permission(Permission.ViewEtudData):
|
|
|
|
raise ScoPermissionDenied()
|
2021-09-27 10:20:10 +02:00
|
|
|
return _etudident_create_or_edit_form(edit=True)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2024-03-24 10:34:02 +01:00
|
|
|
def _validate_date_naissance(val: str, field) -> bool:
|
2024-05-13 17:31:54 +02:00
|
|
|
"vrai si date saisie valide (peut être vide)"
|
|
|
|
if not val:
|
|
|
|
return True
|
2024-03-24 10:34:02 +01:00
|
|
|
try:
|
|
|
|
date_naissance = scu.convert_fr_date(val)
|
|
|
|
except ScoValueError:
|
|
|
|
return False
|
|
|
|
return date_naissance < datetime.datetime.now()
|
|
|
|
|
|
|
|
|
2021-09-27 10:20:10 +02:00
|
|
|
def _etudident_create_or_edit_form(edit):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Le formulaire HTML"
|
2021-12-04 21:06:32 +01:00
|
|
|
H = [html_sco_header.sco_header()]
|
2021-07-29 10:19:00 +02:00
|
|
|
F = html_sco_header.sco_footer()
|
2021-09-28 09:14:04 +02:00
|
|
|
vals = scu.get_request_args()
|
2021-09-27 10:20:10 +02:00
|
|
|
etudid = vals.get("etudid", None)
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-02 22:40:34 +02:00
|
|
|
descr = []
|
|
|
|
if not edit:
|
|
|
|
# creation nouvel etudiant
|
|
|
|
initvalues = {}
|
|
|
|
submitlabel = "Ajouter cet étudiant"
|
|
|
|
H.append(
|
|
|
|
"""<h2>Création d'un étudiant</h2>
|
2022-09-05 14:58:57 +02:00
|
|
|
<p class="warning">En général, il est <b>recommandé</b> d'importer les
|
|
|
|
étudiants depuis Apogée ou via un fichier Excel (menu <b>Inscriptions</b>
|
2022-09-03 09:29:40 +02:00
|
|
|
dans le semestre).
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
N'utilisez ce formulaire au cas par cas que <b>pour les cas particuliers</b>
|
|
|
|
ou si votre établissement n'utilise pas d'autre logiciel de gestion des
|
|
|
|
inscriptions.
|
|
|
|
</p>
|
|
|
|
<p class"warning"><em>L'étudiant créé ne sera pas inscrit.
|
2021-06-02 22:40:34 +02:00
|
|
|
Pensez à l'inscrire dans un semestre !</em></p>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
# edition donnees d'un etudiant existant
|
|
|
|
# setup form init values
|
|
|
|
if not etudid:
|
|
|
|
raise ValueError("missing etudid parameter")
|
2023-10-08 10:01:23 +02:00
|
|
|
etud_o: Identite = Identite.get_etud(etudid)
|
2021-06-02 22:40:34 +02:00
|
|
|
descr.append(("etudid", {"default": etudid, "input_type": "hidden"}))
|
2023-10-08 10:01:23 +02:00
|
|
|
H.append(f"""<h2>Modification des données de {etud_o.html_link_fiche()}</h2>""")
|
2021-06-19 23:21:37 +02:00
|
|
|
initvalues = sco_etud.etudident_list(cnx, {"etudid": etudid})
|
2021-06-02 22:40:34 +02:00
|
|
|
assert len(initvalues) == 1
|
|
|
|
initvalues = initvalues[0]
|
|
|
|
submitlabel = "Modifier les données"
|
|
|
|
|
2021-09-28 09:14:04 +02:00
|
|
|
vals = scu.get_request_args()
|
2021-09-27 10:20:10 +02:00
|
|
|
nom = vals.get("nom", None)
|
2021-06-02 22:40:34 +02:00
|
|
|
if nom is None:
|
|
|
|
nom = initvalues.get("nom", None)
|
|
|
|
if nom is None:
|
|
|
|
infos = []
|
|
|
|
else:
|
2021-09-27 10:20:10 +02:00
|
|
|
prenom = vals.get("prenom", "")
|
|
|
|
if vals.get("tf_submitted", False) and not prenom:
|
2021-06-02 22:40:34 +02:00
|
|
|
prenom = initvalues.get("prenom", "")
|
2021-08-20 10:51:42 +02:00
|
|
|
infos = sco_portal_apogee.get_infos_apogee(nom, prenom)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
if infos:
|
|
|
|
formatted_infos = [
|
|
|
|
"""
|
|
|
|
<script type="text/javascript">
|
|
|
|
function copy_nip(nip) {
|
|
|
|
document.tf.code_nip.value = nip;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<ol>"""
|
|
|
|
]
|
|
|
|
nanswers = len(infos)
|
2022-09-03 09:29:40 +02:00
|
|
|
nmax = 10 # nb max de reponse montrées
|
2021-06-02 22:40:34 +02:00
|
|
|
infos = infos[:nmax]
|
|
|
|
for i in infos:
|
|
|
|
formatted_infos.append("<li><ul>")
|
|
|
|
for k in i.keys():
|
|
|
|
if k != "nip":
|
|
|
|
item = "<li>%s : %s</li>" % (k, i[k])
|
|
|
|
else:
|
|
|
|
item = (
|
|
|
|
'<li><form>%s : %s <input type="button" value="copier ce code" onmousedown="copy_nip(%s);"/></form></li>'
|
|
|
|
% (k, i[k], i[k])
|
|
|
|
)
|
|
|
|
formatted_infos.append(item)
|
|
|
|
|
|
|
|
formatted_infos.append("</ul></li>")
|
|
|
|
formatted_infos.append("</ol>")
|
|
|
|
m = "%d étudiants trouvés" % nanswers
|
|
|
|
if len(infos) != nanswers:
|
|
|
|
m += " (%d montrés)" % len(infos)
|
|
|
|
A = """<div class="infoapogee">
|
|
|
|
<h5>Informations Apogée</h5>
|
|
|
|
<p>%s</p>
|
|
|
|
%s
|
|
|
|
</div>""" % (
|
|
|
|
m,
|
|
|
|
"\n".join(formatted_infos),
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
A = """<div class="infoapogee"><p>Pas d'informations d'Apogée</p></div>"""
|
|
|
|
|
2021-07-28 17:03:54 +02:00
|
|
|
require_ine = sco_preferences.get_preference("always_require_ine")
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
descr += [
|
|
|
|
("adm_id", {"input_type": "hidden"}),
|
|
|
|
("nom", {"size": 25, "title": "Nom", "allow_null": False}),
|
|
|
|
("nom_usuel", {"size": 25, "title": "Nom usuel", "allow_null": True}),
|
|
|
|
(
|
|
|
|
"prenom",
|
|
|
|
{
|
|
|
|
"size": 25,
|
|
|
|
"title": "Prénom",
|
|
|
|
"allow_null": scu.CONFIG.ALLOW_NULL_PRENOM,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"civilite",
|
|
|
|
{
|
|
|
|
"input_type": "menu",
|
|
|
|
"labels": ["Homme", "Femme", "Autre/neutre"],
|
|
|
|
"allowed_values": ["M", "F", "X"],
|
|
|
|
"title": "Civilité",
|
|
|
|
},
|
|
|
|
),
|
2023-03-13 06:39:36 +01:00
|
|
|
(
|
|
|
|
"prenom_etat_civil",
|
|
|
|
{
|
|
|
|
"size": 25,
|
|
|
|
"title": "Prénom (état-civil)",
|
|
|
|
"allow_null": True,
|
|
|
|
"explanation": "Si précisé, remplace le prénom d'usage dans les documents officiels",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"civilite_etat_civil",
|
|
|
|
{
|
|
|
|
"input_type": "menu",
|
2023-10-16 22:51:31 +02:00
|
|
|
"labels": ["(identique à civilité)", "Homme", "Femme", "Autre/neutre"],
|
|
|
|
"allowed_values": ["", "M", "F", "X"],
|
2023-03-13 06:39:36 +01:00
|
|
|
"title": "Civilité (état-civil)",
|
|
|
|
"explanation": "Si précisé: remplace la civilité d'usage dans les documents officiels",
|
|
|
|
},
|
|
|
|
),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
"date_naissance",
|
|
|
|
{
|
|
|
|
"title": "Date de naissance",
|
|
|
|
"input_type": "date",
|
|
|
|
"explanation": "j/m/a",
|
2024-03-24 10:34:02 +01:00
|
|
|
"validator": _validate_date_naissance,
|
2021-06-02 22:40:34 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
("lieu_naissance", {"title": "Lieu de naissance", "size": 32}),
|
|
|
|
("dept_naissance", {"title": "Département de naissance", "size": 5}),
|
|
|
|
("nationalite", {"size": 25, "title": "Nationalité"}),
|
|
|
|
(
|
|
|
|
"statut",
|
|
|
|
{
|
|
|
|
"size": 25,
|
|
|
|
"title": "Statut",
|
|
|
|
"explanation": '("salarie", ...) inutilisé par ScoDoc',
|
|
|
|
},
|
|
|
|
),
|
2022-12-07 13:52:16 +01:00
|
|
|
(
|
|
|
|
"boursier",
|
|
|
|
{
|
|
|
|
"input_type": "boolcheckbox",
|
|
|
|
"labels": ["non", "oui"],
|
|
|
|
"title": "Boursier ?",
|
|
|
|
"explanation": "actuellement",
|
|
|
|
},
|
|
|
|
),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
"annee",
|
|
|
|
{
|
|
|
|
"size": 5,
|
|
|
|
"title": "Année admission IUT",
|
|
|
|
"type": "int",
|
|
|
|
"allow_null": False,
|
|
|
|
"explanation": "année 1ere inscription (obligatoire)",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
#
|
|
|
|
("sep", {"input_type": "separator", "title": "Scolarité antérieure:"}),
|
2022-12-07 13:52:16 +01:00
|
|
|
("bac", {"size": 32, "explanation": "série du bac (S, STI, STT, ...)"}),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
"specialite",
|
|
|
|
{
|
|
|
|
"size": 25,
|
|
|
|
"title": "Spécialité",
|
|
|
|
"explanation": "spécialité bac: SVT M, GENIE ELECTRONIQUE, ...",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"annee_bac",
|
|
|
|
{
|
|
|
|
"size": 5,
|
|
|
|
"title": "Année bac",
|
|
|
|
"type": "int",
|
2022-08-29 15:23:44 +02:00
|
|
|
"min_value": 1945,
|
2022-09-03 09:29:40 +02:00
|
|
|
"max_value": datetime.date.today().year + 1,
|
2021-06-02 22:40:34 +02:00
|
|
|
"explanation": "année obtention du bac",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"math",
|
|
|
|
{
|
|
|
|
"size": 3,
|
|
|
|
"title": "Note de mathématiques",
|
|
|
|
"explanation": "note sur 20 en terminale",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"physique",
|
|
|
|
{
|
|
|
|
"size": 3,
|
|
|
|
"title": "Note de physique",
|
|
|
|
"explanation": "note sur 20 en terminale",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"anglais",
|
|
|
|
{
|
|
|
|
"size": 3,
|
|
|
|
"title": "Note d'anglais",
|
|
|
|
"explanation": "note sur 20 en terminale",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"francais",
|
|
|
|
{
|
|
|
|
"size": 3,
|
|
|
|
"title": "Note de français",
|
|
|
|
"explanation": "note sur 20 obtenue au bac",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"type_admission",
|
|
|
|
{
|
|
|
|
"input_type": "menu",
|
|
|
|
"title": "Voie d'admission",
|
|
|
|
"allowed_values": scu.TYPES_ADMISSION,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"boursier_prec",
|
|
|
|
{
|
|
|
|
"input_type": "boolcheckbox",
|
|
|
|
"labels": ["non", "oui"],
|
|
|
|
"title": "Boursier ?",
|
|
|
|
"explanation": "dans le cycle précédent (lycée)",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"rang",
|
|
|
|
{
|
|
|
|
"size": 1,
|
|
|
|
"type": "int",
|
|
|
|
"title": "Position établissement",
|
|
|
|
"explanation": "rang de notre établissement dans les voeux du candidat (si connu)",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"qualite",
|
|
|
|
{
|
|
|
|
"size": 3,
|
|
|
|
"type": "float",
|
|
|
|
"title": "Qualité",
|
|
|
|
"explanation": "Note de qualité attribuée au dossier (par le jury d'adm.)",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"decision",
|
|
|
|
{
|
|
|
|
"input_type": "menu",
|
|
|
|
"title": "Décision",
|
|
|
|
"allowed_values": [
|
|
|
|
"ADMIS",
|
|
|
|
"ATTENTE 1",
|
|
|
|
"ATTENTE 2",
|
|
|
|
"ATTENTE 3",
|
|
|
|
"REFUS",
|
|
|
|
"?",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"score",
|
|
|
|
{
|
|
|
|
"size": 3,
|
|
|
|
"type": "float",
|
|
|
|
"title": "Score",
|
|
|
|
"explanation": "score calculé lors de l'admission",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"classement",
|
|
|
|
{
|
|
|
|
"size": 3,
|
|
|
|
"type": "int",
|
|
|
|
"title": "Classement",
|
|
|
|
"explanation": "Classement par le jury d'admission (de 1 à N)",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
("apb_groupe", {"size": 15, "title": "Groupe APB ou PS"}),
|
|
|
|
(
|
|
|
|
"apb_classement_gr",
|
|
|
|
{
|
|
|
|
"size": 3,
|
|
|
|
"type": "int",
|
|
|
|
"title": "Classement",
|
|
|
|
"explanation": "Classement par le jury dans le groupe ABP ou PS (de 1 à Ng)",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
("rapporteur", {"size": 50, "title": "Enseignant rapporteur"}),
|
|
|
|
(
|
|
|
|
"commentaire",
|
|
|
|
{
|
|
|
|
"input_type": "textarea",
|
|
|
|
"rows": 4,
|
|
|
|
"cols": 50,
|
|
|
|
"title": "Note du rapporteur",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
("nomlycee", {"size": 20, "title": "Lycée d'origine"}),
|
|
|
|
("villelycee", {"size": 15, "title": "Commune du lycée"}),
|
|
|
|
("codepostallycee", {"size": 15, "title": "Code Postal lycée"}),
|
|
|
|
(
|
|
|
|
"codelycee",
|
|
|
|
{
|
|
|
|
"size": 15,
|
|
|
|
"title": "Code Lycée",
|
|
|
|
"explanation": "Code national établissement du lycée ou établissement d'origine",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
("sep", {"input_type": "separator", "title": "Codes Apogée: (optionnels)"}),
|
|
|
|
(
|
|
|
|
"code_nip",
|
|
|
|
{
|
|
|
|
"size": 25,
|
|
|
|
"title": "Numéro NIP",
|
|
|
|
"allow_null": True,
|
|
|
|
"explanation": "numéro identité étudiant (Apogée)",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"code_ine",
|
|
|
|
{
|
|
|
|
"size": 25,
|
|
|
|
"title": "Numéro INE",
|
|
|
|
"allow_null": not require_ine,
|
|
|
|
"explanation": "numéro INE",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"dont_check_homonyms",
|
|
|
|
{
|
|
|
|
"title": "Autoriser les homonymes",
|
|
|
|
"input_type": "boolcheckbox",
|
|
|
|
"explanation": "ne vérifie pas les noms et prénoms proches",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
initvalues["dont_check_homonyms"] = False
|
|
|
|
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
|
|
|
descr,
|
|
|
|
submitlabel=submitlabel,
|
|
|
|
cancelbutton="Re-interroger Apogee",
|
|
|
|
initvalues=initvalues,
|
|
|
|
)
|
|
|
|
if tf[0] == 0:
|
|
|
|
return "\n".join(H) + tf[1] + "<p>" + A + F
|
|
|
|
elif tf[0] == -1:
|
|
|
|
return "\n".join(H) + tf[1] + "<p>" + A + F
|
|
|
|
# return '\n'.join(H) + '<h4>annulation</h4>' + F
|
|
|
|
else:
|
|
|
|
# form submission
|
|
|
|
if edit:
|
|
|
|
etudid = tf[2]["etudid"]
|
|
|
|
else:
|
|
|
|
etudid = None
|
2023-10-08 10:01:23 +02:00
|
|
|
ok, homonyms = sco_etud.check_nom_prenom_homonyms(
|
|
|
|
nom=tf[2]["nom"], prenom=tf[2]["prenom"], etudid=etudid
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2023-10-08 10:01:23 +02:00
|
|
|
nb_homonyms = len(homonyms)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not ok:
|
|
|
|
return (
|
|
|
|
"\n".join(H)
|
|
|
|
+ tf_error_message("Nom ou prénom invalide")
|
|
|
|
+ tf[1]
|
|
|
|
+ "<p>"
|
|
|
|
+ A
|
|
|
|
+ F
|
|
|
|
)
|
2023-10-08 10:01:23 +02:00
|
|
|
if not tf[2]["dont_check_homonyms"] and nb_homonyms > 0:
|
|
|
|
homonyms_html = f"""
|
|
|
|
<div class="homonyms"
|
|
|
|
style="border-radius: 8px; border: 1px solid black; background-color: #fdd6ad; padding: 8px; max-width: 80%;">
|
|
|
|
<div><b>Homonymes</b> (dans tous les départements)</div>
|
|
|
|
<ul>
|
|
|
|
<li>{'</li><li>'.join( [ '<b style="margin-right: 2em;">' + e.departement.acronym + "</b>" + e.html_link_fiche() for e in homonyms ])}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
"""
|
2021-06-02 22:40:34 +02:00
|
|
|
return (
|
|
|
|
"\n".join(H)
|
|
|
|
+ tf_error_message(
|
2023-10-08 10:01:23 +02:00
|
|
|
"""Attention: il y a déjà un étudiant portant des noms et prénoms proches
|
|
|
|
(voir liste en bas de page).
|
|
|
|
Vous pouvez forcer la présence d'un homonyme en cochant
|
|
|
|
"autoriser les homonymes" en bas du formulaire.
|
|
|
|
"""
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
+ tf[1]
|
|
|
|
+ "<p>"
|
|
|
|
+ A
|
2023-10-08 10:01:23 +02:00
|
|
|
+ homonyms_html
|
2021-06-02 22:40:34 +02:00
|
|
|
+ F
|
|
|
|
)
|
2024-05-13 17:31:54 +02:00
|
|
|
tf[2]["date_naissance"] = (
|
|
|
|
scu.convert_fr_date(tf[2]["date_naissance"])
|
|
|
|
if tf[2]["date_naissance"]
|
|
|
|
else None
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not edit:
|
2021-09-27 10:20:10 +02:00
|
|
|
etud = sco_etud.create_etud(cnx, args=tf[2])
|
2021-06-02 22:40:34 +02:00
|
|
|
etudid = etud["etudid"]
|
|
|
|
else:
|
|
|
|
# modif d'un etudiant
|
2023-05-15 22:20:28 +02:00
|
|
|
etud_o.from_dict(tf[2])
|
2023-10-15 14:42:03 +02:00
|
|
|
admission = etud_o.admission
|
2023-10-08 10:01:23 +02:00
|
|
|
if admission is None:
|
|
|
|
# ? ne devrait pas arriver mais...
|
|
|
|
admission = Admission()
|
2023-10-15 14:42:03 +02:00
|
|
|
etud_o.admission = admission
|
2023-05-15 22:20:28 +02:00
|
|
|
admission.from_dict(tf[2])
|
2023-05-15 19:50:11 +02:00
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
etud = sco_etud.etudident_list(cnx, {"etudid": etud_o.id})[0]
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_etud.fill_etuds_info([etud])
|
2021-06-02 22:40:34 +02:00
|
|
|
# Inval semesters with this student:
|
|
|
|
to_inval = [s["formsemestre_id"] for s in etud["sems"]]
|
2021-07-19 19:53:01 +02:00
|
|
|
for formsemestre_id in to_inval:
|
2023-06-01 19:48:52 +02:00
|
|
|
sco_cache.invalidate_formsemestre(formsemestre_id=formsemestre_id)
|
2021-06-02 22:40:34 +02:00
|
|
|
#
|
2023-03-12 21:22:19 +01:00
|
|
|
return flask.redirect(
|
2024-01-20 14:49:36 +01:00
|
|
|
url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
2023-03-12 21:22:19 +01:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2023-09-25 23:51:38 +02:00
|
|
|
@bp.route("/etud_copy_in_other_dept/<int:etudid>", methods=["GET", "POST"])
|
|
|
|
@scodoc
|
|
|
|
@permission_required(
|
|
|
|
Permission.ScoView
|
2023-09-29 21:17:31 +02:00
|
|
|
) # il faut aussi EtudInscrit dans le nouveau dept
|
2023-09-25 23:51:38 +02:00
|
|
|
def etud_copy_in_other_dept(etudid: int):
|
|
|
|
"""Crée une copie de l'étudiant (avec ses adresses et codes) dans un autre département
|
|
|
|
et l'inscrit à un formsemestre
|
|
|
|
"""
|
|
|
|
etud = Identite.get_etud(etudid)
|
|
|
|
if request.method == "POST":
|
|
|
|
action = request.form.get("action")
|
|
|
|
if action == "cancel":
|
|
|
|
return flask.redirect(
|
2024-01-20 14:49:36 +01:00
|
|
|
url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etud.id)
|
2023-09-25 23:51:38 +02:00
|
|
|
)
|
|
|
|
try:
|
|
|
|
formsemestre_id = int(request.form.get("formsemestre_id"))
|
|
|
|
except ValueError:
|
|
|
|
log("etud_copy_in_other_dept: invalid formsemestre_id")
|
|
|
|
abort(404, description="formsemestre_id invalide")
|
|
|
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
|
|
|
if not current_user.has_permission(
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.EtudInscrit, formsemestre.departement.acronym
|
2023-09-25 23:51:38 +02:00
|
|
|
):
|
|
|
|
raise ScoPermissionDenied("non autorisé")
|
|
|
|
new_etud = etud.clone(new_dept_id=formsemestre.dept_id)
|
|
|
|
db.session.commit()
|
|
|
|
# Attention: change le département pour opérer dans le nouveau
|
|
|
|
# avec les anciennes fonctions ScoDoc7
|
|
|
|
orig_dept = g.scodoc_dept
|
|
|
|
try:
|
|
|
|
app.set_sco_dept(formsemestre.departement.acronym, open_cnx=False)
|
|
|
|
sco_formsemestre_inscriptions.do_formsemestre_inscription_with_modules(
|
|
|
|
formsemestre.id,
|
|
|
|
new_etud.id,
|
|
|
|
method="etud_copy_in_other_dept",
|
|
|
|
dept_id=formsemestre.dept_id,
|
|
|
|
)
|
|
|
|
finally:
|
|
|
|
app.set_sco_dept(orig_dept, open_cnx=False)
|
|
|
|
flash(f"Etudiant dupliqué et inscrit en {formsemestre.departement.acronym}")
|
|
|
|
# Attention, ce redirect change de département !
|
|
|
|
return flask.redirect(
|
|
|
|
url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud",
|
2023-09-25 23:51:38 +02:00
|
|
|
scodoc_dept=formsemestre.departement.acronym,
|
|
|
|
etudid=new_etud.id,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
departements = {
|
|
|
|
dept.id: dept
|
|
|
|
for dept in Departement.query.order_by(Departement.acronym)
|
2023-09-29 21:17:31 +02:00
|
|
|
if current_user.has_permission(Permission.EtudInscrit, dept.acronym)
|
2023-09-25 23:51:38 +02:00
|
|
|
and dept.id != etud.dept_id
|
|
|
|
}
|
|
|
|
formsemestres_by_dept = {
|
|
|
|
dept.id: dept.formsemestres.filter_by(etat=True)
|
|
|
|
.filter(FormSemestre.modalite != "EXT")
|
|
|
|
.order_by(FormSemestre.date_debut, FormSemestre.semestre_id)
|
|
|
|
.all()
|
|
|
|
for dept in departements.values()
|
|
|
|
}
|
|
|
|
return render_template(
|
|
|
|
"scolar/etud_copy_in_other_dept.j2",
|
|
|
|
departements=departements,
|
|
|
|
etud=etud,
|
|
|
|
formsemestres_by_dept=formsemestres_by_dept,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-10-26 16:15:29 +02:00
|
|
|
@bp.route("/etudident_delete/<int:etudid>", methods=["GET", "POST"])
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2023-10-26 16:15:29 +02:00
|
|
|
def etudident_delete(etudid: int = -1, dialog_confirmed=False):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Delete a student"
|
2023-10-26 16:15:29 +02:00
|
|
|
etud = Identite.get_etud(etudid)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not dialog_confirmed:
|
|
|
|
return scu.confirm_dialog(
|
2023-10-26 16:15:29 +02:00
|
|
|
f"""<h2>Confirmer la suppression de l'étudiant <b>{etud.nomprenom}</b> ?</h2>
|
2021-06-02 22:40:34 +02:00
|
|
|
</p>
|
2023-10-25 23:07:34 +02:00
|
|
|
<p style="top-margin: 2ex; bottom-margin: 2ex;">Prenez le temps de vérifier
|
2021-07-11 17:37:12 +02:00
|
|
|
que vous devez vraiment supprimer cet étudiant !
|
|
|
|
</p>
|
|
|
|
<p>Cette opération <font color="red"><b>irréversible</b></font>
|
2023-10-25 23:07:34 +02:00
|
|
|
efface toute trace de l'étudiant: inscriptions, <b>notes</b>, absences...
|
2021-07-11 17:37:12 +02:00
|
|
|
dans <b>tous les semestres</b> qu'il a fréquenté.
|
|
|
|
</p>
|
2023-10-26 16:15:29 +02:00
|
|
|
<p>Dans la plupart des cas, vous avez seulement besoin de le <b>désinscrire</b>
|
|
|
|
d'un semestre ! (pour cela, passez par sa fiche, menu associé au semestre)</p>
|
2021-07-11 17:37:12 +02:00
|
|
|
|
2023-10-26 16:15:29 +02:00
|
|
|
<p><a class="stdlink" href="{url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid
|
2023-10-26 16:15:29 +02:00
|
|
|
)}">Vérifier la fiche de {etud.nomprenom}</a>
|
|
|
|
</p>""",
|
2021-06-02 22:40:34 +02:00
|
|
|
dest_url="",
|
2021-07-11 17:37:12 +02:00
|
|
|
cancel_url=url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid
|
2021-07-11 17:37:12 +02:00
|
|
|
),
|
2021-06-02 22:40:34 +02:00
|
|
|
OK="Supprimer définitivement cet étudiant",
|
|
|
|
parameters={"etudid": etudid},
|
|
|
|
)
|
2023-10-26 16:15:29 +02:00
|
|
|
log(f"etudident_delete: {etud}")
|
|
|
|
formsemestre_ids_to_inval = [
|
|
|
|
ins.formsemestre_id for ins in etud.formsemestre_inscriptions
|
|
|
|
]
|
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
# delete in all tables !
|
2023-10-25 23:07:34 +02:00
|
|
|
# c'est l'ancienne façon de gérer les cascades dans notre pseudo-ORM :)
|
2021-06-02 22:40:34 +02:00
|
|
|
tables = [
|
|
|
|
"notes_appreciations",
|
|
|
|
"scolar_autorisation_inscription",
|
|
|
|
"scolar_formsemestre_validation",
|
2023-10-26 16:15:29 +02:00
|
|
|
"apc_validation_rcue",
|
|
|
|
"apc_validation_annee",
|
2021-06-02 22:40:34 +02:00
|
|
|
"scolar_events",
|
|
|
|
"notes_notes_log",
|
|
|
|
"notes_notes",
|
|
|
|
"notes_moduleimpl_inscription",
|
|
|
|
"notes_formsemestre_inscription",
|
|
|
|
"group_membership",
|
|
|
|
"etud_annotations",
|
|
|
|
"scolog",
|
|
|
|
"adresse",
|
|
|
|
"absences",
|
2021-09-29 14:15:12 +02:00
|
|
|
"absences_notifications",
|
2021-06-02 22:40:34 +02:00
|
|
|
"billet_absence",
|
|
|
|
]
|
|
|
|
for table in tables:
|
2023-10-26 16:15:29 +02:00
|
|
|
db.session.execute(
|
|
|
|
sa.text(f"""delete from {table} where etudid=:etudid"""), {"etudid": etudid}
|
|
|
|
)
|
|
|
|
db.session.delete(etud)
|
|
|
|
db.session.commit()
|
2021-06-02 22:40:34 +02:00
|
|
|
# Inval semestres où il était inscrit:
|
2023-10-26 16:15:29 +02:00
|
|
|
for formsemestre_id in formsemestre_ids_to_inval:
|
2023-06-01 19:48:52 +02:00
|
|
|
sco_cache.invalidate_formsemestre(formsemestre_id=formsemestre_id)
|
2023-04-15 10:50:20 +02:00
|
|
|
flash("Étudiant supprimé !")
|
2024-04-08 18:56:43 +02:00
|
|
|
return flask.redirect(url_for("scolar.index_html", scodoc_dept=g.scodoc_dept))
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/check_group_apogee")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-09-27 10:20:10 +02:00
|
|
|
def check_group_apogee(group_id, etat=None, fix=False, fixmail=False):
|
2021-06-02 22:40:34 +02:00
|
|
|
"""Verification des codes Apogee et mail de tout un groupe.
|
|
|
|
Si fix == True, change les codes avec Apogée.
|
|
|
|
|
|
|
|
XXX A re-écrire pour API 2: prendre liste dans l'étape et vérifier à partir de cela.
|
|
|
|
"""
|
|
|
|
etat = etat or None
|
2024-08-23 08:51:28 +02:00
|
|
|
members, group, _, _, _ = sco_groups.get_group_infos(group_id, etat=etat)
|
2021-06-02 22:40:34 +02:00
|
|
|
formsemestre_id = group["formsemestre_id"]
|
2024-08-16 01:11:06 +02:00
|
|
|
title = f"""Étudiants du {group["group_name"] or "semestre"}"""
|
2021-06-02 22:40:34 +02:00
|
|
|
H = [
|
2024-08-16 01:11:06 +02:00
|
|
|
f"""<h2 class="formsemestre">{title}</h2>
|
|
|
|
<table class="sortable" id="listegroupe">
|
|
|
|
<tr>
|
|
|
|
<th>Nom</th><th>Nom usuel</th><th>Prénom</th><th>Mail</th>
|
|
|
|
<th>NIP (ScoDoc)</th><th>Apogée</th>
|
|
|
|
</tr>"""
|
2021-06-02 22:40:34 +02:00
|
|
|
]
|
|
|
|
nerrs = 0 # nombre d'anomalies détectées
|
|
|
|
nfix = 0 # nb codes changes
|
|
|
|
nmailmissing = 0 # nb etuds sans mail
|
|
|
|
for t in members:
|
|
|
|
nom, nom_usuel, prenom, etudid, email, code_nip = (
|
|
|
|
t["nom"],
|
|
|
|
t["nom_usuel"],
|
|
|
|
t["prenom"],
|
|
|
|
t["etudid"],
|
|
|
|
t["email"],
|
|
|
|
t["code_nip"],
|
|
|
|
)
|
2021-08-20 10:51:42 +02:00
|
|
|
infos = sco_portal_apogee.get_infos_apogee(nom, prenom)
|
2021-06-02 22:40:34 +02:00
|
|
|
if not infos:
|
2024-08-23 04:30:53 +02:00
|
|
|
info_apogee = f"""<b>Pas d'information</b>
|
|
|
|
(<a class="stdlink" href="{
|
|
|
|
url_for("scolar.etudident_edit_form", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
|
|
|
}">Modifier identité</a>)"""
|
2021-06-02 22:40:34 +02:00
|
|
|
nerrs += 1
|
|
|
|
else:
|
|
|
|
if len(infos) == 1:
|
|
|
|
nip_apogee = infos[0]["nip"]
|
|
|
|
if code_nip != nip_apogee:
|
|
|
|
if fix:
|
|
|
|
# Update database
|
2024-08-23 04:30:53 +02:00
|
|
|
etud = Identite.get_etud(etudid)
|
|
|
|
etud.code_nip = nip_apogee
|
|
|
|
db.session.add(etud)
|
|
|
|
db.session.commit()
|
2021-06-02 22:40:34 +02:00
|
|
|
info_apogee = (
|
2024-08-23 04:30:53 +02:00
|
|
|
f'<span style="color:green">copié {nip_apogee}</span>'
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
nfix += 1
|
|
|
|
else:
|
2024-08-23 04:30:53 +02:00
|
|
|
info_apogee = f'<span style="color:red">{nip_apogee}</span>'
|
2021-06-02 22:40:34 +02:00
|
|
|
nerrs += 1
|
|
|
|
else:
|
|
|
|
info_apogee = "ok"
|
|
|
|
else:
|
2024-08-23 04:30:53 +02:00
|
|
|
info_apogee = f"""<b>{len(infos)} correspondances</b>
|
|
|
|
(<a class="stdlink" href="{
|
|
|
|
url_for("scolar.etudident_edit_form", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
|
|
|
}">Choisir</a>)"""
|
2021-06-02 22:40:34 +02:00
|
|
|
nerrs += 1
|
|
|
|
# check mail
|
|
|
|
if email:
|
|
|
|
mailstat = "ok"
|
|
|
|
else:
|
|
|
|
if fixmail and len(infos) == 1 and "mail" in infos[0]:
|
|
|
|
mail_apogee = infos[0]["mail"]
|
2024-08-23 04:30:53 +02:00
|
|
|
etud = Identite.get_etud(etudid)
|
|
|
|
adresse = etud.adresse
|
|
|
|
if adresse:
|
|
|
|
# modif adr existante
|
|
|
|
adresse.email = mail_apogee
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
|
|
|
# creation adresse
|
2024-08-23 04:30:53 +02:00
|
|
|
adresse = Adresse(etudid=etudid, email=mail_apogee)
|
|
|
|
db.session.add(adresse)
|
|
|
|
db.session.commit()
|
2021-06-02 22:40:34 +02:00
|
|
|
mailstat = '<span style="color:green">copié</span>'
|
|
|
|
else:
|
|
|
|
mailstat = "inconnu"
|
|
|
|
nmailmissing += 1
|
|
|
|
H.append(
|
2024-08-23 04:30:53 +02:00
|
|
|
'<tr><td><a class="stdlink" href="%s">%s</a></td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>'
|
2021-07-11 17:37:12 +02:00
|
|
|
% (
|
2024-01-20 14:49:36 +01:00
|
|
|
url_for("scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid),
|
2021-07-11 17:37:12 +02:00
|
|
|
nom,
|
|
|
|
nom_usuel,
|
|
|
|
prenom,
|
|
|
|
mailstat,
|
2024-08-23 04:30:53 +02:00
|
|
|
code_nip or "-",
|
2021-07-11 17:37:12 +02:00
|
|
|
info_apogee,
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
H.append("</table>")
|
|
|
|
H.append("<ul>")
|
|
|
|
if nfix:
|
2024-08-23 08:51:28 +02:00
|
|
|
H.append(f"<li><b>{nfix}</b> codes modifiés</li>")
|
|
|
|
H.append("<li>Codes NIP: <b>{nerrs}</b> anomalies détectées</li>")
|
|
|
|
H.append("<li>Adresse mail: <b>{nmailmissing}</b> étudiants sans adresse</li>")
|
2021-06-02 22:40:34 +02:00
|
|
|
H.append("</ul>")
|
|
|
|
H.append(
|
2024-08-23 04:30:53 +02:00
|
|
|
f"""
|
|
|
|
<div class="scobox">
|
|
|
|
<form method="get" action="{request.base_url}">
|
|
|
|
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"/>
|
|
|
|
<input type="hidden" name="group_id" value="{scu.strnone(group_id)}"/>
|
|
|
|
<input type="hidden" name="etat" value="{scu.strnone(etat)}"/>
|
2021-06-02 22:40:34 +02:00
|
|
|
<input type="hidden" name="fix" value="1"/>
|
|
|
|
<input type="submit" value="Mettre à jour les codes NIP depuis Apogée"/>
|
|
|
|
</form>
|
2024-08-23 04:30:53 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="scobox">
|
|
|
|
<form method="get" action="{request.base_url}">
|
|
|
|
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"/>
|
|
|
|
<input type="hidden" name="group_id" value="{scu.strnone(group_id)}"/>
|
|
|
|
<input type="hidden" name="etat" value="{scu.strnone(etat)}"/>
|
2021-06-02 22:40:34 +02:00
|
|
|
<input type="hidden" name="fixmail" value="1"/>
|
|
|
|
<input type="submit" value="Renseigner les e-mail manquants (adresse institutionnelle)"/>
|
|
|
|
</form>
|
2024-08-23 04:30:53 +02:00
|
|
|
</div>
|
|
|
|
<a class="stdlink" href="{
|
2024-08-23 08:51:28 +02:00
|
|
|
url_for("notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
|
|
|
}">Retour au semestre</a>
|
2021-06-02 22:40:34 +02:00
|
|
|
"""
|
|
|
|
)
|
2024-08-16 01:11:06 +02:00
|
|
|
return render_template("sco_page.j2", title=title, content="\n".join(H))
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
2023-11-26 18:28:56 +01:00
|
|
|
@bp.route("/export_etudiants_courants")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def export_etudiants_courants():
|
|
|
|
"""Table export de tous les étudiants des formsemestres en cours."""
|
2023-11-26 19:04:03 +01:00
|
|
|
fmt = request.args.get("fmt", "html")
|
2024-08-06 23:18:17 +02:00
|
|
|
departement = db.session.get(Departement, g.scodoc_dept_id)
|
2023-11-26 18:28:56 +01:00
|
|
|
if not departement:
|
|
|
|
raise ScoValueError("département invalide")
|
2024-01-31 14:27:08 +01:00
|
|
|
formsemestres = FormSemestre.get_dept_formsemestres_courants(departement).all()
|
|
|
|
if not formsemestres:
|
|
|
|
raise ScoValueError("aucun semestre courant !")
|
2023-11-26 18:28:56 +01:00
|
|
|
table = list_etuds.table_etudiants_courants(formsemestres)
|
2023-11-26 19:04:03 +01:00
|
|
|
if fmt.startswith("xls"):
|
|
|
|
return scu.send_file(
|
|
|
|
table.excel(),
|
|
|
|
f"""{formsemestres[0].departement.acronym}-etudiants-{
|
|
|
|
datetime.datetime.now().strftime("%Y-%m-%dT%Hh%M")}""",
|
|
|
|
scu.XLSX_SUFFIX,
|
|
|
|
mime=scu.XLSX_MIMETYPE,
|
|
|
|
)
|
|
|
|
elif fmt == "html":
|
|
|
|
return render_template(
|
|
|
|
"scolar/export_etudiants_courants.j2", sco=ScoData(), table=table
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
raise ScoValueError("invalid fmt value")
|
2023-11-26 18:28:56 +01:00
|
|
|
|
|
|
|
|
2021-08-14 10:12:40 +02:00
|
|
|
@bp.route("/form_students_import_excel", methods=["GET", "POST"])
|
2021-08-15 21:33:47 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-09-27 10:20:10 +02:00
|
|
|
def form_students_import_excel(formsemestre_id=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"formulaire import xls"
|
2021-09-29 20:08:18 +02:00
|
|
|
formsemestre_id = int(formsemestre_id) if formsemestre_id else None
|
2021-06-02 22:40:34 +02:00
|
|
|
if formsemestre_id:
|
2021-08-19 10:28:35 +02:00
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
2023-03-02 22:55:25 +01:00
|
|
|
dest_url = url_for(
|
|
|
|
"notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=formsemestre_id,
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
sem = None
|
2024-04-08 18:56:43 +02:00
|
|
|
dest_url = url_for("scolar.index_html", scodoc_dept=g.scodoc_dept)
|
2021-08-10 12:57:38 +02:00
|
|
|
if sem and not sem["etat"]:
|
2021-06-02 22:40:34 +02:00
|
|
|
raise ScoValueError("Modification impossible: semestre verrouille")
|
|
|
|
H = [
|
2021-07-29 16:31:15 +02:00
|
|
|
html_sco_header.sco_header(page_title="Import etudiants"),
|
2021-06-02 22:40:34 +02:00
|
|
|
"""<h2 class="formsemestre">Téléchargement d\'une nouvelle liste d\'etudiants</h2>
|
|
|
|
<div style="color: red">
|
|
|
|
<p>A utiliser pour importer de <b>nouveaux</b> étudiants (typiquement au
|
|
|
|
<b>premier semestre</b>).</p>
|
|
|
|
<p>Si les étudiants à inscrire sont déjà dans un autre
|
|
|
|
semestre, utiliser le menu "<em>Inscriptions (passage des étudiants)
|
|
|
|
depuis d'autres semestres</em> à partir du semestre destination.
|
|
|
|
</p>
|
|
|
|
<p>Si vous avez un portail Apogée, il est en général préférable d'importer les
|
|
|
|
étudiants depuis Apogée, via le menu "<em>Synchroniser avec étape Apogée</em>".
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<p>
|
|
|
|
L'opération se déroule en deux étapes. Dans un premier temps,
|
|
|
|
vous téléchargez une feuille Excel type. Vous devez remplir
|
|
|
|
cette feuille, une ligne décrivant chaque étudiant. Ensuite,
|
|
|
|
vous indiquez le nom de votre fichier dans la case "Fichier Excel"
|
|
|
|
ci-dessous, et cliquez sur "Télécharger" pour envoyer au serveur
|
|
|
|
votre liste.
|
|
|
|
</p>
|
|
|
|
""",
|
|
|
|
] # '
|
|
|
|
if sem:
|
|
|
|
H.append(
|
|
|
|
"""<p style="color: red">Les étudiants importés seront inscrits dans
|
|
|
|
le semestre <b>%s</b></p>"""
|
|
|
|
% sem["titremois"]
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
2024-04-08 18:56:43 +02:00
|
|
|
f"""
|
2021-06-02 22:40:34 +02:00
|
|
|
<p>Pour inscrire directement les étudiants dans un semestre de
|
|
|
|
formation, il suffit d'indiquer le code de ce semestre
|
2024-04-08 18:56:43 +02:00
|
|
|
(qui doit avoir été créé au préalable).
|
|
|
|
<a class="stdlink" href="{
|
|
|
|
url_for("scolar.index_html", showcodes=1, scodoc_dept=g.scodoc_dept)
|
|
|
|
}">Cliquez ici pour afficher les codes</a>
|
2021-06-02 22:40:34 +02:00
|
|
|
</p>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append("""<ol><li>""")
|
|
|
|
if formsemestre_id:
|
|
|
|
H.append(
|
|
|
|
"""
|
|
|
|
<a class="stdlink" href="import_generate_excel_sample?with_codesemestre=0">
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append("""<a class="stdlink" href="import_generate_excel_sample">""")
|
|
|
|
H.append(
|
|
|
|
"""Obtenir la feuille excel à remplir</a></li>
|
|
|
|
<li>"""
|
|
|
|
)
|
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
F = html_sco_header.sco_footer()
|
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
|
|
|
(
|
|
|
|
(
|
|
|
|
"csvfile",
|
|
|
|
{"title": "Fichier Excel:", "input_type": "file", "size": 40},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"check_homonyms",
|
|
|
|
{
|
|
|
|
"title": "Vérifier les homonymes",
|
|
|
|
"input_type": "boolcheckbox",
|
|
|
|
"explanation": "arrète l'importation si plus de 10% d'homonymes",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"require_ine",
|
|
|
|
{
|
|
|
|
"title": "Importer INE",
|
|
|
|
"input_type": "boolcheckbox",
|
|
|
|
"explanation": "n'importe QUE les étudiants avec nouveau code INE",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
("formsemestre_id", {"input_type": "hidden"}),
|
|
|
|
),
|
|
|
|
initvalues={"check_homonyms": True, "require_ine": False},
|
|
|
|
submitlabel="Télécharger",
|
|
|
|
)
|
|
|
|
S = [
|
|
|
|
"""<hr/><p>Le fichier Excel décrivant les étudiants doit comporter les colonnes suivantes.
|
|
|
|
<p>Les colonnes peuvent être placées dans n'importe quel ordre, mais
|
|
|
|
le <b>titre</b> exact (tel que ci-dessous) doit être sur la première ligne.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Les champs avec un astérisque (*) doivent être présents (nulls non autorisés).
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<table>
|
|
|
|
<tr><td><b>Attribut</b></td><td><b>Type</b></td><td><b>Description</b></td></tr>"""
|
|
|
|
]
|
2021-06-21 10:17:16 +02:00
|
|
|
for t in sco_import_etuds.sco_import_format(
|
2023-10-15 14:42:03 +02:00
|
|
|
with_codesemestre=(formsemestre_id is None)
|
2021-06-02 22:40:34 +02:00
|
|
|
):
|
|
|
|
if int(t[3]):
|
|
|
|
ast = ""
|
|
|
|
else:
|
|
|
|
ast = "*"
|
|
|
|
S.append(
|
|
|
|
"<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>"
|
|
|
|
% (t[0], t[1], t[4], ast)
|
|
|
|
)
|
|
|
|
if tf[0] == 0:
|
|
|
|
return "\n".join(H) + tf[1] + "</li></ol>" + "\n".join(S) + F
|
|
|
|
elif tf[0] == -1:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(dest_url)
|
2021-06-02 22:40:34 +02:00
|
|
|
else:
|
2021-06-21 10:17:16 +02:00
|
|
|
return sco_import_etuds.students_import_excel(
|
2021-06-02 22:40:34 +02:00
|
|
|
tf[2]["csvfile"],
|
2021-09-29 20:08:18 +02:00
|
|
|
formsemestre_id=int(formsemestre_id) if formsemestre_id else None,
|
2021-06-02 22:40:34 +02:00
|
|
|
check_homonyms=tf[2]["check_homonyms"],
|
|
|
|
require_ine=tf[2]["require_ine"],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/import_generate_excel_sample")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudInscrit)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2021-09-27 10:20:10 +02:00
|
|
|
def import_generate_excel_sample(with_codesemestre="1"):
|
2021-06-02 22:40:34 +02:00
|
|
|
"une feuille excel pour importation etudiants"
|
|
|
|
if with_codesemestre:
|
|
|
|
with_codesemestre = int(with_codesemestre)
|
|
|
|
else:
|
|
|
|
with_codesemestre = 0
|
2023-09-21 10:20:19 +02:00
|
|
|
fmt = sco_import_etuds.sco_import_format()
|
2021-06-21 10:17:16 +02:00
|
|
|
data = sco_import_etuds.sco_import_generate_excel_sample(
|
2023-09-21 10:20:19 +02:00
|
|
|
fmt, with_codesemestre, exclude_cols=["photo_filename"]
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2021-09-18 10:51:19 +02:00
|
|
|
return scu.send_file(
|
2021-09-21 22:19:08 +02:00
|
|
|
data, "ImportEtudiants", scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE
|
2021-09-18 10:51:19 +02:00
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
# --- Données admission
|
|
|
|
@bp.route("/import_generate_admission_sample")
|
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-09-27 10:20:10 +02:00
|
|
|
def import_generate_admission_sample(formsemestre_id):
|
2021-06-02 22:40:34 +02:00
|
|
|
"une feuille excel pour importation données admissions"
|
2021-08-19 10:28:35 +02:00
|
|
|
group = sco_groups.get_group(sco_groups.get_default_group(formsemestre_id))
|
2021-06-21 10:17:16 +02:00
|
|
|
fmt = sco_import_etuds.sco_import_format()
|
|
|
|
data = sco_import_etuds.sco_import_generate_excel_sample(
|
2021-06-02 22:40:34 +02:00
|
|
|
fmt,
|
|
|
|
only_tables=["identite", "admissions", "adresse"],
|
|
|
|
exclude_cols=["nationalite", "foto", "photo_filename"],
|
|
|
|
group_ids=[group["group_id"]],
|
|
|
|
)
|
2021-09-18 10:51:19 +02:00
|
|
|
return scu.send_file(
|
2021-09-21 22:19:08 +02:00
|
|
|
data, "AdmissionEtudiants", scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE
|
2021-08-12 14:49:53 +02:00
|
|
|
)
|
2021-09-27 10:20:10 +02:00
|
|
|
# return sco_excel.send_excel_file(data, "AdmissionEtudiants" + scu.XLSX_SUFFIX)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
# --- Données admission depuis fichier excel (version nov 2016)
|
2021-06-25 19:24:12 +02:00
|
|
|
@bp.route("/form_students_import_infos_admissions", methods=["GET", "POST"])
|
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-09-27 10:20:10 +02:00
|
|
|
def form_students_import_infos_admissions(formsemestre_id=None):
|
2021-06-02 22:40:34 +02:00
|
|
|
"formulaire import xls"
|
2021-09-18 13:42:19 +02:00
|
|
|
authuser = current_user
|
2021-07-29 10:19:00 +02:00
|
|
|
F = html_sco_header.sco_footer()
|
2023-09-29 21:17:31 +02:00
|
|
|
if not authuser.has_permission(Permission.EtudInscrit):
|
2021-06-02 22:40:34 +02:00
|
|
|
# autorise juste l'export
|
|
|
|
H = [
|
2021-06-13 18:29:53 +02:00
|
|
|
html_sco_header.sco_header(
|
2021-06-02 22:40:34 +02:00
|
|
|
page_title="Export données admissions (Parcoursup ou autre)",
|
|
|
|
),
|
2024-02-02 18:23:35 +01:00
|
|
|
f"""<h2 class="formsemestre">Téléchargement des informations sur l'admission
|
|
|
|
des étudiants</h2>
|
2021-06-02 22:40:34 +02:00
|
|
|
<p>
|
2024-02-02 18:23:35 +01:00
|
|
|
<a href="{ url_for('scolar.import_generate_admission_sample',
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id )
|
|
|
|
}">Exporter les informations de ScoDoc (classeur Excel)</a> (ce fichier
|
|
|
|
peut être ré-importé après d'éventuelles modifications)
|
2021-06-02 22:40:34 +02:00
|
|
|
</p>
|
|
|
|
<p class="warning">Vous n'avez pas le droit d'importer les données</p>
|
2024-02-02 18:23:35 +01:00
|
|
|
""",
|
2021-06-02 22:40:34 +02:00
|
|
|
]
|
|
|
|
return "\n".join(H) + F
|
|
|
|
|
|
|
|
# On a le droit d'importer:
|
|
|
|
H = [
|
2021-07-29 16:31:15 +02:00
|
|
|
html_sco_header.sco_header(page_title="Import données admissions Parcoursup"),
|
2024-02-02 18:23:35 +01:00
|
|
|
f"""<h2 class="formsemestre">Téléchargement des informations sur l'admission des étudiants
|
|
|
|
depuis feuilles import Parcoursup</h2>
|
|
|
|
<div style="color: red">
|
|
|
|
<p>A utiliser pour renseigner les informations sur l'origine des étudiants (lycées, bac, etc).
|
|
|
|
Ces informations sont facultatives mais souvent utiles pour mieux connaitre les étudiants
|
|
|
|
et aussi pour effectuer des statistiques (résultats suivant le type de bac...).
|
|
|
|
Les données sont affichées sur les fiches individuelles des étudiants.
|
|
|
|
</p>
|
|
|
|
</div>
|
2024-06-18 20:40:13 +02:00
|
|
|
<div class="help">
|
|
|
|
<p>
|
|
|
|
Vous pouvez importer ici la feuille excel utilisée pour envoyer
|
|
|
|
le classement Parcoursup.
|
|
|
|
Seuls les étudiants actuellement inscrits dans ce semestre ScoDoc seront affectés,
|
|
|
|
les autres lignes de la feuille seront ignorées.
|
|
|
|
Et seules les colonnes intéressant ScoDoc
|
|
|
|
seront importées: il est inutile d'éliminer les autres.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<em>Seules les données "admission" seront modifiées
|
|
|
|
(et pas l'identité de l'étudiant).</em>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<em>Les colonnes "nom" et "prenom" sont requises,
|
|
|
|
ou bien une colonne "etudid" si la case
|
|
|
|
"Utiliser l'identifiant d'étudiant ScoDoc" est cochée.
|
|
|
|
</em>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Avant d'importer vos données, il est recommandé d'enregistrer
|
|
|
|
les informations actuelles:
|
|
|
|
<a class="stdlink" href="{
|
|
|
|
url_for("scolar.import_generate_admission_sample",
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
|
|
|
}">exporter les données actuelles de ScoDoc</a>
|
|
|
|
(ce fichier peut être ré-importé après d'éventuelles modifications)
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
""",
|
2023-10-15 14:42:03 +02:00
|
|
|
]
|
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
|
|
|
(
|
|
|
|
(
|
|
|
|
"csvfile",
|
|
|
|
{"title": "Fichier Excel:", "input_type": "file", "size": 40},
|
|
|
|
),
|
2024-06-18 20:40:13 +02:00
|
|
|
(
|
|
|
|
"use_etudid",
|
|
|
|
{
|
|
|
|
"input_type": "boolcheckbox",
|
|
|
|
"title": "Utiliser l'identifiant d'étudiant ScoDoc (<tt>etudid</tt>)",
|
|
|
|
"explanation": """si cochée, utilise le code pour retrouver dans ScoDoc
|
|
|
|
les étudiants du fichier excel. Sinon, utilise les noms/prénoms.""",
|
|
|
|
},
|
|
|
|
),
|
2021-06-02 22:40:34 +02:00
|
|
|
(
|
|
|
|
"type_admission",
|
|
|
|
{
|
|
|
|
"title": "Type d'admission",
|
|
|
|
"explanation": "sera attribué aux étudiants modifiés par cet import n'ayant pas déjà un type",
|
|
|
|
"input_type": "menu",
|
2023-10-15 14:42:03 +02:00
|
|
|
"allowed_values": scu.TYPES_ADMISSION,
|
2021-06-02 22:40:34 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
("formsemestre_id", {"input_type": "hidden"}),
|
|
|
|
),
|
|
|
|
submitlabel="Télécharger",
|
|
|
|
)
|
|
|
|
|
|
|
|
help_text = (
|
2023-10-25 23:07:34 +02:00
|
|
|
"""<p>Les colonnes importables par cette fonction sont indiquées
|
|
|
|
dans la table ci-dessous.
|
2021-06-02 22:40:34 +02:00
|
|
|
Seule la première feuille du classeur sera utilisée.
|
|
|
|
<div id="adm_table_description_format">
|
|
|
|
"""
|
2021-08-21 00:24:51 +02:00
|
|
|
+ sco_import_etuds.adm_table_description_format().html()
|
2021-06-02 22:40:34 +02:00
|
|
|
+ """</div>"""
|
|
|
|
)
|
|
|
|
|
|
|
|
if tf[0] == 0:
|
|
|
|
return "\n".join(H) + tf[1] + help_text + F
|
|
|
|
elif tf[0] == -1:
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect(
|
2024-04-08 18:56:43 +02:00
|
|
|
url_for(
|
|
|
|
"notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=formsemestre_id,
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
else:
|
2021-06-21 12:13:25 +02:00
|
|
|
return sco_import_etuds.students_import_admission(
|
2021-06-02 22:40:34 +02:00
|
|
|
tf[2]["csvfile"],
|
|
|
|
type_admission=tf[2]["type_admission"],
|
|
|
|
formsemestre_id=formsemestre_id,
|
2024-06-18 20:40:13 +02:00
|
|
|
use_etudid=tf[2]["use_etudid"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/formsemestre_import_etud_admission")
|
2021-08-13 00:34:58 +02:00
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EtudChangeAdr)
|
2021-08-21 00:24:51 +02:00
|
|
|
@scodoc7func
|
2023-11-26 18:28:56 +01:00
|
|
|
def formsemestre_import_etud_admission(
|
|
|
|
formsemestre_id=None, import_email=True, tous_courants=False
|
|
|
|
):
|
|
|
|
"""Ré-importe donnees admissions par synchro Portail Apogée.
|
|
|
|
Si tous_courants, le fait pour tous les formsemestres courants du département
|
|
|
|
"""
|
|
|
|
if tous_courants:
|
2024-08-06 23:18:17 +02:00
|
|
|
departement = db.session.get(Departement, g.scodoc_dept_id)
|
2023-11-26 18:28:56 +01:00
|
|
|
formsemestres = FormSemestre.get_dept_formsemestres_courants(departement)
|
|
|
|
else:
|
|
|
|
formsemestres = [FormSemestre.get_formsemestre(formsemestre_id)]
|
|
|
|
|
|
|
|
diag_by_sem = {}
|
|
|
|
for formsemestre in formsemestres:
|
|
|
|
(
|
|
|
|
etuds_no_nip,
|
|
|
|
etuds_unknown,
|
|
|
|
changed_mails,
|
|
|
|
) = sco_synchro_etuds.formsemestre_import_etud_admission(
|
|
|
|
formsemestre.id, import_identite=True, import_email=import_email
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
2023-11-26 18:28:56 +01:00
|
|
|
diag = ""
|
|
|
|
if etuds_no_nip:
|
|
|
|
diag += f"""<p>Attention: étudiants sans NIP:
|
|
|
|
{', '.join([e.html_link_fiche() for e in etuds_no_nip])}
|
|
|
|
</p>"""
|
|
|
|
|
|
|
|
if etuds_unknown:
|
|
|
|
diag += f"""<p>Attention: étudiants inconnus du portail:
|
|
|
|
{', '.join([(e.html_link_fiche() + ' (nip= ' + e.code_nip + ')')
|
|
|
|
for e in etuds_unknown])}
|
|
|
|
</p>"""
|
|
|
|
|
|
|
|
if changed_mails:
|
|
|
|
diag += """<p>Adresses mails modifiées:</p><ul>"""
|
|
|
|
for etud, old_mail in changed_mails:
|
|
|
|
diag += f"""<li>{etud.nom}: <tt>{old_mail}</tt> devient <tt>{etud.email}</tt></li>"""
|
|
|
|
diag += "</ul>"
|
|
|
|
diag_by_sem[formsemestre.id] = diag
|
|
|
|
|
2024-08-16 01:11:06 +02:00
|
|
|
return render_template(
|
|
|
|
"sco_page.j2",
|
|
|
|
title="Ré-import données admission",
|
|
|
|
content=f"""
|
|
|
|
<h2>Ré-import données admission</h2>
|
2023-11-26 18:28:56 +01:00
|
|
|
<h3>Opération effectuée</h3>
|
|
|
|
<p>Sur le(s) semestres(s):</p>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
{ '</li><li>'.join( [(s.html_link_status() + diag_by_sem[s.id]) for s in formsemestres ]) }
|
|
|
|
</li>
|
|
|
|
</ul>
|
2024-08-16 01:11:06 +02:00
|
|
|
""",
|
|
|
|
)
|
2021-06-02 22:40:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
sco_publish(
|
|
|
|
"/photos_import_files_form",
|
|
|
|
sco_trombino.photos_import_files_form,
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.EtudChangeAdr,
|
2021-08-20 09:17:44 +02:00
|
|
|
methods=["GET", "POST"],
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
sco_publish(
|
|
|
|
"/photos_generate_excel_sample",
|
|
|
|
sco_trombino.photos_generate_excel_sample,
|
2023-09-29 21:17:31 +02:00
|
|
|
Permission.EtudChangeAdr,
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
|
2023-04-06 16:10:32 +02:00
|
|
|
|
2021-06-02 22:40:34 +02:00
|
|
|
# --- Statistiques
|
|
|
|
@bp.route("/stat_bac")
|
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 stat_bac(formsemestre_id):
|
2021-06-02 22:40:34 +02:00
|
|
|
"Renvoie statistisques sur nb d'etudiants par bac"
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-06-16 16:59:31 +02:00
|
|
|
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
|
2021-08-19 10:28:35 +02:00
|
|
|
args={"formsemestre_id": formsemestre_id}
|
2021-06-02 22:40:34 +02:00
|
|
|
)
|
|
|
|
Bacs = {} # type bac : nb etud
|
|
|
|
for i in ins:
|
2021-06-19 23:21:37 +02:00
|
|
|
etud = sco_etud.etudident_list(cnx, {"etudid": i["etudid"]})[0]
|
2021-06-02 22:40:34 +02:00
|
|
|
typebac = "%(bac)s %(specialite)s" % etud
|
|
|
|
Bacs[typebac] = Bacs.get(typebac, 0) + 1
|
|
|
|
return Bacs
|
|
|
|
|
|
|
|
|
2022-03-14 14:09:59 +01:00
|
|
|
# --- Dump (assistance)
|
|
|
|
@bp.route("/sco_dump_and_send_db", methods=["GET", "POST"])
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
@scodoc7func
|
2022-09-10 15:23:54 +02:00
|
|
|
def sco_dump_and_send_db(message="", request_url="", traceback_str_base64=""):
|
2022-03-14 14:09:59 +01:00
|
|
|
"Send anonymized data to supervision"
|
2022-03-21 11:48:34 +01:00
|
|
|
|
2024-05-23 00:15:32 +02:00
|
|
|
r = sco_dump_db.sco_dump_and_send_db(
|
2022-09-10 15:23:54 +02:00
|
|
|
message, request_url, traceback_str_base64=traceback_str_base64
|
|
|
|
)
|
2024-05-23 00:15:32 +02:00
|
|
|
|
|
|
|
status_code = r.status_code
|
|
|
|
|
|
|
|
try:
|
|
|
|
r_msg = r.json()["message"]
|
|
|
|
except (requests.exceptions.JSONDecodeError, KeyError):
|
2024-08-06 23:18:17 +02:00
|
|
|
r_msg = f"""Erreur: code <tt>{status_code}</tt>
|
|
|
|
Merci de contacter <a href="mailto:{scu.SCO_DEV_MAIL}">{scu.SCO_DEV_MAIL}</a>
|
|
|
|
"""
|
2024-05-23 00:15:32 +02:00
|
|
|
|
2022-03-21 11:48:34 +01:00
|
|
|
H = [html_sco_header.sco_header(page_title="Assistance technique")]
|
2024-05-23 00:15:32 +02:00
|
|
|
if status_code == requests.codes.OK: # pylint: disable=no-member
|
|
|
|
H.append(f"""<p>Opération effectuée.</p><p>{r_msg}</p>""")
|
2022-03-21 11:48:34 +01:00
|
|
|
else:
|
2024-05-23 00:15:32 +02:00
|
|
|
H.append(f"""<p class="warning">{r_msg}</p>""")
|
2022-03-21 11:48:34 +01:00
|
|
|
flash("Données envoyées au serveur d'assistance")
|
|
|
|
return "\n".join(H) + html_sco_header.sco_footer()
|
2024-05-23 00:15:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
# --- Report form (assistance)
|
2024-05-24 13:01:56 +02:00
|
|
|
@bp.route("/sco_bug_report", methods=["GET", "POST"])
|
2024-05-23 00:15:32 +02:00
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def sco_bug_report_form():
|
|
|
|
"Formulaire de création d'un ticket d'assistance"
|
|
|
|
|
2024-05-24 13:01:56 +02:00
|
|
|
form = CreateBugReport()
|
|
|
|
if request.method == "POST" and form.cancel.data: # cancel button
|
2024-07-15 19:08:15 +02:00
|
|
|
return flask.redirect(url_for("scolar.index_html", scodoc_dept=g.scodoc_dept))
|
2024-05-24 13:01:56 +02:00
|
|
|
if form.validate_on_submit():
|
|
|
|
r = sco_bug_report.sco_bug_report(
|
|
|
|
form.title.data, form.message.data, form.etab.data, form.include_dump.data
|
|
|
|
)
|
2024-05-23 00:15:32 +02:00
|
|
|
|
2024-05-24 13:01:56 +02:00
|
|
|
status_code = r.status_code
|
|
|
|
try:
|
|
|
|
r_msg = r.json()["message"]
|
|
|
|
except (requests.exceptions.JSONDecodeError, KeyError):
|
2024-05-26 22:57:04 +02:00
|
|
|
log(f"sco_bug_report: error {status_code}")
|
|
|
|
r_msg = f"""Erreur: code <tt>{status_code}</tt>
|
|
|
|
Merci de contacter
|
|
|
|
<a href="mailto:{scu.SCO_DEV_MAIL}">{scu.SCO_DEV_MAIL}</a>
|
|
|
|
"""
|
2024-05-23 00:15:32 +02:00
|
|
|
|
2024-05-24 13:01:56 +02:00
|
|
|
H = [html_sco_header.sco_header(page_title="Assistance technique")]
|
|
|
|
if r.status_code >= 200 and r.status_code < 300:
|
|
|
|
H.append(f"""<p>Opération effectuée.</p><p>{r_msg}</p>""")
|
|
|
|
else:
|
|
|
|
H.append(f"""<p class="warning">{r_msg}</p>""")
|
|
|
|
return "\n".join(H) + html_sco_header.sco_footer()
|
2024-05-23 00:15:32 +02:00
|
|
|
|
2024-05-24 13:01:56 +02:00
|
|
|
return render_template(
|
|
|
|
"sco_bug_report.j2",
|
|
|
|
form=form,
|
|
|
|
)
|