ajout notes stage/apprentissage + suppression

This commit is contained in:
Arthur ZHU 2022-03-29 19:07:59 +02:00
parent dc0212b725
commit a3cbea5dcd
5 changed files with 75 additions and 35 deletions

View File

@ -327,6 +327,7 @@ class StageApprentissageCreationForm(FlaskForm):
date_fin = DateField(
"Date fin (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
)
notes = TextAreaField("Notes")
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
def validate(self):
@ -373,6 +374,7 @@ class StageApprentissageModificationForm(FlaskForm):
date_fin = DateField(
"Date fin (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
)
notes = TextAreaField("Notes")
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
def validate(self):

View File

@ -110,6 +110,7 @@ class EntrepriseStageApprentissage(db.Model):
date_fin = db.Column(db.Date)
formation_text = db.Column(db.Text)
formation_scodoc = db.Column(db.Integer)
notes = db.Column(db.Text)
class EntrepriseEnvoiOffre(db.Model):

View File

@ -784,9 +784,9 @@ def delete_correspondant(id):
)
@bp.route("/add_stages_apprentissages/<int:id>", methods=["GET", "POST"])
@bp.route("/add_stage_apprentissage/<int:id>", methods=["GET", "POST"])
@permission_required(Permission.RelationsEntreprisesChange)
def add_stages_apprentissages(id):
def add_stage_apprentissage(id):
"""
Permet d'ajouter un étudiant ayant réalisé un stage ou une alternance sur la fiche entreprise de l'entreprise
"""
@ -817,6 +817,7 @@ def add_stages_apprentissages(id):
formation_scodoc=formation.formsemestre.formsemestre_id
if formation
else None,
notes=form.notes.data.strip(),
)
db.session.add(stage_apprentissage)
db.session.commit()
@ -829,9 +830,9 @@ def add_stages_apprentissages(id):
)
@bp.route("/edit_stages_apprentissages/<int:id>", methods=["GET", "POST"])
@bp.route("/edit_stage_apprentissage/<int:id>", methods=["GET", "POST"])
@permission_required(Permission.RelationsEntreprisesChange)
def edit_stages_apprentissages(id):
def edit_stage_apprentissage(id):
stage_apprentissage = EntrepriseStageApprentissage.query.filter_by(
id=id
).first_or_404(description=f"stage_apprentissage {id} inconnue")
@ -854,14 +855,15 @@ def edit_stages_apprentissages(id):
)
stage_apprentissage.etudid = etudiant.id
stage_apprentissage.type_offre = form.type_offre.data.strip()
stage_apprentissage.date_debut = (form.date_debut.data,)
stage_apprentissage.date_fin = (form.date_fin.data,)
stage_apprentissage.date_debut = form.date_debut.data
stage_apprentissage.date_fin = form.date_fin.data
stage_apprentissage.formation_text = (
formation.formsemestre.titre if formation else None,
)
stage_apprentissage.formation_scodoc = (
formation.formsemestre.formsemestre_id if formation else None,
)
stage_apprentissage.notes = form.notes.data.strip()
db.session.commit()
return redirect(
url_for(
@ -873,6 +875,7 @@ def edit_stages_apprentissages(id):
form.type_offre.data = stage_apprentissage.type_offre
form.date_debut.data = stage_apprentissage.date_debut
form.date_fin.data = stage_apprentissage.date_fin
form.notes.data = stage_apprentissage.notes
return render_template(
"entreprises/ajout_stage_apprentissage.html",
title="Modification stage / apprentissage",
@ -880,6 +883,27 @@ def edit_stages_apprentissages(id):
)
@bp.route("/delete_stage_apprentissage/<int:id>", methods=["GET", "POST"])
def delete_stage_apprentissage(id):
stage_apprentissage = EntrepriseStageApprentissage.query.filter_by(
id=id
).first_or_404(description=f"stage_apprentissage {id} inconnu")
form = SuppressionConfirmationForm()
if form.validate_on_submit():
db.session.delete(stage_apprentissage)
db.session.commit()
return redirect(
url_for(
"entreprises.fiche_entreprise", id=stage_apprentissage.entreprise_id
)
)
return render_template(
"entreprises/delete_confirmation.html",
title="Supression stage/apprentissage",
form=form,
)
@bp.route("/envoyer_offre/<int:id>", methods=["GET", "POST"])
@permission_required(Permission.RelationsEntreprisesSend)
def envoyer_offre(id):

View File

@ -71,7 +71,7 @@
<div style="margin-bottom: 10px;">
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<a class="btn btn-primary" href="{{ url_for('entreprises.add_stages_apprentissages', id=entreprise.id) }}">Ajouter stages ou apprentissages</a>
<a class="btn btn-primary" href="{{ url_for('entreprises.add_stage_apprentissage', id=entreprise.id) }}">Ajouter stage ou apprentissage</a>
{% endif %}
<h3>Liste des stages et apprentissages réalisés au sein de l'entreprise</h3>
<table id="table-stages-apprentissages">
@ -83,6 +83,7 @@
<td data-priority="">Type</td>
<td data-priority="">Étudiant</td>
<td data-priority="">Formation</td>
<td data-priority="">Notes</td>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<td data-priority="3">Action</td>
{% endif %}
@ -97,6 +98,7 @@
<td>{{ data[0].type_offre }}</td>
<td>{{ data[1].nom|format_nom }} {{ data[1].prenom|format_prenom }}</td>
<td>{% if data[0].formation_text %}{{ data[0].formation_text }}{% endif %}</td>
<td>{{ data[0].notes }}</td>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<td>
<div class="btn-group">
@ -104,8 +106,8 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu pull-left">
<li><a href="{{ url_for('entreprises.edit_stages_apprentissages', id=data[0].id) }}">Modifier</a></li>
<li><a href="{{ url_for('entreprises.delete_entreprise', id=entreprise.id) }}" style="color:red">Supprimer</a></li>
<li><a href="{{ url_for('entreprises.edit_stage_apprentissage', id=data[0].id) }}">Modifier</a></li>
<li><a href="{{ url_for('entreprises.delete_stage_apprentissage', id=data[0].id) }}" style="color:red">Supprimer</a></li>
</ul>
</div>
</td>
@ -121,6 +123,7 @@
<td data-priority="">Type</td>
<td data-priority="">Étudiant</td>
<td data-priority="">Formation</td>
<td data-priority="">Notes</td>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<td>Action</td>
{% endif %}

View File

@ -1,8 +1,8 @@
"""tables module gestion relations entreprises
Revision ID: 72ae180645e5
Revision ID: 71e760aa626a
Revises: b9aadc10227f
Create Date: 2022-03-28 21:40:35.426046
Create Date: 2022-03-29 18:39:24.772970
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "72ae180645e5"
revision = "71e760aa626a"
down_revision = "b9aadc10227f"
branch_labels = None
depends_on = None
@ -76,6 +76,7 @@ def upgrade():
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.Column("notes", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(
["entreprise_id"], ["are_entreprises.id"], ondelete="cascade"
),
@ -150,9 +151,9 @@ def upgrade():
sa.ForeignKeyConstraint(["offre_id"], ["are_offres.id"], ondelete="cascade"),
sa.PrimaryKeyConstraint("id"),
)
op.drop_index("ix_entreprises_dept_id", table_name="entreprises")
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 ###
@ -195,6 +196,37 @@ def downgrade():
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),
@ -224,28 +256,6 @@ def downgrade():
),
sa.PrimaryKeyConstraint("id", name="entreprise_contact_pkey"),
)
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.drop_table("are_offre_departement")
op.drop_table("are_envoi_offre_etudiant")
op.drop_table("are_envoi_offre")