1
0
forked from ScoDoc/ScoDoc

nouveau format refcomp Orebut + supprime migration entreprises

This commit is contained in:
Emmanuel Viennet 2022-01-05 23:42:11 +01:00
commit b1a3a15a94
8 changed files with 95 additions and 309 deletions

View File

@ -54,8 +54,8 @@ def orebut_import_refcomp(xml_data: str, dept_id: int, orig_filename=None):
composantes = competence.find("composantes_essentielles") composantes = competence.find("composantes_essentielles")
for composante in composantes: for composante in composantes:
libelle = "".join(composante.itertext()).strip() libelle = "".join(composante.itertext()).strip()
ce = ApcComposanteEssentielle(libelle=libelle) compo_ess = ApcComposanteEssentielle(libelle=libelle)
c.composantes_essentielles.append(ce) c.composantes_essentielles.append(compo_ess)
# --- NIVEAUX (années) # --- NIVEAUX (années)
niveaux = competence.find("niveaux") niveaux = competence.find("niveaux")
for niveau in niveaux: for niveau in niveaux:
@ -77,17 +77,14 @@ def orebut_import_refcomp(xml_data: str, dept_id: int, orig_filename=None):
a = ApcAnneeParcours(**ApcAnneeParcours.attr_from_xml(annee.attrib)) a = ApcAnneeParcours(**ApcAnneeParcours.attr_from_xml(annee.attrib))
parc.annees.append(a) parc.annees.append(a)
for competence in annee.findall("competence"): for competence in annee.findall("competence"):
nom_court = competence.attrib["nom_court"] comp_id_orebut = competence.attrib["id"]
XXX
niveau = int(competence.attrib["niveau"]) niveau = int(competence.attrib["niveau"])
# Retrouve la competence # Retrouve la competence
comp = ref.competences.filter_by(titre=nom).all() comp = ref.competences.filter_by(id_orebut=comp_id_orebut).first()
if len(comp) == 0: if comp is None:
raise ScoFormatError(f"competence {nom} référencée mais on définie") raise ScoFormatError(f"competence {comp_id_orebut} non définie")
elif len(comp) > 1:
raise ScoFormatError(f"competence {nom} ambigüe")
ass = ApcParcoursNiveauCompetence( ass = ApcParcoursNiveauCompetence(
niveau=niveau, annee_parcours=a, competence=comp[0] niveau=niveau, annee_parcours=a, competence=comp
) )
db.session.add(ass) db.session.add(ass)

View File

@ -49,6 +49,7 @@ class XMLModel:
class ApcReferentielCompetences(db.Model, XMLModel): class ApcReferentielCompetences(db.Model, XMLModel):
"Référentiel de compétence d'une spécialité"
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True) dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True)
annexe = db.Column(db.Text()) annexe = db.Column(db.Text())
@ -103,18 +104,13 @@ class ApcReferentielCompetences(db.Model, XMLModel):
class ApcCompetence(db.Model, XMLModel): class ApcCompetence(db.Model, XMLModel):
__table_args__ = ( "Compétence"
# les compétences dans Orébut sont identifiées par leur "titre"
# unique au sein d'un référentiel:
db.UniqueConstraint(
"referentiel_id", "titre", name="apc_competence_referentiel_id_titre_key"
),
)
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
referentiel_id = db.Column( referentiel_id = db.Column(
db.Integer, db.ForeignKey("apc_referentiel_competences.id"), nullable=False db.Integer, db.ForeignKey("apc_referentiel_competences.id"), nullable=False
) )
id_orebut = db.Column(db.Integer, nullable=True, index=True, unique=True) # les compétences dans Orébut sont identifiées par leur id unique
id_orebut = db.Column(db.Text(), nullable=True, index=True, unique=True)
titre = db.Column(db.Text(), nullable=False, index=True) titre = db.Column(db.Text(), nullable=False, index=True)
titre_long = db.Column(db.Text()) titre_long = db.Column(db.Text())
couleur = db.Column(db.Text()) couleur = db.Column(db.Text())

View File

