From c8949e870fe823c1b63ba0a399fbc134ec57b652 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 16 Sep 2021 14:58:56 +0200 Subject: [PATCH] code cleaning --- app/scodoc/sco_archives.py | 6 +++--- app/scodoc/sco_archives_etud.py | 8 +++----- app/scodoc/sco_bulletins.py | 5 ++--- app/scodoc/sco_evaluations.py | 4 ++-- app/scodoc/sco_liste_notes.py | 6 +++--- app/scodoc/sco_moduleimpl_status.py | 4 ++-- app/scodoc/sco_placement.py | 7 ++----- app/scodoc/sco_saisie_notes.py | 14 ++++++-------- app/views/absences.py | 15 ++++++--------- sco_version.py | 2 +- 10 files changed, 30 insertions(+), 41 deletions(-) diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index ccdbba67f..9381e498b 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -245,7 +245,7 @@ class BaseArchiver(object): log("reading archive file %s" % fname) return open(fname, "rb").read() - def get_archived_file(self, REQUEST, oid, archive_name, filename): + def get_archived_file(self, oid, archive_name, filename): """Recupere donnees du fichier indiqué et envoie au client""" archive_id = self.get_id_from_name(oid, archive_name) data = self.get(archive_id, filename) @@ -544,11 +544,11 @@ def formsemestre_list_archives(REQUEST, formsemestre_id): return "\n".join(H) + html_sco_header.sco_footer() -def formsemestre_get_archived_file(REQUEST, formsemestre_id, archive_name, filename): +def formsemestre_get_archived_file(formsemestre_id, archive_name, filename): """Send file to client.""" sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem_archive_id = sem["scodoc7_id"] or formsemestre_id - return PVArchive.get_archived_file(REQUEST, sem_archive_id, archive_name, filename) + return PVArchive.get_archived_file(sem_archive_id, archive_name, filename) def formsemestre_delete_archive( diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py index 7b21da22a..0f199f97a 100644 --- a/app/scodoc/sco_archives_etud.py +++ b/app/scodoc/sco_archives_etud.py @@ -242,16 +242,14 @@ def etud_delete_archive(REQUEST, etudid, archive_name, dialog_confirmed=False): ) -def etud_get_archived_file(REQUEST, etudid, archive_name, filename): +def etud_get_archived_file(etudid, archive_name, filename): """Send file to client.""" - etuds = sco_etud.get_etud_info(filled=True) + etuds = sco_etud.get_etud_info(etudid=etudid, filled=True) if not etuds: raise ScoValueError("étudiant inexistant") etud = etuds[0] etud_archive_id = etud["scodoc7_id"] or etud["etudid"] - return EtudsArchive.get_archived_file( - REQUEST, etud_archive_id, archive_name, filename - ) + return EtudsArchive.get_archived_file(etud_archive_id, archive_name, filename) # --- Upload d'un ensemble de fichiers (pour un groupe d'étudiants) diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 54e1d6752..215985b9e 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -35,9 +35,8 @@ from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email.header import Header - from reportlab.lib.colors import Color -import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error +import urllib from flask import g from flask import url_for @@ -1064,7 +1063,7 @@ def _formsemestre_bulletinetud_header_html( # Menu endpoint = "notes.formsemestre_bulletinetud" url = REQUEST.URL0 - qurl = six.moves.urllib.parse.quote_plus(url + "?" + REQUEST.QUERY_STRING) + qurl = urllib.parse.quote_plus(url + "?" + REQUEST.QUERY_STRING) menuBul = [ { diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index 257d1c654..2397886d0 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -31,7 +31,7 @@ import datetime import operator import pprint import time -import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error +import urllib import flask from flask import url_for @@ -1089,7 +1089,7 @@ def evaluation_describe(evaluation_id="", edit_in_place=True): % ( scu.ScoURL(), group_id, - six.moves.urllib.parse.quote(E["jour"], safe=""), + urllib.parse.quote(E["jour"], safe=""), ) ) H.append( diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index bb822aa93..9932b9c82 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -27,8 +27,8 @@ """Liste des notes d'une évaluation """ -import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error from operator import itemgetter +import urllib import flask from flask import url_for, g @@ -817,8 +817,8 @@ def evaluation_check_absences_html( 'signaler cette absence' % ( etud["etudid"], - six.moves.urllib.parse.quote(E["jour"]), - six.moves.urllib.parse.quote(E["jour"]), + urllib.parse.quote(E["jour"]), + urllib.parse.quote(E["jour"]), demijournee, E["moduleimpl_id"], ) diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index 94b10ad24..320cf5548 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -28,7 +28,7 @@ """Tableau de bord module """ import time -import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error +import urllib from flask import g, url_for from flask_login import current_user @@ -137,7 +137,7 @@ def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0, REQUEST=None): "title": "Absences ce jour", "endpoint": "absences.EtatAbsencesDate", "args": { - "date": six.moves.urllib.parse.quote(E["jour"], safe=""), + "date": urllib.parse.quote(E["jour"], safe=""), "group_ids": group_id, }, "enabled": E["jour"], diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index d4a68e81c..096b99f29 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -30,9 +30,9 @@ Contribution M. Salomon, UFC / IUT DE BELFORT-MONTBÉLIARD, 2016 """ -import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error import random import time +import urllib import flask @@ -208,10 +208,7 @@ def do_placement_selectetuds(REQUEST): columns = tf[2]["columns"] numbering = tf[2]["numbering"] if columns in ("3", "4", "5", "6", "7", "8"): - gs = [ - ("group_ids%3Alist=" + six.moves.urllib.parse.quote_plus(x)) - for x in group_ids - ] + gs = [("group_ids%3Alist=" + urllib.parse.quote_plus(x)) for x in group_ids] query = ( "evaluation_id=%s&placement_method=%s&teachers=%s&building=%s&room=%s&columns=%s&numbering=%s&" % ( diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index aaf0d19d7..3cd47d541 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -590,18 +590,17 @@ def _notes_add(user, evaluation_id: int, notes: list, comment=None, do_it=True): def saisie_notes_tableur(evaluation_id, group_ids=[], REQUEST=None): """Saisie des notes via un fichier Excel""" - authuser = REQUEST.AUTHENTICATED_USER - authusername = str(authuser) evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) if not evals: raise ScoValueError("invalid evaluation_id") E = evals[0] M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0] formsemestre_id = M["formsemestre_id"] - if not sco_permissions_check.can_edit_notes(authuser, E["moduleimpl_id"]): + if not sco_permissions_check.can_edit_notes(current_user, E["moduleimpl_id"]): return ( html_sco_header.sco_header() - + "

