From c3e3f453707b4d5d5d67ff3f038db95a98bc7f1e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 26 Jul 2021 17:52:38 +0300 Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20code=20formsemestre=5Fstatu?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_formsemestre_status.py | 117 ++++++++++++++------------ app/views/notes.py | 1 + app/views/scolar.py | 2 +- 3 files changed, 65 insertions(+), 55 deletions(-) diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 651bfe9dc..84c24b8e0 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -28,9 +28,6 @@ """Tableau de bord semestre """ -import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error -import cgi - from flask import current_app from flask import g from flask import url_for @@ -773,21 +770,13 @@ def formsemestre_description( def _make_listes_sem(context, sem, REQUEST=None, with_absences=True): context = context authuser = REQUEST.AUTHENTICATED_USER - r = scu.ScoURL() # root url # construit l'URL "destination" # (a laquelle on revient apres saisie absences) - query_args = cgi.parse_qs(REQUEST.QUERY_STRING) # XXX TODO a revoir #py3 - # soit via flask soit via https://docs.python.org/3/library/urllib.parse.html#module-urllib.parse - if "head_message" in query_args: - del query_args["head_message"] - destination = "%s?%s" % ( - REQUEST.URL, - six.moves.urllib.parse.urlencode(query_args, True), + destination = url_for( + "notes.formsemestre_status", + scodoc_dept=g.scodoc_dept, + formsemestre_id=sem["formsemestre_id"], ) - destination = destination.replace( - "%", "%%" - ) # car ici utilisee dans un format string ! - # H = [] # pas de menu absences si pas autorise: @@ -806,39 +795,29 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True): try: if with_absences: first_monday = sco_abs.ddmmyyyy(sem["date_debut"]).prev_monday() - FA = [] # formulaire avec menu saisi absences - FA.append( - '
'.format( - url_for( + form_abs_tmpl = f""" + ' % sem - ) - FA.append('') - - FA.append( - '' % destination - ) - FA.append('') - FA.append(' + + + + ") - FA.append( - 'état' - % sem - ) - FA.append("
") - FormAbs = "\n".join(FA) + form_abs_tmpl += """ + + état + + """ else: - FormAbs = "" + form_abs_tmpl = "" except ScoInvalidDateError: # dates incorrectes dans semestres ? - FormAbs = "" + form_abs_tmpl = "" # H.append('
') # Genere liste pour chaque partition (categorie de groupes) @@ -854,25 +833,50 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True): n_members = len( sco_groups.get_group_members(context, group["group_id"]) ) - group["url"] = r + group["url_etat"] = url_for( + "absences.EtatAbsencesGr", + group_ids=group["group_id"], + debut=sem["date_debut"], + fin=sem["date_fin"], + scodoc_dept=g.scodoc_dept, + ) if group["group_name"]: group["label"] = "groupe %(group_name)s" % group else: group["label"] = "liste" - H.append('') H.append( - """ - %(label)s + f""" + + + {group["label"]} - (format tableur) - Photos - """ - % group + (tableur) + Photos + + ({n_members} étudiants) + """ ) - H.append("(%d étudiants)" % n_members) if with_absences: - H.append(FormAbs % group) + H.append(form_abs_tmpl % group) H.append("") H.append("") @@ -890,8 +894,13 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True): context, REQUEST, formsemestre_id ): H.append( - '

Ajouter une partition

' - % formsemestre_id + f"""

Ajouter une partition

""" ) H.append("
") diff --git a/app/views/notes.py b/app/views/notes.py index 5e5d8ba54..1036c7bc1 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -184,6 +184,7 @@ sco_publish( "/formsemestre_createwithmodules", sco_formsemestre_edit.formsemestre_createwithmodules, Permission.ScoImplement, + methods=["GET", "POST"], ) # controle d'acces specifique pour dir. etud: diff --git a/app/views/scolar.py b/app/views/scolar.py index d5bf596a5..2ceed0ebb 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -1505,7 +1505,7 @@ def _etudident_create_or_edit_form(context, REQUEST, edit): return REQUEST.RESPONSE.redirect("ficheEtud?etudid=" + etudid) -@bp.route("/etudident_delete") +@bp.route("/etudident_delete", methods=["GET", "POST"]) @permission_required(Permission.ScoEtudInscrit) @scodoc7func(context) def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):