@ -279,6 +279,7 @@ class BasePreferences(object):
{ {
"initvalue": "Dept", "initvalue": "Dept",
"title": "Nom abrégé du département", "title": "Nom abrégé du département",
"explanation": "acronyme: par exemple R&T, ORTF, HAL",
"size": 12, "size": 12,
"category": "general", "category": "general",
"only_global": True, "only_global": True,
@ -289,7 +290,7 @@ class BasePreferences(object):
{ {
"initvalue": "nom du département", "initvalue": "nom du département",
"title": "Nom complet du département", "title": "Nom complet du département",
"explanation": "inutilisé par défaut", "explanation": "apparaît sur la page d'accueil",
"size": 40, "size": 40,
"category": "general", "category": "general",
"only_global": True, "only_global": True,

View File

@ -239,6 +239,17 @@ div.box-chercheetud {
margin-top: 12px; margin-top: 12px;
} }
/* Page accueil général */
span.dept_full_name {
font-style: italic;
}
span.dept_visible {
color: rgb(6, 158, 6);
}
span.dept_cache {
color: rgb(194, 5, 5);
}
div.table_etud_in_accessible_depts { div.table_etud_in_accessible_depts {
margin-left: 3em; margin-left: 3em;
margin-bottom: 2em; margin-bottom: 2em;

View File

@ -18,11 +18,13 @@
<a class="stdlink {{'link_accessible' if current_user.has_permission(Permission.ScoView, dept=dept.acronym) else 'link_unauthorized'}}" <a class="stdlink {{'link_accessible' if current_user.has_permission(Permission.ScoView, dept=dept.acronym) else 'link_unauthorized'}}"
href="{{url_for('scolar.index_html', scodoc_dept=dept.acronym)}}">Département href="{{url_for('scolar.index_html', scodoc_dept=dept.acronym)}}">Département
{{dept.preferences.filter_by(name="DeptName").first().value}} {{dept.preferences.filter_by(name="DeptName").first().value}}
{{ dept.preferences.filter_by( name="DeptFullName" ).first().value or "" }}
</a> </a>
<span class="dept_full_name">
{{ dept.preferences.filter_by( name="DeptFullName" ).first().value or "" }}
</span>
{% if current_user.is_administrator() %} {% if current_user.is_administrator() %}
<span class="dept_visibility"> <span {% if dept.visible %}class="dept_visible">visible{% else %}class="dept_cache">caché aux utilisateurs{% endif %}
{% if dept.visible %}visible{% else %}caché aux utilisateurs{% endif %} </span>
<a href="{{ url_for('scodoc.toggle_dept_vis', dept_id=dept.id) }}"> <a href="{{ url_for('scodoc.toggle_dept_vis', dept_id=dept.id) }}">
{% if dept.visible %}cacher{% else %}rendre visible{% endif %} {% if dept.visible %}cacher{% else %}rendre visible{% endif %}
</a> </a>

View File

@ -543,10 +543,10 @@ def create_user_form(user_name=None, edit=0, all_roles=1):
vals["active"] = vals["status"] == "" vals["active"] = vals["status"] == ""
# Département: # Département:
if auth_dept: # pas super-admin if auth_dept: # pas super-admin
if vals["dept"] not in selectable_dept_acronyms: if ("dept" in vals) and (vals["dept"] not in selectable_dept_acronyms):
del vals["dept"] # ne change pas de dept del vals["dept"] # ne change pas de dept
# traitement des roles: ne doit pas affecter les roles # Traitement des roles: ne doit pas affecter les rôles
# que l'on en controle pas: # que l'on en contrôle pas:
for role in orig_roles_strings: # { "Ens_RT", "Secr_CJ", ... } for role in orig_roles_strings: # { "Ens_RT", "Secr_CJ", ... }
if role and not role in editable_roles_strings: if role and not role in editable_roles_strings:
roles.add(role) roles.add(role)
@ -575,7 +575,7 @@ def create_user_form(user_name=None, edit=0, all_roles=1):
# A: envoi de welcome + procedure de reset # A: envoi de welcome + procedure de reset
# B: envoi de welcome seulement (mot de passe saisie dans le formulaire) # B: envoi de welcome seulement (mot de passe saisie dans le formulaire)
# C: Aucun envoi (mot de passe saisi dans le formulaire) # C: Aucun envoi (mot de passe saisi dans le formulaire)
if vals["welcome:list"] == "1": if vals["welcome"] == "1":
if vals["reset_password:list"] == "1": if vals["reset_password:list"] == "1":
mode = Mode.WELCOME_AND_CHANGE_PASSWORD mode = Mode.WELCOME_AND_CHANGE_PASSWORD
else: else:

View File

@ -0,0 +1,62 @@
"""Evolution ref. Orebut
Revision ID: 197c658cefbb
Revises: 91be8a06d423
Create Date: 2022-01-05 22:25:12.384647
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "197c658cefbb"
down_revision = "91be8a06d423"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("apc_competence", sa.Column("id_orebut", sa.Text(), nullable=True))
op.drop_constraint(
"apc_competence_referentiel_id_titre_key", "apc_competence", type_="unique"
)
op.create_index(
op.f("ix_apc_competence_id_orebut"),
"apc_competence",
["id_orebut"],
unique=True,
)
op.add_column(
"apc_referentiel_competences", sa.Column("annexe", sa.Text(), nullable=True)
)
op.add_column(
"apc_referentiel_competences",
sa.Column("type_structure", sa.Text(), nullable=True),
)
op.add_column(
"apc_referentiel_competences",
sa.Column("type_departement", sa.Text(), nullable=True),
)
op.add_column(
"apc_referentiel_competences",
sa.Column("version_orebut", sa.Text(), nullable=True),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("apc_referentiel_competences", "version_orebut")
op.drop_column("apc_referentiel_competences", "type_departement")
op.drop_column("apc_referentiel_competences", "type_structure")
op.drop_column("apc_referentiel_competences", "annexe")
op.drop_index(op.f("ix_apc_competence_id_orebut"), table_name="apc_competence")
op.create_unique_constraint(
"apc_competence_referentiel_id_titre_key",
"apc_competence",
["referentiel_id", "titre"],
)
op.drop_column("apc_competence", "id_orebut")
# ### end Alembic commands ###

View File

@ -1,283 +0,0 @@
"""creation tables relations entreprises
Revision ID: f3b62d64efa3
Revises: 91be8a06d423
Create Date: 2021-12-24 10:36:27.150085
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "f3b62d64efa3"
down_revision = "91be8a06d423"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"entreprise_log",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column(
"date",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
sa.Column("authenticated_user", sa.Text(), nullable=True),
sa.Column("object", sa.Integer(), nullable=True),
sa.Column("text", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"entreprise_etudiant",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("entreprise_id", sa.Integer(), nullable=True),
sa.Column("etudid", sa.Integer(), nullable=True),
sa.Column("type_offre", sa.Text(), nullable=True),
sa.Column("date_debut", sa.Date(), nullable=True),
sa.Column("date_fin", sa.Date(), nullable=True),
sa.Column("formation_text", sa.Text(), nullable=True),
sa.Column("formation_scodoc", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(
["entreprise_id"], ["entreprises.id"], ondelete="cascade"
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"entreprise_offre",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("entreprise_id", sa.Integer(), nullable=True),
sa.Column(
"date_ajout",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
sa.Column("intitule", sa.Text(), nullable=True),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("type_offre", sa.Text(), nullable=True),
sa.Column("missions", sa.Text(), nullable=True),
sa.Column("duree", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(
["entreprise_id"], ["entreprises.id"], ondelete="cascade"
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"entreprise_envoi_offre",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("sender_id", sa.Integer(), nullable=True),
sa.Column("receiver_id", sa.Integer(), nullable=True),
sa.Column("offre_id", sa.Integer(), nullable=True),
sa.Column(
"date_envoi",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
sa.ForeignKeyConstraint(
["offre_id"],
["entreprise_offre.id"],
),
sa.ForeignKeyConstraint(
["sender_id"],
["user.id"],
),
sa.ForeignKeyConstraint(
["receiver_id"],
["user.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"entreprise_envoi_offre_etudiant",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("sender_id", sa.Integer(), nullable=True),
sa.Column("receiver_id", sa.Integer(), nullable=True),
sa.Column("offre_id", sa.Integer(), nullable=True),
sa.Column(
"date_envoi",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
sa.ForeignKeyConstraint(
["offre_id"],
["entreprise_offre.id"],
),
sa.ForeignKeyConstraint(
["sender_id"],
["user.id"],
),
sa.ForeignKeyConstraint(
["receiver_id"],
["identite.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.drop_constraint(
"entreprise_contact_entreprise_corresp_id_fkey",
"entreprise_contact",
type_="foreignkey",
)
op.drop_table("entreprise_correspondant")
op.add_column("entreprise_contact", sa.Column("nom", sa.Text(), nullable=True))
op.add_column("entreprise_contact", sa.Column("prenom", sa.Text(), nullable=True))
op.add_column(
"entreprise_contact", sa.Column("telephone", sa.Text(), nullable=True)
)
op.add_column("entreprise_contact", sa.Column("mail", sa.Text(), nullable=True))
op.add_column("entreprise_contact", sa.Column("poste", sa.Text(), nullable=True))
op.add_column("entreprise_contact", sa.Column("service", sa.Text(), nullable=True))
op.drop_column("entreprise_contact", "description")
op.drop_column("entreprise_contact", "enseignant")
op.drop_column("entreprise_contact", "date")
op.drop_column("entreprise_contact", "type_contact")
op.drop_column("entreprise_contact", "etudid")
op.drop_column("entreprise_contact", "entreprise_corresp_id")
op.add_column("entreprises", sa.Column("siret", sa.Text(), nullable=True))
op.drop_index("ix_entreprises_dept_id", table_name="entreprises")
op.drop_constraint("entreprises_dept_id_fkey", "entreprises", type_="foreignkey")
op.drop_column("entreprises", "qualite_relation")
op.drop_column("entreprises", "note")
op.drop_column("entreprises", "contact_origine")
op.drop_column("entreprises", "plus10salaries")
op.drop_column("entreprises", "privee")
op.drop_column("entreprises", "secteur")
op.drop_column("entreprises", "date_creation")
op.drop_column("entreprises", "dept_id")
op.drop_column("entreprises", "localisation")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"entreprises",
sa.Column("localisation", sa.TEXT(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprises",
sa.Column("dept_id", sa.INTEGER(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprises",
sa.Column(
"date_creation",
postgresql.TIMESTAMP(timezone=True),
server_default=sa.text("now()"),
autoincrement=False,
nullable=True,
),
)
op.add_column(
"entreprises",
sa.Column("secteur", sa.TEXT(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprises",
sa.Column("privee", sa.TEXT(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprises",
sa.Column("plus10salaries", sa.BOOLEAN(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprises",
sa.Column("contact_origine", sa.TEXT(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprises", sa.Column("note", sa.TEXT(), autoincrement=False, nullable=True)
)
op.add_column(
"entreprises",
sa.Column("qualite_relation", sa.INTEGER(), autoincrement=False, nullable=True),
)
op.create_foreign_key(
"entreprises_dept_id_fkey", "entreprises", "departement", ["dept_id"], ["id"]
)
op.create_index("ix_entreprises_dept_id", "entreprises", ["dept_id"], unique=False)
op.drop_column("entreprises", "siret")
op.add_column(
"entreprise_contact",
sa.Column(
"entreprise_corresp_id", sa.INTEGER(), autoincrement=False, nullable=True
),
)
op.add_column(
"entreprise_contact",
sa.Column("etudid", sa.INTEGER(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprise_contact",
sa.Column("type_contact", sa.TEXT(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprise_contact",
sa.Column(
"date",
postgresql.TIMESTAMP(timezone=True),
autoincrement=False,
nullable=True,
),
)
op.add_column(
"entreprise_contact",
sa.Column("enseignant", sa.TEXT(), autoincrement=False, nullable=True),
)
op.add_column(
"entreprise_contact",
sa.Column("description", sa.TEXT(), autoincrement=False, nullable=True),
)
op.create_table(
"entreprise_correspondant",
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column("entreprise_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("nom", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("prenom", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("civilite", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("fonction", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("phone1", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("phone2", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("mobile", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("mail1", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("mail2", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("fax", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("note", sa.TEXT(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(
["entreprise_id"],
["entreprises.id"],
name="entreprise_correspondant_entreprise_id_fkey",
),
sa.PrimaryKeyConstraint("id", name="entreprise_correspondant_pkey"),
)
op.create_foreign_key(
"entreprise_contact_entreprise_corresp_id_fkey",
"entreprise_contact",
"entreprise_correspondant",
["entreprise_corresp_id"],
["id"],
)
op.drop_column("entreprise_contact", "service")
op.drop_column("entreprise_contact", "poste")
op.drop_column("entreprise_contact", "mail")
op.drop_column("entreprise_contact", "telephone")
op.drop_column("entreprise_contact", "prenom")
op.drop_column("entreprise_contact", "nom")
op.drop_table("entreprise_envoi_offre")
op.drop_table("entreprise_envoi_offre_etudiant")
op.drop_table("entreprise_offre")
op.drop_table("entreprise_etudiant")
op.drop_table("entreprise_log")
# ### end Alembic commands ###