forked from ScoDoc/ScoDoc
desactiver entreprise, visibilité correspondants
This commit is contained in:
parent
196f80e210
commit
ff228aef4e
@ -137,7 +137,7 @@ def verif_correspondant_data(correspondant_data):
|
||||
correspondant_data[3]: mail
|
||||
correspondant_data[4]: poste
|
||||
correspondant_data[5]: service
|
||||
correspondant_data[6]: entreprise_id
|
||||
correspondant_data[6]: entreprise_siret
|
||||
"""
|
||||
# champs obligatoires
|
||||
if (
|
||||
@ -182,7 +182,7 @@ def verif_entreprise_data(entreprise_data):
|
||||
if data.strip() == "":
|
||||
return False
|
||||
if EntreprisePreferences.get_check_siret():
|
||||
siret = entreprise_data[0].replace(" ", "") # vérification sur le siret
|
||||
siret = entreprise_data[0].strip().replace(" ", "") # vérification sur le siret
|
||||
if re.match("^\d{14}$", siret) is None:
|
||||
return False
|
||||
try:
|
||||
|
@ -135,7 +135,7 @@ class EntrepriseCreationForm(FlaskForm):
|
||||
|
||||
def validate_siret(self, siret):
|
||||
if EntreprisePreferences.get_check_siret():
|
||||
siret_data = siret.data.replace(" ", "")
|
||||
siret_data = siret.data.strip().replace(" ", "")
|
||||
self.siret.data = siret_data
|
||||
if re.match("^\d{14}$", siret_data) is None:
|
||||
raise ValidationError("Format incorrect")
|
||||
@ -605,6 +605,11 @@ class SuppressionConfirmationForm(FlaskForm):
|
||||
submit = SubmitField("Supprimer", render_kw=SUBMIT_MARGE)
|
||||
|
||||
|
||||
class DesactivationConfirmationForm(FlaskForm):
|
||||
notes_active = TextAreaField("Notes sur la désactivation", validators=[Optional()])
|
||||
submit = SubmitField("Désactiver", render_kw=SUBMIT_MARGE)
|
||||
|
||||
|
||||
class ValidationConfirmationForm(FlaskForm):
|
||||
submit = SubmitField("Valider", render_kw=SUBMIT_MARGE)
|
||||
|
||||
|
@ -12,6 +12,7 @@ class Entreprise(db.Model):
|
||||
pays = db.Column(db.Text, default="FRANCE")
|
||||
visible = db.Column(db.Boolean, default=False)
|
||||
active = db.Column(db.Boolean, default=True)
|
||||
notes_active = db.Column(db.Text)
|
||||
correspondants = db.relationship(
|
||||
"EntrepriseCorrespondant",
|
||||
backref="entreprise",
|
||||
|
@ -13,6 +13,7 @@ from app.decorators import permission_required
|
||||
from app.entreprises import LOGS_LEN
|
||||
from app.entreprises.forms import (
|
||||
CorrespondantsCreationForm,
|
||||
DesactivationConfirmationForm,
|
||||
EntrepriseCreationForm,
|
||||
EntrepriseModificationForm,
|
||||
SuppressionConfirmationForm,
|
||||
@ -101,7 +102,7 @@ def validation():
|
||||
|
||||
|
||||
@bp.route("/correspondants", methods=["GET"])
|
||||
@permission_required(Permission.RelationsEntreprisesView)
|
||||
@permission_required(Permission.RelationsEntreprisesCorrespondants)
|
||||
def correspondants():
|
||||
"""
|
||||
Permet d'afficher une page avec la liste des correspondants des entreprises visibles et une liste des dernières opérations
|
||||
@ -109,7 +110,7 @@ def correspondants():
|
||||
correspondants = (
|
||||
db.session.query(EntrepriseCorrespondant, Entreprise)
|
||||
.join(Entreprise, EntrepriseCorrespondant.entreprise_id == Entreprise.id)
|
||||
.filter_by(visible=True)
|
||||
.filter_by(visible=True, active=True)
|
||||
)
|
||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all()
|
||||
return render_template(
|
||||
@ -129,9 +130,9 @@ def fiche_entreprise(id):
|
||||
La fiche entreprise comporte les informations de l'entreprise, les correspondants de l'entreprise et
|
||||
les offres de l'entreprise.
|
||||
"""
|
||||
entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404(
|
||||
description=f"fiche entreprise {id} inconnue"
|
||||
)
|
||||
entreprise = Entreprise.query.filter_by(
|
||||
id=id, visible=True, active=True
|
||||
).first_or_404(description=f"fiche entreprise {id} inconnue")
|
||||
offres_with_files = []
|
||||
depts = are.get_depts()
|
||||
for offre in entreprise.offres:
|
||||
@ -145,7 +146,9 @@ def fiche_entreprise(id):
|
||||
offre_with_files = are.get_offre_files_and_depts(offre, depts)
|
||||
if offre_with_files is not None:
|
||||
offres_with_files.append(offre_with_files)
|
||||
correspondants = entreprise.correspondants[:]
|
||||
correspondants = []
|
||||
if current_user.has_permission(Permission.RelationsEntreprisesCorrespondants, None):
|
||||
correspondants = entreprise.correspondants[:]
|
||||
logs = (
|
||||
EntrepriseLog.query.order_by(EntrepriseLog.date.desc())
|
||||
.filter_by(object=id)
|
||||
@ -437,21 +440,35 @@ def delete_entreprise(id):
|
||||
flash("L'entreprise a été supprimé de la liste.")
|
||||
return redirect(url_for("entreprises.index"))
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html",
|
||||
"entreprises/confirmation_form.html",
|
||||
title="Supression entreprise",
|
||||
form=form,
|
||||
info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression",
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/fiche_entreprise/desactiver/<int:id>", methods=["GET", "POST"])
|
||||
@permission_required(Permission.RelationsEntreprisesChange)
|
||||
def fiche_entreprise_desactiver(id):
|
||||
"""
|
||||
Permet de désactiver une entreprise
|
||||
"""
|
||||
entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404(
|
||||
description=f"entreprise {id} inconnue"
|
||||
)
|
||||
entreprise.active = False
|
||||
db.session.commit()
|
||||
flash("L'entreprise a été désactivé.")
|
||||
return redirect(url_for("entreprises.index"))
|
||||
form = DesactivationConfirmationForm()
|
||||
if form.validate_on_submit():
|
||||
entreprise.notes_active = form.notes_active.data.strip()
|
||||
entreprise.active = False
|
||||
db.session.commit()
|
||||
flash("L'entreprise a été désactivé.")
|
||||
return redirect(url_for("entreprises.index"))
|
||||
return render_template(
|
||||
"entreprises/confirmation_form.html",
|
||||
title="Désactiver entreprise",
|
||||
form=form,
|
||||
info_message="Cliquez sur le bouton Désactiver pour confirmer la désactivation",
|
||||
)
|
||||
|
||||
|
||||
@bp.route(
|
||||
@ -503,9 +520,10 @@ def delete_validation_entreprise(id):
|
||||
flash("L'entreprise a été supprimé de la liste des entreprise à valider.")
|
||||
return redirect(url_for("entreprises.validation"))
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html",
|
||||
"entreprises/confirmation_form.html",
|
||||
title="Supression entreprise",
|
||||
form=form,
|
||||
info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression",
|
||||
)
|
||||
|
||||
|
||||
@ -659,9 +677,10 @@ def delete_offre(id):
|
||||
flash("L'offre a été supprimé de la fiche entreprise.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise_id))
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html",
|
||||
"entreprises/confirmation_form.html",
|
||||
title="Supression offre",
|
||||
form=form,
|
||||
info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression",
|
||||
)
|
||||
|
||||
|
||||
@ -813,9 +832,10 @@ def delete_correspondant(id):
|
||||
url_for("entreprises.fiche_entreprise", id=correspondant.entreprise_id)
|
||||
)
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html",
|
||||
"entreprises/confirmation_form.html",
|
||||
title="Supression correspondant",
|
||||
form=form,
|
||||
info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression",
|
||||
)
|
||||
|
||||
|
||||
@ -1039,9 +1059,10 @@ def delete_stage_apprentissage(id):
|
||||
)
|
||||
)
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html",
|
||||
"entreprises/confirmation_form.html",
|
||||
title="Supression stage/apprentissage",
|
||||
form=form,
|
||||
info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression",
|
||||
)
|
||||
|
||||
|
||||
@ -1503,9 +1524,10 @@ def delete_offre_file(offre_id, filedir):
|
||||
url_for("entreprises.fiche_entreprise", id=offre.entreprise_id)
|
||||
)
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html",
|
||||
"entreprises/confirmation_form.html",
|
||||
title="Suppression fichier d'une offre",
|
||||
form=form,
|
||||
info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression",
|
||||
)
|
||||
|
||||
|
||||
|
@ -47,6 +47,7 @@ _SCO_PERMISSIONS = (
|
||||
),
|
||||
(1 << 25, "RelationsEntreprisesSend", "Envoyer des offres"),
|
||||
(1 << 26, "RelationsEntreprisesValidate", "Valide les entreprises"),
|
||||
(1 << 27, "RelationsEntreprisesCorrespondants", "Voir les correspondants"),
|
||||
)
|
||||
|
||||
|
||||
|
@ -62,7 +62,11 @@ SCO_ROLES_DEFAULTS = {
|
||||
# ObservateurEntreprise est un observateur de l'application entreprise
|
||||
"ObservateurEntreprise": (p.RelationsEntreprisesView,),
|
||||
# UtilisateurEntreprise est un utilisateur de l'application entreprise (droit de modification)
|
||||
"UtilisateurEntreprise": (p.RelationsEntreprisesView, p.RelationsEntreprisesChange),
|
||||
"UtilisateurEntreprise": (
|
||||
p.RelationsEntreprisesView,
|
||||
p.RelationsEntreprisesChange,
|
||||
p.RelationsEntreprisesCorrespondants,
|
||||
),
|
||||
# AdminEntreprise est un admin de l'application entreprise (toutes les actions possibles de l'application)
|
||||
"AdminEntreprise": (
|
||||
p.RelationsEntreprisesView,
|
||||
@ -70,6 +74,7 @@ SCO_ROLES_DEFAULTS = {
|
||||
p.RelationsEntreprisesExport,
|
||||
p.RelationsEntreprisesSend,
|
||||
p.RelationsEntreprisesValidate,
|
||||
p.RelationsEntreprisesCorrespondants,
|
||||
),
|
||||
# Super Admin est un root: création/suppression de départements
|
||||
# _tous_ les droits
|
||||
|
@ -5,7 +5,7 @@
|
||||
{% block app_content %}
|
||||
<h1>{{ title }}</h1>
|
||||
<br>
|
||||
<div style="color:red;">Cliquez sur le bouton Supprimer pour confirmer votre supression</div>
|
||||
<div style="color:red;">{{ info_message }}</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
@ -71,20 +71,20 @@
|
||||
</div>
|
||||
|
||||
<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_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>
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
|
||||
<a class="btn btn-primary" href="{{ url_for('entreprises.add_stage_apprentissage', id=entreprise.id) }}" style="margin-bottom:10px;">Ajouter stage ou apprentissage</a>
|
||||
{% endif %}
|
||||
<table id="table-stages-apprentissages">
|
||||
<thead>
|
||||
<tr>
|
||||
<td data-priority="">Date début</td>
|
||||
<td data-priority="">Date fin</td>
|
||||
<td data-priority="">Durée</td>
|
||||
<td data-priority="">Type</td>
|
||||
<td data-priority="">Étudiant</td>
|
||||
<td data-priority="">Formation</td>
|
||||
<td data-priority="">Notes</td>
|
||||
<td data-priority="3">Date début</td>
|
||||
<td data-priority="4">Date fin</td>
|
||||
<td data-priority="5">Durée</td>
|
||||
<td data-priority="2">Type</td>
|
||||
<td data-priority="1">Étudiant</td>
|
||||
<td data-priority="6">Formation</td>
|
||||
<td data-priority="7">Notes</td>
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
|
||||
<td data-priority="3">Action</td>
|
||||
{% endif %}
|
||||
|
@ -2,7 +2,9 @@
|
||||
<nav class="nav-entreprise">
|
||||
<ul>
|
||||
<li><a href="{{ url_for('entreprises.index') }}">Entreprises</a></li>
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesCorrespondants, None) %}
|
||||
<li><a href="{{ url_for('entreprises.correspondants') }}">Correspondants</a></li>
|
||||
{% endif %}
|
||||
<li><a href="{{ url_for('entreprises.offres_recues') }}">Offres reçues</a></li>
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesValidate, None) %}
|
||||
<li><a href="{{ url_for('entreprises.validation') }}">Entreprises à valider</a></li>
|
||||
|
@ -0,0 +1,40 @@
|
||||
"""ajout colonnes tables relations entreprises
|
||||
|
||||
Revision ID: 01d13209021e
|
||||
Revises: e97b2a10f86c
|
||||
Create Date: 2022-04-21 21:02:01.319876
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "01d13209021e"
|
||||
down_revision = "e97b2a10f86c"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column(
|
||||
"are_correspondants", sa.Column("civilite", sa.String(length=1), nullable=True)
|
||||
)
|
||||
op.add_column("are_correspondants", sa.Column("origine", sa.Text(), nullable=True))
|
||||
op.add_column("are_correspondants", sa.Column("notes", sa.Text(), nullable=True))
|
||||
op.add_column("are_entreprises", sa.Column("active", sa.Boolean(), nullable=True))
|
||||
op.add_column(
|
||||
"are_entreprises", sa.Column("notes_active", sa.Text(), nullable=True)
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("are_entreprises", "notes_active")
|
||||
op.drop_column("are_entreprises", "active")
|
||||
op.drop_column("are_correspondants", "notes")
|
||||
op.drop_column("are_correspondants", "origine")
|
||||
op.drop_column("are_correspondants", "civilite")
|
||||
# ### end Alembic commands ###
|
@ -1,34 +0,0 @@
|
||||
"""ajout colonnes tables relations entreprises
|
||||
|
||||
Revision ID: b1e6885bae70
|
||||
Revises: e97b2a10f86c
|
||||
Create Date: 2022-04-20 21:45:42.828853
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b1e6885bae70'
|
||||
down_revision = 'e97b2a10f86c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('are_correspondants', sa.Column('civilite', sa.String(length=1), nullable=True))
|
||||
op.add_column('are_correspondants', sa.Column('origine', sa.Text(), nullable=True))
|
||||
op.add_column('are_correspondants', sa.Column('notes', sa.Text(), nullable=True))
|
||||
op.add_column('are_entreprises', sa.Column('active', sa.Boolean(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('are_entreprises', 'active')
|
||||
op.drop_column('are_correspondants', 'notes')
|
||||
op.drop_column('are_correspondants', 'origine')
|
||||
op.drop_column('are_correspondants', 'civilite')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user