1
0
forked from ScoDoc/ScoDoc

formulaire offre/département

This commit is contained in:
Arthur ZHU 2022-02-04 17:12:56 +01:00
parent 5444c8e848
commit 6a734ce06a
9 changed files with 343 additions and 194 deletions

View File

@ -4,6 +4,7 @@
from flask import Blueprint from flask import Blueprint
from app.scodoc import sco_etud from app.scodoc import sco_etud
from app.auth.models import User from app.auth.models import User
from app.models import Departement
bp = Blueprint("entreprises", __name__) bp = Blueprint("entreprises", __name__)
@ -27,9 +28,15 @@ def get_nomcomplet(s):
@bp.app_template_filter() @bp.app_template_filter()
def get_nomcomplet_by_id(s): def get_nomcomplet_by_id(id):
user = User.query.filter_by(id=s).first() user = User.query.filter_by(id=id).first()
return user.get_nomcomplet() 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 from app.entreprises import routes

View File

@ -41,6 +41,7 @@ from wtforms import (
) )
from wtforms.fields import EmailField, DateField from wtforms.fields import EmailField, DateField
from wtforms.validators import ValidationError, DataRequired, Email, Optional from wtforms.validators import ValidationError, DataRequired, Email, Optional
from wtforms.widgets import ListWidget, CheckboxInput
from app.entreprises.models import Entreprise, EntrepriseContact from app.entreprises.models import Entreprise, EntrepriseContact
from app.models import Identite, Departement from app.models import Identite, Departement
@ -131,6 +132,11 @@ class EntrepriseModificationForm(FlaskForm):
submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"}) submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"})
class MultiCheckboxField(SelectMultipleField):
widget = ListWidget(prefix_label=False)
option_widget = CheckboxInput()
class OffreCreationForm(FlaskForm): class OffreCreationForm(FlaskForm):
intitule = StringField("Intitulé", validators=[DataRequired(message=CHAMP_REQUIS)]) intitule = StringField("Intitulé", validators=[DataRequired(message=CHAMP_REQUIS)])
@ -146,7 +152,7 @@ class OffreCreationForm(FlaskForm):
"Missions", validators=[DataRequired(message=CHAMP_REQUIS)] "Missions", validators=[DataRequired(message=CHAMP_REQUIS)]
) )
duree = StringField("Durée", 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( expiration_date = DateField(
"Date expiration", validators=[DataRequired(message=CHAMP_REQUIS)] "Date expiration", validators=[DataRequired(message=CHAMP_REQUIS)]
) )
@ -174,11 +180,19 @@ class OffreModificationForm(FlaskForm):
"Missions", validators=[DataRequired(message=CHAMP_REQUIS)] "Missions", validators=[DataRequired(message=CHAMP_REQUIS)]
) )
duree = StringField("Durée", 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( expiration_date = DateField(
"Date expiration", validators=[DataRequired(message=CHAMP_REQUIS)] "Date expiration", validators=[DataRequired(message=CHAMP_REQUIS)]
) )
submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"}) 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): class ContactCreationForm(FlaskForm):
hidden_entreprise_id = HiddenField() hidden_entreprise_id = HiddenField()

View File

@ -112,7 +112,9 @@ class EntrepriseLog(db.Model):
class EntrepriseEtudiant(db.Model): class EntrepriseEtudiant(db.Model):
__tablename__ = "are_entreprise_etudiant" __tablename__ = "are_entreprise_etudiant"
id = db.Column(db.Integer, primary_key=True) 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) etudid = db.Column(db.Integer)
type_offre = db.Column(db.Text) type_offre = db.Column(db.Text)
date_debut = db.Column(db.Date) date_debut = db.Column(db.Date)
@ -124,23 +126,31 @@ class EntrepriseEtudiant(db.Model):
class EntrepriseEnvoiOffre(db.Model): class EntrepriseEnvoiOffre(db.Model):
__tablename__ = "are_entreprise_envoi_offre" __tablename__ = "are_entreprise_envoi_offre"
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
sender_id = db.Column(db.Integer, db.ForeignKey("user.id")) sender_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade"))
receiver_id = db.Column(db.Integer, db.ForeignKey("user.id")) receiver_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade"))
offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id")) 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()) date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
class EntrepriseEnvoiOffreEtudiant(db.Model): class EntrepriseEnvoiOffreEtudiant(db.Model):
__tablename__ = "are_entreprise_envoi_offre_etudiant" __tablename__ = "are_entreprise_envoi_offre_etudiant"
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
sender_id = db.Column(db.Integer, db.ForeignKey("user.id")) sender_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade"))
receiver_id = db.Column(db.Integer, db.ForeignKey("identite.id")) receiver_id = db.Column(
offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id")) 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()) date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
class EntrepriseOffreDepartement(db.Model): class EntrepriseOffreDepartement(db.Model):
__tablename__ = "are_entreprise_offre_departement" __tablename__ = "are_entreprise_offre_departement"
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id")) offre_id = db.Column(
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id")) db.Integer, db.ForeignKey("are_entreprise_offre.id", ondelete="cascade")
)
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id", ondelete="cascade"))

View File

