forked from ScoDoc/ScoDoc
Script migration: traite départements nommés en minuscules
This commit is contained in:
parent
1c7bbc639a
commit
f4335624fc
@ -51,18 +51,17 @@ def import_scodoc7_user_db(scodoc7_db="dbname=SCOUSERS"):
|
|||||||
)
|
)
|
||||||
# Set roles:
|
# Set roles:
|
||||||
# ScoDoc7 roles are stored as 'AdminRT,EnsRT'
|
# ScoDoc7 roles are stored as 'AdminRT,EnsRT'
|
||||||
|
# ou, dans les rares cas où le dept est en minuscules
|
||||||
|
# "Ensgeii,Admingeii"
|
||||||
if u7["roles"]:
|
if u7["roles"]:
|
||||||
roles7 = u7["roles"].split(",")
|
roles7 = u7["roles"].split(",")
|
||||||
else:
|
else:
|
||||||
roles7 = []
|
roles7 = []
|
||||||
for role_dept in roles7:
|
for role_dept in roles7:
|
||||||
# Cas particulier RespPeRT
|
# Migre les rôles RespPeX, EnsX, AdminX, SecrX et ignore les autres
|
||||||
m = re.match(r"^(-?RespPe)([A-Z][A-Za-z0-9]*?)$", role_dept)
|
m = re.match(r"^(-?Ens|-?Secr|-?ResPe|-?Admin)(.*)$", role_dept)
|
||||||
if not m:
|
if not m:
|
||||||
# Cas général: eg EnsRT
|
msg = f"User {user_name}: role inconnu '{role_dept}' (ignoré)"
|
||||||
m = re.match(r"^(-?[A-Za-z0-9]+?)([A-Z][A-Za-z0-9]*?)$", role_dept)
|
|
||||||
if not m:
|
|
||||||
msg = f"User {user_name}: invalid role '{role_dept}' (ignoring)"
|
|
||||||
current_app.logger.warning(msg)
|
current_app.logger.warning(msg)
|
||||||
messages.append(msg)
|
messages.append(msg)
|
||||||
else:
|
else:
|
||||||
|
@ -193,8 +193,8 @@ su -c "(cd $SCODOC_DIR && source venv/bin/activate && flask import-scodoc7-users
|
|||||||
# (ils ne sont d'ailleurs plus utilisés par ScoDoc 9)
|
# (ils ne sont d'ailleurs plus utilisés par ScoDoc 9)
|
||||||
for f in "$SCODOC_VAR_DIR"/config/depts/*.cfg
|
for f in "$SCODOC_VAR_DIR"/config/depts/*.cfg
|
||||||
do
|
do
|
||||||
dept=$(basename "${f%.*}")
|
dept=$(basename "${f%.*}") # le nom du dept peut-être en minuscules et/ou majuscules (geii, GEII...)
|
||||||
db_name=$(echo "SCO$dept" | tr "[:lower:]" "[:upper:]")
|
db_name=$(echo "SCO$dept" | tr "[:lower:]" "[:upper:]") # nom de BD toujours en majuscule
|
||||||
echo
|
echo
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo "| MIGRATION DU DEPARTEMENT $dept"
|
echo "| MIGRATION DU DEPARTEMENT $dept"
|
||||||
|
Loading…
Reference in New Issue
Block a user