Modification des notes impossible pour %s

" % authusername + + "

Modification des notes impossible pour %s

" + % current_user.user_name + """

(vérifiez que le semestre n'est pas verrouillé et que vous avez l'autorisation d'effectuer cette opération)

Continuer

@@ -859,8 +858,6 @@ def has_existing_decision(M, E, etudid): def saisie_notes(evaluation_id, group_ids=[], REQUEST=None): """Formulaire saisie notes d'une évaluation pour un groupe""" - authuser = REQUEST.AUTHENTICATED_USER - authusername = str(authuser) group_ids = [int(group_id) for group_id in group_ids] evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) if not evals: @@ -872,10 +869,11 @@ def saisie_notes(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(authuser, E["moduleimpl_id"]): + if not sco_permissions_check.can_edit_notes(current_user, E["moduleimpl_id"]): return ( html_sco_header.sco_header() - + "

Modification des notes impossible pour %s

" % authusername + + "

Modification des notes impossible pour %s

" + % current_user.user_name + """

(vérifiez que le semestre n'est pas verrouillé et que vous avez l'autorisation d'effectuer cette opération)

Continuer

diff --git a/app/views/absences.py b/app/views/absences.py index a035a6c8b..b6c463607 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -47,20 +47,17 @@ L'API de plus bas niveau est en gros: """ import calendar -import cgi import datetime import dateutil import dateutil.parser import re -import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error -import string import time +import urllib from xml.etree import ElementTree import flask from flask import g from flask import url_for -from flask import current_app from app.decorators import ( scodoc, @@ -307,14 +304,14 @@ def doSignaleAbsenceGrSemestre( @permission_required(Permission.ScoAbsChange) @scodoc7func def SignaleAbsenceGrHebdo( - datelundi, group_ids=[], destination="", moduleimpl_id=None, REQUEST=None + datelundi, group_ids=[], destination="", moduleimpl_id=None, formsemestre_id=None ): "Saisie hebdomadaire des absences" if not moduleimpl_id: moduleimpl_id = None groups_infos = sco_groups_view.DisplayedGroupsInfos( - group_ids, moduleimpl_id=moduleimpl_id + group_ids, moduleimpl_id=moduleimpl_id, formsemestre_id=formsemestre_id ) if not groups_infos.members: return ( @@ -326,7 +323,7 @@ def SignaleAbsenceGrHebdo( base_url = "SignaleAbsenceGrHebdo?datelundi=%s&%s&destination=%s" % ( datelundi, groups_infos.groups_query_args, - six.moves.urllib.parse.quote(destination), + urllib.parse.quote(destination), ) formsemestre_id = groups_infos.formsemestre_id @@ -510,7 +507,7 @@ def SignaleAbsenceGrSemestre( datedebut, datefin, groups_infos.groups_query_args, - six.moves.urllib.parse.quote(destination), + urllib.parse.quote(destination), ) ) base_url = base_url_noweeks + "&nbweeks=%s" % nbweeks # sans le moduleimpl_id @@ -810,7 +807,7 @@ def _gen_form_saisie_groupe( H.append('' % ",".join(dates)) H.append( '' - % six.moves.urllib.parse.quote(destination) + % urllib.parse.quote(destination) ) # # version pour formulaire avec AJAX (Yann LB) diff --git a/sco_version.py b/sco_version.py index be14469e2..2d3c878b1 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.0.26" +SCOVERSION = "9.0.27" SCONAME = "ScoDoc"