2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Page accueil département (liste des semestres, etc)
|
|
|
|
"""
|
2021-06-26 21:57:54 +02:00
|
|
|
|
2023-10-25 23:07:34 +02:00
|
|
|
from flask import g
|
2022-04-16 15:34:40 +02:00
|
|
|
from flask import url_for
|
2021-07-29 16:31:15 +02:00
|
|
|
from flask_login import current_user
|
2021-06-26 21:57:54 +02:00
|
|
|
|
2021-09-04 11:37:46 +02:00
|
|
|
import app
|
2023-10-25 23:07:34 +02:00
|
|
|
from app import log
|
2022-04-12 17:12:51 +02:00
|
|
|
from app.models import ScolarNews
|
2021-06-19 23:21:37 +02:00
|
|
|
import app.scodoc.sco_utils as scu
|
|
|
|
from app.scodoc.gen_tables import GenTable
|
|
|
|
from app.scodoc.sco_permissions import Permission
|
|
|
|
from app.scodoc import html_sco_header
|
2021-08-19 21:30:22 +02:00
|
|
|
import app.scodoc.notesdb as ndb
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_formsemestre_inscriptions
|
|
|
|
from app.scodoc import sco_modalites
|
|
|
|
from app.scodoc import sco_preferences
|
2021-06-26 21:57:54 +02:00
|
|
|
from app.scodoc import sco_users
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-09-27 10:20:10 +02:00
|
|
|
def index_html(showcodes=0, showsemtable=0):
|
2020-09-26 16:19:37 +02:00
|
|
|
"Page accueil département (liste des semestres)"
|
2021-10-07 22:23:49 +02:00
|
|
|
showcodes = int(showcodes)
|
2020-09-26 16:19:37 +02:00
|
|
|
showsemtable = int(showsemtable)
|
|
|
|
H = []
|
|
|
|
|
|
|
|
# News:
|
2022-04-12 17:12:51 +02:00
|
|
|
H.append(ScolarNews.scolar_news_summary_html())
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Avertissement de mise à jour:
|
2024-03-20 18:13:19 +01:00
|
|
|
H.append("""<div id="update_warning" class="scobox update_warning"></div>""")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Liste de toutes les sessions:
|
2021-08-19 10:28:35 +02:00
|
|
|
sems = sco_formsemestre.do_formsemestre_list()
|
2020-09-26 16:19:37 +02:00
|
|
|
cursems = [] # semestres "courants"
|
|
|
|
othersems = [] # autres (verrouillés)
|
|
|
|
# icon image:
|
2021-02-04 20:02:44 +01:00
|
|
|
groupicon = scu.icontag("groupicon_img", title="Inscrits", border="0")
|
|
|
|
emptygroupicon = scu.icontag(
|
|
|
|
"emptygroupicon_img", title="Pas d'inscrits", border="0"
|
|
|
|
)
|
|
|
|
lockicon = scu.icontag("lock32_img", title="verrouillé", border="0")
|
2020-09-26 16:19:37 +02:00
|
|
|
# Sélection sur l'etat du semestre
|
|
|
|
for sem in sems:
|
2021-08-10 12:57:38 +02:00
|
|
|
if sem["etat"] and sem["modalite"] != "EXT":
|
2020-09-26 16:19:37 +02:00
|
|
|
sem["lockimg"] = ""
|
|
|
|
cursems.append(sem)
|
|
|
|
else:
|
|
|
|
sem["lockimg"] = lockicon
|
|
|
|
othersems.append(sem)
|
|
|
|
# Responsable de formation:
|
2021-08-19 10:28:35 +02:00
|
|
|
sco_formsemestre.sem_set_responsable_name(sem)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-10-07 22:23:49 +02:00
|
|
|
if showcodes:
|
2022-04-16 15:34:40 +02:00
|
|
|
sem["tmpcode"] = f"<td><tt>{sem['formsemestre_id']}</tt></td>"
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
sem["tmpcode"] = ""
|
|
|
|
# Nombre d'inscrits:
|
|
|
|
args = {"formsemestre_id": sem["formsemestre_id"]}
|
2021-08-19 10:28:35 +02:00
|
|
|
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(args=args)
|
2020-09-26 16:19:37 +02:00
|
|
|
nb = len(ins) # nb etudiants
|
|
|
|
sem["nb_inscrits"] = nb
|
|
|
|
if nb > 0:
|
|
|
|
sem["groupicon"] = groupicon
|
|
|
|
else:
|
|
|
|
sem["groupicon"] = emptygroupicon
|
|
|
|
|
|
|
|
# S'il n'y a pas d'utilisateurs dans la base, affiche message
|
2023-09-04 07:15:42 +02:00
|
|
|
if not sco_users.get_users_count(dept=g.scodoc_dept):
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
|
|
|
"""<h2>Aucun utilisateur défini !</h2><p>Pour définir des utilisateurs
|
|
|
|
<a href="Users">passez par la page Utilisateurs</a>.
|
2022-10-02 23:43:29 +02:00
|
|
|
<br>
|
2023-10-25 23:07:34 +02:00
|
|
|
Définissez au moins un utilisateur avec le rôle AdminXXX
|
2023-09-04 07:15:42 +02:00
|
|
|
(le responsable du département XXX).
|
2020-09-26 16:19:37 +02:00
|
|
|
</p>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2024-03-20 18:13:19 +01:00
|
|
|
H.append("""<div class="scobox">""")
|
2020-09-26 16:19:37 +02:00
|
|
|
# Liste des formsemestres "courants"
|
|
|
|
if cursems:
|
2024-03-20 18:13:19 +01:00
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<div class="scobox-title">Sessions en cours</div>
|
|
|
|
{ _sem_table(cursems) }
|
|
|
|
"""
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
# aucun semestre courant: affiche aide
|
|
|
|
H.append(
|
2024-03-20 18:13:19 +01:00
|
|
|
"""
|
|
|
|
<div class="scobox-title">Aucune session en cours !</div>
|
2024-02-14 21:45:58 +01:00
|
|
|
<p>Pour ajouter une session, aller dans <a href="Notes" id="link-programmes">Formations</a>,
|
2020-09-26 16:19:37 +02:00
|
|
|
choisissez une formation, puis suivez le lien "<em>UE, modules, semestres</em>".
|
2024-03-20 18:13:19 +01:00
|
|
|
</p>
|
|
|
|
<p>Là, en bas de page, suivez le lien
|
2020-09-26 16:19:37 +02:00
|
|
|
"<em>Mettre en place un nouveau semestre de formation...</em>"
|
|
|
|
</p>"""
|
|
|
|
)
|
|
|
|
|
|
|
|
if showsemtable:
|
|
|
|
H.append(
|
2024-03-20 18:13:19 +01:00
|
|
|
f"""
|
|
|
|
<div class="scobox-title">Semestres de {sco_preferences.get_preference("DeptName")}</div>
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
|
|
|
)
|
2021-10-07 22:23:49 +02:00
|
|
|
H.append(_sem_table_gt(sems, showcodes=showcodes).html())
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("</table>")
|
2024-03-20 18:13:19 +01:00
|
|
|
else:
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
2024-03-20 18:13:19 +01:00
|
|
|
f"""
|
2023-10-25 23:07:34 +02:00
|
|
|
<p><a class="stdlink" href="{url_for('scolar.index_html',
|
2022-05-05 22:44:46 +02:00
|
|
|
scodoc_dept=g.scodoc_dept, showsemtable=1)
|
2023-10-25 23:07:34 +02:00
|
|
|
}">Voir table des semestres (dont {len(othersems)}
|
2022-05-05 22:44:46 +02:00
|
|
|
verrouillé{'s' if len(othersems) else ''})</a>
|
2022-04-16 15:34:40 +02:00
|
|
|
</p>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
H.append(
|
2024-03-20 18:13:19 +01:00
|
|
|
f"""
|
2022-04-16 15:34:40 +02:00
|
|
|
<form action="{url_for('notes.view_formsemestre_by_etape', scodoc_dept=g.scodoc_dept)}">
|
|
|
|
Chercher étape courante:
|
|
|
|
<input name="etape_apo" type="text" size="8" spellcheck="false"></input>
|
|
|
|
</form>
|
2024-03-20 18:13:19 +01:00
|
|
|
</div>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
#
|
2023-11-26 18:28:56 +01:00
|
|
|
H.append(
|
2024-03-20 18:13:19 +01:00
|
|
|
"""
|
|
|
|
<div class="scobox">
|
|
|
|
<div class="scobox-title">Gestion des étudiants</div>
|
|
|
|
<ul>
|
2023-11-26 18:28:56 +01:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
if current_user.has_permission(Permission.EtudInscrit):
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for("scolar.etudident_create_form", scodoc_dept=g.scodoc_dept)
|
|
|
|
}">créer <em>un</em> nouvel étudiant</a>
|
2022-04-16 15:34:40 +02:00
|
|
|
</li>
|
2023-11-26 18:28:56 +01:00
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for("scolar.form_students_import_excel", scodoc_dept=g.scodoc_dept)
|
|
|
|
}">importer de nouveaux étudiants</a>
|
|
|
|
(<em>ne pas utiliser</em> sauf cas particulier : utilisez plutôt le lien dans
|
2022-04-16 15:34:40 +02:00
|
|
|
le tableau de bord semestre si vous souhaitez inscrire les
|
|
|
|
étudiants importés à un semestre)
|
|
|
|
</li>
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
|
|
|
)
|
2023-11-26 18:28:56 +01:00
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for("scolar.export_etudiants_courants", scodoc_dept=g.scodoc_dept)
|
|
|
|
}">exporter tableau des étudiants des semestres en cours</a>
|
|
|
|
</li>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
if current_user.has_permission(
|
|
|
|
Permission.EtudInscrit
|
|
|
|
) and sco_preferences.get_preference("portal_url"):
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for("scolar.formsemestre_import_etud_admission",
|
|
|
|
scodoc_dept=g.scodoc_dept, tous_courants=1)
|
|
|
|
}">resynchroniser les données étudiants des semestres en cours depuis le portail</a>
|
|
|
|
</li>
|
|
|
|
"""
|
|
|
|
)
|
2024-03-20 18:13:19 +01:00
|
|
|
H.append("</ul></div>")
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
2023-09-29 21:17:31 +02:00
|
|
|
if current_user.has_permission(Permission.EditApogee):
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
2024-03-20 18:13:19 +01:00
|
|
|
f"""
|
|
|
|
<div class="scobox">
|
|
|
|
<div class="scobox-title">Exports Apogée</div>
|
|
|
|
<ul>
|
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for('notes.semset_page', scodoc_dept=g.scodoc_dept)
|
|
|
|
}">Années scolaires / exports Apogée</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
#
|
|
|
|
H.append(
|
2024-03-20 18:13:19 +01:00
|
|
|
"""
|
|
|
|
<div class="scobox">
|
|
|
|
<div class="scobox-title">Assistance</div>
|
2020-09-26 16:19:37 +02:00
|
|
|
<ul>
|
2024-03-20 18:13:19 +01:00
|
|
|
<li><a class="stdlink" href="https://scodoc.org/Contact" target="_blank"
|
|
|
|
rel="noopener noreferrer">Contact (Discord)</a>
|
|
|
|
</li>
|
|
|
|
<li><a class="stdlink" href="sco_dump_and_send_db">Envoyer données</a>
|
|
|
|
</li>
|
2020-09-26 16:19:37 +02:00
|
|
|
</ul>
|
2024-03-20 18:13:19 +01:00
|
|
|
</div>
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
#
|
2022-04-16 15:34:40 +02:00
|
|
|
return (
|
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title=f"ScoDoc {g.scodoc_dept}", javascripts=["js/scolar_index.js"]
|
|
|
|
)
|
|
|
|
+ "\n".join(H)
|
|
|
|
+ html_sco_header.sco_footer()
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def _sem_table(sems):
|
2020-12-30 11:46:52 +01:00
|
|
|
"""Affiche liste des semestres, utilisée pour semestres en cours"""
|
2020-09-26 16:19:37 +02:00
|
|
|
tmpl = """<tr class="%(trclass)s">%(tmpcode)s
|
2023-10-25 23:07:34 +02:00
|
|
|
<td class="semicon">%(lockimg)s <a href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s#groupes">%(groupicon)s</a></td>
|
2021-09-10 23:18:27 +02:00
|
|
|
<td class="datesem">%(mois_debut)s <a title="%(session_id)s">-</a> %(mois_fin)s</td>
|
2021-02-24 09:18:53 +01:00
|
|
|
<td><a class="stdlink" href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titre_num)s</a>
|
2020-09-26 16:19:37 +02:00
|
|
|
<span class="respsem">(%(responsable_name)s)</span>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Liste des semestres, groupés par modalités
|
2021-08-21 00:24:51 +02:00
|
|
|
sems_by_mod, modalites = sco_modalites.group_sems_by_modalite(sems)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
H = ['<table class="listesems">']
|
|
|
|
for modalite in modalites:
|
|
|
|
if len(modalites) > 1:
|
2021-09-10 23:18:27 +02:00
|
|
|
H.append('<tr><th colspan="3">%s</th></tr>' % modalite["titre"])
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if sems_by_mod[modalite["modalite"]]:
|
|
|
|
cur_idx = sems_by_mod[modalite["modalite"]][0]["semestre_id"]
|
|
|
|
for sem in sems_by_mod[modalite["modalite"]]:
|
|
|
|
if cur_idx != sem["semestre_id"]:
|
|
|
|
sem["trclass"] = "firstsem" # separe les groupes de semestres
|
|
|
|
cur_idx = sem["semestre_id"]
|
|
|
|
else:
|
|
|
|
sem["trclass"] = ""
|
2021-06-15 12:34:33 +02:00
|
|
|
sem["notes_url"] = scu.NotesURL()
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(tmpl % sem)
|
|
|
|
H.append("</table>")
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def _sem_table_gt(sems, showcodes=False):
|
2022-04-16 15:34:40 +02:00
|
|
|
"""Nouvelle version de la table des semestres
|
|
|
|
Utilise une datatables.
|
|
|
|
"""
|
2021-08-21 00:24:51 +02:00
|
|
|
_style_sems(sems)
|
2020-09-26 16:19:37 +02:00
|
|
|
columns_ids = (
|
|
|
|
"lockimg",
|
|
|
|
"semestre_id_n",
|
|
|
|
"modalite",
|
|
|
|
#'mois_debut',
|
|
|
|
"dash_mois_fin",
|
|
|
|
"titre_resp",
|
|
|
|
"nb_inscrits",
|
|
|
|
"etapes_apo_str",
|
2022-04-21 13:59:53 +02:00
|
|
|
"elt_annee_apo",
|
|
|
|
"elt_sem_apo",
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
if showcodes:
|
|
|
|
columns_ids = ("formsemestre_id",) + columns_ids
|
|
|
|
|
2022-04-16 15:48:17 +02:00
|
|
|
html_class = "stripe cell-border compact hover order-column table_leftalign semlist"
|
2023-09-29 21:17:31 +02:00
|
|
|
if current_user.has_permission(Permission.EditApogee):
|
2022-04-16 15:48:17 +02:00
|
|
|
html_class += " apo_editable"
|
2020-09-26 16:19:37 +02:00
|
|
|
tab = GenTable(
|
|
|
|
titles={
|
|
|
|
"formsemestre_id": "id",
|
|
|
|
"semestre_id_n": "S#",
|
|
|
|
"modalite": "",
|
|
|
|
"mois_debut": "Début",
|
|
|
|
"dash_mois_fin": "Année",
|
|
|
|
"titre_resp": "Semestre",
|
2022-04-16 15:34:40 +02:00
|
|
|
"nb_inscrits": "N",
|
2022-04-21 13:59:53 +02:00
|
|
|
"etapes_apo_str": "Étape Apo.",
|
|
|
|
"elt_annee_apo": "Elt. année Apo.",
|
|
|
|
"elt_sem_apo": "Elt. sem. Apo.",
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
columns_ids=columns_ids,
|
|
|
|
rows=sems,
|
2022-04-16 15:34:40 +02:00
|
|
|
table_id="semlist",
|
|
|
|
html_class_ignore_default=True,
|
2022-04-16 15:48:17 +02:00
|
|
|
html_class=html_class,
|
2020-09-26 16:19:37 +02:00
|
|
|
html_sortable=True,
|
2022-04-21 13:59:53 +02:00
|
|
|
html_table_attrs=f"""
|
2023-10-25 23:07:34 +02:00
|
|
|
data-apo_save_url="{url_for('notes.formsemestre_set_apo_etapes', scodoc_dept=g.scodoc_dept)}"
|
|
|
|
data-elt_annee_apo_save_url="{url_for('notes.formsemestre_set_elt_annee_apo', scodoc_dept=g.scodoc_dept)}"
|
|
|
|
data-elt_sem_apo_save_url="{url_for('notes.formsemestre_set_elt_sem_apo', scodoc_dept=g.scodoc_dept)}"
|
2022-04-21 13:59:53 +02:00
|
|
|
""",
|
2022-04-16 15:34:40 +02:00
|
|
|
html_with_td_classes=True,
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(),
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
return tab
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def _style_sems(sems):
|
2020-12-30 11:46:52 +01:00
|
|
|
"""ajoute quelques attributs de présentation pour la table"""
|
2020-09-26 16:19:37 +02:00
|
|
|
for sem in sems:
|
2021-06-15 12:34:33 +02:00
|
|
|
sem["notes_url"] = scu.NotesURL()
|
2020-09-26 16:19:37 +02:00
|
|
|
sem["_groupicon_target"] = (
|
2021-02-24 09:18:53 +01:00
|
|
|
"%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s"
|
|
|
|
% sem
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
sem["_formsemestre_id_class"] = "blacktt"
|
|
|
|
sem["dash_mois_fin"] = '<a title="%(session_id)s"></a> %(anneescolaire)s' % sem
|
|
|
|
sem["_dash_mois_fin_class"] = "datesem"
|
|
|
|
sem["titre_resp"] = (
|
2021-02-24 09:18:53 +01:00
|
|
|
"""<a class="stdlink" href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titre_num)s</a>
|
2020-09-26 16:19:37 +02:00
|
|
|
<span class="respsem">(%(responsable_name)s)</span>"""
|
|
|
|
% sem
|
|
|
|
)
|
|
|
|
sem["_css_row_class"] = "css_S%d css_M%s" % (
|
|
|
|
sem["semestre_id"],
|
|
|
|
sem["modalite"],
|
|
|
|
)
|
|
|
|
sem["_semestre_id_class"] = "semestre_id"
|
|
|
|
sem["_modalite_class"] = "modalite"
|
|
|
|
if sem["semestre_id"] == -1:
|
|
|
|
sem["semestre_id_n"] = ""
|
|
|
|
else:
|
|
|
|
sem["semestre_id_n"] = sem["semestre_id"]
|
2022-04-16 15:34:40 +02:00
|
|
|
# pour édition codes Apogée:
|
2024-02-14 21:45:58 +01:00
|
|
|
sem["_etapes_apo_str_td_attrs"] = (
|
|
|
|
f""" data-oid="{sem['formsemestre_id']}" data-value="{sem['etapes_apo_str']}" """
|
|
|
|
)
|
|
|
|
sem["_elt_annee_apo_td_attrs"] = (
|
|
|
|
f""" data-oid="{sem['formsemestre_id']}" data-value="{sem['elt_annee_apo']}" """
|
|
|
|
)
|
|
|
|
sem["_elt_sem_apo_td_attrs"] = (
|
|
|
|
f""" data-oid="{sem['formsemestre_id']}" data-value="{sem['elt_sem_apo']}" """
|
|
|
|
)
|
2021-08-19 21:30:22 +02:00
|
|
|
|
|
|
|
|
2023-02-09 11:56:20 +01:00
|
|
|
def delete_dept(dept_id: int) -> str:
|
2021-09-02 16:32:47 +02:00
|
|
|
"""Suppression irréversible d'un département et de tous les objets rattachés"""
|
2021-08-19 21:30:22 +02:00
|
|
|
assert isinstance(dept_id, int)
|
2021-09-02 16:32:47 +02:00
|
|
|
|
2021-08-19 21:30:22 +02:00
|
|
|
# Un peu complexe, merci JMP :)
|
|
|
|
cnx = ndb.GetDBConnexion()
|
|
|
|
cursor = cnx.cursor()
|
|
|
|
try:
|
|
|
|
# 1- Create temp tables to store ids
|
|
|
|
reqs = [
|
|
|
|
"create temp table etudids_temp as select id from identite where dept_id = %(dept_id)s",
|
2023-10-25 23:07:34 +02:00
|
|
|
"""create temp table formsemestres_temp as select id
|
|
|
|
from notes_formsemestre where dept_id = %(dept_id)s""",
|
|
|
|
"""create temp table moduleimpls_temp as select id from notes_moduleimpl
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp)""",
|
|
|
|
"""create temp table formations_temp as
|
|
|
|
select id from notes_formations where dept_id = %(dept_id)s""",
|
2021-08-19 21:30:22 +02:00
|
|
|
"create temp table tags_temp as select id from notes_tags where dept_id = %(dept_id)s",
|
|
|
|
]
|
|
|
|
for r in reqs:
|
2023-10-25 23:07:34 +02:00
|
|
|
log(f"delete_dept: {r}")
|
2021-08-19 21:30:22 +02:00
|
|
|
cursor.execute(r, {"dept_id": dept_id})
|
|
|
|
|
|
|
|
# 2- Delete student-related informations
|
|
|
|
# ordered list of tables
|
|
|
|
etud_tables = [
|
|
|
|
"notes_notes",
|
|
|
|
"group_membership",
|
|
|
|
"billet_absence",
|
|
|
|
"adresse",
|
|
|
|
"absences",
|
|
|
|
"notes_notes_log",
|
|
|
|
"notes_moduleimpl_inscription",
|
|
|
|
"itemsuivi",
|
|
|
|
"notes_appreciations",
|
|
|
|
"scolar_autorisation_inscription",
|
|
|
|
"absences_notifications",
|
|
|
|
"notes_formsemestre_inscription",
|
|
|
|
"scolar_formsemestre_validation",
|
|
|
|
"scolar_events",
|
|
|
|
]
|
|
|
|
for table in etud_tables:
|
2023-10-25 23:07:34 +02:00
|
|
|
log(f"delete from {table}")
|
2021-08-19 21:30:22 +02:00
|
|
|
cursor.execute(
|
|
|
|
f"delete from {table} where etudid in (select id from etudids_temp)"
|
|
|
|
)
|
|
|
|
|
|
|
|
reqs = [
|
2023-10-25 23:07:34 +02:00
|
|
|
"""delete from apc_validation_annee where referentiel_competence_id
|
|
|
|
in (select id from apc_referentiel_competences where dept_id = %(dept_id)s)""",
|
2023-02-09 11:56:20 +01:00
|
|
|
"delete from apc_referentiel_competences where dept_id = %(dept_id)s",
|
2021-08-19 21:30:22 +02:00
|
|
|
"delete from sco_prefs where dept_id = %(dept_id)s",
|
2023-10-25 23:07:34 +02:00
|
|
|
"""delete from notes_semset_formsemestre
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp)""",
|
|
|
|
"""delete from notes_evaluation
|
|
|
|
where moduleimpl_id in (select id from moduleimpls_temp)""",
|
|
|
|
"""delete from notes_modules_enseignants
|
|
|
|
where moduleimpl_id in (select id from moduleimpls_temp)""",
|
|
|
|
"""delete from notes_formsemestre_uecoef
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp)""",
|
|
|
|
"""delete from notes_formsemestre_ue_computation_expr
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp)""",
|
|
|
|
"""delete from notes_formsemestre_responsables
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp)""",
|
|
|
|
"""delete from notes_moduleimpl
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp)""",
|
|
|
|
"""delete from notes_modules_tags
|
|
|
|
where tag_id in (select id from tags_temp)""",
|
2021-08-19 21:30:22 +02:00
|
|
|
"delete from notes_tags where dept_id = %(dept_id)s",
|
|
|
|
"delete from notes_modules where formation_id in (select id from formations_temp)",
|
2023-10-25 23:07:34 +02:00
|
|
|
"""delete from notes_matieres
|
|
|
|
where ue_id in (select id from notes_ue
|
|
|
|
where formation_id in (select id from formations_temp))""",
|
|
|
|
"""delete from notes_formsemestre_etapes
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp)""",
|
|
|
|
"""delete from group_descr where partition_id in
|
|
|
|
(select id from partition
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp))""",
|
2021-08-19 21:30:22 +02:00
|
|
|
"delete from partition where formsemestre_id in (select id from formsemestres_temp)",
|
2023-10-25 23:07:34 +02:00
|
|
|
"""delete from notes_formsemestre_custommenu
|
|
|
|
where formsemestre_id in (select id from formsemestres_temp)""",
|
2021-08-19 21:30:22 +02:00
|
|
|
"delete from notes_ue where formation_id in (select id from formations_temp)",
|
|
|
|
"delete from notes_formsemestre where dept_id = %(dept_id)s",
|
|
|
|
"delete from scolar_news where dept_id = %(dept_id)s",
|
|
|
|
"delete from notes_semset where dept_id = %(dept_id)s",
|
|
|
|
"delete from notes_formations where dept_id = %(dept_id)s",
|
2023-10-26 16:15:29 +02:00
|
|
|
"delete from itemsuivi_tags where dept_id = %(dept_id)s",
|
|
|
|
"delete from identite where dept_id = %(dept_id)s",
|
2021-08-19 21:30:22 +02:00
|
|
|
"delete from departement where id = %(dept_id)s",
|
|
|
|
"drop table tags_temp",
|
|
|
|
"drop table formations_temp",
|
|
|
|
"drop table moduleimpls_temp",
|
|
|
|
"drop table etudids_temp",
|
|
|
|
"drop table formsemestres_temp",
|
|
|
|
]
|
|
|
|
for r in reqs:
|
2023-10-25 23:07:34 +02:00
|
|
|
log(f"delete_dept: {r}")
|
2021-08-19 21:30:22 +02:00
|
|
|
cursor.execute(r, {"dept_id": dept_id})
|
2023-02-09 11:56:20 +01:00
|
|
|
except Exception as e:
|
2021-08-19 21:30:22 +02:00
|
|
|
cnx.rollback()
|
2023-02-09 11:56:20 +01:00
|
|
|
return str(e)
|
2021-08-19 21:30:22 +02:00
|
|
|
finally:
|
|
|
|
cnx.commit()
|
2021-09-02 16:32:47 +02:00
|
|
|
app.clear_scodoc_cache()
|
2023-02-09 11:56:20 +01:00
|
|
|
return ""
|