code cleaning

This commit is contained in:
Emmanuel Viennet 2021-09-16 14:58:56 +02:00
parent 30481e4729
commit c8949e870f
10 changed files with 30 additions and 41 deletions

View File

@ -245,7 +245,7 @@ class BaseArchiver(object):
log("reading archive file %s" % fname) log("reading archive file %s" % fname)
return open(fname, "rb").read() 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""" """Recupere donnees du fichier indiqué et envoie au client"""
archive_id = self.get_id_from_name(oid, archive_name) archive_id = self.get_id_from_name(oid, archive_name)
data = self.get(archive_id, filename) 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() 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.""" """Send file to client."""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
sem_archive_id = sem["scodoc7_id"] or 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( def formsemestre_delete_archive(

View File

@ -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.""" """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: if not etuds:
raise ScoValueError("étudiant inexistant") raise ScoValueError("étudiant inexistant")
etud = etuds[0] etud = etuds[0]
etud_archive_id = etud["scodoc7_id"] or etud["etudid"] etud_archive_id = etud["scodoc7_id"] or etud["etudid"]
return EtudsArchive.get_archived_file( return EtudsArchive.get_archived_file(etud_archive_id, archive_name, filename)
REQUEST, etud_archive_id, archive_name, filename
)
# --- Upload d'un ensemble de fichiers (pour un groupe d'étudiants) # --- Upload d'un ensemble de fichiers (pour un groupe d'étudiants)

View File

@ -35,9 +35,8 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText from email.mime.text import MIMEText
from email.mime.base import MIMEBase from email.mime.base import MIMEBase
from email.header import Header from email.header import Header
from reportlab.lib.colors import Color 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 g
from flask import url_for from flask import url_for
@ -1064,7 +1063,7 @@ def _formsemestre_bulletinetud_header_html(
# Menu # Menu
endpoint = "notes.formsemestre_bulletinetud" endpoint = "notes.formsemestre_bulletinetud"
url = REQUEST.URL0 url = REQUEST.URL0
qurl = six.moves.urllib.parse.quote_plus(url + "?" + REQUEST.QUERY_STRING) qurl = urllib.parse.quote_plus(url + "?" + REQUEST.QUERY_STRING)
menuBul = [ menuBul = [
{ {

View File

@ -31,7 +31,7 @@ import datetime
import operator import operator
import pprint import pprint
import time import time
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error import urllib
import flask import flask
from flask import url_for from flask import url_for
@ -1089,7 +1089,7 @@ def evaluation_describe(evaluation_id="", edit_in_place=True):
% ( % (
scu.ScoURL(), scu.ScoURL(),
group_id, group_id,
six.moves.urllib.parse.quote(E["jour"], safe=""), urllib.parse.quote(E["jour"], safe=""),
) )
) )
H.append( H.append(

View File

@ -27,8 +27,8 @@
"""Liste des notes d'une évaluation """Liste des notes d'une évaluation
""" """
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
from operator import itemgetter from operator import itemgetter
import urllib
import flask import flask
from flask import url_for, g from flask import url_for, g
@ -817,8 +817,8 @@ def evaluation_check_absences_html(
'<a class="stdlink" href="Absences/doSignaleAbsence?etudid=%s&datedebut=%s&datefin=%s&demijournee=%s&moduleimpl_id=%s">signaler cette absence</a>' '<a class="stdlink" href="Absences/doSignaleAbsence?etudid=%s&datedebut=%s&datefin=%s&demijournee=%s&moduleimpl_id=%s">signaler cette absence</a>'
% ( % (
etud["etudid"], etud["etudid"],
six.moves.urllib.parse.quote(E["jour"]), urllib.parse.quote(E["jour"]),
six.moves.urllib.parse.quote(E["jour"]), urllib.parse.quote(E["jour"]),
demijournee, demijournee,
E["moduleimpl_id"], E["moduleimpl_id"],
) )

View File

@ -28,7 +28,7 @@
"""Tableau de bord module """Tableau de bord module
""" """
import time 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 import g, url_for
from flask_login import current_user from flask_login import current_user
@ -137,7 +137,7 @@ def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0, REQUEST=None):
"title": "Absences ce jour", "title": "Absences ce jour",
"endpoint": "absences.EtatAbsencesDate", "endpoint": "absences.EtatAbsencesDate",
"args": { "args": {
"date": six.moves.urllib.parse.quote(E["jour"], safe=""), "date": urllib.parse.quote(E["jour"], safe=""),
"group_ids": group_id, "group_ids": group_id,
}, },
"enabled": E["jour"], "enabled": E["jour"],

View File

@ -30,9 +30,9 @@
Contribution M. Salomon, UFC / IUT DE BELFORT-MONTBÉLIARD, 2016 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 random
import time import time
import urllib
import flask import flask
@ -208,10 +208,7 @@ def do_placement_selectetuds(REQUEST):
columns = tf[2]["columns"] columns = tf[2]["columns"]
numbering = tf[2]["numbering"] numbering = tf[2]["numbering"]
if columns in ("3", "4", "5", "6", "7", "8"): if columns in ("3", "4", "5", "6", "7", "8"):
gs = [ gs = [("group_ids%3Alist=" + urllib.parse.quote_plus(x)) for x in group_ids]
("group_ids%3Alist=" + six.moves.urllib.parse.quote_plus(x))
for x in group_ids
]
query = ( query = (
"evaluation_id=%s&placement_method=%s&teachers=%s&building=%s&room=%s&columns=%s&numbering=%s&" "evaluation_id=%s&placement_method=%s&teachers=%s&building=%s&room=%s&columns=%s&numbering=%s&"
% ( % (

View File

@ -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): def saisie_notes_tableur(evaluation_id, group_ids=[], REQUEST=None):
"""Saisie des notes via un fichier Excel""" """Saisie des notes via un fichier Excel"""
authuser = REQUEST.AUTHENTICATED_USER
authusername = str(authuser)
evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
if not evals: if not evals:
raise ScoValueError("invalid evaluation_id") raise ScoValueError("invalid evaluation_id")
E = evals[0] E = evals[0]
M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0] M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
formsemestre_id = M["formsemestre_id"] 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 ( return (
html_sco_header.sco_header() html_sco_header.sco_header()
+ "<h2>Modification des notes impossible pour %s</h2>" % authusername + "<h2>Modification des notes impossible pour %s</h2>"
% current_user.user_name
+ """<p>(vérifiez que le semestre n'est pas verrouillé et que vous + """<p>(vérifiez que le semestre n'est pas verrouillé et que vous
avez l'autorisation d'effectuer cette opération)</p> avez l'autorisation d'effectuer cette opération)</p>
<p><a href="moduleimpl_status?moduleimpl_id=%s">Continuer</a></p> <p><a href="moduleimpl_status?moduleimpl_id=%s">Continuer</a></p>
@ -859,8 +858,6 @@ def has_existing_decision(M, E, etudid):
def saisie_notes(evaluation_id, group_ids=[], REQUEST=None): def saisie_notes(evaluation_id, group_ids=[], REQUEST=None):
"""Formulaire saisie notes d'une évaluation pour un groupe""" """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] group_ids = [int(group_id) for group_id in group_ids]
evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
if not evals: if not evals:
@ -872,10 +869,11 @@ def saisie_notes(evaluation_id, group_ids=[], REQUEST=None):
formsemestre_id = M["formsemestre_id"] formsemestre_id = M["formsemestre_id"]
# Check access # Check access
# (admin, respformation, and responsable_id) # (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 ( return (
html_sco_header.sco_header() html_sco_header.sco_header()
+ "<h2>Modification des notes impossible pour %s</h2>" % authusername + "<h2>Modification des notes impossible pour %s</h2>"
% current_user.user_name
+ """<p>(vérifiez que le semestre n'est pas verrouillé et que vous + """<p>(vérifiez que le semestre n'est pas verrouillé et que vous
avez l'autorisation d'effectuer cette opération)</p> avez l'autorisation d'effectuer cette opération)</p>
<p><a href="moduleimpl_status?moduleimpl_id=%s">Continuer</a></p> <p><a href="moduleimpl_status?moduleimpl_id=%s">Continuer</a></p>

View File

@ -47,20 +47,17 @@ L'API de plus bas niveau est en gros:
""" """
import calendar import calendar
import cgi
import datetime import datetime
import dateutil import dateutil
import dateutil.parser import dateutil.parser
import re import re
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import string
import time import time
import urllib
from xml.etree import ElementTree from xml.etree import ElementTree
import flask import flask
from flask import g from flask import g
from flask import url_for from flask import url_for
from flask import current_app
from app.decorators import ( from app.decorators import (
scodoc, scodoc,
@ -307,14 +304,14 @@ def doSignaleAbsenceGrSemestre(
@permission_required(Permission.ScoAbsChange) @permission_required(Permission.ScoAbsChange)
@scodoc7func @scodoc7func
def SignaleAbsenceGrHebdo( 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" "Saisie hebdomadaire des absences"
if not moduleimpl_id: if not moduleimpl_id:
moduleimpl_id = None moduleimpl_id = None
groups_infos = sco_groups_view.DisplayedGroupsInfos( 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: if not groups_infos.members:
return ( return (
@ -326,7 +323,7 @@ def SignaleAbsenceGrHebdo(
base_url = "SignaleAbsenceGrHebdo?datelundi=%s&%s&destination=%s" % ( base_url = "SignaleAbsenceGrHebdo?datelundi=%s&%s&destination=%s" % (
datelundi, datelundi,
groups_infos.groups_query_args, groups_infos.groups_query_args,
six.moves.urllib.parse.quote(destination), urllib.parse.quote(destination),
) )
formsemestre_id = groups_infos.formsemestre_id formsemestre_id = groups_infos.formsemestre_id
@ -510,7 +507,7 @@ def SignaleAbsenceGrSemestre(
datedebut, datedebut,
datefin, datefin,
groups_infos.groups_query_args, 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 base_url = base_url_noweeks + "&nbweeks=%s" % nbweeks # sans le moduleimpl_id
@ -810,7 +807,7 @@ def _gen_form_saisie_groupe(
H.append('<input type="hidden" name="dates" value="%s"/>' % ",".join(dates)) H.append('<input type="hidden" name="dates" value="%s"/>' % ",".join(dates))
H.append( H.append(
'<input type="hidden" name="destination" value="%s"/>' '<input type="hidden" name="destination" value="%s"/>'
% six.moves.urllib.parse.quote(destination) % urllib.parse.quote(destination)
) )
# #
# version pour formulaire avec AJAX (Yann LB) # version pour formulaire avec AJAX (Yann LB)

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.0.26" SCOVERSION = "9.0.27"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"