From 1083f60020b9fe827d7f5a60fc3929a8120148c4 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Fri, 17 Jun 2022 15:50:06 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20ref=20competence=20dans=20la=20cr=C3=A9?= =?UTF-8?q?ation=20de=20la=20fakedatabase=20(pas=20encore=20fonctionnel)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/but_refcomp.py | 99 ++++++++++ .../fakedatabase/create_test_api_database.py | 177 ++++++++++++++++++ 2 files changed, 276 insertions(+) diff --git a/app/models/but_refcomp.py b/app/models/but_refcomp.py index 0750f1a9..eda9c9a1 100644 --- a/app/models/but_refcomp.py +++ b/app/models/but_refcomp.py @@ -81,6 +81,40 @@ class ApcReferentielCompetences(db.Model, XMLModel): ) formations = db.relationship("Formation", backref="referentiel_competence") + def __init__( + self, + id, + dept_id, + annexe, + specialite, + specialite_long, + type_titre, + type_structure, + type_departement, + version_orebut, + _xml_attribs, + scodoc_date_loaded, + scodoc_orig_filename, + competences, + parcours, + formations, + ): + self.id = id + self.dept_id = dept_id + self.annexe = annexe + self.specialite = specialite + self.specialite_long = specialite_long + self.type_titre = type_titre + self.type_structure = type_structure + self.type_departement = type_departement + self.version_orebut = version_orebut + self._xml_attribs = _xml_attribs + self.scodoc_date_loaded = scodoc_date_loaded + self.scodoc_orig_filename = scodoc_orig_filename + self.competences = competences + self.parcours = parcours + self.formations = formations + def __repr__(self): return f"" @@ -143,6 +177,32 @@ class ApcCompetence(db.Model, XMLModel): cascade="all, delete-orphan", ) + def __init__( + self, + id, + referentiel_id, + id_orebut, + titre, + titre_long, + couleur, + numero, + _xml_attribs, + situations, + composantes_essentielles, + niveaux, + ): + self.id = id + self.referentiel_id = referentiel_id + self.id_orebut = id_orebut + self.titre = titre + self.titre_long = titre_long + self.couleur = couleur + self.numero = numero + self._xml_attribs = _xml_attribs + self.situations = situations + self.composantes_essentielles = composantes_essentielles + self.niveaux = niveaux + def __repr__(self): return f"" @@ -169,6 +229,12 @@ class ApcSituationPro(db.Model, XMLModel): ) libelle = db.Column(db.Text(), nullable=False) # aucun attribut (le text devient le libellé) + + def __init__(self, id, competence_id, libelle): + self.id = id + self.competence_id = competence_id + self.libelle = libelle + def to_dict(self): return {"libelle": self.libelle} @@ -181,6 +247,11 @@ class ApcComposanteEssentielle(db.Model, XMLModel): ) libelle = db.Column(db.Text(), nullable=False) + def __init__(self, id, competence_id, libelle): + self.id = id + self.competence_id = competence_id + self.libelle = libelle + def to_dict(self): return {"libelle": self.libelle} @@ -201,6 +272,14 @@ class ApcNiveau(db.Model, XMLModel): cascade="all, delete-orphan", ) + def __init__(self, id, competence_id, libelle, annee, ordre, app_critiques): + self.id = id + self.competence_id = competence_id + self.libelle = libelle + self.annee = annee + self.ordre = ordre + self.app_critiques = app_critiques + def __repr__(self): return f"<{self.__class__.__name__} ordre={self.ordre}>" @@ -227,6 +306,13 @@ class ApcAppCritique(db.Model, XMLModel): backref=db.backref("app_critiques", lazy="dynamic"), ) + def __init__(self, id, niveau_id, code, libelle, modules): + self.id = id + self.niveau_id = niveau_id + self.code = code + self.libelle = libelle + self.modules = modules + def to_dict(self) -> dict: return {"libelle": self.libelle} @@ -263,6 +349,14 @@ class ApcParcours(db.Model, XMLModel): cascade="all, delete-orphan", ) + def __init__(self, id, referentiel_id, numero, code, libelle, annes): + self.id = id + self.referentiel_id = referentiel_id + self.numero = numero + self.code = code + self.libelle = libelle + self.annes = annes + def __repr__(self): return f"<{self.__class__.__name__} {self.code}>" @@ -282,6 +376,11 @@ class ApcAnneeParcours(db.Model, XMLModel): ) ordre = db.Column(db.Integer) + def __init__(self, id, parcours_id, ordre): + self.id = id + self.parcours_id = parcours_id + self.ordre = ordre + def __repr__(self): return f"<{self.__class__.__name__} ordre={self.ordre}>" diff --git a/tools/fakedatabase/create_test_api_database.py b/tools/fakedatabase/create_test_api_database.py index 0195a82d..8fe4e96c 100644 --- a/tools/fakedatabase/create_test_api_database.py +++ b/tools/fakedatabase/create_test_api_database.py @@ -36,8 +36,18 @@ from app.models import ( Identite, ModuleImpl, NotesNotes, + ApcReferentielCompetences, + ApcCompetence, ) from app import db +from app.models.but_refcomp import ( + ApcParcours, + ApcAnneeParcours, + ApcSituationPro, + ApcComposanteEssentielle, + ApcNiveau, + ApcAppCritique, +) from app.scodoc import ( sco_cache, sco_evaluation_db, @@ -257,6 +267,172 @@ def saisie_notes_evaluations(formsemestre: FormSemestre, user: User): saisir_notes(evaluation.id, condition_saisie_notes) +def create_ref_comp(formation: Formation): + """ + Créer un referentiel de competences + """ + ### ApcSituationPro ### + apc_situation_pro_id = 1 + apc_situation_pro_competence_id = 1 + apc_situation_pro_libelle = "" + + apc_situation_pro = ApcSituationPro( + apc_situation_pro_id, apc_situation_pro_competence_id, apc_situation_pro_libelle + ) + db.session.add(apc_situation_pro) + db.session.commit() + + ### ApcComposanteEssentielle ### + apc_composante_essentielle_id = 1 + apc_composante_essentielle_competence_id = 1 + apc_composante_essentielle_libelle = "" + + apc_composante_essentielle = ApcComposanteEssentielle( + apc_composante_essentielle_id, + apc_composante_essentielle_competence_id, + apc_composante_essentielle_libelle, + ) + db.session.add(apc_composante_essentielle) + db.session.commit() + + ### ApcAppCritique ### + apc_app_critique_id = 1 + apc_app_critique_niveau_id = 1 + apc_app_critique_code = "" + apc_app_critique_libelle = "" + apc_app_critique_modules = formation.modules + + apc_app_critique = ApcAppCritique( + apc_app_critique_id, + apc_app_critique_niveau_id, + apc_app_critique_code, + apc_app_critique_libelle, + apc_app_critique_modules, + ) + db.session.add(apc_app_critique) + db.session.commit() + + ### ApcNiveau ### + apc_niveau_id = 1 + apc_niveau_competence_id = 1 + apc_niveau_libelle = "" + apc_niveau_annee = "" + apc_niveau_ordre = 1 + apc_niveau_app_critiques = apc_app_critique + + apc_niveau = ApcNiveau( + apc_niveau_id, + apc_niveau_competence_id, + apc_niveau_libelle, + apc_niveau_annee, + apc_niveau_ordre, + apc_niveau_app_critiques, + ) + db.session.add(apc_niveau) + db.session.commit() + + ### ApcCompetence ### + apc_competence_id = 1 + apc_competence_referentiel_id = 1 + apc_competence_id_orebut = "" + apc_competence_titre = "" + apc_competence_titre_long = "" + apc_competence_couleur = "" + apc_competence_numero = 1 + apc_competence_xml_attribs = { # xml_attrib : attribute + "id": "id_orebut", + "nom_court": "titre", # was name + "libelle_long": "titre_long", + } + apc_competence_situations = apc_situation_pro + apc_competence_composantes_essentielles = apc_composante_essentielle + apc_competence_niveaux = apc_niveau + + apc_competence = ApcCompetence( + apc_competence_id, + apc_competence_referentiel_id, + apc_competence_id_orebut, + apc_competence_titre, + apc_competence_titre_long, + apc_competence_couleur, + apc_competence_numero, + apc_competence_xml_attribs, + apc_competence_situations, + apc_competence_composantes_essentielles, + apc_competence_niveaux, + ) + db.session.add(apc_competence) + db.session.commit() + + ### ApcAnneeParcours ### + apc_annee_parcours_id = 1 + apc_annee_parcours_parcours_id = 1 + apc_annee_parcours_ordre = 1 + + ap_annee_parcours = ApcAnneeParcours( + apc_annee_parcours_id, apc_annee_parcours_parcours_id, apc_annee_parcours_ordre + ) + + ### ApcParcours ### + apc_parcours_id = 1 + apc_parcours_referentiel_id = 1 + apc_parcours_numero = 1 + apc_parcours_code = "" + apc_parcours_libelle = "" + apc_parcours_annees = ap_annee_parcours + + apc_parcours = ApcParcours( + apc_parcours_id, + apc_parcours_referentiel_id, + apc_parcours_numero, + apc_parcours_code, + apc_parcours_libelle, + apc_parcours_annees, + ) + db.session.add(apc_parcours) + db.session.commit() + + ### ApcReferentielCompetences ### + apc_referentiel_competences_id = 1 + apc_referentiel_competences_dept_id = 1 + apc_referentiel_competences_annexe = "" + apc_referentiel_competences_specialite = "" + apc_referentiel_competences_specialite_long = "" + apc_referentiel_competences_type_titre = "" + apc_referentiel_competences_type_structure = "" + apc_referentiel_competences_type_departement = "" + apc_referentiel_competences_version_orebut = "" + apc_referentiel_competences_xml_attribs = { + "type": "type_titre", + "version": "version_orebut", + } + apc_referentiel_competences_scodoc_date_loaded = "" + apc_referentiel_competences_scodoc_orig_filename = "" + apc_referentiel_competences_competences = apc_competence + apc_referentiel_competences_parcours = apc_parcours + apc_referentiel_competences_formations = formation + + apc_referentiel_competences = ApcReferentielCompetences( + apc_referentiel_competences_id, + apc_referentiel_competences_dept_id, + apc_referentiel_competences_annexe, + apc_referentiel_competences_specialite, + apc_referentiel_competences_specialite_long, + apc_referentiel_competences_type_titre, + apc_referentiel_competences_type_structure, + apc_referentiel_competences_type_departement, + apc_referentiel_competences_version_orebut, + apc_referentiel_competences_xml_attribs, + apc_referentiel_competences_scodoc_date_loaded, + apc_referentiel_competences_scodoc_orig_filename, + apc_referentiel_competences_competences, + apc_referentiel_competences_parcours, + apc_referentiel_competences_formations, + ) + db.session.add(apc_referentiel_competences) + db.session.commit() + + def init_test_database(): """Appelé par la commande `flask init-test-database` @@ -271,6 +447,7 @@ def init_test_database(): create_evaluations(formsemestre) inscrit_etudiants(etuds, formsemestre) saisie_notes_evaluations(formsemestre, user_lecteur) + create_ref_comp(formation) # à compléter # - groupes # - absences