From a576dd2f390d67a9c0b1f55c4c300beebe0596bf Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 17 Aug 2021 14:15:15 +0200 Subject: [PATCH] Script install et doc pour Debian 11 --- README.md | 8 +-- app/models/raw_sql_init.py | 2 +- app/scodoc/sco_formsemestre_exterieurs.py | 2 +- app/templates/scodoc.html | 4 ++ requirements-3.9.txt | 67 +++++++++++++++++++++++ tools/config.sh | 2 +- tools/install_debian11.sh | 6 +- tools/utils.sh | 4 +- 8 files changed, 82 insertions(+), 13 deletions(-) create mode 100755 requirements-3.9.txt diff --git a/README.md b/README.md index cdae6ea09..82c373658 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Sur un système Linux Debian 11, en tant que `root`: cd /opt/scodoc/tools ./install_debian11.sh -ce script crée un compte utilisateur "scodoc". +ce script crée un compte utilisateur "scodoc" s'il n'existe pas déjà. Note: si vous installez sur une machine déjà configurée pour ScoDoc 7, il est inutile de reconfigurer la messagerie et le firewall. @@ -90,10 +90,11 @@ Pour créer la base de données, lancer le script: su scodoc # au besoin (pas root !) cd /opt/scodoc + ./tools/create_database.sh SCODOC ./tools/create_database.sh SCODOC_DEV # pour la base "developement" ./tools/create_database.sh SCODOC_TEST # pour les tests unitaires -Les bases créées appartiennent à l'utilisateur (role) postgres `scodoc` +Les bases créées appartiennent à l'utilisateur (rôle) postgres `scodoc` (qui a été créé par le script d'installation précédent). ### Variables d'environnement @@ -121,9 +122,6 @@ En tant qu'utilisateur `scodoc`: su scodoc # si besoin cd /opt/scodoc source venv/bin/activate - #flask db init - #flask db migrate -m "initial database" - #flask db upgrade Puis initialisation de l'appli: diff --git a/app/models/raw_sql_init.py b/app/models/raw_sql_init.py index 54f01cf9f..e10f8d142 100644 --- a/app/models/raw_sql_init.py +++ b/app/models/raw_sql_init.py @@ -38,7 +38,7 @@ $$ LANGUAGE plpgsql; -- Fonction pour anonymisation: -- inspirée par https://www.simononsoftware.com/random-string-in-postgresql/ -CREATE FUNCTION random_text_md5( integer ) returns text +CREATE OR REPLACE FUNCTION random_text_md5( integer ) returns text LANGUAGE SQL AS $$ select upper( substring( (SELECT string_agg(md5(random()::TEXT), '') diff --git a/app/scodoc/sco_formsemestre_exterieurs.py b/app/scodoc/sco_formsemestre_exterieurs.py index ca8b4370c..40555ad7f 100644 --- a/app/scodoc/sco_formsemestre_exterieurs.py +++ b/app/scodoc/sco_formsemestre_exterieurs.py @@ -407,7 +407,7 @@ def _check_values(context, ue_list, values): if code not in _UE_VALID_CODES: return False, "code invalide" + pu if code != None: - if note is False or note is "": + if note is False or note == "": return False, "note manquante" + pu if note != False and note != "": if code == None: diff --git a/app/templates/scodoc.html b/app/templates/scodoc.html index c5fe5c81a..16f0dcc2a 100644 --- a/app/templates/scodoc.html +++ b/app/templates/scodoc.html @@ -17,6 +17,10 @@ href="{{url_for('scolar.index_html', scodoc_dept=dept.acronym)}}">Département {{dept.acronym}} + {% else %} +
  • + Aucun département défini ! +
  • {% endfor %} diff --git a/requirements-3.9.txt b/requirements-3.9.txt new file mode 100755 index 000000000..bfba884cb --- /dev/null +++ b/requirements-3.9.txt @@ -0,0 +1,67 @@ +alembic==1.6.5 +astroid==2.6.6 +attrs==21.2.0 +Babel==2.9.1 +blinker==1.4 +certifi==2021.5.30 +cffi==1.14.6 +chardet==4.0.0 +charset-normalizer==2.0.4 +click==8.0.1 +cracklib==2.9.3 +cryptography==3.4.7 +dnspython==2.1.0 +dominate==2.6.0 +email-validator==1.1.3 +et-xmlfile==1.1.0 +Flask==2.0.1 +Flask-Babel==2.0.0 +Flask-Bootstrap==3.3.7.1 +Flask-Caching==1.10.1 +Flask-Login==0.5.0 +Flask-Mail==0.9.1 +Flask-Migrate==3.1.0 +Flask-Moment==1.0.2 +Flask-SQLAlchemy==2.5.1 +Flask-WTF==0.15.1 +greenlet==1.1.1 +gunicorn==20.1.0 +icalendar==4.0.7 +idna==3.2 +iniconfig==1.1.1 +isort==5.9.3 +itsdangerous==2.0.1 +Jinja2==3.0.1 +jwt==1.2.0 +lazy-object-proxy==1.6.0 +Mako==1.1.4 +MarkupSafe==2.0.1 +mccabe==0.6.1 +openpyxl==3.0.7 +packaging==21.0 +Pillow==8.3.1 +pluggy==0.13.1 +psycopg2==2.9.1 +py==1.10.0 +pycparser==2.20 +pydot==1.4.2 +pylint==2.9.6 +pyOpenSSL==20.0.1 +pyparsing==2.4.7 +pytest==6.2.4 +python-dateutil==2.8.2 +python-dotenv==0.19.0 +python-editor==1.0.4 +pytz==2021.1 +redis==3.5.3 +reportlab==3.6.1 +requests==2.26.0 +rq==1.9.0 +six==1.16.0 +SQLAlchemy==1.4.22 +toml==0.10.2 +urllib3==1.26.6 +visitor==0.1.3 +Werkzeug==2.0.1 +wrapt==1.12.1 +WTForms==2.3.3 diff --git a/tools/config.sh b/tools/config.sh index d33b07f62..39479dcd5 100644 --- a/tools/config.sh +++ b/tools/config.sh @@ -40,7 +40,7 @@ export SCODOC_DB_TEST="SCODOC_TEST" # psql command: if various versions installed, force the one we want: if [ "${debian_version}" = "11" ] then - PSQL=/usr/lib/postgresql/11/bin/psql + PSQL=/usr/lib/postgresql/13/bin/psql export POSTGRES_SERVICE="postgresql@11-main.service" else die "unsupported Debian version" diff --git a/tools/install_debian11.sh b/tools/install_debian11.sh index 55d2342fa..ebcae0d22 100755 --- a/tools/install_debian11.sh +++ b/tools/install_debian11.sh @@ -72,11 +72,11 @@ python3 -m venv venv || die "can't create Python 3 virtualenv" source venv/bin/activate # pip install --upgrade pip => bug [Errno 39] Directory not empty: '_internal' pip install wheel -pip install -r requirements-3.7.txt +pip install -r requirements-3.9.txt # ------------ -GITCOMMIT=$(git rev-parse HEAD) -SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&commit="$GITCOMMIT") +SCODOC_RELEASE=$(cat VERSION) +SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&release="$SCODOC_RELEASE") echo "$SVERSION" > "${SCODOC_VERSION_DIR}/scodoc.sn" diff --git a/tools/utils.sh b/tools/utils.sh index b79027f2e..c3b1f357e 100644 --- a/tools/utils.sh +++ b/tools/utils.sh @@ -51,11 +51,11 @@ scodocctl() { # --- Ensure postgres user scodoc exists init_postgres_user() { # run as root - if [ -z $(echo "select usename from pg_user;" | su -c "$PSQL -d template1 -p $POSTGRES_PORT" $POSTGRES_SUPERUSER | grep $POSTGRES_USER) ] + if [ -z $(echo "select usename from pg_user;" | su -c "(cd; $PSQL -d template1 -p $POSTGRES_PORT)" "$POSTGRES_SUPERUSER" | grep "$POSTGRES_USER") ] then # add database user echo "Creating postgresql user $POSTGRES_USER" - su -c "createuser -p $POSTGRES_PORT --createdb --no-superuser --no-adduser --no-createrole ${POSTGRES_USER}" "$POSTGRES_SUPERUSER" + su -c "(cd; createuser -p $POSTGRES_PORT --createdb --no-superuser --no-createrole ${POSTGRES_USER})" "$POSTGRES_SUPERUSER" fi }