From a3cbea5dcda1405f09ce2dd3127809c7e2c9f29e Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Tue, 29 Mar 2022 19:07:59 +0200 Subject: [PATCH] ajout notes stage/apprentissage + suppression --- app/entreprises/forms.py | 2 + app/entreprises/models.py | 1 + app/entreprises/routes.py | 36 +++++++++-- .../entreprises/fiche_entreprise.html | 9 ++- ...a626a_tables_module_gestion_relations_.py} | 62 +++++++++++-------- 5 files changed, 75 insertions(+), 35 deletions(-) rename migrations/versions/{72ae180645e5_tables_module_gestion_relations_.py => 71e760aa626a_tables_module_gestion_relations_.py} (96%) diff --git a/app/entreprises/forms.py b/app/entreprises/forms.py index 67b6a0f255..e36c027041 100644 --- a/app/entreprises/forms.py +++ b/app/entreprises/forms.py @@ -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): diff --git a/app/entreprises/models.py b/app/entreprises/models.py index 769836b84a..ca3204ccdb 100644 --- a/app/entreprises/models.py +++ b/app/entreprises/models.py @@ -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): diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index bc6564eb5b..6619bf639a 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -784,9 +784,9 @@ def delete_correspondant(id): ) -@bp.route("/add_stages_apprentissages/", methods=["GET", "POST"]) +@bp.route("/add_stage_apprentissage/", 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/", methods=["GET", "POST"]) +@bp.route("/edit_stage_apprentissage/", 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/", 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/", methods=["GET", "POST"]) @permission_required(Permission.RelationsEntreprisesSend) def envoyer_offre(id): diff --git a/app/templates/entreprises/fiche_entreprise.html b/app/templates/entreprises/fiche_entreprise.html index a74a9438a8..732df7e4b6 100644 --- a/app/templates/entreprises/fiche_entreprise.html +++ b/app/templates/entreprises/fiche_entreprise.html @@ -71,7 +71,7 @@
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - Ajouter stages ou apprentissages + Ajouter stage ou apprentissage {% endif %}

Liste des stages et apprentissages réalisés au sein de l'entreprise

@@ -83,6 +83,7 @@ + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} {% endif %} @@ -97,6 +98,7 @@ + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} @@ -121,6 +123,7 @@ + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} {% endif %} diff --git a/migrations/versions/72ae180645e5_tables_module_gestion_relations_.py b/migrations/versions/71e760aa626a_tables_module_gestion_relations_.py similarity index 96% rename from migrations/versions/72ae180645e5_tables_module_gestion_relations_.py rename to migrations/versions/71e760aa626a_tables_module_gestion_relations_.py index 341e0207b4..5b31523999 100644 --- a/migrations/versions/72ae180645e5_tables_module_gestion_relations_.py +++ b/migrations/versions/71e760aa626a_tables_module_gestion_relations_.py @@ -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")
Type Étudiant FormationNotesAction{{ data[0].type_offre }} {{ data[1].nom|format_nom }} {{ data[1].prenom|format_prenom }} {% if data[0].formation_text %}{{ data[0].formation_text }}{% endif %}{{ data[0].notes }}
@@ -104,8 +106,8 @@
Type Étudiant FormationNotesAction