1
0
forked from ScoDoc/ScoDoc

validation entreprises

This commit is contained in:
Arthur ZHU 2022-01-25 19:42:17 +01:00
parent 0220607caa
commit 789d2a8c88
4 changed files with 44 additions and 29 deletions

View File

@ -10,6 +10,7 @@ class Entreprise(db.Model):
codepostal = db.Column(db.Text) codepostal = db.Column(db.Text)
ville = db.Column(db.Text) ville = db.Column(db.Text)
pays = db.Column(db.Text) pays = db.Column(db.Text)
visible = db.Column(db.Boolean, default=False)
contacts = db.relationship( contacts = db.relationship(
"EntrepriseContact", "EntrepriseContact",
backref="entreprise", backref="entreprise",

View File

@ -57,7 +57,7 @@ def index():
logs: logs:
liste des 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() logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all()
return render_template( return render_template(
"entreprises/entreprises.html", "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"]) @bp.route("/contacts", methods=["GET"])
def contacts(): def contacts():
""" """
@ -84,6 +94,7 @@ def contacts():
contacts = ( contacts = (
db.session.query(EntrepriseContact, Entreprise) db.session.query(EntrepriseContact, Entreprise)
.join(Entreprise, EntrepriseContact.entreprise_id == Entreprise.id) .join(Entreprise, EntrepriseContact.entreprise_id == Entreprise.id)
.filter_by(visible=True)
.all() .all()
) )
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).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(): def offres():
""" """
Permet d'afficher la page où l'on recoit les offres Permet d'afficher la page où l'on recoit les offres
@ -184,7 +195,9 @@ def offres():
.all() .all()
) )
return render_template( return render_template(
"entreprises/offres.html", title=("Offres"), offres_recues=offres_recues "entreprises/offres_recues.html",
title=("Offres reçues"),
offres_recues=offres_recues,
) )

View File

@ -1,8 +1,8 @@
"""tables application relations entreprises """tables application relations entreprises
Revision ID: bd5e795fe77d Revision ID: fa4d3f05e4f0
Revises: f40fbaf5831c Revises: f40fbaf5831c
Create Date: 2022-01-24 17:43:29.261983 Create Date: 2022-01-25 17:33:28.546610
""" """
from alembic import op from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
from sqlalchemy.dialects import postgresql from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = "bd5e795fe77d" revision = "fa4d3f05e4f0"
down_revision = "f40fbaf5831c" down_revision = "f40fbaf5831c"
branch_labels = None branch_labels = None
depends_on = None depends_on = None
@ -41,6 +41,7 @@ def upgrade():
sa.Column("codepostal", sa.Text(), nullable=True), sa.Column("codepostal", sa.Text(), nullable=True),
sa.Column("ville", sa.Text(), nullable=True), sa.Column("ville", sa.Text(), nullable=True),
sa.Column("pays", sa.Text(), nullable=True), sa.Column("pays", sa.Text(), nullable=True),
sa.Column("visible", sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint("id"), sa.PrimaryKeyConstraint("id"),
) )
op.create_table( op.create_table(
@ -148,8 +149,8 @@ def upgrade():
sa.PrimaryKeyConstraint("id"), sa.PrimaryKeyConstraint("id"),
) )
op.drop_table("entreprise_contact") op.drop_table("entreprise_contact")
op.drop_table("entreprise_correspondant")
op.drop_index("ix_entreprises_dept_id", table_name="entreprises") op.drop_index("ix_entreprises_dept_id", table_name="entreprises")
op.drop_table("entreprise_correspondant")
op.drop_table("entreprises") op.drop_table("entreprises")
# ### end Alembic commands ### # ### end Alembic commands ###
@ -192,6 +193,28 @@ def downgrade():
postgresql_ignore_search_path=False, postgresql_ignore_search_path=False,
) )
op.create_index("ix_entreprises_dept_id", "entreprises", ["dept_id"], unique=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( op.create_table(
"entreprise_contact", "entreprise_contact",
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
@ -221,28 +244,6 @@ def downgrade():
), ),
sa.PrimaryKeyConstraint("id", name="entreprise_contact_pkey"), 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_etudiant")
op.drop_table("are_entreprise_envoi_offre") op.drop_table("are_entreprise_envoi_offre")
op.drop_table("are_entreprise_offre") op.drop_table("are_entreprise_offre")