From 4b2d5f01a4eb3ed4e64e22912751f277ae055760 Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
Date: Sat, 11 Sep 2021 11:07:53 +0200
Subject: [PATCH 01/47] backup scripts for ScoDoc 9
---
misc/backup_db2 => tools/backups/backup_db9 | 19 +++++++++----------
{misc => tools/backups}/backup_rotation.sh | 2 +-
.../backups}/backup_to_remote_server.sh | 18 +++++++++---------
3 files changed, 19 insertions(+), 20 deletions(-)
rename misc/backup_db2 => tools/backups/backup_db9 (66%)
rename {misc => tools/backups}/backup_rotation.sh (99%)
rename {misc => tools/backups}/backup_to_remote_server.sh (85%)
diff --git a/misc/backup_db2 b/tools/backups/backup_db9
similarity index 66%
rename from misc/backup_db2
rename to tools/backups/backup_db9
index 779287702..ca760ea80 100755
--- a/misc/backup_db2
+++ b/tools/backups/backup_db9
@@ -1,29 +1,28 @@
#!/bin/bash
-# usage: backup_db2 dbname
+# usage: backup_db9 dbname
# Dump une base postgresql, et garde plusieurs dumps dans le passe
# (configurable dans le script backup_rotation.sh)
# Les dumps sont compresses (gzip).
#
-# E. Viennet pour ScoDoc, 2014
+# E. Viennet pour ScoDoc, 2014, 2021 pour ScoDoc 9
# (ce script est meilleur que l'ancien backup-db, car l'espace entre
# deux sauvegardes dépend de leur anciennete)
#
#
# Note: pour restaurer un backup (en supprimant la base existante !):
#
-# 0- Arreter scodoc: /etc/init.d/scodoc stop (ou systemctl stop scodoc)
+# 0- Arreter scodoc: systemctl stop scodoc
#
-# Puis en tant qu'utilisateur postgres: su postgres
-# 1- supprimer la base existante si elle existe: dropdb SCOXXX
+# Puis en tant qu'utilisateur scodoc: su scodoc
+# 1- supprimer la base existante si elle existe: dropdb SCODOC
#
# 2- recreer la base, vide: createdb -E UTF-8 SCOXXX
-# (nom de la base: SCOXXX ou XXX=departement)
-#
-# 3- pg_restore -d SCOXXX SCOXXX_pgdump
+# /opt/scodoc/tools/create_database.sh SCODOC
+# 3- pg_restore -d SCODOC SCODOC_pgdump
#
# Revenir a l'utilisateur root: exit
-# 4- Relancer scodoc: /etc/init.d/scodoc start (ou systemctl start scodoc)
+# 4- Relancer scodoc: systemctl start scodoc
DBNAME=$1
DUMPBASE="$DBNAME"-BACKUPS
@@ -50,4 +49,4 @@ pg_dump --format=t "$DBNAME" -f $DUMPFILE
gzip $DUMPFILE
# 3- Rotate backups: remove unneeded copies
-/opt/scodoc/Products/ScoDoc/misc/backup_rotation.sh "$DUMPBASE"
+/opt/scodoc/tools/backups/backup_rotation.sh "$DUMPBASE"
diff --git a/misc/backup_rotation.sh b/tools/backups/backup_rotation.sh
similarity index 99%
rename from misc/backup_rotation.sh
rename to tools/backups/backup_rotation.sh
index 351a1e365..cfab628df 100755
--- a/misc/backup_rotation.sh
+++ b/tools/backups/backup_rotation.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# Backup rotation
-# Usage example: backup_rotation.sh /var/lib/postgresql/BACKUP-SCOGEII
+# Usage example: backup_rotation.sh /var/lib/postgresql/BACKUP-SCODOC
#
# This script is designed to run each hour
#
diff --git a/misc/backup_to_remote_server.sh b/tools/backups/backup_to_remote_server.sh
similarity index 85%
rename from misc/backup_to_remote_server.sh
rename to tools/backups/backup_to_remote_server.sh
index 2509ab6af..8638e1bd7 100644
--- a/misc/backup_to_remote_server.sh
+++ b/tools/backups/backup_to_remote_server.sh
@@ -11,7 +11,7 @@
#
# A adapter a vos besoins. Utilisation a vos risques et perils.
#
-# E. Viennet, 2002
+# E. Viennet, 2002, 2021
# Installation:
# 1- Installer rsync:
@@ -30,8 +30,8 @@ logfile=/var/log/rsynclog # log sur serveur scodoc
# A qui envoyer un mail en cas d'erreur de la sauvegarde:
SUPERVISORMAIL=emmanuel.viennet@example.com
-CALLER=`basename $0`
-MACHINE=`hostname -s`
+CALLER=$(basename $0)
+MACHINE=$(hostname -s)
# -----------------------------------------------------
@@ -40,7 +40,7 @@ MACHINE=`hostname -s`
# ----------------------------------
terminate()
{
- dateTest=`date`
+ dateTest=$(date)
mail -s "Attention: Probleme sauvegarde ScoDoc" $SUPERVISORMAIL <> $logfile 2>&1
- echo "starting at" `date` >> $logfile 2>&1
- rsync -vaze ssh --delete --rsync-path=/usr/bin/rsync $srcdir $remotehost":"$destdir >> $logfile 2>&1
+ echo "--------------- mirroring $MACHINE:$srcdir to $remotehost:$destdir" >> $logfile 2>&1
+ echo "starting at $(date)" >> $logfile 2>&1
+ rsync -vaze ssh --delete --rsync-path=/usr/bin/rsync "$srcdir" "$remotehost:$destdir" >> $logfile 2>&1
if [ $? -ne 0 ]
then
echo Error in rsync: code=$?
terminate
fi
- echo "ending at" `date` >> $logfile 2>&1
+ echo "ending at $(date)" >> $logfile 2>&1
echo "---------------" >> $logfile 2>&1
}
From badf83cc7fa17b51a22d2bef5c7fa6bc240de2b6 Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
Date: Sat, 11 Sep 2021 15:59:06 +0200
Subject: [PATCH 02/47] fix migration adresses + cosmetique
---
README.md | 8 +++++++-
app/__init__.py | 4 ++--
app/auth/forms.py | 20 +++++++++----------
app/auth/routes.py | 4 ++--
app/scodoc/html_sidebar.py | 4 ++--
app/scodoc/sco_users.py | 1 +
app/static/css/scodoc.css | 3 ++-
app/templates/about.html | 25 +++++++++++++++++++++++
app/templates/auth/login.html | 11 ++++++++---
app/templates/scodoc.html | 11 ++++++-----
app/views/scodoc.py | 12 ++++++++++++
app/views/scolar.py | 37 -----------------------------------
sco_version.py | 4 ++--
tools/import_scodoc7_dept.py | 1 +
14 files changed, 80 insertions(+), 65 deletions(-)
create mode 100644 app/templates/about.html
diff --git a/README.md b/README.md
index 12d2bbca8..b1117729b 100644
--- a/README.md
+++ b/README.md
@@ -148,9 +148,15 @@ Mémo pour développeurs: séquence re-création d'une base:
flask import-scodoc7-users
flask import-scodoc7-dept STID SCOSTID
+Si la base utilisée pour les dev n'est plus en phase avec les scripts de
+migration, utiliser les commandes `flask db history`et `flask db stamp`pour se
+positionner à la bonne étape.
+
# Paquet debian 11
-Les scripts associés au paquet Debian (.deb) sont dans `tools/debian`.
+Les scripts associés au paquet Debian (.deb) sont dans `tools/debian`. Le plus
+important est `postinst`qui se charge de configurer le système (install ou
+upgrade de scodoc9).
La préparation d'une release se fait à l'aide du script
`tools/build_release.sh`.
diff --git a/app/__init__.py b/app/__init__.py
index a913f57ec..33fbd23a5 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -32,7 +32,7 @@ db = SQLAlchemy()
migrate = Migrate(compare_type=True)
login = LoginManager()
login.login_view = "auth.login"
-login.login_message = "Please log in to access this page."
+login.login_message = "Identifiez-vous pour accéder à cette page."
mail = Mail()
bootstrap = Bootstrap()
moment = Moment()
@@ -353,4 +353,4 @@ from app.scodoc import sco_cache
# click.echo(
# "Warning: user database not initialized !\n (use: flask user-db-init)"
# )
-# admin = None
\ No newline at end of file
+# admin = None
diff --git a/app/auth/forms.py b/app/auth/forms.py
index e37478177..143f65546 100644
--- a/app/auth/forms.py
+++ b/app/auth/forms.py
@@ -16,20 +16,20 @@ _l = _
class LoginForm(FlaskForm):
- user_name = StringField(_l("Username"), validators=[DataRequired()])
- password = PasswordField(_l("Password"), validators=[DataRequired()])
- remember_me = BooleanField(_l("Remember Me"))
- submit = SubmitField(_l("Sign In"))
+ user_name = StringField(_l("Nom d'utilisateur"), validators=[DataRequired()])
+ password = PasswordField(_l("Mot de passe"), validators=[DataRequired()])
+ remember_me = BooleanField(_l("mémoriser la connexion"))
+ submit = SubmitField(_l("Suivant"))
class UserCreationForm(FlaskForm):
- user_name = StringField(_l("Username"), validators=[DataRequired()])
+ user_name = StringField(_l("Nom d'utilisateur"), validators=[DataRequired()])
email = StringField(_l("Email"), validators=[DataRequired(), Email()])
- password = PasswordField(_l("Password"), validators=[DataRequired()])
+ password = PasswordField(_l("Mot de passe"), validators=[DataRequired()])
password2 = PasswordField(
- _l("Repeat Password"), validators=[DataRequired(), EqualTo("password")]
+ _l("Répéter"), validators=[DataRequired(), EqualTo("password")]
)
- submit = SubmitField(_l("Register"))
+ submit = SubmitField(_l("Inscrire"))
def validate_user_name(self, user_name):
user = User.query.filter_by(user_name=user_name.data).first()
@@ -48,9 +48,9 @@ class ResetPasswordRequestForm(FlaskForm):
class ResetPasswordForm(FlaskForm):
- password = PasswordField(_l("Password"), validators=[DataRequired()])
+ password = PasswordField(_l("Mot de passe"), validators=[DataRequired()])
password2 = PasswordField(
- _l("Repeat Password"), validators=[DataRequired(), EqualTo("password")]
+ _l("Répéter"), validators=[DataRequired(), EqualTo("password")]
)
submit = SubmitField(_l("Request Password Reset"))
diff --git a/app/auth/routes.py b/app/auth/routes.py
index 7b1712f00..b4d107c2a 100644
--- a/app/auth/routes.py
+++ b/app/auth/routes.py
@@ -38,7 +38,7 @@ def login():
user = User.query.filter_by(user_name=form.user_name.data).first()
if user is None or not user.check_password(form.password.data):
current_app.logger.info("login: invalid (%s)", form.user_name.data)
- flash(_("Invalid user name or password"))
+ flash(_("Nom ou mot de passe invalide"))
return redirect(url_for("auth.login"))
login_user(user, remember=form.remember_me.data)
current_app.logger.info("login: success (%s)", form.user_name.data)
@@ -95,7 +95,7 @@ def reset_password_request():
current_app.logger.info(
"reset_password_request: for unkown user '{}'".format(form.email.data)
)
- flash(_("Check your email for the instructions to reset your password"))
+ flash(_("Voir les instructions enoyez par mail"))
return redirect(url_for("auth.login"))
return render_template(
"auth/reset_password_request.html", title=_("Reset Password"), form=form
diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py
index 5ec2ae26b..dc0b12959 100644
--- a/app/scodoc/html_sidebar.py
+++ b/app/scodoc/html_sidebar.py
@@ -152,10 +152,10 @@ def sidebar():
# Logo
H.append(
f"""
diff --git a/app/scodoc/sco_users.py b/app/scodoc/sco_users.py
index f7eee6731..53437cbe7 100644
--- a/app/scodoc/sco_users.py
+++ b/app/scodoc/sco_users.py
@@ -258,6 +258,7 @@ def user_info(user_name_or_id=None, user=None):
info = u.to_dict()
else:
info = None
+ user_name = "inconnu"
else:
info = user.to_dict()
user_name = user.user_name
diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css
index 47019d941..ef9df0da5 100644
--- a/app/static/css/scodoc.css
+++ b/app/static/css/scodoc.css
@@ -2614,7 +2614,8 @@ div.maindiv {
margin: 1em;
}
ul.main {
- list-style-type: square;
+ list-style-type: square;
+ margin-top: 1em;
}
ul.main li {
diff --git a/app/templates/about.html b/app/templates/about.html
new file mode 100644
index 000000000..2dc506915
--- /dev/null
+++ b/app/templates/about.html
@@ -0,0 +1,25 @@
+{% extends 'base.html' %}
+{% import 'bootstrap/wtf.html' as wtf %}
+
+{% block app_content %}
+
+Système de gestion scolarité
+
+© Emmanuel Viennet 2021
+
+Version {{ version }}
+
+ScoDoc est un logiciel libre écrit en
+Python.
+Information et documentation sur scodoc.org.
+
+
+Dernières évolutions
+
+{{ news|safe }}
+
+
+ {{ logo|safe }}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/auth/login.html b/app/templates/auth/login.html
index 6b775b738..2685383db 100644
--- a/app/templates/auth/login.html
+++ b/app/templates/auth/login.html
@@ -2,14 +2,19 @@
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
-Sign In
+Connexion
{{ wtf.quick_form(form) }}
-Forgot Your Password?
-Click to Reset It
+En cas d'oubli de votre mot de passe
+cliquez ici pour le réinitialiser.
+
+
+L'accès à ScoDoc est strictement réservé aux personnels de
+ l'établissement. Les étudiants n'y ont pas accès. Pour toute information,
+ contactez la personne responsable de votre établissement.
{% endblock %}
\ No newline at end of file
diff --git a/app/templates/scodoc.html b/app/templates/scodoc.html
index f48ad0f46..c0e1eddda 100644
--- a/app/templates/scodoc.html
+++ b/app/templates/scodoc.html
@@ -2,7 +2,7 @@
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
-ScoDoc: gestion scolarité (version béta)
+ScoDoc 9 - suivi scolarité
{% if not current_user.is_anonymous %}
Bonjour {{current_user.get_nomcomplet()}}
@@ -24,10 +24,6 @@
{% endfor %}
-
- Ceci est une version de test,
- ne pas utiliser en production !
-
{% if current_user.is_authenticated %}