diff --git a/.gitignore b/.gitignore index 6d49cf2c8..deaa1705c 100644 --- a/.gitignore +++ b/.gitignore @@ -169,4 +169,5 @@ Thumbs.db .vscode/ *.code-workspace - +# PyCharm projects +.idea/ diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index d14d5e6a0..69220cf14 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -757,6 +757,6 @@ def tf_error_message(msg): if isinstance(msg, str): msg = [msg] return ( - '' - % '
  • '.join(msg) + '' + % '
  • '.join(msg) ) diff --git a/app/scodoc/sco_dept.py b/app/scodoc/sco_dept.py index e723139bc..0bd3bfbb2 100644 --- a/app/scodoc/sco_dept.py +++ b/app/scodoc/sco_dept.py @@ -111,7 +111,7 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0): # aucun semestre courant: affiche aide H.append( """

    Aucune session en cours !

    -

    Pour ajouter une session, aller dans Programmes, +

    Pour ajouter une session, aller dans Programmes, choisissez une formation, puis suivez le lien "UE, modules, semestres".

    Là, en bas de page, suivez le lien diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index 62c17505e..23880f68a 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -259,6 +259,7 @@ def formation_list_table(context, formation_id=None, args={}, REQUEST=None): f["parcours_name"] = "" f["_titre_target"] = "ue_list?formation_id=%(formation_id)s" % f f["_titre_link_class"] = "stdlink" + f["_titre_id"] = "titre-%s" % f["acronyme"].lower().replace(" ", "-") # Ajoute les semestres associés à chaque formation: f["sems"] = sco_formsemestre.do_formsemestre_list( context, args={"formation_id": f["formation_id"]} @@ -266,13 +267,14 @@ def formation_list_table(context, formation_id=None, args={}, REQUEST=None): f["sems_list_txt"] = ", ".join([s["session_id"] for s in f["sems"]]) f["_sems_list_txt_html"] = ", ".join( [ - '%(session_id)s' - % s + '%(' + "session_id)s " % s for s in f["sems"] ] + [ - 'ajouter' - % f + 'ajouter ' + % (f["acronyme"].lower().replace(" ", "-"), f["formation_id"]) ] ) if f["sems"]: @@ -288,16 +290,17 @@ def formation_list_table(context, formation_id=None, args={}, REQUEST=None): else: but_locked = '' if editable and not locked: - but_suppr = ( - '%s' - % (f["formation_id"], suppricon) + but_suppr = '%s' % ( + f["formation_id"], + f["acronyme"].lower().replace(" ", "-"), + suppricon, ) else: but_suppr = '' if editable: but_edit = ( - '%s' - % (f["formation_id"], editicon) + '%s' + % (f["formation_id"], f["acronyme"].lower().replace(" ", "-"), editicon) ) else: but_edit = '' @@ -365,4 +368,4 @@ def formation_create_new_version(context, formation_id, redirect=True, REQUEST=N "ue_list?formation_id=" + new_id + "&msg=Nouvelle version !" ) else: - return new_id, modules_old2new, ues_old2new \ No newline at end of file + return new_id, modules_old2new, ues_old2new diff --git a/app/views/notes.py b/app/views/notes.py index d29e9e971..8f42c6ba0 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -391,7 +391,7 @@ def index_html(context, REQUEST=None): if editable: H.append( - """

    Créer une formation

    + """

    Créer une formation

    Importer une formation (xml)

    Une "formation" est un programme pédagogique structuré en UE, matières et modules. Chaque semestre se réfère à une formation. La modification d'une formation affecte tous les semestres qui s'y réfèrent.

    """ @@ -1968,7 +1968,7 @@ def formsemestre_validation_etud_manu( def formsemestre_validate_previous_ue( context, formsemestre_id, etudid=None, REQUEST=None ): - "Form. saisie UE validée hors ScoDoc " + "Form. saisie UE validée hors ScoDoc" if not sco_permissions_check.can_validate_sem(formsemestre_id): return scu.confirm_dialog( message="

    Opération non autorisée pour %s" diff --git a/scodoc.py b/scodoc.py index a921f2a2e..6c459ca7e 100755 --- a/scodoc.py +++ b/scodoc.py @@ -6,7 +6,6 @@ """ - from __future__ import print_function import os @@ -19,6 +18,7 @@ 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,3 +210,22 @@ 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 new file mode 100755 index 000000000..8baf7a6b7 --- /dev/null +++ b/tests/scenarios/export_formation1.xml @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/delete_dept.sh b/tools/delete_dept.sh index 6ebaff947..a77c0f86a 100755 --- a/tools/delete_dept.sh +++ b/tools/delete_dept.sh @@ -19,7 +19,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" source "$SCRIPT_DIR/config.sh" source "$SCRIPT_DIR/utils.sh" -check_uid_root "$0" +# scodoc may now manage departments TODO To be fixed +# check_uid_root "$0" + usage() { echo "$0 [-n DEPT]" echo "(default to interactive mode)" @@ -57,15 +59,15 @@ cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg if [ -e "$cfg_pathname" ] then - # arret de ScoDoc - scodocctl stop + # arret de ScoDoc (need root permissions so disabled for the moment TODO to be fixed) + # scodocctl stop # suppression de la base postgres db_name=$(sed '/^dbname=*/!d; s///;q' < "$cfg_pathname") - if su -c "psql -lt" "$POSTGRES_SUPERUSER" | cut -d \| -f 1 | grep -wq "$db_name" + if psql -lt | cut -d \| -f 1 | grep -wq "$db_name" then echo "Suppression de la base postgres $db_name ..." - su -c "dropdb $db_name" "$POSTGRES_SUPERUSER" || terminate "ne peux supprimer base de donnees $db_name" + dropdb $db_name || terminate "ne peux supprimer base de donnees $db_name" else echo "la base postgres $db_name n'existe pas." fi