forked from ScoDoc/ScoDoc
Migration: tolère dates logs aberrantes, et élimine relations manquantes dans entreprises
This commit is contained in:
parent
30e7fd516b
commit
01dcd8cccd
16
scodoc.py
16
scodoc.py
@ -278,13 +278,29 @@ def user_role(username, dept_acronym=None, add_role_name=None, remove_role_name=
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def abort_if_false(ctx, param, value):
|
||||
if not value:
|
||||
ctx.abort()
|
||||
|
||||
|
||||
@app.cli.command()
|
||||
@click.option(
|
||||
"--yes",
|
||||
is_flag=True,
|
||||
callback=abort_if_false,
|
||||
expose_value=False,
|
||||
prompt=f"""Attention: Cela va effacer toutes les données du département
|
||||
(étudiants, notes, formations, etc)
|
||||
Voulez-vous vraiment continuer ?
|
||||
""",
|
||||
)
|
||||
@click.argument("dept")
|
||||
def delete_dept(dept): # delete-dept
|
||||
"""Delete existing departement"""
|
||||
from app.scodoc import notesdb as ndb
|
||||
from app.scodoc import sco_dept
|
||||
|
||||
if False:
|
||||
click.confirm(
|
||||
f"""Attention: Cela va effacer toutes les données du département {dept}
|
||||
(étudiants, notes, formations, etc)
|
||||
|
@ -170,6 +170,11 @@ def import_scodoc7_dept(dept_id: str, dept_db_uri=None):
|
||||
logging.info(f"connecting to database {dept_db_uri}")
|
||||
cnx = psycopg2.connect(dept_db_uri)
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
# FIX : des dates aberrantes (dans le futur) peuvent tenir en SQL mais pas en Python
|
||||
cursor.execute(
|
||||
"""UPDATE scolar_events SET event_date='2021-09-30' WHERE event_date > '2200-01-01'"""
|
||||
)
|
||||
cnx.commit()
|
||||
# Create dept:
|
||||
dept = models.Departement(acronym=dept_id, description="migré de ScoDoc7")
|
||||
db.session.add(dept)
|
||||
@ -374,6 +379,8 @@ def convert_object(
|
||||
new_ref = id_from_scodoc7[old_ref]
|
||||
elif (not is_table) and table_name in {
|
||||
"scolog",
|
||||
"entreprise_correspondant",
|
||||
"entreprise_contact",
|
||||
"etud_annotations",
|
||||
"notes_notes_log",
|
||||
"scolar_news",
|
||||
@ -389,7 +396,6 @@ def convert_object(
|
||||
new_ref = None
|
||||
elif is_table and table_name in {
|
||||
"notes_semset_formsemestre",
|
||||
"entreprise_contact",
|
||||
}:
|
||||
# pour anciennes installs où des relations n'avait pas été déclarées clés étrangères
|
||||
# eg: notes_semset_formsemestre.semset_id n'était pas une clé
|
||||
|
Loading…
Reference in New Issue
Block a user