Compare commits

...

2 Commits

Author SHA1 Message Date
leonard_montalbano
1083f60020 ajout ref competence dans la création de la fakedatabase (pas encore fonctionnel) 2022-06-17 15:50:06 +02:00
leonard_montalbano
53a4b6cdd7 ajout de la route /formations 2022-06-17 15:46:17 +02:00
3 changed files with 292 additions and 0 deletions

View File

@ -10,6 +10,22 @@ from app.models.formations import Formation
from app.scodoc import sco_formations from app.scodoc import sco_formations
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
@bp.route("/formations", methods=["GET"])
@token_auth.login_required
@token_permission_required(Permission.APIView)
def formations():
"""
Retourne la liste de toutes les formations (tous départements)
Exemple de résultat :
"""
# Récupération de toutes les formations
list_formations = models.Formation.query.all()
# Mise en forme des données
data = [d.to_dict() for d in list_formations]
return jsonify(data)
@bp.route("/formations_ids", methods=["GET"]) @bp.route("/formations_ids", methods=["GET"])
@token_auth.login_required @token_auth.login_required

View File

@ -81,6 +81,40 @@ class ApcReferentielCompetences(db.Model, XMLModel):
) )
formations = db.relationship("Formation", backref="referentiel_competence") 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): def __repr__(self):
return f"<ApcReferentielCompetences {self.id} {self.specialite}>" return f"<ApcReferentielCompetences {self.id} {self.specialite}>"
@ -143,6 +177,32 @@ class ApcCompetence(db.Model, XMLModel):
cascade="all, delete-orphan", 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): def __repr__(self):
return f"<ApcCompetence {self.id} {self.titre}>" return f"<ApcCompetence {self.id} {self.titre}>"
@ -169,6 +229,12 @@ class ApcSituationPro(db.Model, XMLModel):
) )
libelle = db.Column(db.Text(), nullable=False) libelle = db.Column(db.Text(), nullable=False)
# aucun attribut (le text devient le libellé) # 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): def to_dict(self):
return {"libelle": self.libelle} return {"libelle": self.libelle}
@ -181,6 +247,11 @@ class ApcComposanteEssentielle(db.Model, XMLModel):
) )
libelle = db.Column(db.Text(), nullable=False) 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): def to_dict(self):
return {"libelle": self.libelle} return {"libelle": self.libelle}
@ -201,6 +272,14 @@ class ApcNiveau(db.Model, XMLModel):
cascade="all, delete-orphan", 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): def __repr__(self):
return f"<{self.__class__.__name__} ordre={self.ordre}>" return f"<{self.__class__.__name__} ordre={self.ordre}>"
@ -227,6 +306,13 @@ class ApcAppCritique(db.Model, XMLModel):
backref=db.backref("app_critiques", lazy="dynamic"), 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: def to_dict(self) -> dict:
return {"libelle": self.libelle} return {"libelle": self.libelle}
@ -263,6 +349,14 @@ class ApcParcours(db.Model, XMLModel):
cascade="all, delete-orphan", 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): def __repr__(self):
return f"<{self.__class__.__name__} {self.code}>" return f"<{self.__class__.__name__} {self.code}>"
@ -282,6 +376,11 @@ class ApcAnneeParcours(db.Model, XMLModel):
) )
ordre = db.Column(db.Integer) 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): def __repr__(self):
return f"<{self.__class__.__name__} ordre={self.ordre}>" return f"<{self.__class__.__name__} ordre={self.ordre}>"

View File

@ -36,8 +36,18 @@ from app.models import (
Identite, Identite,
ModuleImpl, ModuleImpl,
NotesNotes, NotesNotes,
ApcReferentielCompetences,
ApcCompetence,
) )
from app import db from app import db
from app.models.but_refcomp import (
ApcParcours,
ApcAnneeParcours,
ApcSituationPro,
ApcComposanteEssentielle,
ApcNiveau,
ApcAppCritique,
)
from app.scodoc import ( from app.scodoc import (
sco_cache, sco_cache,
sco_evaluation_db, sco_evaluation_db,
@ -257,6 +267,172 @@ def saisie_notes_evaluations(formsemestre: FormSemestre, user: User):
saisir_notes(evaluation.id, condition_saisie_notes) 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(): def init_test_database():
"""Appelé par la commande `flask init-test-database` """Appelé par la commande `flask init-test-database`
@ -271,6 +447,7 @@ def init_test_database():
create_evaluations(formsemestre) create_evaluations(formsemestre)
inscrit_etudiants(etuds, formsemestre) inscrit_etudiants(etuds, formsemestre)
saisie_notes_evaluations(formsemestre, user_lecteur) saisie_notes_evaluations(formsemestre, user_lecteur)
create_ref_comp(formation)
# à compléter # à compléter
# - groupes # - groupes
# - absences # - absences