forked from ScoDoc/ScoDoc
refactoring and tests
This commit is contained in:
parent
c153c11606
commit
540623d3b9
3
README.md
Executable file → Normal file
3
README.md
Executable file → Normal file
@ -240,6 +240,9 @@ Puis dérouler les tests unitaires:
|
||||
|
||||
pytest tests/unit
|
||||
|
||||
Ou avec couverture (`pip install pytest-cov`)
|
||||
|
||||
pytest --cov=app --cov-report=term-missing --cov-branch tests/unit/*
|
||||
|
||||
## TODO
|
||||
|
||||
|
@ -164,8 +164,7 @@ def scodoc7func(context):
|
||||
req_args = REQUEST.form # args from query string (get) or form (post)
|
||||
# --- Add positional arguments
|
||||
pos_arg_values = []
|
||||
# PY3 à remplacer par inspect.getfullargspec en py3: TODO
|
||||
argspec = inspect.getargspec(func)
|
||||
argspec = inspect.getfullargspec(func)
|
||||
# current_app.logger.info("argspec=%s" % str(argspec))
|
||||
nb_default_args = len(argspec.defaults) if argspec.defaults else 0
|
||||
if nb_default_args:
|
||||
|
@ -2,14 +2,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
import inspect
|
||||
import time
|
||||
import traceback
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.header import Header
|
||||
from flask import current_app
|
||||
|
||||
from flask import g, current_app
|
||||
|
||||
"""Simple & stupid file logguer, used only to debug
|
||||
(logging to SQL is done in scolog)
|
||||
@ -18,7 +17,7 @@ from flask import current_app
|
||||
LOG_FILENAME = "notes.log" # empty to disable logging
|
||||
DEFAULT_LOG_DIR = "/tmp" # clients should call set_log_directory to change this
|
||||
|
||||
ALARM_DESTINATION = "emmanuel.viennet@univ-paris13.fr" # XXX a mettre en preference
|
||||
ALARM_DESTINATION = "emmanuel.viennet@gmail.com" # XXX a mettre en preference
|
||||
|
||||
|
||||
class _logguer(object):
|
||||
@ -46,7 +45,11 @@ class _logguer(object):
|
||||
if not self.file:
|
||||
self._open()
|
||||
if self.file:
|
||||
dept = retreive_dept()
|
||||
try:
|
||||
dept = getattr(g, "scodoc_dept", "")
|
||||
except RuntimeError:
|
||||
# Flask Working outside of application context.
|
||||
dept = ""
|
||||
if dept:
|
||||
dept = " (%s)" % dept
|
||||
msg = dept + " " + msg
|
||||
@ -60,42 +63,6 @@ class _logguer(object):
|
||||
log = _logguer()
|
||||
|
||||
|
||||
def retreive_request(skip=0):
|
||||
"""Try to retreive a REQUEST variable in caller stack.
|
||||
This is a hack, used only in log functions.
|
||||
"""
|
||||
|
||||
def search(frame):
|
||||
if "REQUEST" in frame.f_locals:
|
||||
return frame.f_locals["REQUEST"]
|
||||
if frame.f_back:
|
||||
return search(frame.f_back)
|
||||
else:
|
||||
return None
|
||||
|
||||
frame = inspect.currentframe()
|
||||
if frame: # not supported by all pythons
|
||||
startframe = frame
|
||||
while skip and startframe.f_back:
|
||||
startframe = startframe.f_back
|
||||
return search(startframe)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def retreive_dept():
|
||||
"""Try to retreive departement (from REQUEST URL)"""
|
||||
REQUEST = retreive_request()
|
||||
if not REQUEST:
|
||||
return ""
|
||||
try:
|
||||
url = REQUEST.URL
|
||||
m = re.match(r"^.*ScoDoc/(\w+).*$", url)
|
||||
return m.group(1)
|
||||
except:
|
||||
return ""
|
||||
|
||||
|
||||
# Alarms by email:
|
||||
def sendAlarm(context, subj, txt):
|
||||
from . import sco_utils
|
||||
|
@ -617,7 +617,6 @@ def add_absence(
|
||||
vars(),
|
||||
)
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
"AddAbsence",
|
||||
etudid=etudid,
|
||||
@ -642,7 +641,6 @@ def add_justif(context, etudid, jour, matin, REQUEST, description=None):
|
||||
vars(),
|
||||
)
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
"AddJustif",
|
||||
etudid=etudid,
|
||||
@ -679,7 +677,6 @@ def annule_absence(context, etudid, jour, matin, moduleimpl_id=None, REQUEST=Non
|
||||
req += " and moduleimpl_id=%(moduleimpl_id)s"
|
||||
cursor.execute(req, vars())
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
"AnnuleAbsence",
|
||||
etudid=etudid,
|
||||
@ -704,7 +701,6 @@ def annule_justif(context, etudid, jour, matin, REQUEST=None):
|
||||
vars(),
|
||||
)
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
"AnnuleJustif",
|
||||
etudid=etudid,
|
||||
|
@ -652,7 +652,6 @@ def AnnuleAbsencesDatesNoJust(context, etudid, dates, moduleimpl_id=None, REQUES
|
||||
else:
|
||||
date1 = None
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
"AnnuleAbsencesDatesNoJust",
|
||||
etudid=etudid,
|
||||
|
@ -488,7 +488,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
|
||||
msg = "Nouvelle%20archive%20créée"
|
||||
|
||||
# submitted or cancelled:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_list_archives?formsemestre_id=%s&head_message=%s"
|
||||
% (formsemestre_id, msg)
|
||||
)
|
||||
@ -566,12 +566,10 @@ def formsemestre_delete_archive(
|
||||
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Confirmer la suppression de l'archive du %s ?</h2>
|
||||
<p>La suppression sera définitive.</p>"""
|
||||
% PVArchive.get_archive_date(archive_id).strftime("%d/%m/%Y %H:%M"),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url=dest_url,
|
||||
parameters={
|
||||
"formsemestre_id": formsemestre_id,
|
||||
@ -580,4 +578,4 @@ def formsemestre_delete_archive(
|
||||
)
|
||||
|
||||
PVArchive.delete_archive(archive_id)
|
||||
return REQUEST.RESPONSE.redirect(dest_url + "&head_message=Archive%20supprimée")
|
||||
return flask.redirect(dest_url + "&head_message=Archive%20supprimée")
|
||||
|
@ -29,6 +29,7 @@
|
||||
Il s'agit de fichiers quelconques, généralement utilisés pour conserver
|
||||
les dossiers d'admission et autres pièces utiles.
|
||||
"""
|
||||
import flask
|
||||
from flask import url_for, g
|
||||
|
||||
import app.scodoc.sco_utils as scu
|
||||
@ -164,7 +165,7 @@ def etud_upload_file_form(context, REQUEST, etudid):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
else:
|
||||
@ -174,7 +175,7 @@ def etud_upload_file_form(context, REQUEST, etudid):
|
||||
_store_etud_file_to_new_archive(
|
||||
context, REQUEST, etudid, data, filename, description=descr
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
|
||||
@ -201,7 +202,6 @@ def etud_delete_archive(context, REQUEST, etudid, archive_name, dialog_confirmed
|
||||
archive_id = EtudsArchive.get_id_from_name(context, etudid, archive_name)
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Confirmer la suppression des fichiers ?</h2>
|
||||
<p>Fichier associé le %s à l'étudiant %s</p>
|
||||
<p>La suppression sera définitive.</p>"""
|
||||
@ -210,7 +210,6 @@ def etud_delete_archive(context, REQUEST, etudid, archive_name, dialog_confirmed
|
||||
etud["nomprenom"],
|
||||
),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url=url_for(
|
||||
"scolar.ficheEtud",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
@ -221,7 +220,7 @@ def etud_delete_archive(context, REQUEST, etudid, archive_name, dialog_confirmed
|
||||
)
|
||||
|
||||
EtudsArchive.delete_archive(archive_id)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
"scolar.ficheEtud",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
@ -311,9 +310,13 @@ def etudarchive_import_files_form(context, group_id, REQUEST=None):
|
||||
return "\n".join(H) + tf[1] + "</li></ol>" + F
|
||||
elif tf[0] == -1:
|
||||
# retrouve le semestre à partir du groupe:
|
||||
g = sco_groups.get_group(context, group_id)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"formsemestre_status?formsemestre_id=" + g["formsemestre_id"]
|
||||
group = sco_groups.get_group(context, group_id)
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
"notes.formsemestre_status",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formsemestre_id=group["formsemestre_id"],
|
||||
)
|
||||
)
|
||||
else:
|
||||
return etudarchive_import_files(
|
||||
|
@ -256,7 +256,7 @@ def itemsuivi_suppress(context, itemsuivi_id, REQUEST=None):
|
||||
item = itemsuivi_get(cnx, itemsuivi_id, ignore_errors=True)
|
||||
if item:
|
||||
_itemsuivi_delete(cnx, itemsuivi_id)
|
||||
logdb(REQUEST, cnx, method="itemsuivi_suppress", etudid=item["etudid"])
|
||||
logdb(cnx, method="itemsuivi_suppress", etudid=item["etudid"])
|
||||
log("suppressed itemsuivi %s" % (itemsuivi_id,))
|
||||
|
||||
|
||||
@ -270,7 +270,7 @@ def itemsuivi_create(
|
||||
itemsuivi_id = _itemsuivi_create(
|
||||
cnx, args={"etudid": etudid, "item_date": item_date, "situation": situation}
|
||||
)
|
||||
logdb(REQUEST, cnx, method="itemsuivi_create", etudid=etudid)
|
||||
logdb(cnx, method="itemsuivi_create", etudid=etudid)
|
||||
log("created itemsuivi %s for %s" % (itemsuivi_id, etudid))
|
||||
item = itemsuivi_get(cnx, itemsuivi_id)
|
||||
if format == "json":
|
||||
|
@ -73,19 +73,17 @@ def formation_delete(context, formation_id=None, dialog_confirmed=False, REQUEST
|
||||
else:
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Confirmer la suppression de la formation %(titre)s (%(acronyme)s) ?</h2>
|
||||
<p><b>Attention:</b> la suppression d'une formation est <b>irréversible</b> et implique la supression de toutes les UE, matières et modules de la formation !
|
||||
</p>
|
||||
"""
|
||||
% F,
|
||||
REQUEST=REQUEST,
|
||||
OK="Supprimer cette formation",
|
||||
cancel_url=scu.NotesURL(),
|
||||
parameters={"formation_id": formation_id},
|
||||
)
|
||||
else:
|
||||
do_formation_delete(context, F["formation_id"], REQUEST)
|
||||
do_formation_delete(context, F["formation_id"])
|
||||
H.append(
|
||||
"""<p>OK, formation supprimée.</p>
|
||||
<p><a class="stdlink" href="%s">continuer</a></p>"""
|
||||
@ -96,7 +94,7 @@ def formation_delete(context, formation_id=None, dialog_confirmed=False, REQUEST
|
||||
return "\n".join(H)
|
||||
|
||||
|
||||
def do_formation_delete(context, oid, REQUEST):
|
||||
def do_formation_delete(context, oid):
|
||||
"""delete a formation (and all its UE, matieres, modules)
|
||||
XXX delete all ues, will break if there are validations ! USE WITH CARE !
|
||||
"""
|
||||
@ -107,7 +105,7 @@ def do_formation_delete(context, oid, REQUEST):
|
||||
# delete all UE in this formation
|
||||
ues = sco_edit_ue.do_ue_list(context, {"formation_id": oid})
|
||||
for ue in ues:
|
||||
sco_edit_ue.do_ue_delete(context, ue["ue_id"], REQUEST=REQUEST, force=True)
|
||||
sco_edit_ue.do_ue_delete(context, ue["ue_id"], force=True)
|
||||
|
||||
sco_formations._formationEditor.delete(cnx, oid)
|
||||
|
||||
@ -222,7 +220,7 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.NotesURL())
|
||||
return flask.redirect(scu.NotesURL())
|
||||
else:
|
||||
# check unicity : constraint UNIQUE(acronyme,titre,version)
|
||||
if create:
|
||||
@ -247,13 +245,13 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None):
|
||||
)
|
||||
#
|
||||
if create:
|
||||
formation_id = do_formation_create(context, tf[2], REQUEST)
|
||||
formation_id = do_formation_create(context, tf[2])
|
||||
else:
|
||||
do_formation_edit(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect("ue_list?formation_id=%s" % formation_id)
|
||||
return flask.redirect("ue_list?formation_id=%s" % formation_id)
|
||||
|
||||
|
||||
def do_formation_create(context, args, REQUEST):
|
||||
def do_formation_create(context, args):
|
||||
"create a formation"
|
||||
cnx = ndb.GetDBConnexion()
|
||||
# check unique acronyme/titre/version
|
||||
@ -338,7 +336,7 @@ def module_move(context, module_id, after=0, REQUEST=None, redirect=1):
|
||||
|
||||
# redirect to ue_list page:
|
||||
if redirect:
|
||||
return REQUEST.RESPONSE.redirect("ue_list?formation_id=" + formation_id)
|
||||
return flask.redirect("ue_list?formation_id=" + formation_id)
|
||||
|
||||
|
||||
def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
|
||||
@ -369,4 +367,4 @@ def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
|
||||
sco_edit_ue._ueEditor.edit(cnx, neigh)
|
||||
# redirect to ue_list page
|
||||
if redirect:
|
||||
return REQUEST.RESPONSE.redirect("ue_list?formation_id=" + o["formation_id"])
|
||||
return flask.redirect("ue_list?formation_id=" + o["formation_id"])
|
@ -68,7 +68,7 @@ def do_matiere_edit(context, *args, **kw):
|
||||
sco_edit_formation.invalidate_sems_in_formation(formation_id)
|
||||
|
||||
|
||||
def do_matiere_create(context, args, REQUEST):
|
||||
def do_matiere_create(context, args):
|
||||
"create a matiere"
|
||||
from app.scodoc import sco_edit_ue
|
||||
from app.scodoc import sco_formations
|
||||
@ -138,7 +138,7 @@ associé.
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
# check unicity
|
||||
mats = do_matiere_list(context, args={"ue_id": ue_id, "titre": tf[2]["titre"]})
|
||||
@ -149,11 +149,11 @@ associé.
|
||||
+ tf[1]
|
||||
+ html_sco_header.sco_footer()
|
||||
)
|
||||
_ = do_matiere_create(context, tf[2], REQUEST)
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
_ = do_matiere_create(context, tf[2])
|
||||
return flask.redirect(dest_url)
|
||||
|
||||
|
||||
def do_matiere_delete(context, oid, REQUEST):
|
||||
def do_matiere_delete(context, oid):
|
||||
"delete matiere and attached modules"
|
||||
from app.scodoc import sco_formations
|
||||
from app.scodoc import sco_edit_ue
|
||||
@ -174,7 +174,7 @@ def do_matiere_delete(context, oid, REQUEST):
|
||||
# delete all modules in this matiere
|
||||
mods = sco_edit_module.do_module_list(context, {"matiere_id": oid})
|
||||
for mod in mods:
|
||||
sco_edit_module.do_module_delete(context, mod["module_id"], REQUEST)
|
||||
sco_edit_module.do_module_delete(context, mod["module_id"])
|
||||
_matiereEditor.delete(cnx, oid)
|
||||
|
||||
# news
|
||||
@ -211,10 +211,10 @@ def matiere_delete(context, matiere_id=None, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
do_matiere_delete(context, matiere_id, REQUEST)
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
do_matiere_delete(context, matiere_id)
|
||||
return flask.redirect(dest_url)
|
||||
|
||||
|
||||
def matiere_edit(context, matiere_id=None, REQUEST=None):
|
||||
@ -284,7 +284,7 @@ associé.
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + help + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
# check unicity
|
||||
mats = do_matiere_list(
|
||||
@ -308,7 +308,7 @@ associé.
|
||||
|
||||
do_matiere_edit(context, tf[2])
|
||||
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
|
||||
|
||||
def matiere_is_locked(context, matiere_id):
|
||||
|
@ -28,6 +28,9 @@
|
||||
"""Ajout/Modification/Suppression modules
|
||||
(portage from DTML)
|
||||
"""
|
||||
import flask
|
||||
from flask import url_for, g
|
||||
|
||||
import app.scodoc.notesdb as ndb
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app.scodoc.notes_log import log
|
||||
@ -96,7 +99,7 @@ def do_module_list(context, *args, **kw):
|
||||
return _moduleEditor.list(cnx, *args, **kw)
|
||||
|
||||
|
||||
def do_module_create(context, args, REQUEST):
|
||||
def do_module_create(context, args):
|
||||
"create a module"
|
||||
# create
|
||||
from app.scodoc import sco_formations
|
||||
@ -237,13 +240,17 @@ def module_create(context, matiere_id=None, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
else:
|
||||
do_module_create(context, tf[2], REQUEST)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
scu.NotesURL() + "/ue_list?formation_id=" + UE["formation_id"]
|
||||
do_module_create(context, tf[2])
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
"notes.ue_list",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formation_id=UE["formation_id"],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def do_module_delete(context, oid, REQUEST):
|
||||
def do_module_delete(context, oid):
|
||||
"delete module"
|
||||
from app.scodoc import sco_formations
|
||||
|
||||
@ -255,12 +262,10 @@ def do_module_delete(context, oid, REQUEST):
|
||||
mods = sco_moduleimpl.do_moduleimpl_list(context, module_id=oid)
|
||||
if mods:
|
||||
err_page = scu.confirm_dialog(
|
||||
context,
|
||||
message="""<h3>Destruction du module impossible car il est utilisé dans des semestres existants !</h3>""",
|
||||
helpmsg="""Il faut d'abord supprimer le semestre. Mais il est peut être préférable de laisser ce programme intact et d'en créer une nouvelle version pour la modifier.""",
|
||||
dest_url="ue_list",
|
||||
parameters={"formation_id": mod["formation_id"]},
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
raise ScoGenError(err_page)
|
||||
# delete
|
||||
@ -303,10 +308,10 @@ def module_delete(context, module_id=None, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
do_module_delete(context, module_id, REQUEST)
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
do_module_delete(context, module_id)
|
||||
return flask.redirect(dest_url)
|
||||
|
||||
|
||||
def do_module_edit(context, val):
|
||||
@ -498,14 +503,14 @@ def module_edit(context, module_id=None, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
# l'UE peut changer
|
||||
tf[2]["ue_id"], tf[2]["matiere_id"] = tf[2]["ue_matiere_id"].split("!")
|
||||
# Check unicité code module dans la formation
|
||||
|
||||
do_module_edit(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
|
||||
|
||||
# Edition en ligne du code Apogee
|
||||
@ -594,7 +599,7 @@ def formation_add_malus_modules(context, formation_id, titre=None, REQUEST=None)
|
||||
ue_add_malus_module(context, ue["ue_id"], titre=titre, REQUEST=REQUEST)
|
||||
|
||||
if REQUEST:
|
||||
return REQUEST.RESPONSE.redirect("ue_list?formation_id=" + formation_id)
|
||||
return flask.redirect("ue_list?formation_id=" + formation_id)
|
||||
|
||||
|
||||
def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None):
|
||||
@ -623,7 +628,7 @@ def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None):
|
||||
Matlist = sco_edit_matiere.do_matiere_list(context, args={"ue_id": ue_id})
|
||||
numero = max([mat["numero"] for mat in Matlist]) + 10
|
||||
matiere_id = sco_edit_matiere.do_matiere_create(
|
||||
context, {"ue_id": ue_id, "titre": "Malus", "numero": numero}, REQUEST
|
||||
context, {"ue_id": ue_id, "titre": "Malus", "numero": numero}
|
||||
)
|
||||
|
||||
module_id = do_module_create(
|
||||
@ -638,7 +643,6 @@ def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None):
|
||||
"semestre_id": semestre_id,
|
||||
"module_type": scu.MODULE_MALUS,
|
||||
},
|
||||
REQUEST,
|
||||
)
|
||||
|
||||
return module_id
|
||||
|
@ -28,6 +28,10 @@
|
||||
"""Ajout/Modification/Suppression UE
|
||||
|
||||
"""
|
||||
import flask
|
||||
from flask import g, url_for
|
||||
from flask_login import current_user
|
||||
|
||||
import app.scodoc.notesdb as ndb
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app.scodoc.notes_log import log
|
||||
@ -83,7 +87,7 @@ def do_ue_list(context, *args, **kw):
|
||||
return _ueEditor.list(cnx, *args, **kw)
|
||||
|
||||
|
||||
def do_ue_create(context, args, REQUEST):
|
||||
def do_ue_create(context, args):
|
||||
"create an ue"
|
||||
from app.scodoc import sco_formations
|
||||
|
||||
@ -130,11 +134,9 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F
|
||||
)
|
||||
if validations and not delete_validations and not force:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"<p>%d étudiants ont validé l'UE %s (%s)</p><p>Si vous supprimez cette UE, ces validations vont être supprimées !</p>"
|
||||
% (len(validations), ue["acronyme"], ue["titre"]),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
target_variable="delete_validations",
|
||||
cancel_url="ue_list?formation_id=%s" % ue["formation_id"],
|
||||
parameters={"ue_id": ue_id, "dialog_confirmed": 1},
|
||||
@ -149,7 +151,7 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F
|
||||
# delete all matiere in this UE
|
||||
mats = sco_edit_matiere.do_matiere_list(context, {"ue_id": ue_id})
|
||||
for mat in mats:
|
||||
sco_edit_matiere.do_matiere_delete(context, mat["matiere_id"], REQUEST)
|
||||
sco_edit_matiere.do_matiere_delete(context, mat["matiere_id"])
|
||||
# delete uecoef and events
|
||||
ndb.SimpleQuery(
|
||||
"DELETE FROM notes_formsemestre_uecoef WHERE ue_id=%(ue_id)s",
|
||||
@ -171,8 +173,12 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F
|
||||
)
|
||||
#
|
||||
if not force:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
scu.NotesURL() + "/ue_list?formation_id=" + str(ue["formation_id"])
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
"notes.ue_list",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formation_id=ue["formation_id"],
|
||||
)
|
||||
)
|
||||
else:
|
||||
return None
|
||||
@ -337,12 +343,11 @@ def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None):
|
||||
context, formation_id, int(tf[2]["semestre_id"] or 0)
|
||||
)
|
||||
|
||||
ue_id = do_ue_create(context, tf[2], REQUEST)
|
||||
ue_id = do_ue_create(context, tf[2])
|
||||
if parcours.UE_IS_MODULE or tf[2]["create_matiere"]:
|
||||
matiere_id = sco_edit_matiere.do_matiere_create(
|
||||
context,
|
||||
{"ue_id": ue_id, "titre": tf[2]["titre"], "numero": 1},
|
||||
REQUEST,
|
||||
)
|
||||
if parcours.UE_IS_MODULE:
|
||||
# dans ce mode, crée un (unique) module dans l'UE:
|
||||
@ -357,12 +362,13 @@ def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None):
|
||||
"formation_id": formation_id,
|
||||
"semestre_id": tf[2]["semestre_id"],
|
||||
},
|
||||
REQUEST,
|
||||
)
|
||||
else:
|
||||
do_ue_edit(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
scu.NotesURL() + "/ue_list?formation_id=" + formation_id
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
"notes.ue_list", scodoc_dept=g.scodoc_dept, formation_id=formation_id
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@ -409,10 +415,8 @@ def ue_delete(
|
||||
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"<h2>Suppression de l'UE %(titre)s (%(acronyme)s))</h2>" % ue,
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
parameters={"ue_id": ue_id},
|
||||
cancel_url="ue_list?formation_id=%s" % ue["formation_id"],
|
||||
)
|
||||
@ -429,8 +433,6 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None):
|
||||
from app.scodoc import sco_formations
|
||||
from app.scodoc import sco_formsemestre_validation
|
||||
|
||||
authuser = REQUEST.AUTHENTICATED_USER
|
||||
|
||||
F = sco_formations.formation_list(context, args={"formation_id": formation_id})
|
||||
if not F:
|
||||
raise ScoValueError("invalid formation_id")
|
||||
@ -444,7 +446,7 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None):
|
||||
ue_list.sort(key=lambda u: (u["semestre_id"], u["numero"]))
|
||||
has_duplicate_ue_codes = len(set([ue["ue_code"] for ue in ue_list])) != len(ue_list)
|
||||
|
||||
perm_change = authuser.has_permission(Permission.ScoChangeFormation)
|
||||
perm_change = current_user.has_permission(Permission.ScoChangeFormation)
|
||||
# editable = (not locked) and perm_change
|
||||
# On autorise maintanant la modification des formations qui ont des semestres verrouillés,
|
||||
# sauf si cela affect les notes passées (verrouillées):
|
||||
@ -452,14 +454,14 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None):
|
||||
# - pas de changement des codes d'UE utilisés dans des semestres verrouillés
|
||||
editable = perm_change
|
||||
tag_editable = (
|
||||
authuser.has_permission(Permission.ScoEditFormationTags) or perm_change
|
||||
current_user.has_permission(Permission.ScoEditFormationTags) or perm_change
|
||||
)
|
||||
if locked:
|
||||
lockicon = scu.icontag("lock32_img", title="verrouillé")
|
||||
else:
|
||||
lockicon = ""
|
||||
|
||||
arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags(context, REQUEST)
|
||||
arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags()
|
||||
delete_icon = scu.icontag(
|
||||
"delete_small_img", title="Supprimer (module inutilisé)", alt="supprimer"
|
||||
)
|
||||
@ -802,7 +804,7 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
|
||||
H.append("</li>")
|
||||
H.append("</ul>")
|
||||
|
||||
if authuser.has_permission(Permission.ScoImplement):
|
||||
if current_user.has_permission(Permission.ScoImplement):
|
||||
H.append(
|
||||
"""<ul>
|
||||
<li><a class="stdlink" href="formsemestre_createwithmodules?formation_id=%(formation_id)s&semestre_id=1">Mettre en place un nouveau semestre de formation %(acronyme)s</a>
|
||||
|
@ -640,7 +640,7 @@ def view_apo_csv_store(
|
||||
context, data, semset["annee_scolaire"], semset["sem_id"]
|
||||
)
|
||||
|
||||
return REQUEST.RESPONSE.redirect("apo_semset_maq_status?semset_id=" + semset_id)
|
||||
return flask.redirect("apo_semset_maq_status?semset_id=" + semset_id)
|
||||
|
||||
|
||||
def view_apo_csv_download_and_store(context, etape_apo="", semset_id="", REQUEST=None):
|
||||
@ -670,12 +670,10 @@ def view_apo_csv_delete(
|
||||
dest_url = "apo_semset_maq_status?semset_id=" + semset_id
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Confirmer la suppression du fichier étape <tt>%s</tt>?</h2>
|
||||
<p>La suppression sera définitive.</p>"""
|
||||
% (etape_apo,),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url=dest_url,
|
||||
parameters={"semset_id": semset_id, "etape_apo": etape_apo},
|
||||
)
|
||||
@ -684,7 +682,7 @@ def view_apo_csv_delete(
|
||||
context, etape_apo, semset["annee_scolaire"], semset["sem_id"]
|
||||
)
|
||||
sco_etape_apogee.apo_csv_delete(context, info["archive_id"])
|
||||
return REQUEST.RESPONSE.redirect(dest_url + "&head_message=Archive%20supprimée")
|
||||
return flask.redirect(dest_url + "&head_message=Archive%20supprimée")
|
||||
|
||||
|
||||
def view_apo_csv(context, etape_apo="", semset_id="", format="html", REQUEST=None):
|
||||
|
@ -351,7 +351,6 @@ def _check_duplicate_code(cnx, args, code_name, context, edit=True, REQUEST=None
|
||||
parameters = {}
|
||||
if context:
|
||||
err_page = scu.confirm_dialog(
|
||||
context,
|
||||
message="""<h3>Code étudiant (%s) dupliqué !</h3>""" % code_name,
|
||||
helpmsg="""Le %s %s est déjà utilisé: un seul étudiant peut avoir ce code. Vérifier votre valeur ou supprimer l'autre étudiant avec cette valeur.<p><ul><li>"""
|
||||
% (code_name, args[code_name])
|
||||
@ -360,7 +359,6 @@ def _check_duplicate_code(cnx, args, code_name, context, edit=True, REQUEST=None
|
||||
OK=OK,
|
||||
dest_url=dest_url,
|
||||
parameters=parameters,
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
else:
|
||||
err_page = """<h3>Code étudiant (%s) dupliqué !</h3>""" % code_name
|
||||
@ -692,7 +690,6 @@ def create_etud(context, cnx, args={}, REQUEST=None):
|
||||
)
|
||||
# log
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="etudident_edit_form",
|
||||
etudid=etudid,
|
||||
|
@ -1046,7 +1046,7 @@ def evaluation_describe(evaluation_id="", edit_in_place=True, REQUEST=None):
|
||||
resp = u["prenomnom"]
|
||||
nomcomplet = u["nomcomplet"]
|
||||
can_edit = sco_permissions_check.can_edit_notes(
|
||||
context, REQUEST.AUTHENTICATED_USER, moduleimpl_id, allow_ens=False
|
||||
REQUEST.AUTHENTICATED_USER, moduleimpl_id, allow_ens=False
|
||||
)
|
||||
|
||||
link = (
|
||||
@ -1363,7 +1363,7 @@ def evaluation_create_form(
|
||||
head = html_sco_header.sco_header(page_title=page_title)
|
||||
return head + "\n".join(H) + "\n" + tf[1] + help + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
# form submission
|
||||
if tf[2]["visibulletinlist"]:
|
||||
@ -1373,7 +1373,7 @@ def evaluation_create_form(
|
||||
if not edit:
|
||||
# creation d'une evaluation
|
||||
evaluation_id = do_evaluation_create(REQUEST=REQUEST, **tf[2])
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
do_evaluation_edit(tf[2])
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
|
@ -116,7 +116,7 @@ def search_etud_in_dept(context, expnom="", REQUEST=None):
|
||||
|
||||
if len(etuds) == 1:
|
||||
# va directement a la fiche
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etuds[0]["etudid"]
|
||||
)
|
||||
|
@ -175,7 +175,7 @@ def formation_import_xml(context, REQUEST, doc, import_tags=True):
|
||||
# create formation
|
||||
# F_unquoted = F.copy()
|
||||
# unescape_html_dict(F_unquoted)
|
||||
formation_id = sco_edit_formation.do_formation_create(context, F, REQUEST)
|
||||
formation_id = sco_edit_formation.do_formation_create(context, F)
|
||||
log("formation %s created" % formation_id)
|
||||
ues_old2new = {} # xml ue_id : new ue_id
|
||||
modules_old2new = {} # xml module_id : new module_id
|
||||
@ -189,14 +189,14 @@ def formation_import_xml(context, REQUEST, doc, import_tags=True):
|
||||
del ue_info[1]["ue_id"]
|
||||
else:
|
||||
xml_ue_id = None
|
||||
ue_id = sco_edit_ue.do_ue_create(context, ue_info[1], REQUEST)
|
||||
ue_id = sco_edit_ue.do_ue_create(context, ue_info[1])
|
||||
if xml_ue_id:
|
||||
ues_old2new[xml_ue_id] = ue_id
|
||||
# -- create matieres
|
||||
for mat_info in ue_info[2]:
|
||||
assert mat_info[0] == "matiere"
|
||||
mat_info[1]["ue_id"] = ue_id
|
||||
mat_id = sco_edit_matiere.do_matiere_create(context, mat_info[1], REQUEST)
|
||||
mat_id = sco_edit_matiere.do_matiere_create(context, mat_info[1])
|
||||
# -- create modules
|
||||
for mod_info in mat_info[2]:
|
||||
assert mod_info[0] == "module"
|
||||
@ -208,7 +208,7 @@ def formation_import_xml(context, REQUEST, doc, import_tags=True):
|
||||
mod_info[1]["formation_id"] = formation_id
|
||||
mod_info[1]["matiere_id"] = mat_id
|
||||
mod_info[1]["ue_id"] = ue_id
|
||||
mod_id = sco_edit_module.do_module_create(context, mod_info[1], REQUEST)
|
||||
mod_id = sco_edit_module.do_module_create(context, mod_info[1])
|
||||
if xml_module_id:
|
||||
modules_old2new[xml_module_id] = mod_id
|
||||
if import_tags:
|
||||
@ -350,7 +350,7 @@ def formation_create_new_version(context, formation_id, redirect=True, REQUEST=N
|
||||
text="Nouvelle version de la formation %(acronyme)s" % F,
|
||||
)
|
||||
if redirect:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"ue_list?formation_id=" + new_id + "&msg=Nouvelle version !"
|
||||
)
|
||||
else:
|
||||
|
@ -130,7 +130,7 @@ def formsemestre_custommenu_edit(context, formsemestre_id, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + "\n" + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
# form submission
|
||||
cnx = ndb.GetDBConnexion()
|
||||
@ -157,4 +157,4 @@ def formsemestre_custommenu_edit(context, formsemestre_id, REQUEST=None):
|
||||
"url": tf[2]["url_" + custommenu_id],
|
||||
},
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
|
@ -741,7 +741,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
|
||||
"responsable_id": tf[2][module_id],
|
||||
}
|
||||
_ = sco_moduleimpl.do_moduleimpl_create(context, modargs)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id=%s&head_message=Nouveau%%20semestre%%20créé"
|
||||
% formsemestre_id
|
||||
)
|
||||
@ -845,7 +845,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
|
||||
)
|
||||
return msg_html
|
||||
else:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id=%s&head_message=Semestre modifié"
|
||||
% formsemestre_id
|
||||
)
|
||||
@ -989,7 +989,7 @@ def formsemestre_clone(context, formsemestre_id, REQUEST=None):
|
||||
if tf[0] == 0 or msg:
|
||||
return "".join(H) + msg + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1: # cancel
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id=%s" % formsemestre_id
|
||||
)
|
||||
else:
|
||||
@ -1003,7 +1003,7 @@ def formsemestre_clone(context, formsemestre_id, REQUEST=None):
|
||||
clone_partitions=tf[2]["clone_partitions"],
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id=%s&head_message=Nouveau%%20semestre%%20créé"
|
||||
% new_formsemestre_id
|
||||
)
|
||||
@ -1173,7 +1173,6 @@ def formsemestre_associate_new_version(
|
||||
)
|
||||
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Associer à une nouvelle version de formation non verrouillée ?</h2>
|
||||
<p>Le programme pédagogique ("formation") va être dupliqué pour que vous puissiez le modifier sans affecter les autres semestres. Les autres paramètres (étudiants, notes...) du semestre seront inchangés.</p>
|
||||
<p>Veillez à ne pas abuser de cette possibilité, car créer trop de versions de formations va vous compliquer la gestion (à vous de garder trace des différences et à ne pas vous tromper par la suite...).
|
||||
@ -1183,7 +1182,6 @@ def formsemestre_associate_new_version(
|
||||
+ "</div>",
|
||||
OK="Associer ces semestres à une nouvelle version",
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="formsemestre_status?formsemestre_id=%s" % formsemestre_id,
|
||||
parameters={"formsemestre_id": formsemestre_id},
|
||||
)
|
||||
@ -1191,7 +1189,7 @@ def formsemestre_associate_new_version(
|
||||
do_formsemestres_associate_new_version(
|
||||
context, [formsemestre_id] + other_formsemestre_ids, REQUEST=REQUEST
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id=%s&head_message=Formation%%20dupliquée"
|
||||
% formsemestre_id
|
||||
)
|
||||
@ -1315,13 +1313,11 @@ def formsemestre_delete(context, formsemestre_id, REQUEST=None):
|
||||
H.append(tf[1])
|
||||
return "\n".join(H) + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1: # cancel
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.NotesURL() + "/formsemestre_status?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
else:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"formsemestre_delete2?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
return flask.redirect("formsemestre_delete2?formsemestre_id=" + formsemestre_id)
|
||||
|
||||
|
||||
def formsemestre_delete2(
|
||||
@ -1331,16 +1327,14 @@ def formsemestre_delete2(
|
||||
# Confirmation dialog
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Vous voulez vraiment supprimer ce semestre ???</h2><p>(opération irréversible)</p>""",
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="formsemestre_status?formsemestre_id=%s" % formsemestre_id,
|
||||
parameters={"formsemestre_id": formsemestre_id},
|
||||
)
|
||||
# Bon, s'il le faut...
|
||||
do_formsemestre_delete(context, formsemestre_id, REQUEST)
|
||||
return REQUEST.RESPONSE.redirect(scu.ScoURL() + "?head_message=Semestre%20supprimé")
|
||||
do_formsemestre_delete(context, formsemestre_id)
|
||||
return flask.redirect(scu.ScoURL() + "?head_message=Semestre%20supprimé")
|
||||
|
||||
|
||||
def formsemestre_has_decisions_or_compensations(context, formsemestre_id):
|
||||
@ -1354,7 +1348,7 @@ def formsemestre_has_decisions_or_compensations(context, formsemestre_id):
|
||||
return r
|
||||
|
||||
|
||||
def do_formsemestre_delete(context, formsemestre_id, REQUEST):
|
||||
def do_formsemestre_delete(context, formsemestre_id):
|
||||
"""delete formsemestre, and all its moduleimpls.
|
||||
No checks, no warnings: erase all !
|
||||
"""
|
||||
@ -1444,9 +1438,7 @@ def formsemestre_edit_options(context, formsemestre_id, target_url=None, REQUEST
|
||||
(accessible par ScoImplement ou dir. etudes)
|
||||
"""
|
||||
log("formsemestre_edit_options")
|
||||
ok, err = sco_permissions_check.check_access_diretud(
|
||||
context, formsemestre_id, REQUEST
|
||||
)
|
||||
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
|
||||
if not ok:
|
||||
return err
|
||||
return sco_preferences.SemPreferences(formsemestre_id).edit(
|
||||
@ -1460,9 +1452,7 @@ def formsemestre_change_lock(
|
||||
"""Change etat (verrouille si ouvert, déverrouille si fermé)
|
||||
nota: etat (1 ouvert, 0 fermé)
|
||||
"""
|
||||
ok, err = sco_permissions_check.check_access_diretud(
|
||||
context, formsemestre_id, REQUEST
|
||||
)
|
||||
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
|
||||
if not ok:
|
||||
return err
|
||||
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
|
||||
@ -1474,7 +1464,6 @@ def formsemestre_change_lock(
|
||||
else:
|
||||
msg = "verrouillage"
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"<h2>Confirmer le %s du semestre ?</h2>" % msg,
|
||||
helpmsg="""Les notes d'un semestre verrouillé ne peuvent plus être modifiées.
|
||||
Un semestre verrouillé peut cependant être déverrouillé facilement à tout moment
|
||||
@ -1483,7 +1472,6 @@ def formsemestre_change_lock(
|
||||
Le programme d'une formation qui a un semestre verrouillé ne peut plus être modifié.
|
||||
""",
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="formsemestre_status?formsemestre_id=%s" % formsemestre_id,
|
||||
parameters={"etat": etat, "formsemestre_id": formsemestre_id},
|
||||
)
|
||||
@ -1493,7 +1481,7 @@ def formsemestre_change_lock(
|
||||
args = {"formsemestre_id": formsemestre_id, "etat": etat}
|
||||
sco_formsemestre.do_formsemestre_edit(context, args)
|
||||
if REQUEST:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id=%s" % formsemestre_id
|
||||
)
|
||||
|
||||
@ -1502,9 +1490,7 @@ def formsemestre_change_publication_bul(
|
||||
context, formsemestre_id, REQUEST=None, dialog_confirmed=False
|
||||
):
|
||||
"""Change etat publication bulletins sur portail"""
|
||||
ok, err = sco_permissions_check.check_access_diretud(
|
||||
context, formsemestre_id, REQUEST
|
||||
)
|
||||
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
|
||||
if not ok:
|
||||
return err
|
||||
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
|
||||
@ -1516,7 +1502,6 @@ def formsemestre_change_publication_bul(
|
||||
else:
|
||||
msg = ""
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"<h2>Confirmer la %s publication des bulletins ?</h2>" % msg,
|
||||
helpmsg="""Il est parfois utile de désactiver la diffusion des bulletins,
|
||||
par exemple pendant la tenue d'un jury ou avant harmonisation des notes.
|
||||
@ -1524,7 +1509,6 @@ def formsemestre_change_publication_bul(
|
||||
Ce réglage n'a d'effet que si votre établissement a interfacé ScoDoc et un portail étudiant.
|
||||
""",
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="formsemestre_status?formsemestre_id=%s" % formsemestre_id,
|
||||
parameters={"bul_hide_xml": etat, "formsemestre_id": formsemestre_id},
|
||||
)
|
||||
@ -1536,7 +1520,7 @@ def formsemestre_change_publication_bul(
|
||||
args = {"formsemestre_id": formsemestre_id, "bul_hide_xml": etat}
|
||||
sco_formsemestre.do_formsemestre_edit(context, args)
|
||||
if REQUEST:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id=%s" % formsemestre_id
|
||||
)
|
||||
return None
|
||||
@ -1546,9 +1530,7 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
|
||||
"""Changement manuel des coefficients des UE capitalisées."""
|
||||
from app.scodoc import notes_table
|
||||
|
||||
ok, err = sco_permissions_check.check_access_diretud(
|
||||
context, formsemestre_id, REQUEST
|
||||
)
|
||||
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
|
||||
if not ok:
|
||||
return err
|
||||
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
|
||||
|
@ -199,14 +199,14 @@ def formsemestre_ext_create_form(context, etudid, formsemestre_id, REQUEST=None)
|
||||
)
|
||||
return "\n".join(H) + "\n" + tf[1] + F
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"%s/formsemestre_bulletinetud?formsemestre_id==%s&etudid=%s"
|
||||
% (scu.ScoURL(), formsemestre_id, etudid)
|
||||
)
|
||||
else:
|
||||
tf[2]["formation_id"] = orig_sem["formation_id"]
|
||||
formsemestre_ext_create(context, etudid, tf[2], REQUEST=REQUEST)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
|
||||
@ -258,7 +258,7 @@ def formsemestre_ext_edit_ue_validations(
|
||||
_record_ue_validations_and_coefs(
|
||||
context, formsemestre_id, etudid, ue_list, tf[2], REQUEST=REQUEST
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_bulletinetud?formsemestre_id=%s&etudid=%s"
|
||||
% (formsemestre_id, etudid)
|
||||
)
|
||||
|
@ -102,7 +102,6 @@ def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
|
||||
)
|
||||
# Log etudiant
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method=method,
|
||||
etudid=args["etudid"],
|
||||
@ -187,13 +186,10 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
|
||||
"do_formsemestre_desinscription: suppression du semestre extérieur %s"
|
||||
% formsemestre_id
|
||||
)
|
||||
sco_formsemestre_edit.do_formsemestre_delete(
|
||||
context, formsemestre_id, REQUEST=REQUEST
|
||||
)
|
||||
sco_formsemestre_edit.do_formsemestre_delete(context, formsemestre_id)
|
||||
|
||||
if REQUEST:
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="formsemestre_desinscription",
|
||||
etudid=etudid,
|
||||
@ -416,7 +412,7 @@ def formsemestre_inscription_with_modules(
|
||||
REQUEST=REQUEST,
|
||||
method="formsemestre_inscription_with_modules",
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
else:
|
||||
@ -569,7 +565,7 @@ function chkbx_select(field_id, state) {
|
||||
)
|
||||
return "\n".join(H) + "\n" + tf[1] + F
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
else:
|
||||
|
@ -417,17 +417,17 @@ def _redirect_valid_choice(
|
||||
adr += "&sortcol=" + sortcol
|
||||
# if desturl:
|
||||
# desturl += "&desturl=" + desturl
|
||||
return REQUEST.RESPONSE.redirect(adr)
|
||||
return flask.redirect(adr)
|
||||
# Si le precedent a été modifié, demande relecture du parcours.
|
||||
# sinon renvoie au listing general,
|
||||
|
||||
|
||||
# if choice.new_code_prev:
|
||||
# REQUEST.RESPONSE.redirect( 'formsemestre_validation_etud_form?formsemestre_id=%s&etudid=%s&check=1&desturl=%s' % (formsemestre_id, etudid, desturl) )
|
||||
# flask.redirect( 'formsemestre_validation_etud_form?formsemestre_id=%s&etudid=%s&check=1&desturl=%s' % (formsemestre_id, etudid, desturl) )
|
||||
# else:
|
||||
# if not desturl:
|
||||
# desturl = 'formsemestre_recapcomplet?modejury=1&hidemodules=1&formsemestre_id=' + formsemestre_id
|
||||
# REQUEST.RESPONSE.redirect(desturl)
|
||||
# flask.redirect(desturl)
|
||||
|
||||
|
||||
def _dispcode(c):
|
||||
@ -1080,7 +1080,7 @@ def formsemestre_validate_previous_ue(context, formsemestre_id, etudid, REQUEST=
|
||||
warn, ue_multiples = check_formation_ues(context, Fo["formation_id"])
|
||||
return "\n".join(H) + tf[1] + X + warn + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.NotesURL() + "/formsemestre_status?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
else:
|
||||
@ -1098,7 +1098,7 @@ def formsemestre_validate_previous_ue(context, formsemestre_id, etudid, REQUEST=
|
||||
semestre_id=semestre_id,
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.ScoURL()
|
||||
+ "/Notes/formsemestre_bulletinetud?formsemestre_id=%s&etudid=%s&head_message=Validation%%20d'UE%%20enregistree"
|
||||
% (formsemestre_id, etudid)
|
||||
@ -1146,7 +1146,6 @@ def do_formsemestre_validate_previous_ue(
|
||||
)
|
||||
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="formsemestre_validate_previous_ue",
|
||||
etudid=etudid,
|
||||
@ -1221,7 +1220,7 @@ def etud_ue_suppress_validation(context, etudid, formsemestre_id, ue_id, REQUEST
|
||||
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
|
||||
_invalidate_etud_formation_caches(context, etudid, sem["formation_id"])
|
||||
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.NotesURL()
|
||||
+ "/formsemestre_validate_previous_ue?etudid=%s&formsemestre_id=%s"
|
||||
% (etudid, formsemestre_id)
|
||||
|
@ -571,7 +571,6 @@ def change_etud_group_in_partition(
|
||||
if REQUEST:
|
||||
cnx = ndb.GetDBConnexion()
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="changeGroup",
|
||||
etudid=etudid,
|
||||
@ -649,7 +648,6 @@ def setGroups(
|
||||
cursor=cursor,
|
||||
)
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="removeFromGroup",
|
||||
etudid=etudid,
|
||||
@ -778,7 +776,7 @@ def partition_create(
|
||||
return partition_id
|
||||
|
||||
|
||||
def getArrowIconsTags(context, REQUEST):
|
||||
def getArrowIconsTags():
|
||||
"""returns html tags for arrows"""
|
||||
#
|
||||
arrow_up = scu.icontag("arrow_up", title="remonter")
|
||||
@ -794,7 +792,7 @@ def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
|
||||
if not sco_permissions_check.can_change_groups(formsemestre_id):
|
||||
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
|
||||
partitions = get_partitions_list(context, formsemestre_id)
|
||||
arrow_up, arrow_down, arrow_none = getArrowIconsTags(context, REQUEST)
|
||||
arrow_up, arrow_down, arrow_none = getArrowIconsTags()
|
||||
suppricon = scu.icontag(
|
||||
"delete_small_img", border="0", alt="supprimer", title="Supprimer"
|
||||
)
|
||||
@ -957,13 +955,11 @@ def partition_delete(
|
||||
else:
|
||||
grnames = ""
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Supprimer la partition "%s" ?</h2>
|
||||
<p>Les groupes %s de cette partition seront supprimés</p>
|
||||
"""
|
||||
% (partition["partition_name"], grnames),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="editPartitionForm?formsemestre_id=%s" % formsemestre_id,
|
||||
parameters={"redirect": redirect, "partition_id": partition_id},
|
||||
)
|
||||
@ -977,9 +973,7 @@ def partition_delete(
|
||||
|
||||
# redirect to partition edit page:
|
||||
if redirect:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"editPartitionForm?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
return flask.redirect("editPartitionForm?formsemestre_id=" + formsemestre_id)
|
||||
|
||||
|
||||
def partition_move(context, partition_id, after=0, REQUEST=None, redirect=1):
|
||||
@ -1012,9 +1006,7 @@ def partition_move(context, partition_id, after=0, REQUEST=None, redirect=1):
|
||||
|
||||
# redirect to partition edit page:
|
||||
if redirect:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"editPartitionForm?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
return flask.redirect("editPartitionForm?formsemestre_id=" + formsemestre_id)
|
||||
|
||||
|
||||
def partition_rename(context, partition_id, REQUEST=None):
|
||||
@ -1051,9 +1043,7 @@ def partition_rename(context, partition_id, REQUEST=None):
|
||||
+ html_sco_header.sco_footer()
|
||||
)
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"editPartitionForm?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
return flask.redirect("editPartitionForm?formsemestre_id=" + formsemestre_id)
|
||||
else:
|
||||
# form submission
|
||||
return partition_set_name(
|
||||
@ -1091,9 +1081,7 @@ def partition_set_name(context, partition_id, partition_name, REQUEST=None, redi
|
||||
|
||||
# redirect to partition edit page:
|
||||
if redirect:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"editPartitionForm?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
return flask.redirect("editPartitionForm?formsemestre_id=" + formsemestre_id)
|
||||
|
||||
|
||||
def group_set_name(context, group_id, group_name, REQUEST=None, redirect=1):
|
||||
@ -1114,9 +1102,7 @@ def group_set_name(context, group_id, group_name, REQUEST=None, redirect=1):
|
||||
|
||||
# redirect to partition edit page:
|
||||
if redirect:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"affectGroups?partition_id=" + group["partition_id"]
|
||||
)
|
||||
return flask.redirect("affectGroups?partition_id=" + group["partition_id"])
|
||||
|
||||
|
||||
def group_rename(context, group_id, REQUEST=None):
|
||||
@ -1153,9 +1139,7 @@ def group_rename(context, group_id, REQUEST=None):
|
||||
+ html_sco_header.sco_footer()
|
||||
)
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"affectGroups?partition_id=" + group["partition_id"]
|
||||
)
|
||||
return flask.redirect("affectGroups?partition_id=" + group["partition_id"])
|
||||
else:
|
||||
# form submission
|
||||
return group_set_name(
|
||||
@ -1213,7 +1197,7 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + "\n" + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
# form submission
|
||||
log(
|
||||
@ -1263,7 +1247,7 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
|
||||
context, etudid, group_id, partition, REQUEST=REQUEST
|
||||
)
|
||||
log("%s in group %s" % (etudid, group_id))
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
|
||||
|
||||
def get_prev_moy(context, etudid, formsemestre_id):
|
||||
|
@ -350,7 +350,6 @@ def formsemestre_inscr_passage(
|
||||
H.append("""<h3>Il n'y a rien à modifier !</h3>""")
|
||||
H.append(
|
||||
scu.confirm_dialog(
|
||||
context,
|
||||
dest_url="formsemestre_inscr_passage",
|
||||
add_headers=False,
|
||||
cancel_url="formsemestre_inscr_passage?formsemestre_id="
|
||||
@ -362,7 +361,6 @@ def formsemestre_inscr_passage(
|
||||
"inscrit_groupes": inscrit_groupes,
|
||||
"submitted": 1,
|
||||
},
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
)
|
||||
else:
|
||||
|
@ -192,7 +192,7 @@ def do_evaluation_listenotes(context, REQUEST):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + "\n" + tf[1]
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"%s/Notes/moduleimpl_status?moduleimpl_id=%s"
|
||||
% (scu.ScoURL(), E["moduleimpl_id"])
|
||||
)
|
||||
|
@ -222,7 +222,6 @@ def do_moduleimpl_inscription_create(context, args, REQUEST=None, formsemestre_i
|
||||
) # > moduleimpl_inscription
|
||||
if REQUEST:
|
||||
scolog.logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="moduleimpl_inscription",
|
||||
etudid=args["etudid"],
|
||||
|
@ -200,9 +200,7 @@ def moduleimpl_inscriptions_edit(
|
||||
sco_moduleimpl.do_moduleimpl_inscrit_etuds(
|
||||
context, moduleimpl_id, formsemestre_id, etuds, reset=True, REQUEST=REQUEST
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"moduleimpl_status?moduleimpl_id=%s" % (moduleimpl_id)
|
||||
)
|
||||
return flask.redirect("moduleimpl_status?moduleimpl_id=%s" % (moduleimpl_id))
|
||||
#
|
||||
H.append(footer)
|
||||
return "\n".join(H)
|
||||
@ -557,7 +555,6 @@ def do_etud_desinscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None)
|
||||
)
|
||||
if REQUEST:
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="etud_desinscrit_ue",
|
||||
etudid=etudid,
|
||||
|
@ -31,6 +31,7 @@ import time
|
||||
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
|
||||
|
||||
from flask import g, url_for
|
||||
from flask_login import current_user
|
||||
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
@ -64,7 +65,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
|
||||
|
||||
if (
|
||||
sco_permissions_check.can_edit_notes(
|
||||
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
)
|
||||
and nbnotes != 0
|
||||
):
|
||||
@ -80,7 +81,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
|
||||
"evaluation_id": evaluation_id,
|
||||
},
|
||||
"enabled": sco_permissions_check.can_edit_notes(
|
||||
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
|
||||
REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
|
||||
),
|
||||
},
|
||||
{
|
||||
@ -90,7 +91,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
|
||||
"evaluation_id": evaluation_id,
|
||||
},
|
||||
"enabled": sco_permissions_check.can_edit_notes(
|
||||
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
),
|
||||
},
|
||||
{
|
||||
@ -101,7 +102,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
|
||||
},
|
||||
"enabled": nbnotes == 0
|
||||
and sco_permissions_check.can_edit_notes(
|
||||
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
),
|
||||
},
|
||||
{
|
||||
@ -111,7 +112,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
|
||||
"evaluation_id": evaluation_id,
|
||||
},
|
||||
"enabled": sco_permissions_check.can_edit_notes(
|
||||
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
),
|
||||
},
|
||||
{
|
||||
@ -130,7 +131,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
|
||||
},
|
||||
"enabled": nbnotes == 0
|
||||
and sco_permissions_check.can_edit_notes(
|
||||
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
|
||||
REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
|
||||
),
|
||||
},
|
||||
{
|
||||
@ -157,7 +158,6 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
|
||||
|
||||
def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=None):
|
||||
"""Tableau de bord module (liste des evaluations etc)"""
|
||||
authuser = REQUEST.AUTHENTICATED_USER
|
||||
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
|
||||
formsemestre_id = M["formsemestre_id"]
|
||||
Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
|
||||
@ -177,12 +177,10 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
|
||||
|
||||
#
|
||||
caneditevals = sco_permissions_check.can_edit_notes(
|
||||
context, authuser, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"]
|
||||
current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"]
|
||||
)
|
||||
caneditnotes = sco_permissions_check.can_edit_notes(
|
||||
context, authuser, moduleimpl_id
|
||||
)
|
||||
arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags(context, REQUEST)
|
||||
caneditnotes = sco_permissions_check.can_edit_notes(current_user, moduleimpl_id)
|
||||
arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags()
|
||||
#
|
||||
H = [
|
||||
html_sco_header.sco_header(page_title="Module %(titre)s" % Mod),
|
||||
@ -240,7 +238,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
|
||||
"""<tr><td class="fichetitre2">Inscrits: </td><td> %d étudiants"""
|
||||
% len(ModInscrits)
|
||||
)
|
||||
if authuser.has_permission(Permission.ScoEtudInscrit):
|
||||
if current_user.has_permission(Permission.ScoEtudInscrit):
|
||||
H.append(
|
||||
"""<a class="stdlink" style="margin-left:2em;" href="moduleimpl_inscriptions_edit?moduleimpl_id=%s">modifier</a>"""
|
||||
% M["moduleimpl_id"]
|
||||
@ -279,7 +277,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
|
||||
)
|
||||
# Adapté à partir d'une suggestion de DS (Le Havre)
|
||||
# Liens saisies absences seulement si permission et date courante dans le semestre
|
||||
if authuser.has_permission(
|
||||
if current_user.has_permission(
|
||||
Permission.ScoAbsChange
|
||||
) and sco_formsemestre.sem_est_courant(context, sem):
|
||||
datelundi = sco_abs.ddmmyyyy(time.strftime("%d/%m/%Y")).prev_monday()
|
||||
|
@ -574,7 +574,6 @@ class SituationEtudParcoursGeneric(object):
|
||||
decision.formsemestre_id_utilise_pour_compenser,
|
||||
)
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="validate_sem",
|
||||
etudid=self.etudid,
|
||||
@ -607,7 +606,6 @@ class SituationEtudParcoursGeneric(object):
|
||||
formsemestre_id_utilise_pour_compenser=fsid,
|
||||
)
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="validate_sem",
|
||||
etudid=self.etudid,
|
||||
@ -932,7 +930,6 @@ def formsemestre_validate_ues(
|
||||
|
||||
if REQUEST:
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="validate_ue",
|
||||
etudid=etudid,
|
||||
|
@ -14,7 +14,7 @@ from app.scodoc import sco_exceptions
|
||||
from app.scodoc import sco_moduleimpl
|
||||
|
||||
|
||||
def can_edit_notes(context, authuser, moduleimpl_id, allow_ens=True):
|
||||
def can_edit_notes(authuser, moduleimpl_id, allow_ens=True):
|
||||
"""True if authuser can enter or edit notes in this module.
|
||||
If allow_ens, grant access to all ens in this module
|
||||
|
||||
@ -24,6 +24,7 @@ def can_edit_notes(context, authuser, moduleimpl_id, allow_ens=True):
|
||||
from app.scodoc import sco_formsemestre
|
||||
from app.scodoc import sco_parcours_dut
|
||||
|
||||
context = None # XXX #context
|
||||
uid = str(authuser)
|
||||
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
|
||||
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
|
||||
@ -139,14 +140,14 @@ def is_chef_or_diretud(sem):
|
||||
return False
|
||||
|
||||
|
||||
def check_access_diretud(
|
||||
context, formsemestre_id, REQUEST, required_permission=Permission.ScoImplement
|
||||
):
|
||||
def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImplement):
|
||||
"""Check if access granted: responsable or ScoImplement
|
||||
Return True|False, HTML_error_page
|
||||
"""
|
||||
from app.scodoc import sco_formsemestre
|
||||
|
||||
context = None # XXX #context
|
||||
|
||||
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
|
||||
header = html_sco_header.sco_header(page_title="Accès interdit")
|
||||
footer = html_sco_header.sco_footer()
|
||||
|
@ -257,8 +257,7 @@ def store_photo(context, etud, data, REQUEST=None):
|
||||
sco_etud.identite_edit_nocheck(cnx, etud)
|
||||
cnx.commit()
|
||||
#
|
||||
if REQUEST:
|
||||
logdb(REQUEST, cnx, method="changePhoto", msg=filename, etudid=etud["etudid"])
|
||||
logdb(cnx, method="changePhoto", msg=filename, etudid=etud["etudid"])
|
||||
#
|
||||
return 1, "ok"
|
||||
|
||||
@ -282,9 +281,7 @@ def suppress_photo(context, etud, REQUEST=None):
|
||||
os.remove(filename)
|
||||
# 3- log
|
||||
if REQUEST:
|
||||
logdb(
|
||||
REQUEST, cnx, method="changePhoto", msg="suppression", etudid=etud["etudid"]
|
||||
)
|
||||
logdb(cnx, method="changePhoto", msg="suppression", etudid=etud["etudid"])
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
@ -195,7 +195,7 @@ def do_placement_selectetuds(context, REQUEST):
|
||||
H.append("""<div class="saisienote_etape1">""")
|
||||
return "\n".join(H) + "\n" + tf[1] + "\n</div>"
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"%s/Notes/moduleimpl_status?moduleimpl_id=%s"
|
||||
% (scu.ScoURL(), E["moduleimpl_id"])
|
||||
)
|
||||
@ -225,7 +225,7 @@ def do_placement_selectetuds(context, REQUEST):
|
||||
)
|
||||
+ "&".join(gs)
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(scu.NotesURL() + "/do_placement?" + query)
|
||||
return flask.redirect(scu.NotesURL() + "/do_placement?" + query)
|
||||
else:
|
||||
raise ValueError(
|
||||
"invalid placement_method (%s)" % tf[2]["placement_method"]
|
||||
@ -248,7 +248,7 @@ def do_placement(context, REQUEST):
|
||||
|
||||
# Check access
|
||||
# (admin, respformation, and responsable_id)
|
||||
if not sco_permissions_check.can_edit_notes(context, authuser, E["moduleimpl_id"]):
|
||||
if not sco_permissions_check.can_edit_notes(authuser, E["moduleimpl_id"]):
|
||||
return (
|
||||
"<h2>Génération du placement impossible pour %s</h2>" % authusername
|
||||
+ """<p>(vérifiez que le semestre n'est pas verrouillé et que vous
|
||||
|
@ -1975,14 +1975,12 @@ class BasePreferences(object):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.ScoURL()) # cancel
|
||||
return flask.redirect(scu.ScoURL()) # cancel
|
||||
else:
|
||||
for pref in self.prefs_definition:
|
||||
self.prefs[None][pref[0]] = tf[2][pref[0]]
|
||||
self.save()
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
scu.ScoURL() + "?head_message=Préférences modifiées"
|
||||
)
|
||||
return flask.redirect(scu.ScoURL() + "?head_message=Préférences modifiées")
|
||||
|
||||
def build_tf_form(self, categories=[], formsemestre_id=None):
|
||||
"""Build list of elements for TrivialFormulator.
|
||||
@ -2151,9 +2149,7 @@ function set_global_pref(el, pref_name) {
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
dest_url + "&head_message=Annulé"
|
||||
) # cancel
|
||||
return flask.redirect(dest_url + "&head_message=Annulé") # cancel
|
||||
else:
|
||||
# Supprime pref locale du semestre (retour à la valeur globale)
|
||||
if tf[2]["suppress"]:
|
||||
@ -2187,15 +2183,13 @@ function set_global_pref(el, pref_name) {
|
||||
# done: change prefs and redirect to semestre status
|
||||
destination = tf[2]["destination"]
|
||||
if destination == "done" or destination == "":
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
dest_url + "&head_message=Préférences modifiées"
|
||||
)
|
||||
return flask.redirect(dest_url + "&head_message=Préférences modifiées")
|
||||
elif destination == "again":
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
REQUEST.URL0 + "?formsemestre_id=" + self.formsemestre_id
|
||||
)
|
||||
elif destination == "global":
|
||||
return REQUEST.RESPONSE.redirect(scu.ScoURL() + "/edit_preferences")
|
||||
return flask.redirect(scu.ScoURL() + "/edit_preferences")
|
||||
|
||||
|
||||
#
|
||||
|
@ -687,7 +687,7 @@ def formsemestre_pvjury_pdf(
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + "\n" + tf[1] + "\n".join(F)
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_pvjury?formsemestre_id=%s" % (formsemestre_id)
|
||||
)
|
||||
else:
|
||||
@ -861,7 +861,7 @@ def formsemestre_lettres_individuelles(
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + "\n" + tf[1] + F
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_pvjury?formsemestre_id=%s" % (formsemestre_id)
|
||||
)
|
||||
else:
|
||||
@ -881,7 +881,7 @@ def formsemestre_lettres_individuelles(
|
||||
finally:
|
||||
PDFLOCK.release()
|
||||
if not pdfdoc:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id={}&head_message=Aucun%20%C3%A9tudiant%20n%27a%20de%20d%C3%A9cision%20de%20jury".format(
|
||||
formsemestre_id
|
||||
)
|
||||
|
@ -33,6 +33,8 @@ import time
|
||||
import datetime
|
||||
import psycopg2
|
||||
|
||||
from flask_login import current_user
|
||||
|
||||
import app.scodoc.sco_utils as scu
|
||||
import app.scodoc.notesdb as ndb
|
||||
from app.scodoc.notes_log import log
|
||||
@ -171,7 +173,7 @@ def do_evaluation_upload_xls(context, REQUEST):
|
||||
)[0]
|
||||
# Check access
|
||||
# (admin, respformation, and responsable_id)
|
||||
if not sco_permissions_check.can_edit_notes(context, authuser, E["moduleimpl_id"]):
|
||||
if not sco_permissions_check.can_edit_notes(authuser, E["moduleimpl_id"]):
|
||||
# XXX imaginer un redirect + msg erreur
|
||||
raise AccessDenied("Modification des notes impossible pour %s" % authuser)
|
||||
#
|
||||
@ -280,21 +282,19 @@ def do_evaluation_upload_xls(context, REQUEST):
|
||||
return 0, msg + "<p>(pas de notes modifiées)</p>"
|
||||
|
||||
|
||||
def do_evaluation_set_missing(
|
||||
context, evaluation_id, value, REQUEST=None, dialog_confirmed=False
|
||||
):
|
||||
def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False):
|
||||
"""Initialisation des notes manquantes"""
|
||||
authuser = REQUEST.AUTHENTICATED_USER
|
||||
evaluation_id = REQUEST.form["evaluation_id"]
|
||||
# ? evaluation_id = REQUEST.form["evaluation_id"]
|
||||
context = None # XXX #context
|
||||
E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0]
|
||||
M = sco_moduleimpl.do_moduleimpl_withmodule_list(
|
||||
context, moduleimpl_id=E["moduleimpl_id"]
|
||||
)[0]
|
||||
# Check access
|
||||
# (admin, respformation, and responsable_id)
|
||||
if not sco_permissions_check.can_edit_notes(context, authuser, E["moduleimpl_id"]):
|
||||
if not sco_permissions_check.can_edit_notes(current_user, E["moduleimpl_id"]):
|
||||
# XXX imaginer un redirect + msg erreur
|
||||
raise AccessDenied("Modification des notes impossible pour %s" % authuser)
|
||||
raise AccessDenied("Modification des notes impossible pour %s" % current_user)
|
||||
#
|
||||
NotesDB = sco_evaluations.do_evaluation_get_all_notes(evaluation_id)
|
||||
etudids = sco_groups.do_evaluation_listeetuds_groups(
|
||||
@ -319,7 +319,6 @@ def do_evaluation_set_missing(
|
||||
# Confirm action
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Mettre toutes les notes manquantes de l'évaluation
|
||||
à la valeur %s ?</h2>
|
||||
<p>Seuls les étudiants pour lesquels aucune note (ni valeur, ni ABS, ni EXC)
|
||||
@ -329,13 +328,12 @@ def do_evaluation_set_missing(
|
||||
"""
|
||||
% (value, len(L)),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="saisie_notes?evaluation_id=%s" % evaluation_id,
|
||||
parameters={"evaluation_id": evaluation_id, "value": value},
|
||||
)
|
||||
# ok
|
||||
comment = "Initialisation notes manquantes"
|
||||
nb_changed, _, _ = _notes_add(context, authuser, evaluation_id, L, comment)
|
||||
nb_changed, _, _ = _notes_add(context, current_user, evaluation_id, L, comment)
|
||||
# news
|
||||
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
|
||||
mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
|
||||
@ -362,41 +360,39 @@ def do_evaluation_set_missing(
|
||||
)
|
||||
|
||||
|
||||
def evaluation_suppress_alln(context, evaluation_id, REQUEST, dialog_confirmed=False):
|
||||
def evaluation_suppress_alln(evaluation_id, dialog_confirmed=False):
|
||||
"suppress all notes in this eval"
|
||||
authuser = REQUEST.AUTHENTICATED_USER
|
||||
context = None # XXX #context
|
||||
E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0]
|
||||
|
||||
if sco_permissions_check.can_edit_notes(
|
||||
context, authuser, E["moduleimpl_id"], allow_ens=False
|
||||
current_user, E["moduleimpl_id"], allow_ens=False
|
||||
):
|
||||
# On a le droit de modifier toutes les notes
|
||||
# recupere les etuds ayant une note
|
||||
NotesDB = sco_evaluations.do_evaluation_get_all_notes(evaluation_id)
|
||||
elif sco_permissions_check.can_edit_notes(
|
||||
context, authuser, E["moduleimpl_id"], allow_ens=True
|
||||
current_user, E["moduleimpl_id"], allow_ens=True
|
||||
):
|
||||
# Enseignant associé au module: ne peut supprimer que les notes qu'il a saisi
|
||||
NotesDB = sco_evaluations.do_evaluation_get_all_notes(
|
||||
evaluation_id, by_uid=str(authuser)
|
||||
evaluation_id, by_uid=current_user.user_name
|
||||
)
|
||||
else:
|
||||
raise AccessDenied("Modification des notes impossible pour %s" % authuser)
|
||||
raise AccessDenied("Modification des notes impossible pour %s" % current_user)
|
||||
|
||||
notes = [(etudid, scu.NOTES_SUPPRESS) for etudid in NotesDB.keys()]
|
||||
|
||||
if not dialog_confirmed:
|
||||
nb_changed, nb_suppress, existing_decisions = _notes_add(
|
||||
context, authuser, evaluation_id, notes, do_it=False
|
||||
context, current_user, evaluation_id, notes, do_it=False
|
||||
)
|
||||
msg = "<p>Confirmer la suppression des %d notes ?</p>" % nb_suppress
|
||||
if existing_decisions:
|
||||
msg += """<p class="warning">Important: il y a déjà des décisions de jury enregistrées, qui seront potentiellement à revoir suite à cette modification !</p>"""
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
msg,
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
OK="Supprimer les notes",
|
||||
cancel_url="moduleimpl_status?moduleimpl_id=%s" % E["moduleimpl_id"],
|
||||
parameters={"evaluation_id": evaluation_id},
|
||||
@ -404,7 +400,7 @@ def evaluation_suppress_alln(context, evaluation_id, REQUEST, dialog_confirmed=F
|
||||
|
||||
# modif
|
||||
nb_changed, nb_suppress, existing_decisions = _notes_add(
|
||||
context, authuser, evaluation_id, notes, comment="effacer tout"
|
||||
context, current_user, evaluation_id, notes, comment="effacer tout"
|
||||
)
|
||||
assert nb_changed == nb_suppress
|
||||
H = ["<p>%s notes supprimées</p>" % nb_suppress]
|
||||
@ -572,7 +568,7 @@ def saisie_notes_tableur(context, evaluation_id, group_ids=[], REQUEST=None):
|
||||
E = evals[0]
|
||||
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
|
||||
formsemestre_id = M["formsemestre_id"]
|
||||
if not sco_permissions_check.can_edit_notes(context, authuser, E["moduleimpl_id"]):
|
||||
if not sco_permissions_check.can_edit_notes(authuser, E["moduleimpl_id"]):
|
||||
return (
|
||||
html_sco_header.sco_header()
|
||||
+ "<h2>Modification des notes impossible pour %s</h2>" % authusername
|
||||
@ -690,12 +686,12 @@ def saisie_notes_tableur(context, evaluation_id, group_ids=[], REQUEST=None):
|
||||
#
|
||||
H.append("""</div><h3>Autres opérations</h3><ul>""")
|
||||
if sco_permissions_check.can_edit_notes(
|
||||
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
|
||||
):
|
||||
H.append(
|
||||
"""
|
||||
<li>
|
||||
<form action="do_evaluation_set_missing" method="get">
|
||||
<form action="do_evaluation_set_missing" method="GET">
|
||||
Mettre toutes les notes manquantes à <input type="text" size="5" name="value"/>
|
||||
<input type="submit" value="OK"/>
|
||||
<input type="hidden" name="evaluation_id" value="%s"/>
|
||||
@ -851,7 +847,7 @@ def saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
|
||||
formsemestre_id = M["formsemestre_id"]
|
||||
# Check access
|
||||
# (admin, respformation, and responsable_id)
|
||||
if not sco_permissions_check.can_edit_notes(context, authuser, E["moduleimpl_id"]):
|
||||
if not sco_permissions_check.can_edit_notes(authuser, E["moduleimpl_id"]):
|
||||
return (
|
||||
html_sco_header.sco_header()
|
||||
+ "<h2>Modification des notes impossible pour %s</h2>" % authusername
|
||||
@ -932,7 +928,7 @@ def saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
|
||||
context, E, M, groups_infos.group_ids, destination=destination, REQUEST=REQUEST
|
||||
)
|
||||
if form is None:
|
||||
return REQUEST.RESPONSE.redirect(destination)
|
||||
return flask.redirect(destination)
|
||||
H.append(form)
|
||||
#
|
||||
H.append("</div>") # /saisie_notes
|
||||
@ -1178,7 +1174,7 @@ def _form_saisie_notes(context, E, M, group_ids, destination="", REQUEST=None):
|
||||
H.append(
|
||||
"""
|
||||
<div>
|
||||
<form action="do_evaluation_set_missing" method="get">
|
||||
<form action="do_evaluation_set_missing" method="GET">
|
||||
Mettre <em>toutes</em> les notes manquantes à <input type="text" size="5" name="value"/>
|
||||
<input type="submit" value="OK"/>
|
||||
<input type="hidden" name="evaluation_id" value="%s"/>
|
||||
@ -1211,7 +1207,7 @@ def save_note(
|
||||
Mod["url"] = "Notes/moduleimpl_status?moduleimpl_id=%(moduleimpl_id)s" % M
|
||||
result = {"nbchanged": 0} # JSON
|
||||
# Check access: admin, respformation, or responsable_id
|
||||
if not sco_permissions_check.can_edit_notes(context, authuser, E["moduleimpl_id"]):
|
||||
if not sco_permissions_check.can_edit_notes(authuser, E["moduleimpl_id"]):
|
||||
result["status"] = "unauthorized"
|
||||
else:
|
||||
L, _, _, _, _ = _check_notes([(etudid, value)], E, Mod)
|
||||
|
@ -353,7 +353,7 @@ def do_semset_create(context, title="", annee_scolaire=None, sem_id=None, REQUES
|
||||
% (title, annee_scolaire, sem_id)
|
||||
)
|
||||
SemSet(context, title=title, annee_scolaire=annee_scolaire, sem_id=sem_id)
|
||||
return REQUEST.RESPONSE.redirect("semset_page")
|
||||
return flask.redirect("semset_page")
|
||||
|
||||
|
||||
def do_semset_delete(context, semset_id, dialog_confirmed=False, REQUEST=None):
|
||||
@ -363,15 +363,13 @@ def do_semset_delete(context, semset_id, dialog_confirmed=False, REQUEST=None):
|
||||
s = SemSet(context, semset_id=semset_id)
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"<h2>Suppression de l'ensemble %(title)s ?</h2>" % s,
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
parameters={"semset_id": semset_id},
|
||||
cancel_url="semset_page",
|
||||
)
|
||||
s.delete()
|
||||
return REQUEST.RESPONSE.redirect("semset_page")
|
||||
return flask.redirect("semset_page")
|
||||
|
||||
|
||||
def edit_semset_set_title(context, id=None, value=None, REQUEST=None):
|
||||
@ -395,7 +393,7 @@ def do_semset_add_sem(context, semset_id, formsemestre_id, REQUEST=None):
|
||||
|
||||
s.add(formsemestre_id)
|
||||
|
||||
return REQUEST.RESPONSE.redirect("apo_semset_maq_status?semset_id=%s" % semset_id)
|
||||
return flask.redirect("apo_semset_maq_status?semset_id=%s" % semset_id)
|
||||
|
||||
|
||||
def do_semset_remove_sem(context, semset_id, formsemestre_id, REQUEST=None):
|
||||
@ -406,7 +404,7 @@ def do_semset_remove_sem(context, semset_id, formsemestre_id, REQUEST=None):
|
||||
|
||||
s.remove(formsemestre_id)
|
||||
|
||||
return REQUEST.RESPONSE.redirect("apo_semset_maq_status?semset_id=%s" % semset_id)
|
||||
return flask.redirect("apo_semset_maq_status?semset_id=%s" % semset_id)
|
||||
|
||||
|
||||
# ----------------------------------------
|
||||
|
@ -208,13 +208,11 @@ def formsemestre_synchro_etuds(
|
||||
|
||||
H.append(
|
||||
scu.confirm_dialog(
|
||||
context,
|
||||
dest_url="formsemestre_synchro_etuds",
|
||||
add_headers=False,
|
||||
cancel_url="formsemestre_synchro_etuds?formsemestre_id="
|
||||
+ formsemestre_id,
|
||||
OK="Effectuer l'opération",
|
||||
REQUEST=REQUEST,
|
||||
parameters={
|
||||
"formsemestre_id": formsemestre_id,
|
||||
"etuds": ",".join(etuds),
|
||||
|
@ -201,7 +201,6 @@ def check_local_photos_availability(context, groups_infos, REQUEST, format=""):
|
||||
return (
|
||||
False,
|
||||
scu.confirm_dialog(
|
||||
context,
|
||||
"""<p>Attention: %d photos ne sont pas disponibles et ne peuvent pas être exportées.</p><p>Vous pouvez <a class="stdlink" href="%s">exporter seulement les photos existantes</a>"""
|
||||
% (
|
||||
nb_missing,
|
||||
@ -211,7 +210,6 @@ def check_local_photos_availability(context, groups_infos, REQUEST, format=""):
|
||||
OK="Exporter seulement les photos existantes",
|
||||
cancel_url="groups_view?curtab=tab-photos&"
|
||||
+ groups_infos.groups_query_args,
|
||||
REQUEST=REQUEST,
|
||||
parameters=parameters,
|
||||
),
|
||||
)
|
||||
@ -268,14 +266,12 @@ def trombino_copy_photos(context, group_ids=[], REQUEST=None, dialog_confirmed=F
|
||||
)
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Copier les photos du portail vers ScoDoc ?</h2>
|
||||
<p>Les photos du groupe %s présentes dans ScoDoc seront remplacées par celles du portail (si elles existent).</p>
|
||||
<p>(les photos sont normalement automatiquement copiées lors de leur première utilisation, l'usage de cette fonction n'est nécessaire que si les photos du portail ont été modifiées)</p>
|
||||
"""
|
||||
% (groups_infos.groups_titles),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url=back_url,
|
||||
parameters={"group_ids": group_ids},
|
||||
)
|
||||
@ -538,7 +534,7 @@ def photos_import_files_form(context, group_ids=[], REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + "</li></ol>" + F
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(back_url)
|
||||
return flask.redirect(back_url)
|
||||
else:
|
||||
return photos_import_files(
|
||||
context,
|
||||
@ -566,7 +562,7 @@ def photos_import_files(
|
||||
zip_excel_import_files(
|
||||
context, xlsfile, zipfile, REQUEST, callback, filename_title, page_title
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(back_url + "&head_message=photos%20 importees")
|
||||
return flask.redirect(back_url + "&head_message=photos%20 importees")
|
||||
|
||||
|
||||
def zip_excel_import_files(
|
||||
|
@ -108,11 +108,10 @@ def external_ue_create(
|
||||
"ects": ects,
|
||||
"is_external": 1,
|
||||
},
|
||||
REQUEST,
|
||||
)
|
||||
|
||||
matiere_id = sco_edit_matiere.do_matiere_create(
|
||||
context, {"ue_id": ue_id, "titre": titre or acronyme, "numero": 1}, REQUEST
|
||||
context, {"ue_id": ue_id, "titre": titre or acronyme, "numero": 1}
|
||||
)
|
||||
|
||||
module_id = sco_edit_module.do_module_create(
|
||||
@ -126,7 +125,6 @@ def external_ue_create(
|
||||
"formation_id": formation_id,
|
||||
"semestre_id": sem["semestre_id"],
|
||||
},
|
||||
REQUEST,
|
||||
)
|
||||
|
||||
moduleimpl_id = sco_moduleimpl.do_moduleimpl_create(
|
||||
@ -343,7 +341,7 @@ def external_ue_create_form(context, formsemestre_id, etudid, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + "\n" + tf[1] + html_footer
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(bull_url)
|
||||
return flask.redirect(bull_url)
|
||||
else:
|
||||
note = tf[2]["note"].strip().upper()
|
||||
note_value, invalid = sco_saisie_notes.convert_note_from_string(note, 20.0)
|
||||
@ -385,4 +383,4 @@ def external_ue_create_form(context, formsemestre_id, etudid, REQUEST=None):
|
||||
{etudid: note_value},
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(bull_url + "&head_message=Ajout%20effectué")
|
||||
return flask.redirect(bull_url + "&head_message=Ajout%20effectué")
|
||||
|
@ -52,7 +52,7 @@ STRING_TYPES = six.string_types
|
||||
|
||||
from PIL import Image as PILImage
|
||||
|
||||
from flask import g, url_for
|
||||
from flask import g, url_for, request
|
||||
|
||||
from scodoc_manager import sco_mgr
|
||||
|
||||
@ -819,7 +819,6 @@ def return_text_if_published(val, REQUEST):
|
||||
|
||||
|
||||
def confirm_dialog(
|
||||
context,
|
||||
message="<p>Confirmer ?</p>",
|
||||
OK="OK",
|
||||
Cancel="Annuler",
|
||||
@ -828,7 +827,6 @@ def confirm_dialog(
|
||||
target_variable="dialog_confirmed",
|
||||
parameters={},
|
||||
add_headers=True, # complete page
|
||||
REQUEST=None, # required
|
||||
helpmsg=None,
|
||||
):
|
||||
from app.scodoc import html_sco_header
|
||||
@ -838,7 +836,7 @@ def confirm_dialog(
|
||||
# Attention: la page a pu etre servie en GET avec des parametres
|
||||
# si on laisse l'url "action" vide, les parametres restent alors que l'on passe en POST...
|
||||
if not dest_url:
|
||||
dest_url = REQUEST.URL
|
||||
dest_url = request.base_url
|
||||
# strip remaining parameters from destination url:
|
||||
dest_url = six.moves.urllib.parse.splitquery(dest_url)[0]
|
||||
H = [
|
||||
@ -866,7 +864,7 @@ def confirm_dialog(
|
||||
H.append("</form>")
|
||||
if helpmsg:
|
||||
H.append('<p class="help">' + helpmsg + "</p>")
|
||||
if add_headers and REQUEST:
|
||||
if add_headers:
|
||||
return (
|
||||
html_sco_header.sco_header() + "\n".join(H) + html_sco_header.sco_footer()
|
||||
)
|
||||
|
@ -28,23 +28,21 @@
|
||||
"""Logging des opérations en base de données
|
||||
"""
|
||||
|
||||
from flask import request
|
||||
from flask_login import current_user
|
||||
import app.scodoc.notesdb as ndb
|
||||
from app.scodoc.notes_log import retreive_request
|
||||
|
||||
|
||||
def logdb(REQUEST=None, cnx=None, method=None, etudid=None, msg=None, commit=True):
|
||||
def logdb(cnx=None, method=None, etudid=None, msg=None, commit=True):
|
||||
"Add entry"
|
||||
if not cnx:
|
||||
raise ValueError("logdb: cnx is None")
|
||||
if not REQUEST:
|
||||
REQUEST = retreive_request(skip=1)
|
||||
if REQUEST:
|
||||
args = {
|
||||
"authenticated_user": str(REQUEST.AUTHENTICATED_USER),
|
||||
"remote_addr": REQUEST.REMOTE_ADDR,
|
||||
}
|
||||
else:
|
||||
args = {"authenticated_user": None, "remote_addr": None}
|
||||
|
||||
args = {
|
||||
"authenticated_user": current_user.user_name,
|
||||
"remote_addr": request.remote_addr,
|
||||
}
|
||||
|
||||
args.update({"method": method, "etudid": etudid, "msg": msg})
|
||||
ndb.quote_dict(args)
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
|
@ -1155,7 +1155,7 @@ def AddBilletAbsenceForm(context, etudid, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.ScoURL())
|
||||
return flask.redirect(scu.ScoURL())
|
||||
else:
|
||||
e = tf[2]["begin"].split("/")
|
||||
begin = e[2] + "-" + e[1] + "-" + e[0] + " 00:00:00"
|
||||
@ -1172,7 +1172,7 @@ def AddBilletAbsenceForm(context, etudid, REQUEST=None):
|
||||
justified=tf[2]["justified"],
|
||||
)
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect("listeBilletsEtud?etudid=" + etudid)
|
||||
return flask.redirect("listeBilletsEtud?etudid=" + etudid)
|
||||
|
||||
|
||||
def _tableBillets(context, billets, etud=None, title=""):
|
||||
@ -1289,7 +1289,7 @@ def listeBillets(context, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + T + html_sco_header.sco_footer()
|
||||
else:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"ProcessBilletAbsenceForm?billet_id=" + tf[2]["billet_id"]
|
||||
)
|
||||
|
||||
@ -1302,23 +1302,21 @@ def deleteBilletAbsence(context, billet_id, REQUEST=None, dialog_confirmed=False
|
||||
cnx = ndb.GetDBConnexion()
|
||||
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
|
||||
if not billets:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"listeBillets?head_message=Billet%%20%s%%20inexistant !" % billet_id
|
||||
)
|
||||
if not dialog_confirmed:
|
||||
tab = _tableBillets(context, billets)
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Supprimer ce billet ?</h2>""" + tab.html(),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="listeBillets",
|
||||
parameters={"billet_id": billet_id},
|
||||
)
|
||||
|
||||
sco_abs.billet_absence_delete(cnx, billet_id)
|
||||
|
||||
return REQUEST.RESPONSE.redirect("listeBillets?head_message=Billet%20supprimé")
|
||||
return flask.redirect("listeBillets?head_message=Billet%20supprimé")
|
||||
|
||||
|
||||
def _ProcessBilletAbsence(context, billet, estjust, description, REQUEST):
|
||||
@ -1398,7 +1396,7 @@ def ProcessBilletAbsenceForm(context, billet_id, REQUEST=None):
|
||||
cnx = ndb.GetDBConnexion()
|
||||
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
|
||||
if not billets:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"listeBillets?head_message=Billet%%20%s%%20inexistant !" % billet_id
|
||||
)
|
||||
billet = billets[0]
|
||||
@ -1454,7 +1452,7 @@ def ProcessBilletAbsenceForm(context, billet_id, REQUEST=None):
|
||||
|
||||
return "\n".join(H) + "<br/>" + tf[1] + F + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.ScoURL())
|
||||
return flask.redirect(scu.ScoURL())
|
||||
else:
|
||||
n = _ProcessBilletAbsence(
|
||||
context, billet, tf[2]["estjust"], tf[2]["description"], REQUEST
|
||||
|
@ -551,7 +551,7 @@ def entreprise_contact_edit(context, entreprise_contact_id, REQUEST=None):
|
||||
% entreprise_contact_id
|
||||
)
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context))
|
||||
return flask.redirect(scu.EntreprisesURL(context))
|
||||
else:
|
||||
etudok = sco_entreprises.do_entreprise_check_etudiant(
|
||||
context, tf[2]["etudiant"]
|
||||
@ -561,7 +561,7 @@ def entreprise_contact_edit(context, entreprise_contact_id, REQUEST=None):
|
||||
else:
|
||||
tf[2].update({"etudid": etudok[1]})
|
||||
sco_entreprises.do_entreprise_contact_edit(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.EntreprisesURL(context, )
|
||||
+ "/entreprise_contact_list?entreprise_id="
|
||||
+ str(c["entreprise_id"])
|
||||
@ -671,13 +671,13 @@ def entreprise_correspondant_edit(context, entreprise_corresp_id, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
H.append(tf[1])
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"%s/entreprise_correspondant_list?entreprise_id=%s"
|
||||
% (scu.EntreprisesURL(context, ), c["entreprise_id"])
|
||||
)
|
||||
else:
|
||||
sco_entreprises.do_entreprise_correspondant_edit(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"%s/entreprise_correspondant_list?entreprise_id=%s"
|
||||
% (scu.EntreprisesURL(context, ), c["entreprise_id"])
|
||||
)
|
||||
@ -782,7 +782,7 @@ def entreprise_contact_create(context, entreprise_id, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
H.append(tf[1])
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context))
|
||||
return flask.redirect(scu.EntreprisesURL(context))
|
||||
else:
|
||||
etudok = sco_entreprises.do_entreprise_check_etudiant(
|
||||
context, tf[2]["etudiant"]
|
||||
@ -792,7 +792,7 @@ def entreprise_contact_create(context, entreprise_id, REQUEST=None):
|
||||
else:
|
||||
tf[2].update({"etudid": etudok[1]})
|
||||
sco_entreprises.do_entreprise_contact_create(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ))
|
||||
return flask.redirect(scu.EntreprisesURL(context, ))
|
||||
H.append(entreprise_footer(context, REQUEST))
|
||||
return "\n".join(H)
|
||||
|
||||
@ -823,12 +823,12 @@ def entreprise_contact_delete(context, entreprise_contact_id, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
H.append(tf[1])
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context))
|
||||
return flask.redirect(scu.EntreprisesURL(context))
|
||||
else:
|
||||
sco_entreprises.do_entreprise_contact_delete(
|
||||
context, c["entreprise_contact_id"]
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context))
|
||||
return flask.redirect(scu.EntreprisesURL(context))
|
||||
H.append(entreprise_footer(context, REQUEST))
|
||||
return "\n".join(H)
|
||||
|
||||
@ -932,10 +932,10 @@ def entreprise_correspondant_create(context, entreprise_id, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
H.append(tf[1])
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context))
|
||||
return flask.redirect(scu.EntreprisesURL(context))
|
||||
else:
|
||||
sco_entreprises.do_entreprise_correspondant_create(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context))
|
||||
return flask.redirect(scu.EntreprisesURL(context))
|
||||
H.append(entreprise_footer(context, REQUEST))
|
||||
return "\n".join(H)
|
||||
|
||||
@ -966,12 +966,12 @@ def entreprise_correspondant_delete(context, entreprise_corresp_id, REQUEST=None
|
||||
if tf[0] == 0:
|
||||
H.append(tf[1])
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ))
|
||||
return flask.redirect(scu.EntreprisesURL(context, ))
|
||||
else:
|
||||
sco_entreprises.do_entreprise_correspondant_delete(
|
||||
context, c["entreprise_corresp_id"]
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ))
|
||||
return flask.redirect(scu.EntreprisesURL(context, ))
|
||||
H.append(entreprise_footer(context, REQUEST))
|
||||
return "\n".join(H)
|
||||
|
||||
@ -1026,10 +1026,10 @@ def entreprise_delete(context, entreprise_id, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
H.append(tf[1])
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ))
|
||||
return flask.redirect(scu.EntreprisesURL(context, ))
|
||||
else:
|
||||
sco_entreprises.do_entreprise_delete(context, E["entreprise_id"])
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ))
|
||||
return flask.redirect(scu.EntreprisesURL(context, ))
|
||||
H.append(entreprise_footer(context, REQUEST))
|
||||
return "\n".join(H)
|
||||
|
||||
@ -1123,10 +1123,10 @@ def entreprise_create(context, REQUEST=None):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + entreprise_footer(context, REQUEST)
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ))
|
||||
return flask.redirect(scu.EntreprisesURL(context, ))
|
||||
else:
|
||||
sco_entreprises.do_entreprise_create(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ))
|
||||
return flask.redirect(scu.EntreprisesURL(context, ))
|
||||
|
||||
|
||||
security.declareProtected(ScoEntrepriseView, "entreprise_edit")
|
||||
@ -1298,7 +1298,7 @@ def entreprise_edit(context, entreprise_id, REQUEST=None, start=1):
|
||||
H.append("</ul>")
|
||||
return "\n".join(H) + entreprise_footer(context, REQUEST)
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ) + "?start=" + start)
|
||||
return flask.redirect(scu.EntreprisesURL(context, ) + "?start=" + start)
|
||||
else:
|
||||
sco_entreprises.do_entreprise_edit(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(scu.EntreprisesURL(context, ) + "?start=" + start)
|
||||
return flask.redirect(scu.EntreprisesURL(context, ) + "?start=" + start)
|
||||
|
@ -479,7 +479,7 @@ def formation_import_xml_form(context, REQUEST):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + footer
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.NotesURL())
|
||||
return flask.redirect(scu.NotesURL())
|
||||
else:
|
||||
formation_id, _, _ = sco_formations.formation_import_xml(
|
||||
context, tf[2]["xmlfile"], REQUEST
|
||||
@ -742,9 +742,7 @@ def edit_enseignants_form(context, REQUEST, moduleimpl_id):
|
||||
if tf[0] == 0:
|
||||
return header + "\n".join(H) + tf[1] + F + footer
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"moduleimpl_status?moduleimpl_id=" + moduleimpl_id
|
||||
)
|
||||
return flask.redirect("moduleimpl_status?moduleimpl_id=" + moduleimpl_id)
|
||||
else:
|
||||
ens_id = User.get_user_name_from_nomplogin(tf[2]["ens_id"])
|
||||
if not ens_id:
|
||||
@ -764,7 +762,7 @@ def edit_enseignants_form(context, REQUEST, moduleimpl_id):
|
||||
sco_moduleimpl.do_ens_create(
|
||||
context, {"moduleimpl_id": moduleimpl_id, "ens_id": ens_id}
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"edit_enseignants_form?moduleimpl_id=%s" % moduleimpl_id
|
||||
)
|
||||
return header + "\n".join(H) + tf[1] + F + footer
|
||||
@ -836,23 +834,19 @@ def edit_moduleimpl_resp(context, REQUEST, moduleimpl_id):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + help_str + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"moduleimpl_status?moduleimpl_id=" + moduleimpl_id
|
||||
)
|
||||
return flask.redirect("moduleimpl_status?moduleimpl_id=" + moduleimpl_id)
|
||||
else:
|
||||
responsable_id = User.get_user_name_from_nomplogin(tf[2]["responsable_id"])
|
||||
if (
|
||||
not responsable_id
|
||||
): # presque impossible: tf verifie les valeurs (mais qui peuvent changer entre temps)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"moduleimpl_status?moduleimpl_id=" + moduleimpl_id
|
||||
)
|
||||
return flask.redirect("moduleimpl_status?moduleimpl_id=" + moduleimpl_id)
|
||||
sco_moduleimpl.do_moduleimpl_edit(
|
||||
context,
|
||||
{"moduleimpl_id": moduleimpl_id, "responsable_id": responsable_id},
|
||||
formsemestre_id=sem["formsemestre_id"],
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"moduleimpl_status?moduleimpl_id="
|
||||
+ moduleimpl_id
|
||||
+ "&head_message=responsable%20modifié"
|
||||
@ -929,9 +923,7 @@ def edit_moduleimpl_expr(context, REQUEST, moduleimpl_id):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"moduleimpl_status?moduleimpl_id=" + moduleimpl_id
|
||||
)
|
||||
return flask.redirect("moduleimpl_status?moduleimpl_id=" + moduleimpl_id)
|
||||
else:
|
||||
sco_moduleimpl.do_moduleimpl_edit(
|
||||
context,
|
||||
@ -944,7 +936,7 @@ def edit_moduleimpl_expr(context, REQUEST, moduleimpl_id):
|
||||
sco_cache.invalidate_formsemestre(
|
||||
formsemestre_id=sem["formsemestre_id"]
|
||||
) # > modif regle calcul
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"moduleimpl_status?moduleimpl_id="
|
||||
+ moduleimpl_id
|
||||
+ "&head_message=règle%20de%20calcul%20modifiée"
|
||||
@ -1085,9 +1077,7 @@ def edit_ue_expr(context, REQUEST, formsemestre_id, ue_id):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"formsemestre_status?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
return flask.redirect("formsemestre_status?formsemestre_id=" + formsemestre_id)
|
||||
else:
|
||||
if el:
|
||||
el[0]["computation_expr"] = tf[2]["computation_expr"]
|
||||
@ -1098,7 +1088,7 @@ def edit_ue_expr(context, REQUEST, formsemestre_id, ue_id):
|
||||
sco_cache.invalidate_formsemestre(
|
||||
formsemestre_id=formsemestre_id
|
||||
) # > modif regle calcul
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"formsemestre_status?formsemestre_id="
|
||||
+ formsemestre_id
|
||||
+ "&head_message=règle%20de%20calcul%20modifiée"
|
||||
@ -1204,9 +1194,7 @@ def edit_enseignants_form_delete(context, REQUEST, moduleimpl_id, ens_id):
|
||||
if not ok:
|
||||
raise ScoValueError("invalid ens_id (%s)" % ens_id)
|
||||
sco_moduleimpl.do_ens_delete(context, ens["modules_enseignants_id"])
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
"edit_enseignants_form?moduleimpl_id=%s" % moduleimpl_id
|
||||
)
|
||||
return flask.redirect("edit_enseignants_form?moduleimpl_id=%s" % moduleimpl_id)
|
||||
|
||||
|
||||
# --- Gestion des inscriptions aux semestres
|
||||
@ -1304,10 +1292,8 @@ def formsemestre_desinscription(
|
||||
</p>
|
||||
"""
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Confirmer la demande de desinscription ?</h2>""" + msg_ext,
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="formsemestre_status?formsemestre_id=%s" % formsemestre_id,
|
||||
parameters={"etudid": etudid, "formsemestre_id": formsemestre_id},
|
||||
)
|
||||
@ -1339,7 +1325,7 @@ def etud_desinscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
|
||||
sco_moduleimpl_inscriptions.do_etud_desinscrit_ue(
|
||||
context, etudid, formsemestre_id, ue_id, REQUEST=REQUEST
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.ScoURL()
|
||||
+ "/Notes/moduleimpl_inscriptions_stats?formsemestre_id="
|
||||
+ formsemestre_id
|
||||
@ -1354,7 +1340,7 @@ def etud_inscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
|
||||
sco_moduleimpl_inscriptions.do_etud_inscrit_ue(
|
||||
context, etudid, formsemestre_id, ue_id, REQUEST=REQUEST
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.ScoURL()
|
||||
+ "/Notes/moduleimpl_inscriptions_stats?formsemestre_id="
|
||||
+ formsemestre_id
|
||||
@ -1465,7 +1451,7 @@ def evaluation_delete(context, REQUEST, evaluation_id):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.ScoURL()
|
||||
+ "/Notes/moduleimpl_status?moduleimpl_id="
|
||||
+ E["moduleimpl_id"]
|
||||
@ -1725,10 +1711,8 @@ def formsemestre_bulletins_mailetuds(
|
||||
# Confirmation dialog
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"<h2>Envoyer les %d bulletins par e-mail aux étudiants ?" % len(etudids),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="formsemestre_status?formsemestre_id=%s" % formsemestre_id,
|
||||
parameters={
|
||||
"version": version,
|
||||
@ -1810,8 +1794,8 @@ def appreciation_add_form(
|
||||
)
|
||||
if suppress:
|
||||
sco_etud.appreciations_delete(cnx, id)
|
||||
logdb(REQUEST, cnx, method="appreciation_suppress", etudid=etudid, msg="")
|
||||
return REQUEST.RESPONSE.redirect(bull_url)
|
||||
logdb(cnx, method="appreciation_suppress", etudid=etudid, msg="")
|
||||
return flask.redirect(bull_url)
|
||||
#
|
||||
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
|
||||
if id:
|
||||
@ -1849,7 +1833,7 @@ def appreciation_add_form(
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + "\n" + tf[1] + F
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(bull_url)
|
||||
return flask.redirect(bull_url)
|
||||
else:
|
||||
args = {
|
||||
"etudid": etudid,
|
||||
@ -1866,7 +1850,6 @@ def appreciation_add_form(
|
||||
sco_etud.appreciations_create(cnx, args, has_uniq_values=False)
|
||||
# log
|
||||
logdb(
|
||||
REQUEST,
|
||||
cnx,
|
||||
method="appreciation_add",
|
||||
etudid=etudid,
|
||||
@ -1876,7 +1859,7 @@ def appreciation_add_form(
|
||||
sco_cache.invalidate_formsemestre(
|
||||
pdfonly=True, formsemestre_id=formsemestre_id
|
||||
) # > appreciation_add
|
||||
return REQUEST.RESPONSE.redirect(bull_url)
|
||||
return flask.redirect(bull_url)
|
||||
|
||||
|
||||
# --- FORMULAIRE POUR VALIDATION DES UE ET SEMESTRES
|
||||
@ -1925,11 +1908,9 @@ def formsemestre_validation_etud(
|
||||
"Enregistre choix jury pour un étudiant"
|
||||
if not sco_permissions_check.can_validate_sem(formsemestre_id):
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
message="<p>Opération non autorisée pour %s</h2>"
|
||||
% REQUEST.AUTHENTICATED_USER,
|
||||
dest_url=scu.ScoURL(),
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
|
||||
return sco_formsemestre_validation.formsemestre_validation_etud(
|
||||
@ -1961,11 +1942,9 @@ def formsemestre_validation_etud_manu(
|
||||
"Enregistre choix jury pour un étudiant"
|
||||
if not sco_permissions_check.can_validate_sem(formsemestre_id):
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
message="<p>Opération non autorisée pour %s</h2>"
|
||||
% REQUEST.AUTHENTICATED_USER,
|
||||
dest_url=scu.ScoURL(),
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
|
||||
return sco_formsemestre_validation.formsemestre_validation_etud_manu(
|
||||
@ -1991,11 +1970,9 @@ def formsemestre_validate_previous_ue(
|
||||
"Form. saisie UE validée hors ScoDoc "
|
||||
if not sco_permissions_check.can_validate_sem(formsemestre_id):
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
message="<p>Opération non autorisée pour %s</h2>"
|
||||
% REQUEST.AUTHENTICATED_USER,
|
||||
dest_url=scu.ScoURL(),
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
return sco_formsemestre_validation.formsemestre_validate_previous_ue(
|
||||
context, formsemestre_id, etudid, REQUEST=REQUEST
|
||||
@ -2019,11 +1996,9 @@ def formsemestre_ext_edit_ue_validations(
|
||||
"Form. edition UE semestre extérieur"
|
||||
if not sco_permissions_check.can_validate_sem(formsemestre_id):
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
message="<p>Opération non autorisée pour %s</h2>"
|
||||
% REQUEST.AUTHENTICATED_USER,
|
||||
dest_url=scu.ScoURL(),
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
return sco_formsemestre_exterieurs.formsemestre_ext_edit_ue_validations(
|
||||
context, formsemestre_id, etudid, REQUEST=REQUEST
|
||||
@ -2044,11 +2019,9 @@ def etud_ue_suppress_validation(context, etudid, formsemestre_id, ue_id, REQUEST
|
||||
"""Suppress a validation (ue_id, etudid) and redirect to formsemestre"""
|
||||
if not sco_permissions_check.can_validate_sem(formsemestre_id):
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
message="<p>Opération non autorisée pour %s</h2>"
|
||||
% REQUEST.AUTHENTICATED_USER,
|
||||
dest_url=scu.ScoURL(),
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
return sco_formsemestre_validation.etud_ue_suppress_validation(
|
||||
context, etudid, formsemestre_id, ue_id, REQUEST=REQUEST
|
||||
@ -2062,11 +2035,9 @@ def formsemestre_validation_auto(context, formsemestre_id, REQUEST):
|
||||
"Formulaire saisie automatisee des decisions d'un semestre"
|
||||
if not sco_permissions_check.can_validate_sem(formsemestre_id):
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
message="<p>Opération non autorisée pour %s</h2>"
|
||||
% REQUEST.AUTHENTICATED_USER,
|
||||
dest_url=scu.ScoURL(),
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
|
||||
return sco_formsemestre_validation.formsemestre_validation_auto(
|
||||
@ -2081,11 +2052,9 @@ def do_formsemestre_validation_auto(context, formsemestre_id, REQUEST):
|
||||
"Formulaire saisie automatisee des decisions d'un semestre"
|
||||
if not sco_permissions_check.can_validate_sem(formsemestre_id):
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
message="<p>Opération non autorisée pour %s</h2>"
|
||||
% REQUEST.AUTHENTICATED_USER,
|
||||
dest_url=scu.ScoURL(),
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
|
||||
return sco_formsemestre_validation.do_formsemestre_validation_auto(
|
||||
@ -2102,11 +2071,9 @@ def formsemestre_validation_suppress_etud(
|
||||
"""Suppression des decisions de jury pour un etudiant."""
|
||||
if not sco_permissions_check.can_validate_sem(formsemestre_id):
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
message="<p>Opération non autorisée pour %s</h2>"
|
||||
% REQUEST.AUTHENTICATED_USER,
|
||||
dest_url=scu.ScoURL(),
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
if not dialog_confirmed:
|
||||
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
|
||||
@ -2120,7 +2087,6 @@ def formsemestre_validation_suppress_etud(
|
||||
else:
|
||||
existing = ""
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Confirmer la suppression des décisions du semestre %s (%s - %s) pour %s ?</h2>%s
|
||||
<p>Cette opération est irréversible.
|
||||
</p>
|
||||
@ -2134,7 +2100,6 @@ def formsemestre_validation_suppress_etud(
|
||||
),
|
||||
OK="Supprimer",
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url="formsemestre_validation_etud_form?formsemestre_id=%s&etudid=%s"
|
||||
% (formsemestre_id, etudid),
|
||||
parameters={"etudid": etudid, "formsemestre_id": formsemestre_id},
|
||||
@ -2143,7 +2108,7 @@ def formsemestre_validation_suppress_etud(
|
||||
sco_formsemestre_validation.formsemestre_validation_suppress_etud(
|
||||
context, formsemestre_id, etudid
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.ScoURL()
|
||||
+ "/Notes/formsemestre_validation_etud_form?formsemestre_id=%s&etudid=%s&head_message=Décision%%20supprimée"
|
||||
% (formsemestre_id, etudid)
|
||||
|
@ -505,8 +505,8 @@ def doAddAnnotation(context, etudid, comment, REQUEST):
|
||||
"zope_remote_addr": REQUEST.REMOTE_ADDR,
|
||||
},
|
||||
)
|
||||
logdb(REQUEST, cnx, method="addAnnotation", etudid=etudid)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
logdb(cnx, method="addAnnotation", etudid=etudid)
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
|
||||
@ -525,10 +525,10 @@ def doSuppressAnnotation(context, etudid, annotation_id, REQUEST):
|
||||
raise ScoValueError("annotation inexistante !")
|
||||
anno = annos[0]
|
||||
log("suppress annotation: %s" % str(anno))
|
||||
logdb(REQUEST, cnx, method="SuppressAnnotation", etudid=etudid)
|
||||
logdb(cnx, method="SuppressAnnotation", etudid=etudid)
|
||||
sco_etud.etud_annotations_delete(cnx, annotation_id)
|
||||
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
"scolar.ficheEtud",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
@ -598,14 +598,14 @@ def formChangeCoordonnees(context, etudid, REQUEST):
|
||||
if tf[0] == 0:
|
||||
return header + "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
if adrs:
|
||||
sco_etud.adresse_edit(cnx, args=tf[2], context=context)
|
||||
else:
|
||||
sco_etud.adresse_create(cnx, args=tf[2])
|
||||
logdb(REQUEST, cnx, method="changeCoordonnees", etudid=etudid)
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
logdb(cnx, method="changeCoordonnees", etudid=etudid)
|
||||
return flask.redirect(dest_url)
|
||||
|
||||
|
||||
# --- Gestion des groupes:
|
||||
@ -776,12 +776,12 @@ def formChangePhoto(context, etudid=None, REQUEST=None):
|
||||
+ html_sco_header.sco_footer()
|
||||
)
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
data = tf[2]["photofile"].read()
|
||||
status, diag = sco_photos.store_photo(context, etud, data, REQUEST=REQUEST)
|
||||
if status != 0:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
H.append('<p class="warning">Erreur:' + diag + "</p>")
|
||||
return "\n".join(H) + html_sco_header.sco_footer()
|
||||
@ -795,10 +795,8 @@ def formSuppressPhoto(context, etudid=None, REQUEST=None, dialog_confirmed=False
|
||||
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"<p>Confirmer la suppression de la photo de %(nomprenom)s ?</p>" % etud,
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url=url_for(
|
||||
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid
|
||||
),
|
||||
@ -807,7 +805,7 @@ def formSuppressPhoto(context, etudid=None, REQUEST=None, dialog_confirmed=False
|
||||
|
||||
sco_photos.suppress_photo(context, etud, REQUEST=REQUEST)
|
||||
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
|
||||
@ -951,7 +949,7 @@ def _do_dem_or_def_etud(
|
||||
sco_formsemestre_inscriptions.do_formsemestre_inscription_edit(
|
||||
context, args=ins, formsemestre_id=formsemestre_id
|
||||
)
|
||||
logdb(REQUEST, cnx, method=operation_method, etudid=etudid)
|
||||
logdb(cnx, method=operation_method, etudid=etudid)
|
||||
sco_etud.scolar_events_create(
|
||||
cnx,
|
||||
args={
|
||||
@ -962,7 +960,7 @@ def _do_dem_or_def_etud(
|
||||
},
|
||||
)
|
||||
if REQUEST:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
|
||||
@ -1042,10 +1040,8 @@ def _do_cancel_dem_or_def(
|
||||
raise ScoValueError("etudiant non inscrit ???")
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"<p>Confirmer l'annulation de la %s ?</p>" % operation_name,
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url=url_for(
|
||||
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid
|
||||
),
|
||||
@ -1062,7 +1058,7 @@ def _do_cancel_dem_or_def(
|
||||
sco_formsemestre_inscriptions.do_formsemestre_inscription_edit(
|
||||
context, args=ins, formsemestre_id=formsemestre_id
|
||||
)
|
||||
logdb(REQUEST, cnx, method=operation_method, etudid=etudid)
|
||||
logdb(cnx, method=operation_method, etudid=etudid)
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
cursor.execute(
|
||||
"delete from scolar_events where etudid=%(etudid)s and formsemestre_id=%(formsemestre_id)s and event_type='"
|
||||
@ -1071,7 +1067,7 @@ def _do_cancel_dem_or_def(
|
||||
{"etudid": etudid, "formsemestre_id": formsemestre_id},
|
||||
)
|
||||
cnx.commit()
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
|
||||
)
|
||||
|
||||
@ -1487,7 +1483,7 @@ def _etudident_create_or_edit_form(context, REQUEST, edit):
|
||||
formsemestre_id=formsemestre_id
|
||||
) # > etudident_create_or_edit
|
||||
#
|
||||
return REQUEST.RESPONSE.redirect("ficheEtud?etudid=" + etudid)
|
||||
return flask.redirect("ficheEtud?etudid=" + etudid)
|
||||
|
||||
|
||||
@bp.route("/etudident_delete", methods=["GET", "POST"])
|
||||
@ -1504,7 +1500,6 @@ def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):
|
||||
sco_etud.fill_etuds_info([etud])
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Confirmer la suppression de l'étudiant <b>{e[nomprenom]}</b> ?</h2>
|
||||
</p>
|
||||
<p style="top-margin: 2ex; bottom-margin: 2ex;">Prenez le temps de vérifier
|
||||
@ -1525,7 +1520,6 @@ def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):
|
||||
),
|
||||
),
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url=url_for(
|
||||
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid
|
||||
),
|
||||
@ -1561,9 +1555,7 @@ def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):
|
||||
to_inval = [s["formsemestre_id"] for s in etud["sems"]]
|
||||
for formsemestre_id in to_inval:
|
||||
sco_cache.invalidate_formsemestre(formsemestre_id=formsemestre_id) # >
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
scu.ScoURL() + r"?head_message=Etudiant%20supprimé"
|
||||
)
|
||||
return flask.redirect(scu.ScoURL() + r"?head_message=Etudiant%20supprimé")
|
||||
|
||||
|
||||
@bp.route("/check_group_apogee")
|
||||
@ -1845,7 +1837,7 @@ Les champs avec un astérisque (*) doivent être présents (nulls non autorisés
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + "</li></ol>" + "\n".join(S) + F
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(dest_url)
|
||||
return flask.redirect(dest_url)
|
||||
else:
|
||||
return sco_import_etuds.students_import_excel(
|
||||
context,
|
||||
@ -1985,7 +1977,7 @@ def form_students_import_infos_admissions(context, REQUEST, formsemestre_id=None
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + tf[1] + help_text + F
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
scu.ScoURL() + "/formsemestre_status?formsemestre_id=" + formsemestre_id
|
||||
)
|
||||
else:
|
||||
|
@ -336,7 +336,7 @@ def create_user_form(context, REQUEST, user_name=None, edit=0):
|
||||
if tf[0] == 0:
|
||||
return "\n".join(H) + "\n" + tf[1] + F
|
||||
elif tf[0] == -1:
|
||||
return REQUEST.RESPONSE.redirect(scu.UsersURL())
|
||||
return flask.redirect(scu.UsersURL())
|
||||
else:
|
||||
vals = tf[2]
|
||||
roles = set(vals["roles"]).intersection(editable_roles_strings)
|
||||
@ -417,7 +417,7 @@ def create_user_form(context, REQUEST, user_name=None, edit=0):
|
||||
log("sco_users: previous_values=%s" % initvalues)
|
||||
log("sco_users: new_values=%s" % vals)
|
||||
sco_users.user_edit(user_name, vals)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"user_info_page?user_name=%s&head_message=Utilisateur %s modifié"
|
||||
% (user_name, user_name)
|
||||
)
|
||||
@ -449,7 +449,7 @@ def create_user_form(context, REQUEST, user_name=None, edit=0):
|
||||
u.from_dict(vals, new_user=True)
|
||||
db.session.add(u)
|
||||
db.session.commit()
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
return flask.redirect(
|
||||
"user_info_page?user_name=%s&head_message=Nouvel utilisateur créé"
|
||||
% (user_name)
|
||||
)
|
||||
@ -605,7 +605,6 @@ def delete_user_form(REQUEST, user_name, dialog_confirmed=False):
|
||||
)
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
context,
|
||||
"""<h2>Confirmer la suppression de l\'utilisateur %s ?</h2>
|
||||
<p class="warning">En général, il est <b>déconseillé de supprimer un utilisateur</b>, son
|
||||
identité étant référencé dans les modules de formation. N'utilisez
|
||||
@ -614,7 +613,6 @@ def delete_user_form(REQUEST, user_name, dialog_confirmed=False):
|
||||
"""
|
||||
% user_name,
|
||||
dest_url="",
|
||||
REQUEST=REQUEST,
|
||||
cancel_url=scu.UsersURL(),
|
||||
parameters={"user_name": user_name},
|
||||
)
|
||||
@ -622,6 +620,4 @@ def delete_user_form(REQUEST, user_name, dialog_confirmed=False):
|
||||
db.session.delete(u)
|
||||
db.session.commit()
|
||||
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
scu.UsersURL() + r"?head_message=Utilisateur%20supprimé"
|
||||
)
|
||||
return flask.redirect(scu.UsersURL() + r"?head_message=Utilisateur%20supprimé")
|
||||
|
@ -19,6 +19,7 @@ Fonction de l'API utilisé :
|
||||
|
||||
import sys
|
||||
import random
|
||||
|
||||
# La variable context est définie par le script de lancement
|
||||
# l'affecte ainsi pour évietr les warnins pylint:
|
||||
context = context # pylint: disable=undefined-variable
|
||||
@ -88,13 +89,13 @@ for etud in etuds:
|
||||
|
||||
# --- Création des évaluations
|
||||
|
||||
#création d'éval avec create_evaluation
|
||||
# création d'éval avec create_evaluation
|
||||
e = G.create_evaluation(
|
||||
moduleimpl_id=mi["moduleimpl_id"],
|
||||
jour="7/01/2021",
|
||||
description="evaluation test 1",
|
||||
coefficient=1.0,
|
||||
)
|
||||
)
|
||||
|
||||
e2 = G.create_evaluation(
|
||||
moduleimpl_id=mi2["moduleimpl_id"],
|
||||
@ -104,39 +105,39 @@ e2 = G.create_evaluation(
|
||||
)
|
||||
|
||||
|
||||
# création d'éval avec evaluation_create
|
||||
# e3 = context.Notes.evaluation_create(mi["moduleimpl_id"], REQUEST)
|
||||
# e4 = context.Notes.evaluation_create(mi2["moduleimpl_id"], REQUEST) # rien ne se passe
|
||||
|
||||
#création d'éval avec evaluation_create
|
||||
#e3 = context.Notes.evaluation_create(mi["moduleimpl_id"], REQUEST)
|
||||
#e4 = context.Notes.evaluation_create(mi2["moduleimpl_id"], REQUEST) # rien ne se passe
|
||||
|
||||
#création d'éval avec do_evaluation_create ! WARNING : retourne l'id de l'éval !
|
||||
# création d'éval avec do_evaluation_create ! WARNING : retourne l'id de l'éval !
|
||||
e5 = context.Notes.do_evaluation_create(
|
||||
moduleimpl_id=mi["moduleimpl_id"],
|
||||
jour="01/02/2021",
|
||||
heure_debut="9h0",
|
||||
heure_fin="11h0",
|
||||
description="evaluation test 5",
|
||||
note_max="20.0",
|
||||
coefficient="1",
|
||||
REQUEST=REQUEST
|
||||
)
|
||||
moduleimpl_id=mi["moduleimpl_id"],
|
||||
jour="01/02/2021",
|
||||
heure_debut="9h0",
|
||||
heure_fin="11h0",
|
||||
description="evaluation test 5",
|
||||
note_max="20.0",
|
||||
coefficient="1",
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
|
||||
e6 = context.Notes.do_evaluation_create(
|
||||
moduleimpl_id=mi2["moduleimpl_id"],
|
||||
jour="01/02/2021",
|
||||
heure_debut="13h0",
|
||||
heure_fin="15h0",
|
||||
description="evaluation test 6",
|
||||
note_max="20.0",
|
||||
coefficient="1",
|
||||
REQUEST=REQUEST
|
||||
)
|
||||
|
||||
moduleimpl_id=mi2["moduleimpl_id"],
|
||||
jour="01/02/2021",
|
||||
heure_debut="13h0",
|
||||
heure_fin="15h0",
|
||||
description="evaluation test 6",
|
||||
note_max="20.0",
|
||||
coefficient="1",
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
|
||||
|
||||
# --- Liste des évaluations dans le semestre
|
||||
|
||||
lie = context.Notes.do_evaluation_list_in_formsemestre(formsemestre_id=sem["formsemestre_id"])
|
||||
lie = context.Notes.do_evaluation_list_in_formsemestre(
|
||||
formsemestre_id=sem["formsemestre_id"]
|
||||
)
|
||||
assert len(lie) == 4
|
||||
""" print(lie[0])
|
||||
print(" ")
|
||||
@ -146,8 +147,8 @@ print(lie[2])
|
||||
print(" ")
|
||||
print(lie[3]) """
|
||||
|
||||
eval5 = context.Notes.do_evaluation_list({"evaluation_id" : e5})[0]
|
||||
eval6 = context.Notes.do_evaluation_list({"evaluation_id" : e6})[0]
|
||||
eval5 = context.Notes.do_evaluation_list({"evaluation_id": e5})[0]
|
||||
eval6 = context.Notes.do_evaluation_list({"evaluation_id": e6})[0]
|
||||
|
||||
# --- Saisie des absences aux évaluations
|
||||
|
||||
@ -180,9 +181,9 @@ _ = sco_abs_views.doJustifAbsence(
|
||||
|
||||
# --- Saisie des notes
|
||||
|
||||
evals = [e,e2,eval5,eval6]
|
||||
evals = [e, e2, eval5, eval6]
|
||||
|
||||
for eval in evals :
|
||||
for eval in evals:
|
||||
for etud in etuds:
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
||||
evaluation=eval, etud=etud, note=float(random.randint(0, 20))
|
||||
@ -190,39 +191,61 @@ for eval in evals :
|
||||
|
||||
# --- Check abs
|
||||
|
||||
check = sco_liste_notes.evaluation_check_absences(context.Notes, evaluation_id=e["evaluation_id"])
|
||||
check = sco_liste_notes.evaluation_check_absences(
|
||||
context.Notes, evaluation_id=e["evaluation_id"]
|
||||
)
|
||||
|
||||
check2 = sco_liste_notes.evaluation_check_absences(context.Notes, evaluation_id=e2["evaluation_id"])
|
||||
check2 = sco_liste_notes.evaluation_check_absences(
|
||||
context.Notes, evaluation_id=e2["evaluation_id"]
|
||||
)
|
||||
|
||||
# --- Liste de note d'une évaluation
|
||||
|
||||
#lien = sco_liste_notes.do_evaluation_listenotes(context=context.Notes, REQUEST=REQUEST)
|
||||
# lien = sco_liste_notes.do_evaluation_listenotes(context=context.Notes, REQUEST=REQUEST)
|
||||
|
||||
cal = sco_evaluations.formsemestre_evaluations_cal(context.Notes, formsemestre_id=sem["formsemestre_id"], REQUEST=REQUEST)
|
||||
#html
|
||||
cal = sco_evaluations.formsemestre_evaluations_cal(
|
||||
context.Notes, formsemestre_id=sem["formsemestre_id"], REQUEST=REQUEST
|
||||
)
|
||||
# html
|
||||
|
||||
delai = sco_evaluations.formsemestre_evaluations_delai_correction(context.Notes, formsemestre_id=sem["formsemestre_id"], format="json", REQUEST=REQUEST)
|
||||
#html
|
||||
delai = sco_evaluations.formsemestre_evaluations_delai_correction(
|
||||
context.Notes,
|
||||
formsemestre_id=sem["formsemestre_id"],
|
||||
format="json",
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
# html
|
||||
|
||||
lio = sco_undo_notes.evaluation_list_operations(context.Notes, evaluation_id=e["evaluation_id"], REQUEST=REQUEST)
|
||||
#html
|
||||
lio = sco_undo_notes.evaluation_list_operations(
|
||||
context.Notes, evaluation_id=e["evaluation_id"], REQUEST=REQUEST
|
||||
)
|
||||
# html
|
||||
|
||||
|
||||
# --- Supression de toutes les notes d'une évaluations
|
||||
|
||||
etat = sco_evaluations.do_evaluation_etat(context.Notes, e2["evaluation_id"])
|
||||
assert etat["evalcomplete"]
|
||||
sco_saisie_notes.evaluation_suppress_alln(context.Notes, e2["evaluation_id"], REQUEST=REQUEST)
|
||||
sco_saisie_notes.evaluation_suppress_alln(e2["evaluation_id"])
|
||||
etat2 = sco_evaluations.do_evaluation_etat(context.Notes, e2["evaluation_id"])
|
||||
|
||||
#assert not etat2["evalcomplete"] rien ne se passe...
|
||||
# assert not etat2["evalcomplete"] rien ne se passe...
|
||||
|
||||
# --- Modification d'une évaluation
|
||||
# --- Modification d'une évaluation
|
||||
|
||||
context.Notes.do_evaluation_edit(REQUEST=REQUEST, args={"evaluation_id" : e5, "coefficient": 2.0 ,
|
||||
"description" : "modification", "note_max" : 20,
|
||||
"heure_debut" : "8h0", "heure_fin" : "10h0", "jour" : "03/02/2021"})
|
||||
new_eval5 = context.Notes.do_evaluation_list({"evaluation_id" : e5})[0]
|
||||
context.Notes.do_evaluation_edit(
|
||||
REQUEST=REQUEST,
|
||||
args={
|
||||
"evaluation_id": e5,
|
||||
"coefficient": 2.0,
|
||||
"description": "modification",
|
||||
"note_max": 20,
|
||||
"heure_debut": "8h0",
|
||||
"heure_fin": "10h0",
|
||||
"jour": "03/02/2021",
|
||||
},
|
||||
)
|
||||
new_eval5 = context.Notes.do_evaluation_list({"evaluation_id": e5})[0]
|
||||
|
||||
assert new_eval5["description"] == "modification"
|
||||
assert new_eval5["jour"] == "03/02/2021"
|
||||
@ -239,13 +262,19 @@ e7 = G.create_evaluation(
|
||||
coefficient=1.0,
|
||||
)
|
||||
|
||||
lie = context.Notes.do_evaluation_list_in_formsemestre(formsemestre_id=sem["formsemestre_id"])
|
||||
lie = context.Notes.do_evaluation_list_in_formsemestre(
|
||||
formsemestre_id=sem["formsemestre_id"]
|
||||
)
|
||||
assert len(lie) == 5
|
||||
|
||||
#context.Notes.evaluation_delete(REQUEST=REQUEST, evaluation_id=e7) rien ne se passe
|
||||
sco_evaluations.do_evaluation_delete(context.Notes, REQUEST=REQUEST, evaluation_id=e7["evaluation_id"])
|
||||
lie2 = context.Notes.do_evaluation_list_in_formsemestre(formsemestre_id=sem["formsemestre_id"])
|
||||
assert len(lie2) == 4
|
||||
# context.Notes.evaluation_delete(REQUEST=REQUEST, evaluation_id=e7) rien ne se passe
|
||||
sco_evaluations.do_evaluation_delete(
|
||||
context.Notes, REQUEST=REQUEST, evaluation_id=e7["evaluation_id"]
|
||||
)
|
||||
lie2 = context.Notes.do_evaluation_list_in_formsemestre(
|
||||
formsemestre_id=sem["formsemestre_id"]
|
||||
)
|
||||
assert len(lie2) == 4
|
||||
|
||||
|
||||
"""
|
||||
|
@ -1,75 +0,0 @@
|
||||
""" Création d'une évaluation, saisie des notes et supressions de toutes les notes """
|
||||
|
||||
import random
|
||||
# La variable context est définie par le script de lancement
|
||||
# l'affecte ainsi pour évietr les warnins pylint:
|
||||
context = context # pylint: disable=undefined-variable
|
||||
REQUEST = REQUEST # pylint: disable=undefined-variable
|
||||
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
||||
import sco_saisie_notes
|
||||
import sco_evaluations
|
||||
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
# --- Création d'étudiants
|
||||
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
||||
|
||||
# --- Création d'une formation et de deux UE
|
||||
f = G.create_formation(acronyme="")
|
||||
ue = G.create_ue(formation_id=f["formation_id"], acronyme="TST1", titre="ue test")
|
||||
mat = G.create_matiere(ue_id=ue["ue_id"], titre="matière test")
|
||||
mod = G.create_module(
|
||||
matiere_id=mat["matiere_id"],
|
||||
code="TSM1",
|
||||
coefficient=1.0,
|
||||
titre="module test",
|
||||
ue_id=ue["ue_id"], # faiblesse de l'API
|
||||
formation_id=f["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
|
||||
# --- Mise place d'un semestre
|
||||
sem = G.create_formsemestre(
|
||||
formation_id=f["formation_id"],
|
||||
semestre_id=1,
|
||||
date_debut="01/01/2021",
|
||||
date_fin="30/06/2021",
|
||||
)
|
||||
|
||||
mi = G.create_moduleimpl(
|
||||
module_id=mod["module_id"],
|
||||
formsemestre_id=sem["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
# --- Inscription des étudiants
|
||||
for etud in etuds:
|
||||
G.inscrit_etudiant(sem, etud)
|
||||
|
||||
# --- Création d'une évaluation
|
||||
e = G.create_evaluation(
|
||||
moduleimpl_id=mi["moduleimpl_id"],
|
||||
jour="7/01/2021",
|
||||
description="evaluation test 1",
|
||||
coefficient=1.0,
|
||||
)
|
||||
|
||||
# --- Saisie des notes
|
||||
for etud in etuds:
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
||||
evaluation=e, etud=etud, note=float(random.randint(0, 20))
|
||||
)
|
||||
|
||||
etat = sco_evaluations.do_evaluation_etat(context.Notes, e["evaluation_id"])
|
||||
assert etat["evalcomplete"]
|
||||
|
||||
# --- Suppression des notes
|
||||
sco_saisie_notes.evaluation_suppress_alln(context.Notes, e["evaluation_id"], REQUEST=REQUEST)
|
||||
etat = sco_evaluations.do_evaluation_etat(context.Notes, e["evaluation_id"])
|
||||
assert not etat["evalcomplete"]
|
||||
|
||||
"""
|
||||
Commentaire : Les notes ne se suppriment pas et l'etat ne change donc pas
|
||||
"""
|
@ -1,319 +0,0 @@
|
||||
""" Créer 2 formations, une test et une normale. Créer 2 semestres dans la formation normale et un
|
||||
dans la formation test, créer 2 semestres dans la formation normale (un test et un normal),
|
||||
2 ue (un test et un normal), 2 modules (un test et un normal) et 2 matieres (test et normal).
|
||||
Et dans la formations test, un semestre, un module, un ue et une matiere.
|
||||
Afficher la liste de tout ca puis supprimer les ue, mod, mat et sem test ainsi
|
||||
que la formation test. Afficher la liste des UE, formations et modules restante.
|
||||
|
||||
Vérification :
|
||||
|
||||
- Les listes initiales comprennent bien tout les éléments créés avec les bon noms etc
|
||||
- La supression s'est bien effectué au niveau de scodoc web et en python
|
||||
- Vérifier que les fonctions listes font bien la mise à jour après supression
|
||||
|
||||
Fonction de l'API utilisé :
|
||||
|
||||
- create_formation
|
||||
- create_ue
|
||||
- create_matiere
|
||||
- create_module
|
||||
- create_formsemestre
|
||||
- create_moduleimpl
|
||||
- formation_list
|
||||
- formation_export
|
||||
- formsemestre_list
|
||||
- do_moduleimpl_list
|
||||
- do_module_impl_with_module_list
|
||||
- do_formsemestre_delete
|
||||
- do_module_list
|
||||
- do_module_delete
|
||||
- do_matiere_list
|
||||
- do_matiere_delete
|
||||
- do_ue_list
|
||||
- do_ue_delete
|
||||
- do_formation_delete
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import random
|
||||
|
||||
# La variable context est définie par le script de lancement
|
||||
# l'affecte ainsi pour évietr les warnins pylint:
|
||||
context = context # pylint: disable=undefined-variable
|
||||
REQUEST = REQUEST # pylint: disable=undefined-variable
|
||||
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
||||
import sco_formsemestre_status
|
||||
import ZNotes
|
||||
import sco_formations
|
||||
import sco_moduleimpl
|
||||
import sco_edit_ue
|
||||
import sco_edit_matiere
|
||||
import sco_edit_module
|
||||
import sco_formsemestre_edit
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
# --- Création de formations
|
||||
|
||||
f = G.create_formation(acronyme="F1", titre="Formation 1", titre_officiel="Titre officiel 1")
|
||||
|
||||
ue = G.create_ue(formation_id=f["formation_id"], acronyme="TST1", titre="ue test")
|
||||
mat = G.create_matiere(ue_id=ue["ue_id"], titre="matière test")
|
||||
mod = G.create_module(
|
||||
matiere_id=mat["matiere_id"],
|
||||
code="TSM1",
|
||||
coefficient=1.0,
|
||||
titre="module test",
|
||||
ue_id=ue["ue_id"], # faiblesse de l'API
|
||||
formation_id=f["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
ue2 = G.create_ue(formation_id=f["formation_id"], acronyme="TST2", titre="ue test2")
|
||||
mat2 = G.create_matiere(ue_id=ue2["ue_id"], titre="matière test2")
|
||||
mod2 = G.create_module(
|
||||
matiere_id=mat2["matiere_id"],
|
||||
code="TSM2",
|
||||
coefficient=1.0,
|
||||
titre="module test",
|
||||
ue_id=ue2["ue_id"], # faiblesse de l'API
|
||||
formation_id=f["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
uet = G.create_ue(formation_id=f["formation_id"], acronyme="TSTt", titre="ue testt")
|
||||
matt = G.create_matiere(ue_id=uet["ue_id"], titre="matière testt")
|
||||
modt = G.create_module(
|
||||
matiere_id=matt["matiere_id"],
|
||||
code="TSMt",
|
||||
coefficient=1.0,
|
||||
titre="module test",
|
||||
ue_id=uet["ue_id"], # faiblesse de l'API
|
||||
formation_id=f["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
|
||||
f2 = G.create_formation(acronyme="", titre="Formation test")
|
||||
|
||||
ue3 = G.create_ue(formation_id=f2["formation_id"], acronyme="TST3", titre="ue test3")
|
||||
mat3 = G.create_matiere(ue_id=ue3["ue_id"], titre="matière test3")
|
||||
mod3 = G.create_module(
|
||||
matiere_id=mat3["matiere_id"],
|
||||
code="TSM3",
|
||||
coefficient=1.0,
|
||||
titre="module test3",
|
||||
ue_id=ue3["ue_id"], # faiblesse de l'API
|
||||
formation_id=f2["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
# --- Création et implémentation des semestres
|
||||
|
||||
sem1 = G.create_formsemestre(
|
||||
formation_id=f["formation_id"],
|
||||
semestre_id=1,
|
||||
date_debut="01/01/2021",
|
||||
date_fin="30/06/2021",
|
||||
)
|
||||
|
||||
sem2 = G.create_formsemestre(
|
||||
formation_id=f["formation_id"],
|
||||
semestre_id=2,
|
||||
date_debut="01/09/2020",
|
||||
date_fin="31/12/2020",
|
||||
)
|
||||
|
||||
mi = G.create_moduleimpl(
|
||||
module_id=mod["module_id"],
|
||||
formsemestre_id=sem1["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
mi2 = G.create_moduleimpl(
|
||||
module_id=mod2["module_id"],
|
||||
formsemestre_id=sem1["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
mit = G.create_moduleimpl(
|
||||
module_id=modt["module_id"],
|
||||
formsemestre_id=sem2["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
semt = G.create_formsemestre(
|
||||
formation_id=f2["formation_id"],
|
||||
semestre_id=3,
|
||||
date_debut="01/01/2021",
|
||||
date_fin="30/06/2021",
|
||||
)
|
||||
|
||||
mi3 = G.create_moduleimpl(
|
||||
module_id=mod3["module_id"],
|
||||
formsemestre_id=semt["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
# --- Affichier la liste des formations
|
||||
|
||||
lif = context.Notes.formation_list(format="json", REQUEST=REQUEST, formation_id=f["formation_id"])
|
||||
|
||||
load_lif = json.loads(lif)
|
||||
assert len(load_lif) == 1
|
||||
assert load_lif[0]["acronyme"] == f["acronyme"]
|
||||
assert load_lif[0]["titre_officiel"] == f["titre_officiel"]
|
||||
assert load_lif[0]["formation_id"] == f["formation_id"]
|
||||
assert load_lif[0]["titre"] == f["titre"]
|
||||
|
||||
lif2 = context.Notes.formation_list(format = 'json', REQUEST=REQUEST)
|
||||
|
||||
load_lif2 = json.loads(lif2)
|
||||
assert len(load_lif2) == 2
|
||||
assert load_lif2[0] == load_lif[0]
|
||||
assert load_lif2[1]["titre"] == f2["titre"]
|
||||
|
||||
|
||||
# --- Export de formation_id
|
||||
|
||||
exp = sco_formations.formation_export(context.Notes, formation_id=f["formation_id"], format="json", REQUEST=REQUEST)
|
||||
|
||||
load_exp = json.loads(exp)
|
||||
|
||||
assert load_exp["acronyme"] == "F1"
|
||||
assert load_exp["titre_officiel"] == "Titre officiel 1"
|
||||
assert load_exp["titre"] == "Formation 1"
|
||||
assert load_exp["formation_code"] == f["formation_code"]
|
||||
assert len(load_exp["ue"]) == 3
|
||||
assert load_exp["ue"][0]["acronyme"] == "TST1"
|
||||
assert load_exp["ue"][0]["titre"] == "ue test"
|
||||
assert load_exp["formation_id"] == f["formation_id"]
|
||||
assert load_exp["formation_code"] == f["formation_code"]
|
||||
|
||||
|
||||
# --- Liste des semestres
|
||||
|
||||
li_sem1 = context.Notes.formsemestre_list(formsemestre_id=sem1["formsemestre_id"], format = "json", REQUEST=REQUEST)
|
||||
load_li_sem1 = json.loads(li_sem1) #uniquement le semestre 1 dans la liste
|
||||
|
||||
assert len(load_li_sem1) == 1
|
||||
assert load_li_sem1[0]["date_fin"] == sem1["date_fin"]
|
||||
assert load_li_sem1[0]["semestre_id"] == sem1["semestre_id"]
|
||||
assert load_li_sem1[0]["formation_id"] ==sem1["formation_id"]
|
||||
|
||||
|
||||
li_semf = context.Notes.formsemestre_list(formation_id=f["formation_id"], format = "json", REQUEST=REQUEST)
|
||||
load_li_semf = json.loads(li_semf)
|
||||
|
||||
assert load_li_sem1[0] in load_li_semf
|
||||
assert len(load_li_semf) == 2
|
||||
assert load_li_semf[1]["semestre_id"] == sem2["semestre_id"]
|
||||
|
||||
|
||||
li_sem = context.Notes.formsemestre_list(format = "json", REQUEST=REQUEST)
|
||||
load_li_sem = json.loads(li_sem)
|
||||
|
||||
assert len(load_li_sem) == 3
|
||||
assert load_li_semf[0] and load_li_semf[1] in load_li_sem
|
||||
assert load_li_sem[0]["semestre_id"] == semt["semestre_id"]
|
||||
|
||||
|
||||
# --- Liste des modules
|
||||
|
||||
lim_sem1 = sco_moduleimpl.do_moduleimpl_list(context.Notes, formsemestre_id=sem1["formsemestre_id"], REQUEST=REQUEST)
|
||||
load_lim_sem1 = json.loads(lim_sem1)
|
||||
|
||||
|
||||
assert len(load_lim_sem1) == 2
|
||||
assert mod["module_id"] == load_lim_sem1[0]["module_id"] or load_lim_sem1[1]["module_id"]
|
||||
assert mod2["module_id"] == load_lim_sem1[0]["module_id"] or load_lim_sem1[1]["module_id"]
|
||||
|
||||
lim_modid = sco_moduleimpl.do_moduleimpl_list(context.Notes, module_id=mod["module_id"], REQUEST=REQUEST)
|
||||
load_lim_modid = json.loads(lim_modid) #Liste avec seulement mod
|
||||
|
||||
assert len(load_lim_modid) == 1
|
||||
|
||||
lim_modimpl_id = sco_moduleimpl.do_moduleimpl_list(context.Notes, moduleimpl_id=mi["moduleimpl_id"], REQUEST=REQUEST)
|
||||
print(lim_modimpl_id)
|
||||
|
||||
# ---- Test de do_moduleimpl_withmodule_list
|
||||
|
||||
assert lim_modid == lim_modimpl_id #doit etre le meme resultat
|
||||
|
||||
liimp_sem1 = sco_moduleimpl.do_moduleimpl_withmodule_list(context.Notes, formsemestre_id=sem1["formsemestre_id"], REQUEST=REQUEST)
|
||||
load_liimp_sem1 = json.loads(liimp_sem1)
|
||||
|
||||
assert len(load_liimp_sem1) == 2
|
||||
assert mod["module_id"] == load_liimp_sem1[0]["module_id"] or load_liimp_sem1[1]["module_id"] or load_liim_sem1[2]["module_id"]
|
||||
assert mod2["module_id"] == load_liimp_sem1[0]["module_id"] or load_liimp_sem1[1]["module_id"] or load_liim_sem1[2]["module_id"]
|
||||
assert modt["module_id"] == load_liimp_sem1[0]["module_id"] or load_liimp_sem1[1]["module_id"] or load_liim_sem1[2]["module_id"]
|
||||
|
||||
liimp_modid = sco_moduleimpl.do_moduleimpl_withmodule_list(context.Notes, module_id=mod["module_id"], REQUEST=REQUEST)
|
||||
|
||||
load_liimp_modid = json.loads(liimp_modid)
|
||||
assert len(load_liimp_modid) == 1
|
||||
|
||||
liimp_modimplid = sco_moduleimpl.do_moduleimpl_withmodule_list(context.Notes, moduleimpl_id=mi["moduleimpl_id"], REQUEST=REQUEST)
|
||||
|
||||
assert liimp_modid == liimp_modimplid
|
||||
|
||||
|
||||
# --- Suppression du module, matiere et ue test du semestre 2
|
||||
|
||||
#on doit d'abbord supprimer le semestre
|
||||
|
||||
#sco_formsemestre_edit.formsemestre_delete(context.Notes, formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST)
|
||||
#sco_formsemestre_edit.formsemestre_delete2(context.Notes, formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST)
|
||||
|
||||
# RIEN NE SE PASSE AVEC CES FONCTIONS
|
||||
|
||||
sco_formsemestre_edit.do_formsemestre_delete(context.Notes, formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST)
|
||||
|
||||
#sco_edit_module.module_delete(context.Notes, module_id=modt["module_id"], REQUEST=REQUEST)
|
||||
#sco_edit_matiere.matiere_delete(context.Notes, matiere_id=matt["matiere_id"], REQUEST=REQUEST)
|
||||
#sco_edit_ue.ue_delete(context.Notes, ue_id=uet["ue_id"], REQUEST=REQUEST)
|
||||
|
||||
# RIEN NE SE PASSE AVEC CES FONCTIONS
|
||||
|
||||
|
||||
li_module = context.Notes.do_module_list()
|
||||
assert len(li_module) == 4
|
||||
context.Notes.do_module_delete(oid=modt["module_id"], REQUEST=REQUEST) #on supprime le semestre
|
||||
#sco_formsemestre_edit.formsemestre_delete_moduleimpls(context.Notes, formsemestre_id=sem2["formsemestre_id"], module_ids_to_del=[modt["module_id"]])
|
||||
#deuxieme methode de supression d'un module
|
||||
li_module2 = context.Notes.do_module_list()
|
||||
|
||||
assert len(li_module2) == 3 #verification de la suppression du module
|
||||
|
||||
lim_sem2 = sco_moduleimpl.do_moduleimpl_list(context.Notes, formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST)
|
||||
load_lim_sem2 = json.loads(lim_sem2)
|
||||
|
||||
assert len(load_lim_sem2) == 0 #deuxieme vérification si le module s'est bien sup
|
||||
|
||||
|
||||
li_mat = context.Notes.do_matiere_list()
|
||||
assert len(li_mat) == 4
|
||||
context.Notes.do_matiere_delete(oid=matt["matiere_id"], REQUEST=REQUEST) #on supprime la matiere
|
||||
li_mat2 = context.Notes.do_matiere_list()
|
||||
assert len(li_mat2) == 3 #verification de la suppression de la matiere
|
||||
|
||||
|
||||
li_ue = context.Notes.do_ue_list()
|
||||
assert len(li_ue) == 4
|
||||
sco_edit_ue.ue_delete(context.Notes, ue_id=uet["ue_id"], REQUEST=REQUEST)
|
||||
li_ue2 = context.Notes.do_ue_list()
|
||||
#assert len(li_ue) == 3 #verification de la suppression de l'UE #comment supprimer un ue?
|
||||
|
||||
|
||||
# --- Suppression d'une formation
|
||||
|
||||
|
||||
#Il faut d'abbord supprimer le semestre aussi.
|
||||
|
||||
sco_formsemestre_edit.do_formsemestre_delete(context.Notes, formsemestre_id=semt["formsemestre_id"], REQUEST=REQUEST)
|
||||
|
||||
|
||||
context.Notes.do_formation_delete(oid=f2["formation_id"], REQUEST=REQUEST)
|
||||
lif3 = context.Notes.formation_list(format = 'json', REQUEST=REQUEST)
|
||||
|
||||
load_lif3 = json.loads(lif3)
|
||||
assert len(load_lif3) == 1
|
@ -24,13 +24,13 @@ def test_client():
|
||||
db.create_all()
|
||||
Role.insert_roles()
|
||||
u = User(user_name="admin")
|
||||
admin_role = Role.query.filter_by(name="Admin").first()
|
||||
admin_role = Role.query.filter_by(name="SuperAdmin").first()
|
||||
u.add_role(admin_role, "TEST00")
|
||||
# u.set_password("admin")
|
||||
login_user(u)
|
||||
# db.session.add(u)
|
||||
|
||||
g.scodoc_dept = "RT"
|
||||
g.scodoc_dept = "TEST00"
|
||||
g.db_conn = ndb.open_dept_connection()
|
||||
yield client
|
||||
# ndb.close_dept_connection()
|
||||
|
@ -149,7 +149,7 @@ class ScoFake(object):
|
||||
"""Crée une formation"""
|
||||
if not acronyme:
|
||||
acronyme = "TEST" + str(random.randint(100000, 999999))
|
||||
oid = sco_edit_formation.do_formation_create(context, locals(), REQUEST=REQUEST)
|
||||
oid = sco_edit_formation.do_formation_create(context, locals())
|
||||
oids = sco_formations.formation_list(context, formation_id=oid)
|
||||
if not oids:
|
||||
raise ScoValueError("formation not created !")
|
||||
@ -172,7 +172,7 @@ class ScoFake(object):
|
||||
"""Crée une UE"""
|
||||
if numero is None:
|
||||
numero = sco_edit_ue.next_ue_numero(context, formation_id, 0)
|
||||
oid = sco_edit_ue.do_ue_create(context, locals(), REQUEST)
|
||||
oid = sco_edit_ue.do_ue_create(context, locals())
|
||||
oids = sco_edit_ue.do_ue_list(context, args={"ue_id": oid})
|
||||
if not oids:
|
||||
raise ScoValueError("ue not created !")
|
||||
@ -180,7 +180,7 @@ class ScoFake(object):
|
||||
|
||||
@logging_meth
|
||||
def create_matiere(self, ue_id=None, titre=None, numero=None):
|
||||
oid = sco_edit_matiere.do_matiere_create(context, locals(), REQUEST)
|
||||
oid = sco_edit_matiere.do_matiere_create(context, locals())
|
||||
oids = sco_edit_matiere.do_matiere_list(context, args={"matiere_id": oid})
|
||||
if not oids:
|
||||
raise ScoValueError("matiere not created !")
|
||||
@ -205,7 +205,7 @@ class ScoFake(object):
|
||||
code_apogee=None,
|
||||
module_type=None,
|
||||
):
|
||||
oid = sco_edit_module.do_module_create(context, locals(), REQUEST)
|
||||
oid = sco_edit_module.do_module_create(context, locals())
|
||||
oids = sco_edit_module.do_module_list(context, args={"module_id": oid})
|
||||
if not oids:
|
||||
raise ScoValueError("module not created ! (oid=%s)" % oid)
|
||||
|
@ -9,12 +9,13 @@ Usage: pytest tests/unit/test_caches.py
|
||||
"""
|
||||
|
||||
|
||||
from flask import current_app
|
||||
from flask import current_app, g
|
||||
|
||||
from app import db
|
||||
from app.scodoc import sco_cache
|
||||
from app.scodoc import sco_evaluations
|
||||
from app.scodoc import sco_formsemestre
|
||||
from app.scodoc import notesdb as ndb
|
||||
|
||||
DEPT = "RT" # ce département (BD) doit exister
|
||||
context = None # #context
|
||||
@ -22,6 +23,8 @@ context = None # #context
|
||||
|
||||
def test_notes_table(test_client):
|
||||
"""Test construction et cache de NotesTable"""
|
||||
ndb.set_sco_dept(DEPT)
|
||||
assert g.scodoc_dept == DEPT
|
||||
sems = sco_formsemestre.do_formsemestre_list(context)
|
||||
assert len(sems)
|
||||
sem = sems[0]
|
||||
@ -41,6 +44,7 @@ def test_notes_table(test_client):
|
||||
def test_cache_evaluations(test_client):
|
||||
""""""
|
||||
# cherche un semestre ayant des evaluations
|
||||
ndb.set_sco_dept(DEPT)
|
||||
sems = sco_formsemestre.do_formsemestre_list(None)
|
||||
assert len(sems)
|
||||
sem_evals = []
|
||||
|
346
tests/unit/test_formations.py
Normal file
346
tests/unit/test_formations.py
Normal file
@ -0,0 +1,346 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Test creation/edition/import/export formations
|
||||
"""
|
||||
|
||||
# test écrit par Fares Amer, mai 2021 et porté sur ScoDoc 8 en juillet 2021
|
||||
|
||||
# Créer 2 formations, une test et une normale. Créer 2 semestres dans la formation normale et un
|
||||
# dans la formation test, créer 2 semestres dans la formation normale (un test et un normal),
|
||||
# 2 ue (un test et un normal), 2 modules (un test et un normal) et 2 matieres (test et normal).
|
||||
# Et dans la formations test, un semestre, un module, un ue et une matiere.
|
||||
# Afficher la liste de tout ca puis supprimer les ue, mod, mat et sem test ainsi
|
||||
# que la formation test. Afficher la liste des UE, formations et modules restante.
|
||||
#
|
||||
# Vérification :
|
||||
#
|
||||
# - Les listes initiales comprennent bien tout les éléments créés avec les bon noms etc
|
||||
# - La supression s'est bien effectué au niveau de scodoc web et en python
|
||||
# - Vérifier que les fonctions listes font bien la mise à jour après supression
|
||||
#
|
||||
# Fonction de l'API utilisé :
|
||||
#
|
||||
# - create_formation
|
||||
# - create_ue
|
||||
# - create_matiere
|
||||
# - create_module
|
||||
# - create_formsemestre
|
||||
# - create_moduleimpl
|
||||
# - formation_list
|
||||
# - formation_export
|
||||
# - formsemestre_list
|
||||
# - do_moduleimpl_list
|
||||
# - do_module_impl_with_module_list
|
||||
# - do_formsemestre_delete
|
||||
# - do_module_list
|
||||
# - do_module_delete
|
||||
# - do_matiere_list
|
||||
# - do_matiere_delete
|
||||
# - do_ue_list
|
||||
# - do_ue_delete
|
||||
# - do_formation_delete
|
||||
|
||||
import json
|
||||
import flask
|
||||
from flask import g
|
||||
|
||||
from tests.unit import sco_fake_gen
|
||||
|
||||
from app.scodoc import sco_edit_formation
|
||||
from app.scodoc import sco_edit_matiere
|
||||
from app.scodoc import sco_edit_module
|
||||
from app.scodoc import sco_edit_ue
|
||||
from app.scodoc import sco_formations
|
||||
from app.scodoc import sco_formsemestre_edit
|
||||
from app.scodoc import sco_formsemestre_status
|
||||
from app.scodoc import sco_moduleimpl
|
||||
from app.views import notes
|
||||
|
||||
context = None # #context
|
||||
|
||||
|
||||
def test_formations(test_client):
|
||||
"""Test création/édition/import/export formations"""
|
||||
G = sco_fake_gen.ScoFake(verbose=False)
|
||||
|
||||
# --- Création de formations
|
||||
|
||||
f = G.create_formation(
|
||||
acronyme="F1", titre="Formation 1", titre_officiel="Titre officiel 1"
|
||||
)
|
||||
|
||||
ue = G.create_ue(formation_id=f["formation_id"], acronyme="TST1", titre="ue test")
|
||||
mat = G.create_matiere(ue_id=ue["ue_id"], titre="matière test")
|
||||
mod = G.create_module(
|
||||
matiere_id=mat["matiere_id"],
|
||||
code="TSM1",
|
||||
coefficient=1.0,
|
||||
titre="module test",
|
||||
ue_id=ue["ue_id"], # faiblesse de l'API
|
||||
formation_id=f["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
ue2 = G.create_ue(formation_id=f["formation_id"], acronyme="TST2", titre="ue test2")
|
||||
mat2 = G.create_matiere(ue_id=ue2["ue_id"], titre="matière test2")
|
||||
mod2 = G.create_module(
|
||||
matiere_id=mat2["matiere_id"],
|
||||
code="TSM2",
|
||||
coefficient=1.0,
|
||||
titre="module test",
|
||||
ue_id=ue2["ue_id"], # faiblesse de l'API
|
||||
formation_id=f["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
uet = G.create_ue(formation_id=f["formation_id"], acronyme="TSTt", titre="ue testt")
|
||||
matt = G.create_matiere(ue_id=uet["ue_id"], titre="matière testt")
|
||||
modt = G.create_module(
|
||||
matiere_id=matt["matiere_id"],
|
||||
code="TSMt",
|
||||
coefficient=1.0,
|
||||
titre="module test",
|
||||
ue_id=uet["ue_id"], # faiblesse de l'API
|
||||
formation_id=f["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
f2 = G.create_formation(acronyme="", titre="Formation test")
|
||||
|
||||
ue3 = G.create_ue(
|
||||
formation_id=f2["formation_id"], acronyme="TST3", titre="ue test3"
|
||||
)
|
||||
mat3 = G.create_matiere(ue_id=ue3["ue_id"], titre="matière test3")
|
||||
mod3 = G.create_module(
|
||||
matiere_id=mat3["matiere_id"],
|
||||
code="TSM3",
|
||||
coefficient=1.0,
|
||||
titre="module test3",
|
||||
ue_id=ue3["ue_id"], # faiblesse de l'API
|
||||
formation_id=f2["formation_id"], # faiblesse de l'API
|
||||
)
|
||||
|
||||
# --- Création et implémentation des semestres
|
||||
|
||||
sem1 = G.create_formsemestre(
|
||||
formation_id=f["formation_id"],
|
||||
semestre_id=1,
|
||||
date_debut="01/01/2021",
|
||||
date_fin="30/06/2021",
|
||||
)
|
||||
|
||||
sem2 = G.create_formsemestre(
|
||||
formation_id=f["formation_id"],
|
||||
semestre_id=2,
|
||||
date_debut="01/09/2020",
|
||||
date_fin="31/12/2020",
|
||||
)
|
||||
|
||||
mi = G.create_moduleimpl(
|
||||
module_id=mod["module_id"],
|
||||
formsemestre_id=sem1["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
mi2 = G.create_moduleimpl(
|
||||
module_id=mod2["module_id"],
|
||||
formsemestre_id=sem1["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
mit = G.create_moduleimpl(
|
||||
module_id=modt["module_id"],
|
||||
formsemestre_id=sem2["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
semt = G.create_formsemestre(
|
||||
formation_id=f2["formation_id"],
|
||||
semestre_id=3,
|
||||
date_debut="01/01/2021",
|
||||
date_fin="30/06/2021",
|
||||
)
|
||||
|
||||
mi3 = G.create_moduleimpl(
|
||||
module_id=mod3["module_id"],
|
||||
formsemestre_id=semt["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
# --- Afficher la liste des formations
|
||||
|
||||
lif = notes.formation_list(context, format="json", formation_id=f["formation_id"])
|
||||
# lif est une Response car on a appelé une vue (1er appel)
|
||||
assert isinstance(lif, flask.Response)
|
||||
load_lif = json.loads(lif.get_data().decode("utf-8"))
|
||||
assert len(load_lif) == 1
|
||||
assert load_lif[0]["acronyme"] == f["acronyme"]
|
||||
assert load_lif[0]["titre_officiel"] == f["titre_officiel"]
|
||||
assert load_lif[0]["formation_id"] == f["formation_id"]
|
||||
assert load_lif[0]["titre"] == f["titre"]
|
||||
|
||||
lif2 = notes.formation_list(context, format="json")
|
||||
# lif2 est un chaine
|
||||
assert isinstance(lif2, str)
|
||||
load_lif2 = json.loads(lif2)
|
||||
assert len(load_lif2) == 2
|
||||
assert load_lif2[0] == load_lif[0]
|
||||
assert load_lif2[1]["titre"] == f2["titre"]
|
||||
|
||||
# --- Export de formation_id
|
||||
|
||||
exp = sco_formations.formation_export(
|
||||
context, formation_id=f["formation_id"], format="json"
|
||||
)
|
||||
assert isinstance(exp, str)
|
||||
load_exp = json.loads(exp)
|
||||
|
||||
assert load_exp["acronyme"] == "F1"
|
||||
assert load_exp["titre_officiel"] == "Titre officiel 1"
|
||||
assert load_exp["titre"] == "Formation 1"
|
||||
assert load_exp["formation_code"] == f["formation_code"]
|
||||
assert len(load_exp["ue"]) == 3
|
||||
assert load_exp["ue"][0]["acronyme"] == "TST1"
|
||||
assert load_exp["ue"][0]["titre"] == "ue test"
|
||||
assert load_exp["formation_id"] == f["formation_id"]
|
||||
assert load_exp["formation_code"] == f["formation_code"]
|
||||
|
||||
# --- Liste des semestres
|
||||
|
||||
li_sem1 = notes.formsemestre_list(
|
||||
context, formsemestre_id=sem1["formsemestre_id"], format="json"
|
||||
)
|
||||
assert isinstance(li_sem1, str)
|
||||
load_li_sem1 = json.loads(li_sem1) # uniquement le semestre 1 dans la liste
|
||||
|
||||
assert len(load_li_sem1) == 1
|
||||
assert load_li_sem1[0]["date_fin"] == sem1["date_fin"]
|
||||
assert load_li_sem1[0]["semestre_id"] == sem1["semestre_id"]
|
||||
assert load_li_sem1[0]["formation_id"] == sem1["formation_id"]
|
||||
|
||||
li_semf = notes.formsemestre_list(
|
||||
context,
|
||||
formation_id=f["formation_id"],
|
||||
format="json",
|
||||
)
|
||||
assert isinstance(li_semf, str)
|
||||
load_li_semf = json.loads(li_semf)
|
||||
|
||||
assert load_li_sem1[0] in load_li_semf
|
||||
assert len(load_li_semf) == 2
|
||||
assert load_li_semf[1]["semestre_id"] == sem2["semestre_id"]
|
||||
|
||||
li_sem = notes.formsemestre_list(context, format="json")
|
||||
load_li_sem = json.loads(li_sem)
|
||||
|
||||
assert len(load_li_sem) == 3
|
||||
assert load_li_semf[0] and load_li_semf[1] in load_li_sem
|
||||
assert load_li_sem[0]["semestre_id"] == semt["semestre_id"]
|
||||
|
||||
# --- Liste des modules
|
||||
|
||||
lim_sem1 = sco_moduleimpl.do_moduleimpl_list(
|
||||
context, formsemestre_id=sem1["formsemestre_id"]
|
||||
)
|
||||
|
||||
assert len(lim_sem1) == 2
|
||||
assert mod["module_id"] in (lim_sem1[0]["module_id"], lim_sem1[1]["module_id"])
|
||||
assert mod2["module_id"] in (lim_sem1[0]["module_id"], lim_sem1[1]["module_id"])
|
||||
|
||||
lim_modid = sco_moduleimpl.do_moduleimpl_list(context, module_id=mod["module_id"])
|
||||
|
||||
assert len(lim_modid) == 1
|
||||
|
||||
lim_modimpl_id = sco_moduleimpl.do_moduleimpl_list(
|
||||
context, moduleimpl_id=mi["moduleimpl_id"]
|
||||
)
|
||||
# print(lim_modimpl_id)
|
||||
|
||||
# ---- Test de do_moduleimpl_withmodule_list
|
||||
|
||||
assert lim_modid == lim_modimpl_id # doit etre le meme resultat
|
||||
|
||||
liimp_sem1 = sco_moduleimpl.do_moduleimpl_withmodule_list(
|
||||
context, formsemestre_id=sem1["formsemestre_id"]
|
||||
)
|
||||
|
||||
assert len(liimp_sem1) == 2
|
||||
assert mod["module_id"] in (liimp_sem1[0]["module_id"], liimp_sem1[1]["module_id"])
|
||||
assert mod2["module_id"] in (
|
||||
liimp_sem1[0]["module_id"],
|
||||
liimp_sem1[1]["module_id"],
|
||||
)
|
||||
liimp_sem2 = sco_moduleimpl.do_moduleimpl_withmodule_list(
|
||||
context, formsemestre_id=sem2["formsemestre_id"]
|
||||
)
|
||||
assert modt["module_id"] == liimp_sem2[0]["module_id"]
|
||||
liimp_modid = sco_moduleimpl.do_moduleimpl_withmodule_list(
|
||||
context, module_id=mod["module_id"]
|
||||
)
|
||||
assert len(liimp_modid) == 1
|
||||
|
||||
liimp_modimplid = sco_moduleimpl.do_moduleimpl_withmodule_list(
|
||||
context, moduleimpl_id=mi["moduleimpl_id"]
|
||||
)
|
||||
|
||||
assert liimp_modid == liimp_modimplid
|
||||
|
||||
# --- Suppression du module, matiere et ue test du semestre 2
|
||||
|
||||
# on doit d'abbord supprimer le semestre
|
||||
|
||||
# sco_formsemestre_edit.formsemestre_delete(context.Notes, formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST)
|
||||
# sco_formsemestre_edit.formsemestre_delete2(context.Notes, formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST)
|
||||
|
||||
# RIEN NE SE PASSE AVEC CES FONCTIONS
|
||||
|
||||
sco_formsemestre_edit.do_formsemestre_delete(
|
||||
context, formsemestre_id=sem2["formsemestre_id"]
|
||||
)
|
||||
|
||||
# sco_edit_module.module_delete(context.Notes, module_id=modt["module_id"], REQUEST=REQUEST)
|
||||
# sco_edit_matiere.matiere_delete(context.Notes, matiere_id=matt["matiere_id"], REQUEST=REQUEST)
|
||||
# sco_edit_ue.ue_delete(context.Notes, ue_id=uet["ue_id"], REQUEST=REQUEST)
|
||||
|
||||
# RIEN NE SE PASSE AVEC CES FONCTIONS
|
||||
|
||||
li_module = sco_edit_module.do_module_list(context)
|
||||
assert len(li_module) == 4
|
||||
sco_edit_module.do_module_delete(
|
||||
context, oid=modt["module_id"]
|
||||
) # on supprime le semestre
|
||||
# sco_formsemestre_edit.formsemestre_delete_moduleimpls(context.Notes, formsemestre_id=sem2["formsemestre_id"], module_ids_to_del=[modt["module_id"]])
|
||||
# deuxieme methode de supression d'un module
|
||||
li_module2 = sco_edit_module.do_module_list(context)
|
||||
|
||||
assert len(li_module2) == 3 # verification de la suppression du module
|
||||
|
||||
lim_sem2 = sco_moduleimpl.do_moduleimpl_list(
|
||||
context, formsemestre_id=sem2["formsemestre_id"]
|
||||
)
|
||||
|
||||
assert len(lim_sem2) == 0 # deuxieme vérification si le module s'est bien sup
|
||||
|
||||
li_mat = sco_edit_matiere.do_matiere_list(context)
|
||||
assert len(li_mat) == 4
|
||||
sco_edit_matiere.do_matiere_delete(
|
||||
context, oid=matt["matiere_id"]
|
||||
) # on supprime la matiere
|
||||
li_mat2 = sco_edit_matiere.do_matiere_list(context)
|
||||
assert len(li_mat2) == 3 # verification de la suppression de la matiere
|
||||
|
||||
li_ue = sco_edit_ue.do_ue_list(context)
|
||||
assert len(li_ue) == 4
|
||||
sco_edit_ue.ue_delete(context, ue_id=uet["ue_id"], dialog_confirmed=True)
|
||||
li_ue2 = sco_edit_ue.do_ue_list(context)
|
||||
assert len(li_ue2) == 3 # verification de la suppression de l'UE
|
||||
|
||||
# --- Suppression d'une formation
|
||||
# Il faut d'abbord supprimer le semestre aussi.
|
||||
sco_formsemestre_edit.do_formsemestre_delete(
|
||||
context, formsemestre_id=semt["formsemestre_id"]
|
||||
)
|
||||
|
||||
sco_edit_formation.do_formation_delete(context, oid=f2["formation_id"])
|
||||
lif3 = notes.formation_list(context, format="json")
|
||||
assert isinstance(lif3, str)
|
||||
load_lif3 = json.loads(lif3)
|
||||
assert len(load_lif3) == 1
|
@ -7,6 +7,9 @@
|
||||
Utiliser comme:
|
||||
pytest tests/unit/test_sco_basic.py
|
||||
|
||||
Au préalable, créer un département de test neuf:
|
||||
flask sco-delete-dept TEST00 && flask sco-create-dept TEST00
|
||||
|
||||
"""
|
||||
import random
|
||||
|
||||
@ -16,14 +19,15 @@ from tests.unit import sco_fake_gen
|
||||
|
||||
from app import decorators
|
||||
from app.scodoc import notesdb as ndb
|
||||
from app.scodoc import sco_utils as scu
|
||||
from app.scodoc import sco_abs
|
||||
from app.scodoc import sco_abs_views
|
||||
from app.scodoc import sco_bulletins
|
||||
from app.scodoc import sco_evaluations
|
||||
from app.scodoc import sco_codes_parcours
|
||||
from app.scodoc import sco_parcours_dut
|
||||
from app.scodoc import sco_evaluations
|
||||
from app.scodoc import sco_formsemestre_validation
|
||||
from app.scodoc import sco_parcours_dut
|
||||
from app.scodoc import sco_saisie_notes
|
||||
from app.scodoc import sco_utils as scu
|
||||
|
||||
context = None # #context
|
||||
|
||||
@ -92,6 +96,8 @@ def test_sco_basic(test_client):
|
||||
# Toute les notes sont saisies, donc eval complète
|
||||
etat = sco_evaluations.do_evaluation_etat(e["evaluation_id"])
|
||||
assert etat["evalcomplete"]
|
||||
assert etat["nb_inscrits"] == len(etuds)
|
||||
assert etat["nb_notes"] == len(etuds)
|
||||
# Un seul module, donc moy gen == note module
|
||||
assert b["ues"][0]["cur_moy_ue_txt"] == b["ues"][0]["modules"][0]["mod_moy_txt"]
|
||||
# Note au module égale à celle de l'éval
|
||||
@ -137,6 +143,18 @@ def test_sco_basic(test_client):
|
||||
assert etat["nb_att"] == 0
|
||||
assert not etat["evalattente"] # toutes les notes sont présentes
|
||||
|
||||
# --- Suppression des notes
|
||||
sco_saisie_notes.evaluation_suppress_alln(e["evaluation_id"], dialog_confirmed=True)
|
||||
etat = sco_evaluations.do_evaluation_etat(e["evaluation_id"])
|
||||
assert etat["nb_notes"] == 0
|
||||
assert not etat["evalcomplete"]
|
||||
# --- Saisie des notes manquantes
|
||||
ans = sco_saisie_notes.do_evaluation_set_missing(
|
||||
e["evaluation_id"], 12.34, dialog_confirmed=True
|
||||
)
|
||||
assert f'{etat["nb_inscrits"]} notes changées' in ans
|
||||
etat = sco_evaluations.do_evaluation_etat(e["evaluation_id"])
|
||||
assert etat["evalcomplete"]
|
||||
# --- Saisie absences
|
||||
etudid = etuds[0]["etudid"]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user