diff --git a/app/decorators.py b/app/decorators.py
index 4987f0d834..a72d825355 100644
--- a/app/decorators.py
+++ b/app/decorators.py
@@ -46,15 +46,15 @@ class ZRequest(object):
# if current_app.config["DEBUG"]:
# le ReverseProxied se charge maintenant de mettre le bon protocole http ou https
- self.URL = request.base_url
- self.BASE0 = request.url_root
+ # self.URL = request.base_url
+ # self.BASE0 = request.url_root
# else:
# self.URL = request.base_url.replace("http://", "https://")
# self.BASE0 = request.url_root.replace("http://", "https://")
- self.URL0 = self.URL
+ # self.URL0 = self.URL
# query_string is bytes:
- self.QUERY_STRING = request.query_string.decode("utf-8")
- self.REQUEST_METHOD = request.method
+ # self.QUERY_STRING = request.query_string.decode("utf-8")
+ # self.REQUEST_METHOD = request.method
self.AUTHENTICATED_USER = current_user
self.REMOTE_ADDR = request.remote_addr
if request.method == "POST":
@@ -79,11 +79,7 @@ class ZRequest(object):
self.RESPONSE = ZResponse()
def __str__(self):
- return """REQUEST
- URL={r.URL}
- QUERY_STRING={r.QUERY_STRING}
- REQUEST_METHOD={r.REQUEST_METHOD}
- AUTHENTICATED_USER={r.AUTHENTICATED_USER}
+ return """ZREQUEST
form={r.form}
""".format(
r=self
diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py
index a05d42c5ef..f75e0b6bda 100644
--- a/app/scodoc/sco_abs_views.py
+++ b/app/scodoc/sco_abs_views.py
@@ -30,7 +30,7 @@
"""
import datetime
-from flask import url_for, g
+from flask import url_for, g, request
import app.scodoc.sco_utils as scu
from app.scodoc import notesdb as ndb
@@ -814,8 +814,8 @@ def ListeAbsEtud(
etudid, datedebut, with_evals=with_evals, format=format
)
if REQUEST:
- base_url_nj = "%s?etudid=%s&absjust_only=0" % (REQUEST.URL0, etudid)
- base_url_j = "%s?etudid=%s&absjust_only=1" % (REQUEST.URL0, etudid)
+ base_url_nj = "%s?etudid=%s&absjust_only=0" % (request.base_url, etudid)
+ base_url_j = "%s?etudid=%s&absjust_only=1" % (request.base_url, etudid)
else:
base_url_nj = base_url_j = ""
tab_absnonjust = GenTable(
diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py
index f69041e902..e17cea63d1 100644
--- a/app/scodoc/sco_archives.py
+++ b/app/scodoc/sco_archives.py
@@ -29,19 +29,19 @@
Archives are plain files, stored in
- /archives/
- (where is usually /opt/scodoc-data, and a departement id)
+ /archives/
+ (where is usually /opt/scodoc-data, and a departement id (int))
Les PV de jurys et documents associés sont stockées dans un sous-repertoire de la forme
///
(formsemestre_id est ici FormSemestre.id)
Les documents liés à l'étudiant sont dans
- /docetuds///
+ /docetuds///
(etudid est ici Identite.id)
Les maquettes Apogée pour l'export des notes sont dans
- /apo_csv//-//.csv
+ /apo_csv//-//.csv
Un répertoire d'archive contient des fichiers quelconques, et un fichier texte nommé _description.txt
qui est une description (humaine, format libre) de l'archive.
@@ -56,11 +56,12 @@ import shutil
import time
import flask
-from flask import g
+from flask import g, request
import app.scodoc.sco_utils as scu
from config import Config
from app import log
+from app.models import Departement
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc.sco_exceptions import (
AccessDenied,
@@ -109,7 +110,8 @@ class BaseArchiver(object):
If directory does not yet exist, create it.
"""
self.initialize()
- dept_dir = os.path.join(self.root, g.scodoc_dept)
+ dept = Departement.query.filter_by(acronym=g.scodoc_dept).first()
+ dept_dir = os.path.join(self.root, str(dept.id))
try:
scu.GSL.acquire()
if not os.path.isdir(dept_dir):
@@ -128,7 +130,8 @@ class BaseArchiver(object):
:return: list of archive oids
"""
self.initialize()
- base = os.path.join(self.root, g.scodoc_dept) + os.path.sep
+ dept = Departement.query.filter_by(acronym=g.scodoc_dept).first()
+ base = os.path.join(self.root, str(dept.id)) + os.path.sep
dirs = glob.glob(base + "*")
return [os.path.split(x)[1] for x in dirs]
@@ -454,7 +457,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
)
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
descr,
cancelbutton="Annuler",
diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py
index d2482a8f15..0d871cda07 100644
--- a/app/scodoc/sco_archives_etud.py
+++ b/app/scodoc/sco_archives_etud.py
@@ -30,7 +30,7 @@
les dossiers d'admission et autres pièces utiles.
"""
import flask
-from flask import url_for, g
+from flask import url_for, g, request
import app.scodoc.sco_utils as scu
from app.scodoc import sco_import_etuds
@@ -153,7 +153,7 @@ def etud_upload_file_form(REQUEST, etudid):
% (scu.CONFIG.ETUD_MAX_FILE_SIZE // (1024 * 1024)),
]
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
("etudid", {"default": etudid, "input_type": "hidden"}),
@@ -313,7 +313,7 @@ def etudarchive_import_files_form(group_id, REQUEST=None):
]
F = html_sco_header.sco_footer()
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
("xlsfile", {"title": "Fichier Excel:", "input_type": "file", "size": 40}),
diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py
index 215985b9e6..6a5bbb96db 100644
--- a/app/scodoc/sco_bulletins.py
+++ b/app/scodoc/sco_bulletins.py
@@ -28,6 +28,7 @@
"""Génération des bulletins de notes
"""
+from app.models import formsemestre
import time
import pprint
import email
@@ -38,7 +39,7 @@ from email.header import Header
from reportlab.lib.colors import Color
import urllib
-from flask import g
+from flask import g, request
from flask import url_for
from flask_login import current_user
from flask_mail import Message
@@ -143,7 +144,7 @@ def formsemestre_bulletinetud_dict(
I["formsemestre_id"] = formsemestre_id
I["sem"] = nt.sem
if REQUEST:
- I["server_name"] = REQUEST.BASE0
+ I["server_name"] = request.url_root
else:
I["server_name"] = ""
@@ -1032,7 +1033,7 @@ def _formsemestre_bulletinetud_header_html(
),
"""
""" % (
- REQUEST.URL0,
+ request.base_url,
formsemestre_id,
n_group_td,
n_group_tp,
@@ -190,7 +192,7 @@ def formsemestre_estim_cost(
)
tab.html_before_table = h
tab.base_url = "%s?formsemestre_id=%s&n_group_td=%s&n_group_tp=%s&coef_tp=%s" % (
- REQUEST.URL0,
+ request.base_url,
formsemestre_id,
n_group_td,
n_group_tp,
diff --git a/app/scodoc/sco_debouche.py b/app/scodoc/sco_debouche.py
index df93897c73..2dc2f10a87 100644
--- a/app/scodoc/sco_debouche.py
+++ b/app/scodoc/sco_debouche.py
@@ -29,7 +29,7 @@
Rapport (table) avec dernier semestre fréquenté et débouché de chaque étudiant
"""
import http
-from flask import url_for, g
+from flask import url_for, g, request
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
@@ -64,7 +64,7 @@ def report_debouche_date(start_year=None, format="html", REQUEST=None):
"Généré par %s le " % sco_version.SCONAME + scu.timedate_human_repr() + ""
)
tab.caption = "Récapitulatif débouchés à partir du 1/1/%s." % start_year
- tab.base_url = "%s?start_year=%s" % (REQUEST.URL0, start_year)
+ tab.base_url = "%s?start_year=%s" % (request.base_url, start_year)
return tab.make_page(
title="""""",
init_qtip=True,
diff --git a/app/scodoc/sco_dept.py b/app/scodoc/sco_dept.py
index 349ad00952..3d342dcc45 100644
--- a/app/scodoc/sco_dept.py
+++ b/app/scodoc/sco_dept.py
@@ -28,7 +28,7 @@
"""Page accueil département (liste des semestres, etc)
"""
-from flask import g
+from flask import g, request
from flask_login import current_user
import app
@@ -131,7 +131,7 @@ def index_html(REQUEST=None, showcodes=0, showsemtable=0):
if not showsemtable:
H.append(
'Voir tous les semestres
'
- % REQUEST.URL0
+ % request.base_url
)
H.append(
@@ -242,7 +242,7 @@ def _sem_table_gt(sems, showcodes=False):
rows=sems,
html_class="table_leftalign semlist",
html_sortable=True,
- # base_url = '%s?formsemestre_id=%s' % (REQUEST.URL0, formsemestre_id),
+ # base_url = '%s?formsemestre_id=%s' % (request.base_url, formsemestre_id),
# caption='Maquettes enregistrées',
preferences=sco_preferences.SemPreferences(),
)
diff --git a/app/scodoc/sco_edit_formation.py b/app/scodoc/sco_edit_formation.py
index b52c3a53ea..3ee2357530 100644
--- a/app/scodoc/sco_edit_formation.py
+++ b/app/scodoc/sco_edit_formation.py
@@ -29,7 +29,7 @@
(portage from DTML)
"""
import flask
-from flask import g, url_for
+from flask import g, url_for, request
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
@@ -159,7 +159,7 @@ def formation_edit(formation_id=None, create=False, REQUEST=None):
)
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
("formation_id", {"default": formation_id, "input_type": "hidden"}),
diff --git a/app/scodoc/sco_edit_matiere.py b/app/scodoc/sco_edit_matiere.py
index 6b9e7d4379..f3fbabe011 100644
--- a/app/scodoc/sco_edit_matiere.py
+++ b/app/scodoc/sco_edit_matiere.py
@@ -29,7 +29,7 @@
(portage from DTML)
"""
import flask
-from flask import g, url_for
+from flask import g, url_for, request
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
@@ -116,7 +116,7 @@ associé.
""",
]
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
("ue_id", {"input_type": "hidden", "default": ue_id}),
@@ -202,7 +202,7 @@ def matiere_delete(matiere_id=None, REQUEST=None):
]
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(UE["formation_id"])
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(("matiere_id", {"input_type": "hidden"}),),
initvalues=M,
@@ -256,7 +256,7 @@ des notes.
associé.
"""
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
("matiere_id", {"input_type": "hidden"}),
@@ -323,4 +323,4 @@ def matiere_is_locked(matiere_id):
""",
{"matiere_id": matiere_id},
)
- return len(r) > 0
\ No newline at end of file
+ return len(r) > 0
diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py
index 3b4ce2540d..b0b6ca76f2 100644
--- a/app/scodoc/sco_edit_module.py
+++ b/app/scodoc/sco_edit_module.py
@@ -29,7 +29,7 @@
(portage from DTML)
"""
import flask
-from flask import url_for, g
+from flask import url_for, g, request
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
@@ -143,7 +143,7 @@ def module_create(matiere_id=None, REQUEST=None):
else:
default_num = 10
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
(
@@ -294,7 +294,7 @@ def module_delete(module_id=None, REQUEST=None):
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(Mod["formation_id"])
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(("module_id", {"input_type": "hidden"}),),
initvalues=Mod,
@@ -388,7 +388,7 @@ def module_edit(module_id=None, REQUEST=None):
)
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
(
diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py
index db19d56bde..6f51ee4d84 100644
--- a/app/scodoc/sco_edit_ue.py
+++ b/app/scodoc/sco_edit_ue.py
@@ -29,7 +29,7 @@
"""
import flask
-from flask import g, url_for
+from flask import g, url_for, request
from flask_login import current_user
import app.scodoc.notesdb as ndb
@@ -326,7 +326,11 @@ def ue_edit(ue_id=None, create=False, formation_id=None, REQUEST=None):
)
)
tf = TrivialFormulator(
- REQUEST.URL0, REQUEST.form, fw, initvalues=initvalues, submitlabel=submitlabel
+ request.base_url,
+ REQUEST.form,
+ fw,
+ initvalues=initvalues,
+ submitlabel=submitlabel,
)
if tf[0] == 0:
X = """
@@ -1033,7 +1037,7 @@ def formation_table_recap(formation_id, format="html", REQUEST=None):
caption=title,
html_caption=title,
html_class="table_leftalign",
- base_url="%s?formation_id=%s" % (REQUEST.URL0, formation_id),
+ base_url="%s?formation_id=%s" % (request.base_url, formation_id),
page_title=title,
html_title="" + title + " ",
pdf_title=title,
diff --git a/app/scodoc/sco_etape_apogee.py b/app/scodoc/sco_etape_apogee.py
index 5409c58eb6..582497e95e 100644
--- a/app/scodoc/sco_etape_apogee.py
+++ b/app/scodoc/sco_etape_apogee.py
@@ -32,11 +32,11 @@
Voir sco_apogee_csv.py pour la structure du fichier Apogée.
Stockage: utilise sco_archive.py
- => /opt/scodoc/var/scodoc/archives/apo_csv/RT/2016-1/2016-07-03-16-12-19/V3ASR.csv
+ => /opt/scodoc/var/scodoc/archives/apo_csv//2016-1/2016-07-03-16-12-19/V3ASR.csv
pour une maquette de l'année scolaire 2016, semestre 1, etape V3ASR
ou bien (à partir de ScoDoc 1678) :
- /opt/scodoc/var/scodoc/archives/apo_csv/RT/2016-1/2016-07-03-16-12-19/V3ASR!111.csv
+ /opt/scodoc/var/scodoc/archives/apo_csv//2016-1/2016-07-03-16-12-19/V3ASR!111.csv
pour une maquette de l'étape V3ASR version VDI 111.
La version VDI sera ignorée sauf si elle est indiquée dans l'étape du semestre.
diff --git a/app/scodoc/sco_etape_apogee_view.py b/app/scodoc/sco_etape_apogee_view.py
index 1b625bcd5d..a4440bf7b1 100644
--- a/app/scodoc/sco_etape_apogee_view.py
+++ b/app/scodoc/sco_etape_apogee_view.py
@@ -32,7 +32,7 @@ import io
from zipfile import ZipFile
import flask
-from flask import url_for, g, send_file
+from flask import url_for, g, send_file, request
# from werkzeug.utils import send_file
@@ -250,7 +250,7 @@ def apo_semset_maq_status(
"""
"""
- % (REQUEST.URL0, formsemestre_id),
+ % (request.base_url, formsemestre_id),
]
H.append("""""")
for (v, e) in (
@@ -1928,7 +1928,7 @@ def appreciation_add_form(
else:
initvalues = {}
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
descr,
initvalues=initvalues,
diff --git a/app/views/scolar.py b/app/views/scolar.py
index 781b966fdb..e57e0a01bd 100644
--- a/app/views/scolar.py
+++ b/app/views/scolar.py
@@ -267,7 +267,7 @@ def showEtudLog(etudid, format="html", REQUEST=None):
rows=ops,
html_sortable=True,
html_class="table_leftalign",
- base_url="%s?etudid=%s" % (REQUEST.URL0, etudid),
+ base_url="%s?etudid=%s" % (request.base_url, etudid),
page_title="Opérations sur %(nomprenom)s" % etud,
html_title="Opérations effectuées sur l'étudiant %(nomprenom)s " % etud,
filename="log_" + scu.make_filename(etud["nomprenom"]),
@@ -617,7 +617,7 @@ def formChangeCoordonnees(etudid, REQUEST):
)
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
("adresse_id", {"input_type": "hidden"}),
@@ -823,7 +823,7 @@ def formChangePhoto(etudid=None, REQUEST=None):
""",
]
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
("etudid", {"default": etudid, "input_type": "hidden"}),
@@ -1496,7 +1496,7 @@ def _etudident_create_or_edit_form(REQUEST, edit):
]
initvalues["dont_check_homonyms"] = False
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
descr,
submitlabel=submitlabel,
@@ -1748,7 +1748,7 @@ def check_group_apogee(group_id, REQUEST=None, etat=None, fix=False, fixmail=Fal
Retour au semestre
"""
% (
- REQUEST.URL0,
+ request.base_url,
formsemestre_id,
scu.strnone(group_id),
scu.strnone(etat),
@@ -1767,7 +1767,7 @@ def check_group_apogee(group_id, REQUEST=None, etat=None, fix=False, fixmail=Fal
Retour au semestre
"""
% (
- REQUEST.URL0,
+ request.base_url,
formsemestre_id,
scu.strnone(group_id),
scu.strnone(etat),
@@ -1856,7 +1856,7 @@ def form_students_import_excel(REQUEST, formsemestre_id=None):
F = html_sco_header.sco_footer()
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
(
@@ -2021,7 +2021,7 @@ def form_students_import_infos_admissions(REQUEST, formsemestre_id=None):
)
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
(
diff --git a/app/views/users.py b/app/views/users.py
index e69b02a7d0..c9f680d617 100644
--- a/app/views/users.py
+++ b/app/views/users.py
@@ -342,7 +342,7 @@ def create_user_form(REQUEST, user_name=None, edit=0, all_roles=1):
)
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
descr,
initvalues=initvalues,
@@ -529,7 +529,7 @@ def import_users_form(REQUEST=None):
)
F = html_sco_header.sco_footer()
tf = TrivialFormulator(
- REQUEST.URL0,
+ request.base_url,
REQUEST.form,
(
(
diff --git a/sco_version.py b/sco_version.py
index 8fb397ce7a..cbe325861a 100644
--- a/sco_version.py
+++ b/sco_version.py
@@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
-SCOVERSION = "9.0.28"
+SCOVERSION = "9.0.29"
SCONAME = "ScoDoc"
diff --git a/scodoc.py b/scodoc.py
index dd7e3f1107..c32a84195d 100755
--- a/scodoc.py
+++ b/scodoc.py
@@ -264,6 +264,17 @@ def create_dept(dept): # create-dept
return 0
+@app.cli.command()
+@click.argument("depts", nargs=-1)
+def list_depts(depts=""): # list-dept
+ """If dept exists, print it, else nothing.
+ Called without arguments, list all depts along with their ids.
+ """
+ for dept in models.Departement.query.order_by(models.Departement.id):
+ if not depts or dept.acronym in depts:
+ print(f"{dept.id}\t{dept.acronym}")
+
+
@app.cli.command()
@with_appcontext
def import_scodoc7_users(): # import-scodoc7-users
diff --git a/tools/migrate_from_scodoc7.sh b/tools/migrate_from_scodoc7.sh
index 67ba70d662..f8af51bd92 100755
--- a/tools/migrate_from_scodoc7.sh
+++ b/tools/migrate_from_scodoc7.sh
@@ -65,6 +65,27 @@ else
SCODOC7_HOME="$1" # racine de l'archive importée
fi
+# --- 1. Vérifie qu'aucun des départements à importer n'existe déjà
+check_existing_depts() {
+ sco7_depts=""
+ for f in "${SCODOC7_HOME}/var/scodoc/"/config/depts/*.cfg
+ do
+ dept=$(basename "${f%.*}") # le nom du dept peut-être en minuscules
+ sco9_name=$(echo "$dept" | tr "[:lower:]" "[:upper:]") # acronym ScoDoc 9 toujours en majuscule
+ sco7_depts="$sco7_depts $sco9_name"
+ done
+ nb_existing=$(echo "$sco7_depts" | su -c "cd $SCODOC_DIR && source venv/bin/activate && xargs flask list-depts" "$SCODOC_USER" | wc -l)
+ if [ "$nb_existing" -gt 0 ]
+ then
+ echo "Attention: il existe déjà $nb_existing départements de même nom que celles"
+ echo "que vous souhaitez importer !"
+ echo "Département qui allaient être importées: $sco7_depts"
+ echo "=> arrêt."
+ exit 2
+ fi
+}
+
+
# --- 2. Propriétaire des bases de données pour import "en place"
# Bases appartenant à www-data: les attribue à "scodoc" pour le script de migration SQL
# qui tourne en tant que "scodoc"
@@ -160,6 +181,8 @@ migrate_local_files() {
# ------ MAIN
+check_existing_depts
+
change_scodoc_file_ownership
if [ "$INPLACE" == 1 ]
@@ -190,10 +213,15 @@ su -c "(cd $SCODOC_DIR && source venv/bin/activate && flask import-scodoc7-users
# ----- Migration bases départements
# les départements ScoDoc7 ont été déplacés dans /opt/scodoc-data/config/dept
-# (ils ne sont d'ailleurs plus utilisés par ScoDoc 9)
+# (ils ne sont plus utilisés par ScoDoc 9)
+# Le nom du dept peut-être en minuscules et/ou majuscules (Geii, GEII...)
+# Le nom de BD ScoDoc7 est toujours en majuscules (SCOGEII)
+# Rappel: les archives ScoDoc7 étaient .../archives//... donc minuscules/majuscules
+# alors qu'en ScoDoc9 elles seront .../archives// : le numéro interne du département,
+# puisque l'acronyme peut changer.
for f in "$SCODOC_VAR_DIR"/config/depts/*.cfg
do
- dept=$(basename "${f%.*}") # le nom du dept peut-être en minuscules et/ou majuscules (geii, GEII...)
+ dept=$(basename "${f%.*}") # le nom du dept peut-être en minuscules
db_name=$(echo "SCO$dept" | tr "[:lower:]" "[:upper:]") # nom de BD toujours en majuscule
echo
echo "----------------------------------------------"
diff --git a/tools/migrate_scodoc7_archives.py b/tools/migrate_scodoc7_archives.py
index 55acd84219..6e7553db68 100644
--- a/tools/migrate_scodoc7_archives.py
+++ b/tools/migrate_scodoc7_archives.py
@@ -4,6 +4,7 @@
import glob
import os
import shutil
+import sys
from app.models import Departement
from app.models.formsemestre import FormSemestre
@@ -25,7 +26,8 @@ def migrate_scodoc7_dept_archive(dept_name=""):
migrate_docetuds(dept)
# ApoCSVArchiver:
- # /opt/scodoc-data/archives/apo_csv// ne bouge pas
+ # /opt/scodoc-data/archives/apo_csv// -> apo_csv//
+ migrate_apo_csv(dept)
def migrate_sem_archives(dept):
@@ -35,7 +37,7 @@ def migrate_sem_archives(dept):
for sem in FormSemestre.query.filter_by(dept_id=dept.id):
n += 1
arch_dir7 = f"/opt/scodoc-data/archives/{dept.acronym}/{sem.scodoc7_id}"
- arch_dir9 = f"/opt/scodoc-data/archives/{dept.acronym}/{sem.id}"
+ arch_dir9 = f"/opt/scodoc-data/archives/{dept.id}/{sem.id}"
if os.path.exists(arch_dir7):
n_moves += 1
if not os.path.exists(arch_dir9):
@@ -58,7 +60,7 @@ def migrate_docetuds(dept):
arch_dir7 = (
f"/opt/scodoc-data/archives/docetuds/{dept.acronym}/{etud.scodoc7_id}"
)
- arch_dir9 = f"/opt/scodoc-data/archives/docetuds/{dept.acronym}/{etud.id}"
+ arch_dir9 = f"/opt/scodoc-data/archives/docetuds/{dept.id}/{etud.id}"
if os.path.exists(arch_dir7):
n_moves += 1
if not os.path.exists(arch_dir9):
@@ -70,3 +72,25 @@ def migrate_docetuds(dept):
# print(f"\tmoving {arch}")
shutil.move(arch, arch_dir9)
# print(f"moved {n_moves}/{n} etuds")
+
+
+def migrate_apo_csv(dept):
+ "/opt/scodoc-data/archives/apo_csv// -> .../apo_csv//"
+ arch_dir7 = f"/opt/scodoc-data/archives/apo_csv/{dept.acronym}"
+ arch_dir7_upper = f"/opt/scodoc-data/archives/apo_csv/{dept.acronym.upper()}"
+ arch_dir9 = f"/opt/scodoc-data/archives/apo_csv/{dept.id}"
+ if os.path.exists(arch_dir7):
+ if os.path.exists(arch_dir9):
+ print(
+ f"Warning: {arch_dir9} exist ! not moving {arch_dir7}", file=sys.stderr
+ )
+ else:
+ shutil.move(arch_dir7, arch_dir9)
+ elif os.path.exists(arch_dir7_upper):
+ if os.path.exists(arch_dir9):
+ print(
+ f"Warning: {arch_dir9} exist ! not moving {arch_dir7_upper}",
+ file=sys.stderr,
+ )
+ else:
+ shutil.move(arch_dir7_upper, arch_dir9)