forked from ScoDoc/ScoDoc
Merge branch 'master' into dyn_fields
This commit is contained in:
commit
1aa39c72fd
@ -272,7 +272,6 @@ def etudarchive_generate_excel_sample(group_id=None, REQUEST=None):
|
||||
suffix=scu.XLSX_SUFFIX,
|
||||
mime=scu.XLSX_MIMETYPE,
|
||||
)
|
||||
# return sco_excel.send_excel_file(REQUEST, data, "ImportFichiersEtudiants" + scu.XLSX_SUFFIX)
|
||||
|
||||
|
||||
def etudarchive_import_files_form(group_id, REQUEST=None):
|
||||
|
@ -47,7 +47,7 @@ from app.scodoc import sco_formsemestre
|
||||
from app.scodoc import sco_news
|
||||
|
||||
|
||||
def formation_delete(formation_id=None, dialog_confirmed=False, REQUEST=None):
|
||||
def formation_delete(formation_id=None, dialog_confirmed=False):
|
||||
"""Delete a formation"""
|
||||
F = sco_formations.formation_list(args={"formation_id": formation_id})
|
||||
if not F:
|
||||
|
@ -786,7 +786,7 @@ def groups_table(
|
||||
L = [dicttakestr(m, keys) for m in groups_infos.members]
|
||||
title = "etudiants_%s" % groups_infos.groups_filename
|
||||
xls = sco_excel.excel_simple_table(titles=titles, lines=L, sheet_name=title)
|
||||
filename = title + scu.XLSX_SUFFIX
|
||||
filename = title
|
||||
return scu.send_file(xls, filename, scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE)
|
||||
else:
|
||||
raise ValueError("unsupported format")
|
||||
|
@ -328,7 +328,7 @@ def feuille_preparation_jury(formsemestre_id, REQUEST):
|
||||
xls = ws.generate()
|
||||
return scu.send_file(
|
||||
xls,
|
||||
f"PrepaJury{sn}{scu.XLSX_SUFFIX}",
|
||||
f"PrepaJury{sn}",
|
||||
scu.XLSX_SUFFIX,
|
||||
mime=scu.XLSX_MIMETYPE,
|
||||
)
|
||||
|
@ -231,7 +231,7 @@ def do_formsemestre_recapcomplet(
|
||||
return data
|
||||
elif format == "csv":
|
||||
return scu.send_file(data, filename=filename, mime=scu.CSV_MIMETYPE)
|
||||
elif format[:3] == "xls" or format[:3] == "xlsx":
|
||||
elif format[:3] == "xls" or format[:4] == "xlsx":
|
||||
return scu.send_file(data, filename=filename, mime=scu.XLSX_MIMETYPE)
|
||||
elif format == "json":
|
||||
js = json.dumps(data, indent=1, cls=scu.ScoDocJSONEncoder)
|
||||
|
@ -229,7 +229,7 @@ SCODOC_CFG_DIR = os.path.join(Config.SCODOC_VAR_DIR, "config")
|
||||
SCODOC_VERSION_DIR = os.path.join(SCODOC_CFG_DIR, "version")
|
||||
# ----- Repertoire tmp : /opt/scodoc-data/tmp
|
||||
SCO_TMP_DIR = os.path.join(Config.SCODOC_VAR_DIR, "tmp")
|
||||
if not os.path.exists(SCO_TMP_DIR):
|
||||
if not os.path.exists(SCO_TMP_DIR) and os.path.exists(Config.SCODOC_VAR_DIR):
|
||||
os.mkdir(SCO_TMP_DIR, 0o755)
|
||||
# ----- Les logos: /opt/scodoc-data/config/logos
|
||||
SCODOC_LOGOS_DIR = os.path.join(SCODOC_CFG_DIR, "logos")
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.0.36"
|
||||
SCOVERSION = "9.0.37"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
87
tools/restore_scodoc9_data.sh
Normal file
87
tools/restore_scodoc9_data.sh
Normal file
@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# ScoDoc: restore data (saved by save_scodoc9_data) into current install
|
||||
#
|
||||
# Utile pour migrer ScoDoc 9 d'un serveur a un autre
|
||||
# A executer en tant que root sur le nouveau serveur
|
||||
#
|
||||
# E. Viennet, Sept 2021
|
||||
#
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
source "$SCRIPT_DIR/config.sh"
|
||||
source "$SCRIPT_DIR/utils.sh"
|
||||
|
||||
# Ce script doit tourner comme "root"
|
||||
check_uid_root "$0"
|
||||
|
||||
|
||||
# Usage
|
||||
if [ ! $# -eq 2 ]
|
||||
then
|
||||
echo "Usage: $0 archive dbname"
|
||||
echo "Exemple: $0 /tmp/mon-scodoc.tgz SCODOC"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SRC=$1
|
||||
DBNAME=$2
|
||||
|
||||
|
||||
# Safety check
|
||||
echo "Ce script va remplacer les donnees de votre installation ScoDoc par celles"
|
||||
echo "enregistrees dans le fichier fourni."
|
||||
echo "Ce fichier doit avoir ete cree par le script save_scodoc9_data.sh."
|
||||
echo
|
||||
echo "Attention: TOUTES LES DONNEES DE CE SCODOC SERONT REMPLACEES !"
|
||||
echo "Notamment, tous les utilisateurs et departements existants seront effaces !"
|
||||
echo
|
||||
echo "La base SQL $DBNAME sera effacée et remplacée !!!"
|
||||
echo
|
||||
echo -n "Voulez vous poursuivre cette operation ? (y/n) [n]"
|
||||
read -r ans
|
||||
if [ ! "$(norm_ans "$ans")" = 'Y' ]
|
||||
then
|
||||
echo "Annulation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -- Stop ScoDoc
|
||||
echo "Arrêt de scodoc9..."
|
||||
systemctl stop scodoc9
|
||||
|
||||
# Clear caches
|
||||
echo "Purge des caches..."
|
||||
su -c "(cd $SCODOC_DIR && source venv/bin/activate && flask clear-cache)" "$SCODOC_USER" || die "Erreur purge cache scodoc9"
|
||||
|
||||
# Déplace scodoc-data s'il existe
|
||||
if [ -e "$SCODOC_VAR_DIR" ]
|
||||
then
|
||||
echo "$SCODOC_VAR_DIR existe: le renomme en .old"
|
||||
mv "$SCODOC_VAR_DIR" "$SCODOC_VAR_DIR".old || die "Erreur renommage scodoc-data"
|
||||
fi
|
||||
|
||||
# -- Ouverture archive
|
||||
echo "Ouverture archive $SRC..."
|
||||
(cd $(dirname "$SCODOC_VAR_DIR"); tar xfz "$SRC") || die "Error opening archive"
|
||||
|
||||
# -- Ckeck/fix owner
|
||||
echo "Vérification du propriétaire..."
|
||||
chown -R "${SCODOC_USER}:${SCODOC_GROUP}" "${SCODOC_VAR_DIR}" || die "Error chowning ${SCODOC_VAR_DIR}"
|
||||
|
||||
# --- La base SQL: nommée $(db_name).dump
|
||||
nb=$(su -c "psql -l" "$SCODOC_USER" | awk '{print $1}' | grep -c -e '^'"$DBNAME"'$')
|
||||
if [ "$nb" -gt 0 ]
|
||||
then
|
||||
echo "Suppression de la base $DBNAME..."
|
||||
su -c "dropdb $DBNAME" "$SCODOC_USER" || die "Erreur destruction db"
|
||||
fi
|
||||
su -c "createdb $DBNAME" "$SCODOC_USER" || die "Erreur destruction db"
|
||||
|
||||
echo "Chargement de la base SQL..."
|
||||
su -c "pg_restore -d $DBNAME ${SCODOC_VAR_DIR}/SCODOC.dump" "$SCODOC_USER" || die "Erreur chargement de la base SQL"
|
||||
|
||||
# -- Start ScoDoc
|
||||
systemctl start scodoc9
|
||||
|
||||
echo "Terminé."
|
51
tools/save_scodoc9_data.sh
Normal file
51
tools/save_scodoc9_data.sh
Normal file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# ScoDoc: save all user data (database, configs, images, archives...) in separate directory
|
||||
#
|
||||
# Utile pour migrer ScoDoc version 9 (et plus) d'un serveur a un autre
|
||||
# Executer en tant que scodoc sur le serveur d'origine.
|
||||
# Utiliser - pour sortir sur la sortie standard (eg pipe dans ssh...)
|
||||
#
|
||||
# E. Viennet, Sept 2011, Aug 2020, Aug 21
|
||||
#
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
source "$SCRIPT_DIR/config.sh"
|
||||
source "$SCRIPT_DIR/utils.sh"
|
||||
|
||||
if [ "$(id -nu)" != "$SCODOC_USER" ]
|
||||
then
|
||||
echo "$0: script must be runned as user $SCODOC_USER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Ce script est utile pour transférer toutes les données d'un serveur ScoDoc 9"
|
||||
echo "à un autre ScoDoc 9."
|
||||
echo "Il est vivement recommandé de mettre à jour votre ScoDoc avant."
|
||||
echo ""
|
||||
echo -n "Voulez-vous poursuivre cette sauvegarde ? (y/n) [n]"
|
||||
read -r ans
|
||||
if [ ! "$(norm_ans "$ans")" = 'Y' ]
|
||||
then
|
||||
echo "Annulation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Destination
|
||||
if [ ! $# -eq 1 ]
|
||||
then
|
||||
echo "Usage: $0 destination_file"
|
||||
echo "(- sort sur stdout)"
|
||||
echo "Exemple: $0 /tmp/mon-scodoc.tgz"
|
||||
exit 1
|
||||
fi
|
||||
DEST=$1
|
||||
db_name="$SCODOC_DB_PROD" # SCODOC
|
||||
|
||||
# dump dans /opt/scodoc-data/SCODOC.dump
|
||||
pg_dump --format=custom --file="$SCODOC_VAR_DIR/$db_name.dump" "$db_name" || die "Error dumping database"
|
||||
|
||||
# tar scodoc-data vers le fichier indiqué ou stdout
|
||||
(cd $(dirname "$SCODOC_VAR_DIR"); tar cfz "$DEST" $(basename "$SCODOC_VAR_DIR")) || die "Error archiving data"
|
||||
|
Loading…
x
Reference in New Issue
Block a user