From 0d60da2675d14a8a1f0f60584c78cc97706bc411 Mon Sep 17 00:00:00 2001 From: Place Jean-Marie Date: Tue, 10 Aug 2021 09:30:08 +0200 Subject: [PATCH] reduction PR aux balises --- .gitignore | 3 +- scodoc.py | 21 +-- tests/scenarios/export_formation1.xml | 205 -------------------------- tools/delete_dept.sh | 12 +- 4 files changed, 7 insertions(+), 234 deletions(-) delete mode 100755 tests/scenarios/export_formation1.xml diff --git a/.gitignore b/.gitignore index deaa1705c..6d49cf2c8 100644 --- a/.gitignore +++ b/.gitignore @@ -169,5 +169,4 @@ Thumbs.db .vscode/ *.code-workspace -# PyCharm projects -.idea/ + diff --git a/scodoc.py b/scodoc.py index 6c459ca7e..a921f2a2e 100755 --- a/scodoc.py +++ b/scodoc.py @@ -6,6 +6,7 @@ """ + from __future__ import print_function import os @@ -18,7 +19,6 @@ from flask.cli import with_appcontext from app import create_app, cli, db from app.auth.models import User, Role, UserRole -from app.scodoc.notesdb import set_sco_dept from app.views import notes, scolar, absences import app.utils as utils @@ -210,22 +210,3 @@ def clear_cache(): # clear-cache r = redis.Redis() r.flushall() click.echo("Redis caches flushed.") - - -@app.cli.command() -@click.argument("xml_file") -@click.argument("dept") -def import_xml(xml_file, dept): - import flask_login - from flask_login import login_user, logout_user, current_user - from app.scodoc.notesdb import close_dept_connection, open_dept_connection - from app.scodoc.sco_formations import formation_import_xml - - with app.test_request_context(): - u = User.query.first() - flask_login.login_user(u) - click.echo("Importing {}".format(xml_file)) - set_sco_dept(dept) - doc = open(xml_file).read() - formation_import_xml(None, doc) - click.echo("Done") diff --git a/tests/scenarios/export_formation1.xml b/tests/scenarios/export_formation1.xml deleted file mode 100755 index 8baf7a6b7..000000000 --- a/tests/scenarios/export_formation1.xml +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/delete_dept.sh b/tools/delete_dept.sh index a77c0f86a..6ebaff947 100755 --- a/tools/delete_dept.sh +++ b/tools/delete_dept.sh @@ -19,9 +19,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" source "$SCRIPT_DIR/config.sh" source "$SCRIPT_DIR/utils.sh" -# scodoc may now manage departments TODO To be fixed -# check_uid_root "$0" - +check_uid_root "$0" usage() { echo "$0 [-n DEPT]" echo "(default to interactive mode)" @@ -59,15 +57,15 @@ cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg if [ -e "$cfg_pathname" ] then - # arret de ScoDoc (need root permissions so disabled for the moment TODO to be fixed) - # scodocctl stop + # arret de ScoDoc + scodocctl stop # suppression de la base postgres db_name=$(sed '/^dbname=*/!d; s///;q' < "$cfg_pathname") - if psql -lt | cut -d \| -f 1 | grep -wq "$db_name" + if su -c "psql -lt" "$POSTGRES_SUPERUSER" | cut -d \| -f 1 | grep -wq "$db_name" then echo "Suppression de la base postgres $db_name ..." - dropdb $db_name || terminate "ne peux supprimer base de donnees $db_name" + su -c "dropdb $db_name" "$POSTGRES_SUPERUSER" || terminate "ne peux supprimer base de donnees $db_name" else echo "la base postgres $db_name n'existe pas." fi