", methods=["GET", "POST"])
+def delete_offre_file(offre_id, filedir):
+ offre = EntrepriseOffre.query.filter_by(id=offre_id).first_or_404()
+ form = SuppressionConfirmationForm()
+ if form.validate_on_submit():
+ path = os.path.join(
+ Config.SCODOC_VAR_DIR,
+ "entreprises",
+ f"{offre.entreprise_id}",
+ f"{offre_id}",
+ f"{filedir}",
+ )
+ if os.path.isdir(path):
+ shutil.rmtree(path)
+ flash("Le fichier relié à l'offre a été supprimé.")
+ return redirect(
+ url_for("entreprises.fiche_entreprise", id=offre.entreprise_id)
+ )
+ return render_template(
+ "entreprises/delete_confirmation.html",
+ title=("Suppression fichier d'une offre"),
+ form=form,
+ )
diff --git a/app/models/__init__.py b/app/models/__init__.py
index 0fee7bc48..642e31873 100644
--- a/app/models/__init__.py
+++ b/app/models/__init__.py
@@ -14,12 +14,6 @@ from app.models.raw_sql_init import create_database_functions
from app.models.absences import Absence, AbsenceNotification, BilletAbsence
from app.models.departements import Departement
-
-from app.models.entreprises import (
- Entreprise,
- EntrepriseCorrespondant,
- EntrepriseContact,
-)
from app.models.etudiants import (
Identite,
Adresse,
diff --git a/app/models/departements.py b/app/models/departements.py
index 0734e35b0..7ed2f4b56 100644
--- a/app/models/departements.py
+++ b/app/models/departements.py
@@ -19,7 +19,7 @@ class Departement(db.Model):
db.Boolean(), nullable=False, default=True, server_default="true"
) # sur page d'accueil
- entreprises = db.relationship("Entreprise", lazy="dynamic", backref="departement")
+ # entreprises = db.relationship("Entreprise", lazy="dynamic", backref="departement")
etudiants = db.relationship("Identite", lazy="dynamic", backref="departement")
formations = db.relationship("Formation", lazy="dynamic", backref="departement")
formsemestres = db.relationship(
diff --git a/app/models/entreprises.py b/app/models/entreprises.py
deleted file mode 100644
index bdb5672a8..000000000
--- a/app/models/entreprises.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# -*- coding: UTF-8 -*
-
-"""Gestion des absences
-"""
-
-from app import db
-from app.models import APO_CODE_STR_LEN
-from app.models import SHORT_STR_LEN
-from app.models import CODE_STR_LEN
-
-
-class Entreprise(db.Model):
- """une entreprise"""
-
- __tablename__ = "entreprises"
- id = db.Column(db.Integer, primary_key=True)
- entreprise_id = db.synonym("id")
- dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True)
- nom = db.Column(db.Text)
- adresse = db.Column(db.Text)
- ville = db.Column(db.Text)
- codepostal = db.Column(db.Text)
- pays = db.Column(db.Text)
- contact_origine = db.Column(db.Text)
- secteur = db.Column(db.Text)
- note = db.Column(db.Text)
- privee = db.Column(db.Text)
- localisation = db.Column(db.Text)
- # -1 inconnue, 0, 25, 50, 75, 100:
- qualite_relation = db.Column(db.Integer)
- plus10salaries = db.Column(db.Boolean())
- date_creation = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
-
-
-class EntrepriseCorrespondant(db.Model):
- """Personne contact en entreprise"""
-
- __tablename__ = "entreprise_correspondant"
- id = db.Column(db.Integer, primary_key=True)
- entreprise_corresp_id = db.synonym("id")
- entreprise_id = db.Column(db.Integer, db.ForeignKey("entreprises.id"))
- nom = db.Column(db.Text)
- prenom = db.Column(db.Text)
- civilite = db.Column(db.Text)
- fonction = db.Column(db.Text)
- phone1 = db.Column(db.Text)
- phone2 = db.Column(db.Text)
- mobile = db.Column(db.Text)
- mail1 = db.Column(db.Text)
- mail2 = db.Column(db.Text)
- fax = db.Column(db.Text)
- note = db.Column(db.Text)
-
-
-class EntrepriseContact(db.Model):
- """Evènement (contact) avec une entreprise"""
-
- __tablename__ = "entreprise_contact"
- id = db.Column(db.Integer, primary_key=True)
- entreprise_contact_id = db.synonym("id")
- date = db.Column(db.DateTime(timezone=True))
- type_contact = db.Column(db.Text)
- entreprise_id = db.Column(db.Integer, db.ForeignKey("entreprises.id"))
- entreprise_corresp_id = db.Column(
- db.Integer, db.ForeignKey("entreprise_correspondant.id")
- )
- etudid = db.Column(db.Integer) # sans contrainte pour garder logs après suppression
- description = db.Column(db.Text)
- enseignant = db.Column(db.Text)
diff --git a/app/models/etudiants.py b/app/models/etudiants.py
index 220bf28be..eb018e704 100644
--- a/app/models/etudiants.py
+++ b/app/models/etudiants.py
@@ -144,6 +144,17 @@ class Identite(db.Model):
]
return r[0] if r else None
+ def inscription_courante_date(self, date_debut, date_fin):
+ """La première inscription à un formsemestre incluant la
+ période [date_debut, date_fin]
+ """
+ r = [
+ ins
+ for ins in self.formsemestre_inscriptions
+ if ins.formsemestre.contient_periode(date_debut, date_fin)
+ ]
+ return r[0] if r else None
+
def etat_inscription(self, formsemestre_id):
"""etat de l'inscription de cet étudiant au semestre:
False si pas inscrit, ou scu.INSCRIT, DEMISSION, DEF
diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py
index 98edbba1e..4ada23e87 100644
--- a/app/models/formsemestre.py
+++ b/app/models/formsemestre.py
@@ -150,6 +150,13 @@ class FormSemestre(db.Model):
today = datetime.date.today()
return (self.date_debut <= today) and (today <= self.date_fin)
+ def contient_periode(self, date_debut, date_fin) -> bool:
+ """Vrai si l'intervalle [date_debut, date_fin] est
+ inclus dans le semestre.
+ (les dates de début et fin sont incluses)
+ """
+ return (self.date_debut <= date_debut) and (date_fin <= self.date_fin)
+
def est_decale(self):
"""Vrai si semestre "décalé"
c'est à dire semestres impairs commençant entre janvier et juin
diff --git a/app/templates/entreprises/_contact.html b/app/templates/entreprises/_contact.html
new file mode 100644
index 000000000..0eb8ebfee
--- /dev/null
+++ b/app/templates/entreprises/_contact.html
@@ -0,0 +1,14 @@
+{# -*- mode: jinja-html -*- #}
+
+
+ Nom : {{ contact.nom }}
+ Prénom : {{ contact.prenom }}
+ Téléphone : {{ contact.telephone }}
+ Mail : {{ contact.mail }}
+
+
+
+
\ No newline at end of file
diff --git a/app/templates/entreprises/_offre.html b/app/templates/entreprises/_offre.html
new file mode 100644
index 000000000..ea69110e9
--- /dev/null
+++ b/app/templates/entreprises/_offre.html
@@ -0,0 +1,21 @@
+{# -*- mode: jinja-html -*- #}
+
+
+ Intitulé : {{ offre[0].intitule }}
+ Description : {{ offre[0].description }}
+ Type de l'offre : {{ offre[0].type_offre }}
+ Missions : {{ offre[0].missions }}
+ Durée : {{ offre[0].duree }}
+ {% for fichier in offre[1] %}
+ {{ fichier[1] }}
+
+ {% endfor %}
+ Ajoutez un fichier
+
+
+
+
\ No newline at end of file
diff --git a/app/templates/entreprises/ajout_entreprise.html b/app/templates/entreprises/ajout_entreprise.html
new file mode 100644
index 000000000..15cf174fb
--- /dev/null
+++ b/app/templates/entreprises/ajout_entreprise.html
@@ -0,0 +1,54 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+{% import 'bootstrap/wtf.html' as wtf %}
+
+{% block app_content %}
+ {{ title }}
+
+
+
+
+ Les champs s'autocomplète selon le SIRET
+
+ {{ wtf.quick_form(form, novalidate=True) }}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/entreprises/ajout_historique.html b/app/templates/entreprises/ajout_historique.html
new file mode 100644
index 000000000..c0a546d59
--- /dev/null
+++ b/app/templates/entreprises/ajout_historique.html
@@ -0,0 +1,32 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+{% import 'bootstrap/wtf.html' as wtf %}
+
+{% block styles %}
+{{super()}}
+
+
+{% endblock %}
+
+{% block app_content %}
+ {{ title }}
+
+
+
+ {{ wtf.quick_form(form, novalidate=True) }}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/entreprises/contacts.html b/app/templates/entreprises/contacts.html
new file mode 100644
index 000000000..54d77bd55
--- /dev/null
+++ b/app/templates/entreprises/contacts.html
@@ -0,0 +1,47 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+
+{% block app_content %}
+ {% if logs %}
+
+
Dernières opérations
+
+ {% for log in logs %}
+ - {{ log.date.strftime('%d %b %Hh%M') }}{{ log.text|safe }} par {{ log.authenticated_user|get_nomcomplet }}
+ {% endfor %}
+
+
+ {% endif %}
+
+
Liste des contacts
+ {% if contacts %}
+
+
+
+ Nom |
+ Prenom |
+ Telephone |
+ Mail |
+ Entreprise |
+
+ {% for contact in contacts %}
+
+ {{ contact[0].nom }} |
+ {{ contact[0].prenom }} |
+ {{ contact[0].telephone }} |
+ {{ contact[0].mail }} |
+ {{ contact[1].nom }} |
+
+ {% endfor %}
+
+ {% else %}
+
Aucun contact présent dans la base
+
+ {% endif %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/entreprises/delete_confirmation.html b/app/templates/entreprises/delete_confirmation.html
new file mode 100644
index 000000000..4894bca3e
--- /dev/null
+++ b/app/templates/entreprises/delete_confirmation.html
@@ -0,0 +1,15 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+{% import 'bootstrap/wtf.html' as wtf %}
+
+{% block app_content %}
+ {{ title }}
+
+ Cliquez sur le bouton supprimer pour confirmer votre supression
+
+
+
+ {{ wtf.quick_form(form) }}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/entreprises/entreprises.html b/app/templates/entreprises/entreprises.html
new file mode 100644
index 000000000..fe790a8d6
--- /dev/null
+++ b/app/templates/entreprises/entreprises.html
@@ -0,0 +1,63 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+
+{% block app_content %}
+ {% if logs %}
+
+
Dernières opérations
+
+ {% for log in logs %}
+ - {{ log.date.strftime('%d %b %Hh%M') }}{{ log.text|safe }} par {{ log.authenticated_user|get_nomcomplet }}
+ {% endfor %}
+
+
+ {% endif %}
+
+
Liste des entreprises
+ {% if entreprises %}
+
+
+
+ SIRET |
+ Nom |
+ Adresse |
+ Code postal |
+ Ville |
+ Pays |
+ Action |
+
+ {% for entreprise in entreprises %}
+
+ {{ entreprise.siret }} |
+ {{ entreprise.nom }} |
+ {{ entreprise.adresse }} |
+ {{ entreprise.codepostal }} |
+ {{ entreprise.ville }} |
+ {{ entreprise.pays }} |
+
+
+ |
+
+ {% endfor %}
+
+ {% else %}
+
Aucune entreprise présent dans la base
+
+
+ {% endif %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/entreprises/envoi_offre_form.html b/app/templates/entreprises/envoi_offre_form.html
new file mode 100644
index 000000000..f67cb4e40
--- /dev/null
+++ b/app/templates/entreprises/envoi_offre_form.html
@@ -0,0 +1,32 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+{% import 'bootstrap/wtf.html' as wtf %}
+
+{% block styles %}
+{{super()}}
+
+
+{% endblock %}
+
+{% block app_content %}
+ {{ title }}
+
+
+
+ {{ wtf.quick_form(form, novalidate=True) }}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/entreprises/fiche_entreprise.html b/app/templates/entreprises/fiche_entreprise.html
new file mode 100644
index 000000000..d34531207
--- /dev/null
+++ b/app/templates/entreprises/fiche_entreprise.html
@@ -0,0 +1,76 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+
+{% block app_content %}
+{% if logs %}
+
+
Dernières opérations sur cette fiche
+
+ {% for log in logs %}
+ -
+ {{ log.date.strftime('%d %b %Hh%M') }}
+ {{ log.text|safe }} par {{ log.authenticated_user|get_nomcomplet }}
+
+ {% endfor %}
+
+
+{% endif %}
+{% if historique %}
+
+
Historique
+
+ {% for data in historique %}
+ -
+ {{ data[0].date_debut.strftime('%d/%m/%Y') }} - {{
+ data[0].date_fin.strftime('%d/%m/%Y') }}
+
+ {{ data[0].type_offre }} réalisé par {{ data[1].nom|format_nom }} {{ data[1].prenom|format_prenom }} en
+ {{ data[0].formation_text }}
+
+
+ {% endfor %}
+
+
+{% endif %}
+
+
Fiche entreprise - {{ entreprise.nom }} ({{ entreprise.siret }})
+
+
+
+ SIRET : {{ entreprise.siret }}
+ Nom : {{ entreprise.nom }}
+ Adresse : {{ entreprise.adresse }}
+ Code postal : {{ entreprise.codepostal }}
+ Ville : {{ entreprise.ville }}
+ Pays : {{ entreprise.pays }}
+
+
+
+ {% if contacts %}
+
+ {% for contact in contacts %}
+ Contact {{loop.index}}
+ {% include 'entreprises/_contact.html' %}
+ {% endfor %}
+
+ {% endif %}
+
+ {% if offres %}
+
+ {% for offre in offres %}
+ Offre {{loop.index}} (ajouté le {{offre[0].date_ajout.strftime('%d/%m/%Y') }})
+ {% include 'entreprises/_offre.html' %}
+ {% endfor %}
+
+ {% endif %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/entreprises/form.html b/app/templates/entreprises/form.html
new file mode 100644
index 000000000..066224d8b
--- /dev/null
+++ b/app/templates/entreprises/form.html
@@ -0,0 +1,19 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+{% import 'bootstrap/wtf.html' as wtf %}
+
+{% block styles %}
+{{super()}}
+
+
+{% endblock %}
+
+{% block app_content %}
+ {{ title }}
+
+
+
+ {{ wtf.quick_form(form, novalidate=True) }}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/templates/entreprises/offres.html b/app/templates/entreprises/offres.html
new file mode 100644
index 000000000..ff3ab9bdc
--- /dev/null
+++ b/app/templates/entreprises/offres.html
@@ -0,0 +1,29 @@
+{# -*- mode: jinja-html -*- #}
+{% extends 'base.html' %}
+
+{% block app_content %}
+
+
{{ title }}
+ {% if offres_recus %}
+
+
+ {% for offre in offres_recus %}
+
+
+ Date envoi : {{ offre[0].date_envoi.strftime('%d/%m/%Y %H:%M') }}
+ Intitulé : {{ offre[1].intitule }}
+ Description : {{ offre[1].description }}
+ Type de l'offre : {{ offre[1].type_offre }}
+ Missions : {{ offre[1].missions }}
+ Durée : {{ offre[1].duree }}
+
+
+ {% endfor %}
+
+
+ {% else %}
+
Aucune offre reçue
+
+ {% endif %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/migrations/versions/2dfafee725ae_creation_table_relations_entreprrises.py b/migrations/versions/2dfafee725ae_creation_table_relations_entreprrises.py
new file mode 100644
index 000000000..05adc3566
--- /dev/null
+++ b/migrations/versions/2dfafee725ae_creation_table_relations_entreprrises.py
@@ -0,0 +1,255 @@
+"""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.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_offre")
+ op.drop_table("entreprise_etudiant")
+ op.drop_table("entreprise_log")
+ # ### end Alembic commands ###
diff --git a/scodoc.py b/scodoc.py
index 94c8a7f09..1be505527 100755
--- a/scodoc.py
+++ b/scodoc.py
@@ -248,6 +248,16 @@ def edit_role(rolename, addpermissionname=None, removepermissionname=None): # e
db.session.add(role)
db.session.commit()
+@app.cli.command()
+@click.argument("rolename")
+def delete_role(rolename):
+ """Delete a role"""
+ role = Role.query.filter_by(name=rolename).first()
+ if role is None:
+ sys.stderr.write(f"delete_role: role {rolename} does not exists\n")
+ return 1
+ db.session.delete(role)
+ db.session.commit()
@app.cli.command()
@click.argument("username")