From 789d2a8c8803f94a2f5371ea76b3215fb2edf167 Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Tue, 25 Jan 2022 19:42:17 +0100 Subject: [PATCH] validation entreprises --- app/entreprises/models.py | 1 + app/entreprises/routes.py | 19 +++++-- .../{offres.html => offres_recues.html} | 0 ...bles_application_relations_entreprises.py} | 53 ++++++++++--------- 4 files changed, 44 insertions(+), 29 deletions(-) rename app/templates/entreprises/{offres.html => offres_recues.html} (100%) rename migrations/versions/{bd5e795fe77d_tables_application_relations_entreprises.py => fa4d3f05e4f0_tables_application_relations_entreprises.py} (98%) diff --git a/app/entreprises/models.py b/app/entreprises/models.py index 0585b4cc4..b3389fa4a 100644 --- a/app/entreprises/models.py +++ b/app/entreprises/models.py @@ -10,6 +10,7 @@ class Entreprise(db.Model): codepostal = db.Column(db.Text) ville = db.Column(db.Text) pays = db.Column(db.Text) + visible = db.Column(db.Boolean, default=False) contacts = db.relationship( "EntrepriseContact", backref="entreprise", diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index 51c693def..c7be9643b 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -57,7 +57,7 @@ def index(): logs: liste des logs """ - entreprises = Entreprise.query.all() + entreprises = Entreprise.query.filter_by(visible=True).all() logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all() return render_template( "entreprises/entreprises.html", @@ -67,6 +67,16 @@ def index(): ) +@bp.route("/validation", methods=["GET"]) +def validation_entreprise(): + entreprises = Entreprise.query.filter_by(visible=False).all() + return render_template( + "entreprises/entreprises.html", + title=("Entreprises"), + entreprises=entreprises, + ) + + @bp.route("/contacts", methods=["GET"]) def contacts(): """ @@ -84,6 +94,7 @@ def contacts(): contacts = ( db.session.query(EntrepriseContact, Entreprise) .join(Entreprise, EntrepriseContact.entreprise_id == Entreprise.id) + .filter_by(visible=True) .all() ) logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all() @@ -165,7 +176,7 @@ def fiche_entreprise(id): ) -@bp.route("/offres", methods=["GET"]) +@bp.route("/offres_recues", methods=["GET"]) def offres(): """ Permet d'afficher la page où l'on recoit les offres @@ -184,7 +195,9 @@ def offres(): .all() ) return render_template( - "entreprises/offres.html", title=("Offres"), offres_recues=offres_recues + "entreprises/offres_recues.html", + title=("Offres reçues"), + offres_recues=offres_recues, ) diff --git a/app/templates/entreprises/offres.html b/app/templates/entreprises/offres_recues.html similarity index 100% rename from app/templates/entreprises/offres.html rename to app/templates/entreprises/offres_recues.html diff --git a/migrations/versions/bd5e795fe77d_tables_application_relations_entreprises.py b/migrations/versions/fa4d3f05e4f0_tables_application_relations_entreprises.py similarity index 98% rename from migrations/versions/bd5e795fe77d_tables_application_relations_entreprises.py rename to migrations/versions/fa4d3f05e4f0_tables_application_relations_entreprises.py index 54ea8e09f..b116c8e0f 100644 --- a/migrations/versions/bd5e795fe77d_tables_application_relations_entreprises.py +++ b/migrations/versions/fa4d3f05e4f0_tables_application_relations_entreprises.py @@ -1,8 +1,8 @@ """tables application relations entreprises -Revision ID: bd5e795fe77d +Revision ID: fa4d3f05e4f0 Revises: f40fbaf5831c -Create Date: 2022-01-24 17:43:29.261983 +Create Date: 2022-01-25 17:33:28.546610 """ from alembic import op @@ -10,7 +10,7 @@ import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = "bd5e795fe77d" +revision = "fa4d3f05e4f0" down_revision = "f40fbaf5831c" branch_labels = None depends_on = None @@ -41,6 +41,7 @@ def upgrade(): 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( @@ -148,8 +149,8 @@ def upgrade(): 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("entreprise_correspondant") op.drop_table("entreprises") # ### end Alembic commands ### @@ -192,6 +193,28 @@ 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(), 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_table( "entreprise_contact", sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), @@ -221,28 +244,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_entreprise_envoi_offre_etudiant") op.drop_table("are_entreprise_envoi_offre") op.drop_table("are_entreprise_offre")