@ -74,8 +74,6 @@ def logs():
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).paginate( logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).paginate(
page=page, per_page=20 page=page, per_page=20
) )
if logs is None:
abort(404)
return render_template("entreprises/logs.html", title=("Logs"), logs=logs) 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}/*"): for file in glob.glob(f"{dir}/*"):
file = [os.path.basename(dir), os.path.basename(file)] file = [os.path.basename(dir), os.path.basename(file)]
files.append(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 contacts = entreprise.contacts
logs = ( logs = (
EntrepriseLog.query.order_by(EntrepriseLog.date.desc()) EntrepriseLog.query.order_by(EntrepriseLog.date.desc())
@ -180,8 +181,6 @@ def logs_entreprise(id):
.filter_by(object=id) .filter_by(object=id)
.paginate(page=page, per_page=20) .paginate(page=page, per_page=20)
) )
if logs is None:
abort(404)
return render_template( return render_template(
"entreprises/logs_entreprise.html", "entreprises/logs_entreprise.html",
title=("Logs"), title=("Logs"),
@ -267,7 +266,10 @@ def offres_expirees(id):
for file in glob.glob(f"{dir}/*"): for file in glob.glob(f"{dir}/*"):
file = [os.path.basename(dir), os.path.basename(file)] file = [os.path.basename(dir), os.path.basename(file)]
files.append(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( return render_template(
"entreprises/offres_expirees.html", "entreprises/offres_expirees.html",
title=("Offres expirées"), title=("Offres expirées"),
@ -491,7 +493,9 @@ def edit_offre(id):
Permet de modifier une offre Permet de modifier une offre
""" """
offre = EntrepriseOffre.query.filter_by(id=id).first_or_404() offre = EntrepriseOffre.query.filter_by(id=id).first_or_404()
offre_depts = EntrepriseOffreDepartement.query.filter_by(offre_id=offre.id).all()
form = OffreModificationForm() form = OffreModificationForm()
offre_depts_list = [(offre_dept.dept_id) for offre_dept in offre_depts]
if form.validate_on_submit(): if form.validate_on_submit():
offre.intitule = form.intitule.data.strip() offre.intitule = form.intitule.data.strip()
offre.description = form.description.data.strip() offre.description = form.description.data.strip()
@ -499,6 +503,20 @@ def edit_offre(id):
offre.missions = form.missions.data.strip() offre.missions = form.missions.data.strip()
offre.duree = form.duree.data.strip() offre.duree = form.duree.data.strip()
offre.expiration_date = form.expiration_date.data 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( log = EntrepriseLog(
authenticated_user=current_user.user_name, authenticated_user=current_user.user_name,
object=offre.entreprise_id, object=offre.entreprise_id,
@ -515,6 +533,7 @@ def edit_offre(id):
form.missions.data = offre.missions form.missions.data = offre.missions
form.duree.data = offre.duree form.duree.data = offre.duree
form.expiration_date.data = offre.expiration_date form.expiration_date.data = offre.expiration_date
form.depts.data = offre_depts_list
return render_template( return render_template(
"entreprises/form.html", title=("Modification offre"), form=form "entreprises/form.html", title=("Modification offre"), form=form
) )

View File

@ -69,3 +69,15 @@
.contacts-et-offres > div:nth-child(2) { .contacts-et-offres > div:nth-child(2) {
margin-left: 20px; margin-left: 20px;
} }
#depts {
list-style: none;
padding-left: 10px;
}
.offre_depts {
display: inline-block;
border: black solid 2px;
border-radius: 5px;
padding: 1px;
}

View File

@ -6,6 +6,9 @@
Type de l'offre : {{ offre[0].type_offre }}<br> Type de l'offre : {{ offre[0].type_offre }}<br>
Missions : {{ offre[0].missions }}<br> Missions : {{ offre[0].missions }}<br>
Durée : {{ offre[0].duree }}<br> Durée : {{ offre[0].duree }}<br>
{% if offre[2] %}
Département(s) : {% for offre_dept in offre[2] %} <div class="offre_depts">{{ offre_dept.dept_id|get_dept_acronym }}</div> {% endfor %}<br>
{% endif %}
{% for fichier in offre[1] %} {% for fichier in offre[1] %}
<a href="{{ url_for('entreprises.get_offre_file', entreprise_id=entreprise.id, offre_id=offre[0].id, filedir=fichier[0], filename=fichier[1] )}}">{{ fichier[1] }}</a> <a href="{{ url_for('entreprises.get_offre_file', entreprise_id=entreprise.id, offre_id=offre[0].id, filedir=fichier[0], filename=fichier[1] )}}">{{ fichier[1] }}</a>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}

View File

@ -16,4 +16,11 @@
{{ wtf.quick_form(form, novalidate=True) }} {{ wtf.quick_form(form, novalidate=True) }}
</div> </div>
</div> </div>
<script>
<!-- pour le formulaire ajout offre -->
var element = document.getElementById("depts");
var closest_form_control = element.closest(".form-control")
closest_form_control.classList.remove("form-control")
</script>
{% endblock %} {% endblock %}

View File

@ -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 ###

View File

@ -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 ###