petits bugs variés

This commit is contained in:
Emmanuel Viennet 2021-08-15 21:33:47 +02:00
parent 1b2813d7d2
commit 1d1513f782
8 changed files with 59 additions and 43 deletions

View File

@ -129,12 +129,6 @@ def permission_required(permission):
@wraps(f)
def decorated_function(*args, **kwargs):
# current_app.logger.info("PERMISSION; kwargs=%s" % str(kwargs))
if "scodoc_dept" in kwargs:
g.scodoc_dept = kwargs["scodoc_dept"]
del kwargs["scodoc_dept"]
# current_app.logger.info(
# "permission_required: %s in %s" % (permission, g.scodoc_dept)
# )
scodoc_dept = getattr(g, "scodoc_dept", None)
if not current_user.has_permission(permission, scodoc_dept):
abort(403)
@ -153,7 +147,6 @@ def admin_required(f):
def scodoc7func(context):
"""Décorateur pour intégrer les fonctions Zope 2 de ScoDoc 7.
Si on a un kwarg `scodoc_dept`(venant de la route), le stocke dans `g.scodoc_dept`.
Ajoute l'argument REQUEST s'il est dans la signature de la fonction.
Les paramètres de la query string deviennent des (keywords) paramètres de la fonction.
"""

View File

@ -161,10 +161,11 @@ def formsemestre_bulletinetud_dict(
if I["etud"]["inscription_formsemestre_id"]:
I[
"descr_situation_html"
] = """<a href="formsemestre_status?formsemestre_id=%s">%s</a>""" % (
I["etud"]["inscription_formsemestre_id"],
I["descr_situation"],
)
] = f"""<a href="{url_for(
"notes.formsemestre_status",
scodoc_dept=g.scodoc_dept,
formsemestre_id=I["etud"]["inscription_formsemestre_id"],
)}">{I["descr_situation"]}</a>"""
else:
I["descr_situation_html"] = I["descr_situation"]
# Groupes:
@ -811,8 +812,11 @@ def formsemestre_bulletinetud(
H.append("""<p>Situation actuelle: """)
if etud["inscription_formsemestre_id"]:
H.append(
"""<a class="stdlink" href="formsemestre_status?formsemestre_id=%s">"""
% etud["inscription_formsemestre_id"]
f"""<a class="stdlink" href="{url_for(
"notes.formsemestre_status",
scodoc_dept=g.scodoc_dept,
formsemestre_id=etud["inscription_formsemestre_id"])
}">"""
)
H.append(etud["inscriptionstr"])
if etud["inscription_formsemestre_id"]:
@ -1054,8 +1058,11 @@ def _formsemestre_bulletinetud_header_html(
"""
<form name="f" method="GET" action="%s">"""
% REQUEST.URL0,
"""Bulletin <span class="bull_liensemestre"><a href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">
%(titremois)s</a></span>
f"""Bulletin <span class="bull_liensemestre"><a href="{
url_for("notes.formsemestre_status",
scodoc_dept=g.scodoc_dept,
formsemestre_id=sem["formsemestre_id"])}
">{sem["titremois"]}</a></span>
<br/>"""
% sem,
"""<table><tr>""",

View File

@ -573,7 +573,7 @@ def _excel_to_list(filelike): # we may need 'encoding' argument ?
wb = load_workbook(filename=filelike, read_only=True, data_only=True)
except:
log("Excel_to_list: failure to import document")
open("/tmp/last_scodoc_import_failure" + scu.XLSX_SUFFIX, "w").write(filelike)
open("/tmp/last_scodoc_import_failure" + scu.XLSX_SUFFIX, "wb").write(filelike)
raise ScoValueError(
"Fichier illisible: assurez-vous qu'il s'agit bien d'un document Excel !"
)

View File

@ -106,7 +106,7 @@ def search_etud_in_dept(context, expnom="", REQUEST=None):
Args:
expnom: string, regexp sur le nom ou un code_nip ou un etudid
"""
if len(expnom) > 1:
if isinstance(expnom, int) or len(expnom) > 1:
try:
etudid = int(expnom)
except ValueError:

View File

@ -221,7 +221,9 @@ def get_default_group(formsemestre_id, fix_if_missing=False):
]
except ScoException:
log("creating default partition for %s" % formsemestre_id)
partition_id = partition_create(context, formsemestre_id, default=True)
partition_id = partition_create(
context, formsemestre_id, default=True, redirect=False
)
group_id = createGroup(context, partition_id, default=True)
return group_id
# debug check
@ -623,17 +625,15 @@ def change_etud_group_in_partition(
partition = get_partition(context, group["partition_id"])
# 1- Supprime membership dans cette partition
ndb.SimpleQuery(
"""DELETE FROM group_membership
WHERE id IN
(SELECT gm.id
FROM group_membership gm, group_descr gd
"""DELETE FROM group_membership gm
WHERE EXISTS
(SELECT 1 FROM group_descr gd
WHERE gm.etudid = %(etudid)s
AND gm.group_id = gd.id
AND gd.partition_id = %(partition_id)s)
""",
{"etudid": etudid, "partition_id": partition["partition_id"]},
)
# 2- associe au nouveau groupe
set_group(context, etudid, group_id)
@ -810,7 +810,7 @@ def partition_create(
partition_name="",
default=False,
numero=None,
redirect=1,
redirect=True,
):
"""Create a new partition"""
if not sco_permissions_check.can_change_groups(formsemestre_id):

View File

@ -35,6 +35,7 @@ import time
from datetime import date
import flask
from flask import g, url_for
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
@ -101,8 +102,6 @@ ADMISSION_MODIFIABLE_FIELDS = (
"paysdomicile",
"telephone",
"telephonemobile",
# Debouche
"debouche",
# Groupes
"groupes",
)
@ -242,9 +241,13 @@ def students_import_excel(
)
if REQUEST:
if formsemestre_id:
dest = "Notes/formsemestre_status?formsemestre_id=%s" % formsemestre_id
dest = url_for(
"notes.formsemestre_status",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
)
else:
dest = scu.NotesURL()
dest = url_for("notes.index_html", scodoc_dept=g.scodoc_dept)
H = [html_sco_header.sco_header(page_title="Import etudiants")]
H.append("<ul>")
for d in diag:
@ -467,7 +470,7 @@ def scolars_import_excel_file(
{"etudid": etudid},
)
cursor.execute(
"delete from identite where etudid=%(etudid)s", {"etudid": etudid}
"delete from identite where id=%(etudid)s", {"etudid": etudid}
)
cnx.commit()
log("scolars_import_excel_file: re-raising exception")
@ -508,8 +511,11 @@ def students_import_admission(
H.append("<p>Import terminé !</p>")
H.append(
'<p><a class="stdlink" href="%s">Continuer</a></p>'
% "formsemestre_status?formsemestre_id=%s"
% formsemestre_id
% url_for(
"notes.formsemestre_status",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
)
)
if diag:
H.append("<p>Diagnostic: <ul><li>%s</li></ul></p>" % "</li><li>".join(diag))
@ -649,8 +655,11 @@ def scolars_import_admission(
log("fields titles =" + ", ".join([fields[x][0] for x in fields]))
raise FormatError(
"scolars_import_admission: colonnes nom et prenom requises",
dest_url="form_students_import_infos_admissions?formsemestre_id=%s"
% formsemestre_id,
dest_url=url_for(
"notes.form_students_import_infos_admissions",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
),
)
modifiable_fields = set(ADMISSION_MODIFIABLE_FIELDS)
@ -679,8 +688,11 @@ def scolars_import_admission(
raise FormatError(
'scolars_import_admission: valeur invalide, ligne %d colonne %s: "%s"'
% (nline, field_name, line[idx]),
dest_url="form_students_import_infos_admissions?formsemestre_id=%s"
% formsemestre_id,
dest_url=url_for(
"notes.form_students_import_infos_admissions",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
),
)
if val is not None: # note: ne peut jamais supprimer une valeur
args[field_name] = val
@ -762,8 +774,11 @@ def adm_get_fields(titles, formsemestre_id):
raise FormatError(
'scolars_import_admission: titre "%s" en double (ligne 1)'
% (title),
dest_url="form_students_import_infos_admissions_apb?formsemestre_id=%s"
% formsemestre_id,
dest_url=url_for(
"notes.form_students_import_infos_admissions_apb",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
),
)
fields[idx] = (k, convertor)
idx += 1

View File

@ -354,7 +354,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
)
# Devenir de l'étudiant:
has_debouche = True # info['debouche']
has_debouche = True
if sco_permissions_check.can_edit_suivi():
suivi_readonly = "0"
link_add_suivi = """<li class="adddebouche">

View File

@ -1594,11 +1594,11 @@ def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):
"adresse",
"absences",
"billet_absence",
"identite",
]
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for table in tables:
cursor.execute("delete from %s where etudid=%%(etudid)s" % table, etud)
cursor.execute("delete from identite where id=%(etudid)s", etud)
cnx.commit()
# Inval semestres où il était inscrit:
to_inval = [s["formsemestre_id"] for s in etud["sems"]]
@ -1760,6 +1760,7 @@ def check_group_apogee(
@bp.route("/form_students_import_excel", methods=["GET", "POST"])
@scodoc
@permission_required(Permission.ScoEtudInscrit)
@scodoc7func(context)
def form_students_import_excel(context, REQUEST, formsemestre_id=None):