From 7b61b25ff19818e9aec85d8688d12dae1be0cae1 Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
Date: Sat, 12 Jun 2021 22:43:22 +0200
Subject: [PATCH] WIP refactoring: permissions, ...
---
app/decorators.py | 2 +-
app/scodoc/ZEntreprises.py | 30 +++--
app/scodoc/ZScoDoc.py | 11 +-
app/scodoc/ZScoUsers.py | 20 +--
app/scodoc/html_sco_header.py | 4 +-
app/scodoc/html_sidebar.py | 10 +-
app/scodoc/sco_abs_views.py | 10 +-
app/scodoc/sco_archives_etud.py | 2 +-
app/scodoc/sco_bulletins.py | 8 +-
app/scodoc/sco_bulletins_legacy.py | 2 +-
app/scodoc/sco_bulletins_standard.py | 2 +-
app/scodoc/sco_core.py | 7 +
app/scodoc/sco_dept.py | 4 +-
app/scodoc/sco_edit_formation.py | 29 ++++-
app/scodoc/sco_edit_module.py | 4 +-
app/scodoc/sco_edit_ue.py | 8 +-
app/scodoc/sco_find_etud.py | 2 +-
app/scodoc/sco_formations.py | 4 +-
app/scodoc/sco_formsemestre_edit.py | 6 +-
app/scodoc/sco_formsemestre_status.py | 28 ++--
app/scodoc/sco_groups.py | 2 +-
app/scodoc/sco_groups_view.py | 8 +-
app/scodoc/sco_moduleimpl.py | 4 +-
app/scodoc/sco_moduleimpl_inscriptions.py | 5 +-
app/scodoc/sco_moduleimpl_status.py | 2 +-
app/scodoc/sco_page_etud.py | 46 ++++---
app/scodoc/sco_saisie_notes.py | 4 +-
app/scodoc/sco_synchro_etuds.py | 2 +-
app/scodoc/sco_tag_module.py | 2 +-
app/scodoc/sco_ue_external.py | 4 +-
app/views/absences.py | 10 ++
app/views/notes.py | 151 ++++++++++------------
app/views/scolar.py | 93 +++++++------
refactor.py | 79 +++++++++--
34 files changed, 368 insertions(+), 237 deletions(-)
mode change 100644 => 100755 app/scodoc/sco_core.py
diff --git a/app/decorators.py b/app/decorators.py
index b8bc694b7..93feccc71 100644
--- a/app/decorators.py
+++ b/app/decorators.py
@@ -76,7 +76,7 @@ class ZResponse(object):
return flask.redirect(url) # http 302
def setHeader(self, header, value):
- self.headers[header.tolower()] = value
+ self.headers[header.lower()] = value
def permission_required(permission):
diff --git a/app/scodoc/ZEntreprises.py b/app/scodoc/ZEntreprises.py
index dd7f50472..56be1de44 100644
--- a/app/scodoc/ZEntreprises.py
+++ b/app/scodoc/ZEntreprises.py
@@ -111,7 +111,9 @@ class ZEntreprises(
authuser = REQUEST.AUTHENTICATED_USER
try:
dept = getattr(self, deptfoldername)
- if authuser.has_permission(ScoView, dept):
+ if authuser.has_permission(Permission.ScoView, dept):
return REQUEST.RESPONSE.redirect("ScoDoc/%s/Scolarite" % deptfoldername)
except:
log(
diff --git a/app/scodoc/ZScoUsers.py b/app/scodoc/ZScoUsers.py
index ec86bfa17..8429bd662 100644
--- a/app/scodoc/ZScoUsers.py
+++ b/app/scodoc/ZScoUsers.py
@@ -141,7 +141,7 @@ class ZScoUsers(
H = [self.sco_header(REQUEST, page_title="Gestion des utilisateurs")]
H.append("Gestion des utilisateurs
")
- if authuser.has_permission(ScoUsersAdmin, self):
+ if authuser.has_permission(Permission.ScoUsersAdmin, self):
H.append(
'Ajouter un utilisateur'
)
@@ -170,7 +170,7 @@ class ZScoUsers(
with_olds=with_olds,
format=format,
REQUEST=REQUEST,
- with_links=authuser.has_permission(ScoUsersAdmin, self),
+ with_links=authuser.has_permission(Permission.ScoUsersAdmin, self),
)
if format != "html":
return L
@@ -338,7 +338,7 @@ class ZScoUsers(
if str(authuser) == user_name:
return True
# has permission ?
- if not authuser.has_permission(ScoUsersAdmin, self):
+ if not authuser.has_permission(Permission.ScoUsersAdmin, self):
return False
# Ok, now check that authuser can manage users from this departement
# Get user info
@@ -499,11 +499,11 @@ class ZScoUsers(
"
L' utilisateur '%s' n'est pas défini dans ce module.
"
% user_name
)
- if authuser.has_permission(ScoEditAllNotes, self):
+ if authuser.has_permission(Permission.ScoEditAllNotes, self):
H.append("(il peut modifier toutes les notes)
")
- if authuser.has_permission(ScoEditAllEvals, self):
+ if authuser.has_permission(Permission.ScoEditAllEvals, self):
H.append("(il peut modifier toutes les évaluations)
")
- if authuser.has_permission(ScoImplement, self):
+ if authuser.has_permission(Permission.ScoImplement, self):
H.append("(il peut creer des formations)
")
else:
H.append(
@@ -520,7 +520,7 @@ class ZScoUsers(
changer le mot de passe"""
% info[0]
)
- if authuser.has_permission(ScoUsersAdmin, self):
+ if authuser.has_permission(Permission.ScoUsersAdmin, self):
H.append(
"""
modifier/déactiver ce compte
@@ -560,7 +560,7 @@ class ZScoUsers(
b = "non"
H.append("%s : %s" % (permname, b))
H.append("")
- if authuser.has_permission(ScoUsersAdmin, self):
+ if authuser.has_permission(Permission.ScoUsersAdmin, self):
H.append(
'Liste de tous les utilisateurs
'
% self.ScoURL()
@@ -602,13 +602,13 @@ class ZScoUsers(
else:
H.append("Création d'un utilisateur
")
- if authuser.has_permission(ScoSuperAdmin, self):
+ if authuser.has_permission(Permission.ScoSuperAdmin, self):
H.append("""Vous êtes super administrateur !
""")
# Noms de roles pouvant etre attribues aux utilisateurs via ce dialogue
# si pas SuperAdmin, restreint aux rôles EnsX, SecrX, DeptX
#
- if authuser.has_permission(ScoSuperAdmin, self):
+ if authuser.has_permission(Permission.ScoSuperAdmin, self):
log("create_user_form called by %s (super admin)" % (auth_name,))
editable_roles = set(self._all_roles())
else:
diff --git a/app/scodoc/html_sco_header.py b/app/scodoc/html_sco_header.py
index 89003b667..3eb22aab4 100644
--- a/app/scodoc/html_sco_header.py
+++ b/app/scodoc/html_sco_header.py
@@ -28,7 +28,6 @@
import cgi
import sco_utils as scu
-from sco_formsemestre_status import formsemestre_page_title
"""
HTML Header/Footer for ScoDoc pages
@@ -263,3 +262,6 @@ def sco_footer(context, REQUEST=None):
return (
"""""" + scu.CUSTOM_HTML_FOOTER + """