forked from ScoDoc/ScoDoc
enrichissement correspondant, desactiver une entreprise
This commit is contained in:
parent
a06854eb12
commit
cf0a136071
@ -39,4 +39,12 @@ def get_dept_acronym(id):
|
||||
return dept.acronym
|
||||
|
||||
|
||||
@bp.app_template_filter()
|
||||
def get_civilité(civ):
|
||||
if civ == "H":
|
||||
return "Monsieur"
|
||||
else:
|
||||
return "Madame"
|
||||
|
||||
|
||||
from app.entreprises import routes
|
||||
|
@ -80,6 +80,11 @@ class EntrepriseCreationForm(FlaskForm):
|
||||
ville = _build_string_field("Ville de l'entreprise (*)")
|
||||
pays = _build_string_field("Pays de l'entreprise", required=False)
|
||||
|
||||
civilite = SelectField(
|
||||
"Civilité du correspondant",
|
||||
choices=[("M", "Monsieur"), ("F", "Madame")],
|
||||
validators=[DataRequired(message=CHAMP_REQUIS)],
|
||||
)
|
||||
nom_correspondant = _build_string_field("Nom du correspondant", required=False)
|
||||
prenom_correspondant = _build_string_field(
|
||||
"Prénom du correspondant", required=False
|
||||
@ -91,6 +96,8 @@ class EntrepriseCreationForm(FlaskForm):
|
||||
)
|
||||
poste = _build_string_field("Poste du correspondant", required=False)
|
||||
service = _build_string_field("Service du correspondant", required=False)
|
||||
origine = _build_string_field("Origine du correspondant", required=False)
|
||||
notes = _build_string_field("Notes sur le correspondant", required=False)
|
||||
|
||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||
|
||||
@ -106,6 +113,8 @@ class EntrepriseCreationForm(FlaskForm):
|
||||
or self.mail.data.strip()
|
||||
or self.poste.data.strip()
|
||||
or self.service.data.strip()
|
||||
or self.origine.data.strip()
|
||||
or self.notes.data.strip()
|
||||
):
|
||||
if not self.nom_correspondant.data.strip():
|
||||
self.nom_correspondant.errors.append("Ce champ est requis")
|
||||
@ -184,11 +193,11 @@ class OffreCreationForm(FlaskForm):
|
||||
"Missions (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
duree = _build_string_field("Durée (*)")
|
||||
depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int)
|
||||
depts = MultiCheckboxField("Départements (*)", validators=[Optional()], coerce=int)
|
||||
expiration_date = DateField("Date expiration", validators=[Optional()])
|
||||
correspondant = SelectField("Correspondant à contacté", validators=[Optional()])
|
||||
fichier = FileField(
|
||||
"Fichier (*)",
|
||||
"Fichier",
|
||||
validators=[
|
||||
Optional(),
|
||||
FileAllowed(["pdf", "docx"], "Fichier .pdf ou .docx uniquement"),
|
||||
@ -237,7 +246,7 @@ class OffreModificationForm(FlaskForm):
|
||||
"Missions (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
duree = _build_string_field("Durée (*)")
|
||||
depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int)
|
||||
depts = MultiCheckboxField("Départements (*)", validators=[Optional()], coerce=int)
|
||||
expiration_date = DateField("Date expiration", validators=[Optional()])
|
||||
correspondant = SelectField("Correspondant à contacté", validators=[Optional()])
|
||||
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||
@ -269,6 +278,12 @@ class OffreModificationForm(FlaskForm):
|
||||
|
||||
|
||||
class CorrespondantCreationForm(FlaskForm):
|
||||
civilite = SelectField(
|
||||
"Civilité (*)",
|
||||
choices=[("H", "Monsieur"), ("F", "Madame")],
|
||||
validators=[DataRequired(message=CHAMP_REQUIS)],
|
||||
render_kw={"class": "form-control"},
|
||||
)
|
||||
nom = _build_string_field("Nom (*)", render_kw={"class": "form-control"})
|
||||
prenom = _build_string_field("Prénom (*)", render_kw={"class": "form-control"})
|
||||
telephone = _build_string_field(
|
||||
@ -285,14 +300,12 @@ class CorrespondantCreationForm(FlaskForm):
|
||||
service = _build_string_field(
|
||||
"Service", required=False, render_kw={"class": "form-control"}
|
||||
)
|
||||
# depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int)
|
||||
|
||||
# def __init__(self, *args, **kwargs):
|
||||
# super().__init__(*args, **kwargs)
|
||||
|
||||
# self.depts.choices = [
|
||||
# (dept.id, dept.acronym) for dept in Departement.query.all()
|
||||
# ]
|
||||
origine = _build_string_field(
|
||||
"Origine", required=False, render_kw={"class": "form-control"}
|
||||
)
|
||||
notes = _build_string_field(
|
||||
"Notes", required=False, render_kw={"class": "form-control"}
|
||||
)
|
||||
|
||||
def validate(self):
|
||||
validate = True
|
||||
@ -351,6 +364,11 @@ class CorrespondantsCreationForm(FlaskForm):
|
||||
class CorrespondantModificationForm(FlaskForm):
|
||||
hidden_correspondant_id = HiddenField()
|
||||
hidden_entreprise_id = HiddenField()
|
||||
civilite = SelectField(
|
||||
"Civilité (*)",
|
||||
choices=[("H", "Monsieur"), ("F", "Madame")],
|
||||
validators=[DataRequired(message=CHAMP_REQUIS)],
|
||||
)
|
||||
nom = _build_string_field("Nom (*)")
|
||||
prenom = _build_string_field("Prénom (*)")
|
||||
telephone = _build_string_field("Téléphone (*)", required=False)
|
||||
@ -360,16 +378,10 @@ class CorrespondantModificationForm(FlaskForm):
|
||||
)
|
||||
poste = _build_string_field("Poste", required=False)
|
||||
service = _build_string_field("Service", required=False)
|
||||
# depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int)
|
||||
origine = _build_string_field("Origine", required=False)
|
||||
notes = _build_string_field("Notes", required=False)
|
||||
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||
|
||||
# def __init__(self, *args, **kwargs):
|
||||
# super().__init__(*args, **kwargs)
|
||||
|
||||
# self.depts.choices = [
|
||||
# (dept.id, dept.acronym) for dept in Departement.query.all()
|
||||
# ]
|
||||
|
||||
def validate(self):
|
||||
validate = True
|
||||
if not FlaskForm.validate(self):
|
||||
|
@ -11,6 +11,7 @@ class Entreprise(db.Model):
|
||||
ville = db.Column(db.Text)
|
||||
pays = db.Column(db.Text, default="FRANCE")
|
||||
visible = db.Column(db.Boolean, default=False)
|
||||
active = db.Column(db.Boolean, default=True)
|
||||
correspondants = db.relationship(
|
||||
"EntrepriseCorrespondant",
|
||||
backref="entreprise",
|
||||
@ -51,12 +52,15 @@ class EntrepriseCorrespondant(db.Model):
|
||||
db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade")
|
||||
)
|
||||
# site_id = db.Column(db.Integer, db.ForeignKey("are_sites.id", ondelete="cascade"))
|
||||
civilite = db.Column(db.String(1))
|
||||
nom = db.Column(db.Text)
|
||||
prenom = db.Column(db.Text)
|
||||
telephone = db.Column(db.Text)
|
||||
mail = db.Column(db.Text)
|
||||
poste = db.Column(db.Text)
|
||||
service = db.Column(db.Text)
|
||||
origine = db.Column(db.Text)
|
||||
notes = db.Column(db.Text)
|
||||
|
||||
def to_dict(self):
|
||||
entreprise = Entreprise.query.filter_by(id=self.entreprise_id).first()
|
||||
@ -161,15 +165,6 @@ class EntrepriseOffreDepartement(db.Model):
|
||||
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id", ondelete="cascade"))
|
||||
|
||||
|
||||
# class EntrepriseCorrespondantDepartement(db.Model):
|
||||
# __tablename__ = "are_correspondant_departement"
|
||||
# id = db.Column(db.Integer, primary_key=True)
|
||||
# correspondant_id = db.Column(
|
||||
# db.Integer, db.ForeignKey("are_correspondants.id", ondelete="cascade")
|
||||
# )
|
||||
# dept_id = db.Column(db.Integer, db.ForeignKey("departement.id", ondelete="cascade"))
|
||||
|
||||
|
||||
class EntreprisePreferences(db.Model):
|
||||
__tablename__ = "are_preferences"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
@ -59,7 +59,7 @@ def index():
|
||||
"""
|
||||
Permet d'afficher une page avec la liste des entreprises (visible) et une liste des dernières opérations
|
||||
"""
|
||||
entreprises = Entreprise.query.filter_by(visible=True)
|
||||
entreprises = Entreprise.query.filter_by(visible=True, active=True)
|
||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all()
|
||||
return render_template(
|
||||
"entreprises/entreprises.html",
|
||||
@ -298,12 +298,15 @@ def add_entreprise():
|
||||
db.session.refresh(entreprise)
|
||||
correspondant = EntrepriseCorrespondant(
|
||||
entreprise_id=entreprise.id,
|
||||
civilite=form.civilite.data,
|
||||
nom=form.nom_correspondant.data.strip(),
|
||||
prenom=form.prenom_correspondant.data.strip(),
|
||||
telephone=form.telephone.data.strip(),
|
||||
mail=form.mail.data.strip(),
|
||||
poste=form.poste.data.strip(),
|
||||
service=form.service.data.strip(),
|
||||
origine=form.origine.data.strip(),
|
||||
notes=form.notes.data.strip(),
|
||||
)
|
||||
db.session.add(correspondant)
|
||||
if current_user.has_permission(Permission.RelationsEntreprisesValidate, None):
|
||||
@ -440,6 +443,17 @@ def delete_entreprise(id):
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/fiche_entreprise/desactiver/<int:id>", methods=["GET", "POST"])
|
||||
def fiche_entreprise_desactiver(id):
|
||||
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"))
|
||||
|
||||
|
||||
@bp.route(
|
||||
"/fiche_entreprise_validation/<int:id>/validate_entreprise", methods=["GET", "POST"]
|
||||
)
|
||||
@ -697,12 +711,15 @@ def add_correspondant(id):
|
||||
for correspondant_entry in form.correspondants.entries:
|
||||
correspondant = EntrepriseCorrespondant(
|
||||
entreprise_id=entreprise.id,
|
||||
civilite=correspondant_entry.civilite.data,
|
||||
nom=correspondant_entry.nom.data.strip(),
|
||||
prenom=correspondant_entry.prenom.data.strip(),
|
||||
telephone=correspondant_entry.telephone.data.strip(),
|
||||
mail=correspondant_entry.mail.data.strip(),
|
||||
poste=correspondant_entry.poste.data.strip(),
|
||||
service=correspondant_entry.service.data.strip(),
|
||||
origine=correspondant_entry.origine.data.strip(),
|
||||
notes=correspondant_entry.notes.data.strip(),
|
||||
)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
@ -735,12 +752,15 @@ def edit_correspondant(id):
|
||||
hidden_correspondant_id=correspondant.id,
|
||||
)
|
||||
if form.validate_on_submit():
|
||||
correspondant.civilite = form.civilite.data
|
||||
correspondant.nom = form.nom.data.strip()
|
||||
correspondant.prenom = form.prenom.data.strip()
|
||||
correspondant.telephone = form.telephone.data.strip()
|
||||
correspondant.mail = form.mail.data.strip()
|
||||
correspondant.poste = form.poste.data.strip()
|
||||
correspondant.service = form.service.data.strip()
|
||||
correspondant.origine = form.origine.data.strip()
|
||||
correspondant.notes = form.notes.data.strip()
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=correspondant.entreprise_id,
|
||||
@ -753,12 +773,15 @@ def edit_correspondant(id):
|
||||
url_for("entreprises.fiche_entreprise", id=correspondant.entreprise.id)
|
||||
)
|
||||
elif request.method == "GET":
|
||||
form.civilite.data = correspondant.civilite
|
||||
form.nom.data = correspondant.nom
|
||||
form.prenom.data = correspondant.prenom
|
||||
form.telephone.data = correspondant.telephone
|
||||
form.mail.data = correspondant.mail
|
||||
form.poste.data = correspondant.poste
|
||||
form.service.data = correspondant.service
|
||||
form.origine.data = correspondant.origine
|
||||
form.notes.data = correspondant.notes
|
||||
return render_template(
|
||||
"entreprises/form.html",
|
||||
title="Modification correspondant",
|
||||
|
@ -1,6 +1,7 @@
|
||||
{# -*- mode: jinja-html -*- #}
|
||||
<div class="correspondant">
|
||||
<div>
|
||||
Civilité : {{ correspondant.civilite|get_civilité }}<br>
|
||||
Nom : {{ correspondant.nom }}<br>
|
||||
Prénom : {{ correspondant.prenom }}<br>
|
||||
{% if correspondant.telephone %}
|
||||
@ -15,6 +16,12 @@
|
||||
{% if correspondant.service %}
|
||||
Service : {{ correspondant.service }}<br>
|
||||
{% endif %}
|
||||
{% if correspondant.origine %}
|
||||
Origine : {{ correspondant.origine }}<br>
|
||||
{% endif %}
|
||||
{% if correspondant.notes %}
|
||||
Notes : {{ correspondant.notes }}<br>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{# -*- mode: jinja-html -*- #}
|
||||
<div class="offre">
|
||||
<div>
|
||||
<div style="word-break:break-all; text-align: justify;">
|
||||
Ajouté le {{ offre[0].date_ajout.strftime('%d/%m/%y') }} à {{ offre[0].date_ajout.strftime('%Hh%M') }}<br>
|
||||
Intitulé : {{ offre[0].intitule }}<br>
|
||||
Description : {{ offre[0].description }}<br>
|
||||
|
@ -67,6 +67,7 @@
|
||||
</a>
|
||||
<ul class="dropdown-menu pull-left">
|
||||
<li><a href="{{ url_for('entreprises.edit_entreprise', id=entreprise.id) }}">Modifier</a></li>
|
||||
<li><a href="{{ url_for('entreprises.fiche_entreprise_desactiver', id=entreprise.id)}}" style="color:red">Désactiver</a></li>
|
||||
<li><a href="{{ url_for('entreprises.delete_entreprise', id=entreprise.id) }}" style="color:red">Supprimer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -9,7 +9,7 @@
|
||||
{% if offres_recues %}
|
||||
{% for offre in offres_recues %}
|
||||
<div class="offre offre-recue">
|
||||
<div>
|
||||
<div style="word-break:break-all; text-align: justify;">
|
||||
Envoyé le {{ offre[0].date_envoi.strftime('%d/%m/%Y') }} à {{ offre[0].date_envoi.strftime('%Hh%M') }} par {{ offre[0].sender_id|get_nomcomplet_by_id }}<br>
|
||||
Intitulé : {{ offre[1].intitule }}<br>
|
||||
Description : {{ offre[1].description }}<br>
|
||||
@ -19,12 +19,20 @@
|
||||
|
||||
{% if offre[1].correspondant_id %}
|
||||
Contacté {{ offre[3].nom }} {{ offre[3].prenom }}
|
||||
{% if offre[3].mail and offre[3].telephone %}
|
||||
({{ offre[3].mail }} - {{ offre[3].telephone }})<br>
|
||||
{% else %}
|
||||
({{ offre[3].mail }}{{offre[3].telephone}})<br>
|
||||
{% if offre[3].mail and offre[3].telephone %}
|
||||
({{ offre[3].mail }} - {{ offre[3].telephone }})
|
||||
{% else %}
|
||||
({{ offre[3].mail }}{{ offre[3].telephone }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if offre[3].poste %}
|
||||
, poste : {{ offre[3].poste }}
|
||||
{% endif %}
|
||||
{% if offre[3].service %}
|
||||
, service : {{ offre[3].service }}
|
||||
{% endif %}
|
||||
<br>
|
||||
|
||||
<a href="{{ url_for('entreprises.fiche_entreprise', id=offre[1].entreprise_id) }}">lien vers l'entreprise</a><br>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user