From bfad156ac2a6714ab244f1fad4d7480fb33533d6 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 20 Aug 2021 09:57:38 +0200 Subject: [PATCH] Fix import dept (si minuscules dans le nom). --- scodoc.py | 8 +++++--- tools/import_scodoc7_dept.py | 4 ++-- tools/migrate_from_scodoc7.sh | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scodoc.py b/scodoc.py index 2ea8105b4..e88bf6399 100755 --- a/scodoc.py +++ b/scodoc.py @@ -222,10 +222,12 @@ def import_scodoc7_users(): # import-scodoc7-users @app.cli.command() @click.argument("dept") +@click.argument("dept_db_name") @with_appcontext -def import_scodoc7_dept(dept): # import-scodoc7-dept - """Import département ScoDoc7""" - tools.import_scodoc7_dept(dept) +def import_scodoc7_dept(dept: str, dept_db_name: str): # import-scodoc7-dept + """Import département ScoDoc 7: dept: InfoComm, dept_db_name: SCOINFOCOMM""" + dept_db_uri = f"postgresql:///{dept_db_name}" + tools.import_scodoc7_dept(dept, dept_db_uri) @app.cli.command() diff --git a/tools/import_scodoc7_dept.py b/tools/import_scodoc7_dept.py index be183716b..7f6b45855 100644 --- a/tools/import_scodoc7_dept.py +++ b/tools/import_scodoc7_dept.py @@ -421,5 +421,5 @@ SCO7_TABLES_ORDONNEES = [ """ from tools.import_scodoc7_dept import * -import_scodoc7_dept( "RT" ) -""" \ No newline at end of file +import_scodoc7_dept( "RT", "SCORT" ) +""" diff --git a/tools/migrate_from_scodoc7.sh b/tools/migrate_from_scodoc7.sh index 09663c38a..4aa28ed5e 100755 --- a/tools/migrate_from_scodoc7.sh +++ b/tools/migrate_from_scodoc7.sh @@ -122,11 +122,12 @@ su -c "(cd $SCODOC_DIR && flask import-scodoc7-users)" "$SCODOC_USER" for f in "$SCODOC_VAR_DIR"/config/depts/*.cfg do dept=$(basename "${f%.*}") + db_name=$(echo "SCO$dept" | tr "[:lower:]" "[:upper:]") echo echo "----------------------------------------------" echo "| MIGRATION DU DEPARTEMENT $dept" echo "----------------------------------------------" - su -c "(cd $SCODOC_DIR && flask import-scodoc7-dept $dept)" "$SCODOC_USER" + su -c "(cd $SCODOC_DIR && flask import-scodoc7-dept $dept $db_name)" "$SCODOC_USER" echo "restarting postgresql server..." systemctl restart postgresql done