From 6a734ce06a0a2d6b8b41ff4d1458ecf410ac4303 Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Fri, 4 Feb 2022 17:12:56 +0100 Subject: [PATCH] =?UTF-8?q?formulaire=20offre/d=C3=A9partement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/entreprises/__init__.py | 11 +- app/entreprises/forms.py | 16 +- app/entreprises/models.py | 28 +- app/entreprises/routes.py | 31 ++- app/static/css/entreprises.css | 12 + app/templates/entreprises/_offre.html | 3 + app/templates/entreprises/form.html | 7 + ...ab68b3_tables_module_gestion_relations_.py | 253 ++++++++++++++++++ ...ables_application_relations_entreprises.py | 176 ------------ 9 files changed, 343 insertions(+), 194 deletions(-) create mode 100644 migrations/versions/593451ab68b3_tables_module_gestion_relations_.py delete mode 100644 migrations/versions/e63f6a9dcc75_tables_application_relations_entreprises.py diff --git a/app/entreprises/__init__.py b/app/entreprises/__init__.py index 301b8eaf3..34dcaed82 100644 --- a/app/entreprises/__init__.py +++ b/app/entreprises/__init__.py @@ -4,6 +4,7 @@ from flask import Blueprint from app.scodoc import sco_etud from app.auth.models import User +from app.models import Departement bp = Blueprint("entreprises", __name__) @@ -27,9 +28,15 @@ def get_nomcomplet(s): @bp.app_template_filter() -def get_nomcomplet_by_id(s): - user = User.query.filter_by(id=s).first() +def get_nomcomplet_by_id(id): + user = User.query.filter_by(id=id).first() return user.get_nomcomplet() +@bp.app_template_filter() +def get_dept_acronym(id): + dept = Departement.query.filter_by(id=id).first() + return dept.acronym + + from app.entreprises import routes diff --git a/app/entreprises/forms.py b/app/entreprises/forms.py index 1451f25c5..59cd85929 100644 --- a/app/entreprises/forms.py +++ b/app/entreprises/forms.py @@ -41,6 +41,7 @@ from wtforms import ( ) from wtforms.fields import EmailField, DateField from wtforms.validators import ValidationError, DataRequired, Email, Optional +from wtforms.widgets import ListWidget, CheckboxInput from app.entreprises.models import Entreprise, EntrepriseContact from app.models import Identite, Departement @@ -131,6 +132,11 @@ class EntrepriseModificationForm(FlaskForm): submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"}) +class MultiCheckboxField(SelectMultipleField): + widget = ListWidget(prefix_label=False) + option_widget = CheckboxInput() + + class OffreCreationForm(FlaskForm): intitule = StringField("Intitulé", validators=[DataRequired(message=CHAMP_REQUIS)]) @@ -146,7 +152,7 @@ class OffreCreationForm(FlaskForm): "Missions", validators=[DataRequired(message=CHAMP_REQUIS)] ) duree = StringField("Durée", validators=[DataRequired(message=CHAMP_REQUIS)]) - depts = SelectMultipleField("Départements", validators=[Optional()], coerce=int) + depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int) expiration_date = DateField( "Date expiration", validators=[DataRequired(message=CHAMP_REQUIS)] ) @@ -174,11 +180,19 @@ class OffreModificationForm(FlaskForm): "Missions", validators=[DataRequired(message=CHAMP_REQUIS)] ) duree = StringField("Durée", validators=[DataRequired(message=CHAMP_REQUIS)]) + depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int) expiration_date = DateField( "Date expiration", validators=[DataRequired(message=CHAMP_REQUIS)] ) submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"}) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.depts.choices = [ + (dept.id, dept.acronym) for dept in Departement.query.all() + ] + class ContactCreationForm(FlaskForm): hidden_entreprise_id = HiddenField() diff --git a/app/entreprises/models.py b/app/entreprises/models.py index 6bdba3333..a91dc09b9 100644 --- a/app/entreprises/models.py +++ b/app/entreprises/models.py @@ -112,7 +112,9 @@ class EntrepriseLog(db.Model): class EntrepriseEtudiant(db.Model): __tablename__ = "are_entreprise_etudiant" id = db.Column(db.Integer, primary_key=True) - entreprise_id = db.Column(db.Integer, db.ForeignKey("are_entreprises.id")) + entreprise_id = db.Column( + db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") + ) etudid = db.Column(db.Integer) type_offre = db.Column(db.Text) date_debut = db.Column(db.Date) @@ -124,23 +126,31 @@ class EntrepriseEtudiant(db.Model): class EntrepriseEnvoiOffre(db.Model): __tablename__ = "are_entreprise_envoi_offre" id = db.Column(db.Integer, primary_key=True) - sender_id = db.Column(db.Integer, db.ForeignKey("user.id")) - receiver_id = db.Column(db.Integer, db.ForeignKey("user.id")) - offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id")) + sender_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade")) + receiver_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade")) + offre_id = db.Column( + db.Integer, db.ForeignKey("are_entreprise_offre.id", ondelete="cascade") + ) date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) class EntrepriseEnvoiOffreEtudiant(db.Model): __tablename__ = "are_entreprise_envoi_offre_etudiant" id = db.Column(db.Integer, primary_key=True) - sender_id = db.Column(db.Integer, db.ForeignKey("user.id")) - receiver_id = db.Column(db.Integer, db.ForeignKey("identite.id")) - offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id")) + sender_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade")) + receiver_id = db.Column( + db.Integer, db.ForeignKey("identite.id", ondelete="cascade") + ) + offre_id = db.Column( + db.Integer, db.ForeignKey("are_entreprise_offre.id", ondelete="cascade") + ) date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) class EntrepriseOffreDepartement(db.Model): __tablename__ = "are_entreprise_offre_departement" id = db.Column(db.Integer, primary_key=True) - offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id")) - dept_id = db.Column(db.Integer, db.ForeignKey("departement.id")) + offre_id = db.Column( + db.Integer, db.ForeignKey("are_entreprise_offre.id", ondelete="cascade") + ) + dept_id = db.Column(db.Integer, db.ForeignKey("departement.id", ondelete="cascade")) diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index bd39da002..7c7415187 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -74,8 +74,6 @@ def logs(): logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).paginate( page=page, per_page=20 ) - if logs is None: - abort(404) return render_template("entreprises/logs.html", title=("Logs"), logs=logs) @@ -141,7 +139,10 @@ def fiche_entreprise(id): for file in glob.glob(f"{dir}/*"): file = [os.path.basename(dir), os.path.basename(file)] files.append(file) - offres_with_files.append([offre, files]) + offre_depts = EntrepriseOffreDepartement.query.filter_by( + offre_id=offre.id + ).all() + offres_with_files.append([offre, files, offre_depts]) contacts = entreprise.contacts logs = ( EntrepriseLog.query.order_by(EntrepriseLog.date.desc()) @@ -180,8 +181,6 @@ def logs_entreprise(id): .filter_by(object=id) .paginate(page=page, per_page=20) ) - if logs is None: - abort(404) return render_template( "entreprises/logs_entreprise.html", title=("Logs"), @@ -267,7 +266,10 @@ def offres_expirees(id): for file in glob.glob(f"{dir}/*"): file = [os.path.basename(dir), os.path.basename(file)] files.append(file) - offres_expirees_with_files.append([offre, files]) + offre_depts = EntrepriseOffreDepartement.query.filter_by( + offre_id=offre.id + ).all() + offres_expirees_with_files.append([offre, files, offre_depts]) return render_template( "entreprises/offres_expirees.html", title=("Offres expirées"), @@ -491,7 +493,9 @@ def edit_offre(id): Permet de modifier une offre """ offre = EntrepriseOffre.query.filter_by(id=id).first_or_404() + offre_depts = EntrepriseOffreDepartement.query.filter_by(offre_id=offre.id).all() form = OffreModificationForm() + offre_depts_list = [(offre_dept.dept_id) for offre_dept in offre_depts] if form.validate_on_submit(): offre.intitule = form.intitule.data.strip() offre.description = form.description.data.strip() @@ -499,6 +503,20 @@ def edit_offre(id): offre.missions = form.missions.data.strip() offre.duree = form.duree.data.strip() offre.expiration_date = form.expiration_date.data + if offre_depts_list != form.depts.data: + for dept in form.depts.data: + if dept not in offre_depts_list: + offre_dept = EntrepriseOffreDepartement( + offre_id=offre.id, + dept_id=dept, + ) + db.session.add(offre_dept) + for dept in offre_depts_list: + if dept not in form.depts.data: + offre_dept = EntrepriseOffreDepartement.query.filter_by( + offre_id=offre.id, dept_id=dept + ).first_or_404() + db.session.delete(offre_dept) log = EntrepriseLog( authenticated_user=current_user.user_name, object=offre.entreprise_id, @@ -515,6 +533,7 @@ def edit_offre(id): form.missions.data = offre.missions form.duree.data = offre.duree form.expiration_date.data = offre.expiration_date + form.depts.data = offre_depts_list return render_template( "entreprises/form.html", title=("Modification offre"), form=form ) diff --git a/app/static/css/entreprises.css b/app/static/css/entreprises.css index bd9560938..8883fb9ec 100644 --- a/app/static/css/entreprises.css +++ b/app/static/css/entreprises.css @@ -68,4 +68,16 @@ .contacts-et-offres > div:nth-child(2) { margin-left: 20px; +} + +#depts { + list-style: none; + padding-left: 10px; +} + +.offre_depts { + display: inline-block; + border: black solid 2px; + border-radius: 5px; + padding: 1px; } \ No newline at end of file diff --git a/app/templates/entreprises/_offre.html b/app/templates/entreprises/_offre.html index a81dc647f..8e1f56ccb 100644 --- a/app/templates/entreprises/_offre.html +++ b/app/templates/entreprises/_offre.html @@ -6,6 +6,9 @@ Type de l'offre : {{ offre[0].type_offre }}
Missions : {{ offre[0].missions }}
Durée : {{ offre[0].duree }}
+ {% if offre[2] %} + Département(s) : {% for offre_dept in offre[2] %}
{{ offre_dept.dept_id|get_dept_acronym }}
{% endfor %}
+ {% endif %} {% for fichier in offre[1] %} {{ fichier[1] }} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} diff --git a/app/templates/entreprises/form.html b/app/templates/entreprises/form.html index 066224d8b..7659250ba 100644 --- a/app/templates/entreprises/form.html +++ b/app/templates/entreprises/form.html @@ -16,4 +16,11 @@ {{ wtf.quick_form(form, novalidate=True) }} + + {% endblock %} \ No newline at end of file diff --git a/migrations/versions/593451ab68b3_tables_module_gestion_relations_.py b/migrations/versions/593451ab68b3_tables_module_gestion_relations_.py new file mode 100644 index 000000000..e72dff94b --- /dev/null +++ b/migrations/versions/593451ab68b3_tables_module_gestion_relations_.py @@ -0,0 +1,253 @@ +"""tables module gestion relations entreprises + +Revision ID: 593451ab68b3 +Revises: c95d5a3bf0de +Create Date: 2022-02-04 17:06:02.519231 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = "593451ab68b3" +down_revision = "c95d5a3bf0de" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "are_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( + "are_entreprises", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("siret", sa.Text(), nullable=True), + sa.Column("nom", sa.Text(), nullable=True), + sa.Column("adresse", sa.Text(), nullable=True), + sa.Column("codepostal", sa.Text(), nullable=True), + sa.Column("ville", sa.Text(), nullable=True), + sa.Column("pays", sa.Text(), nullable=True), + sa.Column("visible", sa.Boolean(), nullable=True), + sa.PrimaryKeyConstraint("id"), + ) + op.create_table( + "are_entreprise_contact", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("entreprise_id", sa.Integer(), nullable=True), + sa.Column("nom", sa.Text(), nullable=True), + sa.Column("prenom", sa.Text(), nullable=True), + sa.Column("telephone", sa.Text(), nullable=True), + sa.Column("mail", sa.Text(), nullable=True), + sa.Column("poste", sa.Text(), nullable=True), + sa.Column("service", sa.Text(), nullable=True), + sa.ForeignKeyConstraint( + ["entreprise_id"], ["are_entreprises.id"], ondelete="cascade" + ), + sa.PrimaryKeyConstraint("id"), + ) + op.create_table( + "are_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"], ["are_entreprises.id"], ondelete="cascade" + ), + sa.PrimaryKeyConstraint("id"), + ) + op.create_table( + "are_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.Column("expiration_date", sa.Date(), nullable=True), + sa.ForeignKeyConstraint( + ["entreprise_id"], ["are_entreprises.id"], ondelete="cascade" + ), + sa.PrimaryKeyConstraint("id"), + ) + op.create_table( + "are_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"], ["are_entreprise_offre.id"], ondelete="cascade" + ), + sa.ForeignKeyConstraint(["receiver_id"], ["user.id"], ondelete="cascade"), + sa.ForeignKeyConstraint(["sender_id"], ["user.id"], ondelete="cascade"), + sa.PrimaryKeyConstraint("id"), + ) + op.create_table( + "are_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"], ["are_entreprise_offre.id"], ondelete="cascade" + ), + sa.ForeignKeyConstraint(["receiver_id"], ["identite.id"], ondelete="cascade"), + sa.ForeignKeyConstraint(["sender_id"], ["user.id"], ondelete="cascade"), + sa.PrimaryKeyConstraint("id"), + ) + op.create_table( + "are_entreprise_offre_departement", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("offre_id", sa.Integer(), nullable=True), + sa.Column("dept_id", sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(["dept_id"], ["departement.id"], ondelete="cascade"), + sa.ForeignKeyConstraint( + ["offre_id"], ["are_entreprise_offre.id"], ondelete="cascade" + ), + sa.PrimaryKeyConstraint("id"), + ) + op.drop_table("entreprise_contact") + op.drop_table("entreprise_correspondant") + op.drop_index("ix_entreprises_dept_id", table_name="entreprises") + op.drop_table("entreprises") + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "entreprises", + sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("nom", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("adresse", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("ville", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("codepostal", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("pays", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("localisation", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("dept_id", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "date_creation", + postgresql.TIMESTAMP(timezone=True), + server_default=sa.text("now()"), + autoincrement=False, + nullable=True, + ), + sa.Column("secteur", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("privee", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("plus10salaries", sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column("contact_origine", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("note", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("qualite_relation", sa.INTEGER(), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint( + ["dept_id"], ["departement.id"], name="entreprises_dept_id_fkey" + ), + sa.PrimaryKeyConstraint("id", name="entreprises_pkey"), + ) + op.create_table( + "entreprise_correspondant", + sa.Column( + "id", + sa.INTEGER(), + server_default=sa.text( + "nextval('entreprise_correspondant_id_seq'::regclass)" + ), + 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"), + postgresql_ignore_search_path=False, + ) + op.create_table( + "entreprise_contact", + sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("entreprise_id", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "entreprise_corresp_id", sa.INTEGER(), autoincrement=False, nullable=True + ), + sa.Column("etudid", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("type_contact", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column( + "date", + postgresql.TIMESTAMP(timezone=True), + autoincrement=False, + nullable=True, + ), + sa.Column("enseignant", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("description", sa.TEXT(), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint( + ["entreprise_corresp_id"], + ["entreprise_correspondant.id"], + name="entreprise_contact_entreprise_corresp_id_fkey", + ), + sa.ForeignKeyConstraint( + ["entreprise_id"], + ["entreprises.id"], + name="entreprise_contact_entreprise_id_fkey", + ), + sa.PrimaryKeyConstraint("id", name="entreprise_contact_pkey"), + ) + op.create_index("ix_entreprises_dept_id", "entreprises", ["dept_id"], unique=False) + op.drop_table("are_entreprise_offre_departement") + op.drop_table("are_entreprise_envoi_offre_etudiant") + op.drop_table("are_entreprise_envoi_offre") + op.drop_table("are_entreprise_offre") + op.drop_table("are_entreprise_etudiant") + op.drop_table("are_entreprise_contact") + op.drop_table("are_entreprises") + op.drop_table("are_entreprise_log") + # ### end Alembic commands ### diff --git a/migrations/versions/e63f6a9dcc75_tables_application_relations_entreprises.py b/migrations/versions/e63f6a9dcc75_tables_application_relations_entreprises.py deleted file mode 100644 index 73b7b0d14..000000000 --- a/migrations/versions/e63f6a9dcc75_tables_application_relations_entreprises.py +++ /dev/null @@ -1,176 +0,0 @@ -"""tables application relations entreprises - -Revision ID: e63f6a9dcc75 -Revises: c95d5a3bf0de -Create Date: 2022-02-03 15:47:02.445248 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'e63f6a9dcc75' -down_revision = 'c95d5a3bf0de' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('are_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('are_entreprises', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('siret', sa.Text(), nullable=True), - sa.Column('nom', sa.Text(), nullable=True), - sa.Column('adresse', sa.Text(), nullable=True), - sa.Column('codepostal', sa.Text(), nullable=True), - sa.Column('ville', sa.Text(), nullable=True), - sa.Column('pays', sa.Text(), nullable=True), - sa.Column('visible', sa.Boolean(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('are_entreprise_contact', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('entreprise_id', sa.Integer(), nullable=True), - sa.Column('nom', sa.Text(), nullable=True), - sa.Column('prenom', sa.Text(), nullable=True), - sa.Column('telephone', sa.Text(), nullable=True), - sa.Column('mail', sa.Text(), nullable=True), - sa.Column('poste', sa.Text(), nullable=True), - sa.Column('service', sa.Text(), nullable=True), - sa.ForeignKeyConstraint(['entreprise_id'], ['are_entreprises.id'], ondelete='cascade'), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('are_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'], ['are_entreprises.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('are_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.Column('expiration_date', sa.Date(), nullable=True), - sa.ForeignKeyConstraint(['entreprise_id'], ['are_entreprises.id'], ondelete='cascade'), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('are_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'], ['are_entreprise_offre.id'], ), - sa.ForeignKeyConstraint(['receiver_id'], ['user.id'], ), - sa.ForeignKeyConstraint(['sender_id'], ['user.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('are_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'], ['are_entreprise_offre.id'], ), - sa.ForeignKeyConstraint(['receiver_id'], ['identite.id'], ), - sa.ForeignKeyConstraint(['sender_id'], ['user.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('are_entreprise_offre_departement', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('offre_id', sa.Integer(), nullable=True), - sa.Column('dept_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['dept_id'], ['departement.id'], ), - sa.ForeignKeyConstraint(['offre_id'], ['are_entreprise_offre.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.drop_table('entreprise_contact') - op.drop_table('entreprise_correspondant') - op.drop_index('ix_entreprises_dept_id', table_name='entreprises') - op.drop_table('entreprises') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('entreprises', - sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('entreprises_id_seq'::regclass)"), autoincrement=True, nullable=False), - sa.Column('nom', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('adresse', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('ville', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('codepostal', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('pays', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('localisation', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('dept_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('date_creation', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True), - sa.Column('secteur', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('privee', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('plus10salaries', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.Column('contact_origine', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('note', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('qualite_relation', sa.INTEGER(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['dept_id'], ['departement.id'], name='entreprises_dept_id_fkey'), - sa.PrimaryKeyConstraint('id', name='entreprises_pkey'), - postgresql_ignore_search_path=False - ) - op.create_index('ix_entreprises_dept_id', 'entreprises', ['dept_id'], unique=False) - op.create_table('entreprise_correspondant', - sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('entreprise_correspondant_id_seq'::regclass)"), 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'), - postgresql_ignore_search_path=False - ) - op.create_table('entreprise_contact', - sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('entreprise_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('entreprise_corresp_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('etudid', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('type_contact', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.Column('enseignant', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['entreprise_corresp_id'], ['entreprise_correspondant.id'], name='entreprise_contact_entreprise_corresp_id_fkey'), - sa.ForeignKeyConstraint(['entreprise_id'], ['entreprises.id'], name='entreprise_contact_entreprise_id_fkey'), - sa.PrimaryKeyConstraint('id', name='entreprise_contact_pkey') - ) - op.drop_table('are_entreprise_offre_departement') - op.drop_table('are_entreprise_envoi_offre_etudiant') - op.drop_table('are_entreprise_envoi_offre') - op.drop_table('are_entreprise_offre') - op.drop_table('are_entreprise_etudiant') - op.drop_table('are_entreprise_contact') - op.drop_table('are_entreprises') - op.drop_table('are_entreprise_log') - # ### end Alembic commands ###