1
0
forked from ScoDoc/ScoDoc

oups: fichiers oubliés.

This commit is contained in:
Emmanuel Viennet 2021-09-16 22:31:47 +02:00
parent 72e075530c
commit 80238545f3
2 changed files with 100 additions and 0 deletions

View File

@ -0,0 +1,28 @@
"""Flag bloquage calcul moyennes
Revision ID: 669065fb2d20
Revises: a217bf588f4c
Create Date: 2021-09-16 22:04:11.624632
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '669065fb2d20'
down_revision = 'a217bf588f4c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('notes_formsemestre', sa.Column('block_moyennes', sa.Boolean(), server_default='false', nullable=False))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('notes_formsemestre', 'block_moyennes')
# ### end Alembic commands ###

View File

@ -0,0 +1,72 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
import glob
import os
import shutil
from app.models import Departement
from app.models.formsemestre import FormSemestre
from app.models.etudiants import Identite
def migrate_scodoc7_dept_archive(dept_name=""):
if dept_name:
depts = Departement.query.filter_by(acronym=dept_name)
else:
depts = Departement.query
for dept in depts:
print(f"Migrating {dept.acronym} archives...")
# SemsArchiver
# /opt/scodoc-data/archives/<dept>/<scodoc7id> -> formsemestre_id
migrate_sem_archives(dept)
# EtudsArchiver:
migrate_docetuds(dept)
# ApoCSVArchiver:
# /opt/scodoc-data/archives/apo_csv/<dept>/ ne bouge pas
def migrate_sem_archives(dept):
"/opt/scodoc-data/archives/<dept>/<scodoc7id> -> formsemestre_id"
n = 0
n_moves = 0
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}"
if os.path.exists(arch_dir7):
n_moves += 1
if not os.path.exists(arch_dir9):
# print(f"renaming {arch_dir7} to {arch_dir9}")
shutil.move(arch_dir7, arch_dir9)
else:
# print(f"merging {arch_dir7} with {arch_dir9}")
for arch in glob.glob(f"{arch_dir7}/*"):
# print(f"\tmoving {arch}")
shutil.move(arch, arch_dir9)
# print(f"moved {n_moves}/{n} sems")
def migrate_docetuds(dept):
"/opt/scodoc-data/archives/docetuds/<dept>/<scodoc7_id>/ -> etudid"
n = 0
n_moves = 0
for etud in Identite.query.filter_by(dept_id=dept.id):
n += 1
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}"
if os.path.exists(arch_dir7):
n_moves += 1
if not os.path.exists(arch_dir9):
# print(f"renaming {arch_dir7} to {arch_dir9}")
shutil.move(arch_dir7, arch_dir9)
else:
# print(f"merging {arch_dir7} with {arch_dir9}")
for arch in glob.glob(f"{arch_dir7}/*"):
# print(f"\tmoving {arch}")
shutil.move(arch, arch_dir9)
# print(f"moved {n_moves}/{n} etuds")