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( ") - 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 + """""" ) + + +from sco_formsemestre_status import formsemestre_page_title diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py index 5fc75035d..76b8253ba 100644 --- a/app/scodoc/html_sidebar.py +++ b/app/scodoc/html_sidebar.py @@ -62,14 +62,14 @@ def sidebar_common(context, REQUEST=None): % params, ] - if authuser.has_permission(ScoUsersAdmin, context) or authuser.has_permission( - ScoUsersView, context - ): + if authuser.has_permission( + Permission.ScoUsersAdmin, context + ) or authuser.has_permission(ScoUsersView, context): H.append( """Utilisateurs
""" % params ) - if authuser.has_permission(ScoChangePreferences, context): + if authuser.has_permission(Permission.ScoChangePreferences, context): H.append( """Paramétrage
""" % params @@ -120,7 +120,7 @@ def sidebar(context, REQUEST=None): ) H.append("