forked from ScoDoc/DocScoDoc
correction bug, refactoring routes, ajout champ valeur par défaut, saisie entreprise (contact optionnel)
This commit is contained in:
parent
37832c5bb1
commit
edd9fde616
@ -141,28 +141,28 @@ def verif_correspondant_data(correspondant_data):
|
|||||||
"""
|
"""
|
||||||
# champs obligatoires
|
# champs obligatoires
|
||||||
if (
|
if (
|
||||||
correspondant_data[0] == ""
|
correspondant_data[0].strip() == ""
|
||||||
or correspondant_data[1] == ""
|
or correspondant_data[1].strip() == ""
|
||||||
or correspondant_data[6] == ""
|
or correspondant_data[6].strip() == ""
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# entreprise_id existant
|
# entreprise_id existant
|
||||||
entreprise = Entreprise.query.filter_by(siret=correspondant_data[6]).first()
|
entreprise = Entreprise.query.filter_by(siret=correspondant_data[6].strip()).first()
|
||||||
if entreprise is None:
|
if entreprise is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# correspondant possède le meme nom et prénom dans la meme entreprise
|
# correspondant possède le meme nom et prénom dans la meme entreprise
|
||||||
correspondant = EntrepriseCorrespondant.query.filter_by(
|
correspondant = EntrepriseCorrespondant.query.filter_by(
|
||||||
nom=correspondant_data[0],
|
nom=correspondant_data[0].strip(),
|
||||||
prenom=correspondant_data[1],
|
prenom=correspondant_data[1].strip(),
|
||||||
entreprise_id=entreprise.id,
|
entreprise_id=entreprise.id,
|
||||||
).first()
|
).first()
|
||||||
if correspondant is not None:
|
if correspondant is not None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if (
|
if (
|
||||||
correspondant_data[2] == "" and correspondant_data[3] == ""
|
correspondant_data[2].strip() == "" and correspondant_data[3].strip() == ""
|
||||||
): # 1 moyen de contact
|
): # 1 moyen de contact
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -175,11 +175,11 @@ def verif_entreprise_data(entreprise_data):
|
|||||||
"""
|
"""
|
||||||
if EntreprisePreferences.get_check_siret():
|
if EntreprisePreferences.get_check_siret():
|
||||||
for data in entreprise_data: # champs obligatoires
|
for data in entreprise_data: # champs obligatoires
|
||||||
if data == "":
|
if data.strip() == "":
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
for data in entreprise_data[1:]: # champs obligatoires
|
for data in entreprise_data[1:]: # champs obligatoires
|
||||||
if data == "":
|
if data.strip() == "":
|
||||||
return False
|
return False
|
||||||
if EntreprisePreferences.get_check_siret():
|
if EntreprisePreferences.get_check_siret():
|
||||||
siret = entreprise_data[0].replace(" ", "") # vérification sur le siret
|
siret = entreprise_data[0].replace(" ", "") # vérification sur le siret
|
||||||
@ -192,7 +192,7 @@ def verif_entreprise_data(entreprise_data):
|
|||||||
if req.status_code != 200:
|
if req.status_code != 200:
|
||||||
return False
|
return False
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
print("no internet")
|
return False
|
||||||
entreprise = Entreprise.query.filter_by(siret=siret).first()
|
entreprise = Entreprise.query.filter_by(siret=siret).first()
|
||||||
if entreprise is not None:
|
if entreprise is not None:
|
||||||
return False
|
return False
|
||||||
|
@ -80,8 +80,50 @@ class EntrepriseCreationForm(FlaskForm):
|
|||||||
ville = _build_string_field("Ville de l'entreprise (*)")
|
ville = _build_string_field("Ville de l'entreprise (*)")
|
||||||
pays = _build_string_field("Pays de l'entreprise", required=False)
|
pays = _build_string_field("Pays de l'entreprise", required=False)
|
||||||
|
|
||||||
|
nom_correspondant = _build_string_field("Nom du correspondant", required=False)
|
||||||
|
prenom_correspondant = _build_string_field(
|
||||||
|
"Prénom du correspondant", required=False
|
||||||
|
)
|
||||||
|
telephone = _build_string_field("Téléphone du correspondant", required=False)
|
||||||
|
mail = StringField(
|
||||||
|
"Mail du correspondant",
|
||||||
|
validators=[Optional(), Email(message="Adresse e-mail invalide")],
|
||||||
|
)
|
||||||
|
poste = _build_string_field("Poste du correspondant", required=False)
|
||||||
|
service = _build_string_field("Service du correspondant", required=False)
|
||||||
|
|
||||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
validate = True
|
||||||
|
if not FlaskForm.validate(self):
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.nom_correspondant.data.strip()
|
||||||
|
or self.prenom_correspondant.data.strip()
|
||||||
|
or self.telephone.data.strip()
|
||||||
|
or self.mail.data.strip()
|
||||||
|
or self.poste.data.strip()
|
||||||
|
or self.service.data.strip()
|
||||||
|
):
|
||||||
|
if not self.nom_correspondant.data.strip():
|
||||||
|
self.nom_correspondant.errors.append("Ce champ est requis")
|
||||||
|
validate = False
|
||||||
|
if not self.prenom_correspondant.data.strip():
|
||||||
|
self.prenom_correspondant.errors.append("Ce champ est requis")
|
||||||
|
validate = False
|
||||||
|
if not self.telephone.data.strip() and not self.mail.data.strip():
|
||||||
|
self.telephone.errors.append(
|
||||||
|
"Saisir un moyen de contact (mail ou téléphone)"
|
||||||
|
)
|
||||||
|
self.mail.errors.append(
|
||||||
|
"Saisir un moyen de contact (mail ou téléphone)"
|
||||||
|
)
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
return validate
|
||||||
|
|
||||||
def validate_siret(self, siret):
|
def validate_siret(self, siret):
|
||||||
if EntreprisePreferences.get_check_siret():
|
if EntreprisePreferences.get_check_siret():
|
||||||
siret_data = siret.data.replace(" ", "")
|
siret_data = siret.data.replace(" ", "")
|
||||||
@ -95,7 +137,7 @@ class EntrepriseCreationForm(FlaskForm):
|
|||||||
if req.status_code != 200:
|
if req.status_code != 200:
|
||||||
raise ValidationError("SIRET inexistant")
|
raise ValidationError("SIRET inexistant")
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
print("no internet")
|
raise ValidationError("Impossible de vérifier l'existance du SIRET")
|
||||||
entreprise = Entreprise.query.filter_by(siret=siret_data).first()
|
entreprise = Entreprise.query.filter_by(siret=siret_data).first()
|
||||||
if entreprise is not None:
|
if entreprise is not None:
|
||||||
lien = f'<a href="/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}">ici</a>'
|
lien = f'<a href="/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}">ici</a>'
|
||||||
@ -197,7 +239,7 @@ class OffreModificationForm(FlaskForm):
|
|||||||
duree = _build_string_field("Durée (*)")
|
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()])
|
expiration_date = DateField("Date expiration", validators=[Optional()])
|
||||||
correspondant = SelectField("Correspondant à contacté (*)", validators=[Optional()])
|
correspondant = SelectField("Correspondant à contacté", validators=[Optional()])
|
||||||
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -35,6 +35,12 @@ class Entreprise(db.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# class EntrepriseSite(db.Model):
|
||||||
|
# __tablename__ = "are_sites"
|
||||||
|
# id = db.Column(db.Integer, primary_key=True)
|
||||||
|
# nom = db.Column(db.Text)
|
||||||
|
|
||||||
|
|
||||||
class EntrepriseCorrespondant(db.Model):
|
class EntrepriseCorrespondant(db.Model):
|
||||||
__tablename__ = "are_correspondants"
|
__tablename__ = "are_correspondants"
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
@ -170,7 +170,7 @@ def fiche_entreprise(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/logs/<int:id>", methods=["GET"])
|
@bp.route("/fiche_entreprise/<int:id>/logs", methods=["GET"])
|
||||||
@permission_required(Permission.RelationsEntreprisesView)
|
@permission_required(Permission.RelationsEntreprisesView)
|
||||||
def logs_entreprise(id):
|
def logs_entreprise(id):
|
||||||
"""
|
"""
|
||||||
@ -294,6 +294,18 @@ def add_entreprise():
|
|||||||
)
|
)
|
||||||
db.session.add(entreprise)
|
db.session.add(entreprise)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
if form.nom_correspondant.data.strip():
|
||||||
|
db.session.refresh(entreprise)
|
||||||
|
correspondant = EntrepriseCorrespondant(
|
||||||
|
entreprise_id=entreprise.id,
|
||||||
|
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(),
|
||||||
|
)
|
||||||
|
db.session.add(correspondant)
|
||||||
if current_user.has_permission(Permission.RelationsEntreprisesValidate, None):
|
if current_user.has_permission(Permission.RelationsEntreprisesValidate, None):
|
||||||
entreprise.visible = True
|
entreprise.visible = True
|
||||||
nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{entreprise.nom}</a>"
|
nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{entreprise.nom}</a>"
|
||||||
@ -321,7 +333,7 @@ def add_entreprise():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/edit_entreprise/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/edit_entreprise/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def edit_entreprise(id):
|
def edit_entreprise(id):
|
||||||
"""
|
"""
|
||||||
@ -392,7 +404,7 @@ def edit_entreprise(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/delete_entreprise/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/delete_entreprise/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def delete_entreprise(id):
|
def delete_entreprise(id):
|
||||||
"""
|
"""
|
||||||
@ -428,7 +440,9 @@ def delete_entreprise(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/validate_entreprise/<int:id>", methods=["GET", "POST"])
|
@bp.route(
|
||||||
|
"/fiche_entreprise_validation/<int:id>/validate_entreprise", methods=["GET", "POST"]
|
||||||
|
)
|
||||||
@permission_required(Permission.RelationsEntreprisesValidate)
|
@permission_required(Permission.RelationsEntreprisesValidate)
|
||||||
def validate_entreprise(id):
|
def validate_entreprise(id):
|
||||||
"""
|
"""
|
||||||
@ -456,7 +470,10 @@ def validate_entreprise(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/delete_validation_entreprise/<int:id>", methods=["GET", "POST"])
|
@bp.route(
|
||||||
|
"/fiche_entreprise_validation/<int:id>/delete_validation_entreprise",
|
||||||
|
methods=["GET", "POST"],
|
||||||
|
)
|
||||||
@permission_required(Permission.RelationsEntreprisesValidate)
|
@permission_required(Permission.RelationsEntreprisesValidate)
|
||||||
def delete_validation_entreprise(id):
|
def delete_validation_entreprise(id):
|
||||||
"""
|
"""
|
||||||
@ -478,7 +495,7 @@ def delete_validation_entreprise(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/add_offre/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/<int:id>/add_offre", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def add_offre(id):
|
def add_offre(id):
|
||||||
"""
|
"""
|
||||||
@ -537,7 +554,7 @@ def add_offre(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/edit_offre/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/edit_offre/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def edit_offre(id):
|
def edit_offre(id):
|
||||||
"""
|
"""
|
||||||
@ -597,7 +614,7 @@ def edit_offre(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/delete_offre/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/delete_offre/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def delete_offre(id):
|
def delete_offre(id):
|
||||||
"""
|
"""
|
||||||
@ -634,7 +651,7 @@ def delete_offre(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/delete_offre_recue/<int:id>", methods=["GET", "POST"])
|
@bp.route("/offres_recues/delete_offre_recue/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesView)
|
@permission_required(Permission.RelationsEntreprisesView)
|
||||||
def delete_offre_recue(id):
|
def delete_offre_recue(id):
|
||||||
"""
|
"""
|
||||||
@ -648,7 +665,7 @@ def delete_offre_recue(id):
|
|||||||
return redirect(url_for("entreprises.offres_recues"))
|
return redirect(url_for("entreprises.offres_recues"))
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/expired/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/expired/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def expired(id):
|
def expired(id):
|
||||||
"""
|
"""
|
||||||
@ -666,7 +683,7 @@ def expired(id):
|
|||||||
return redirect(url_for("entreprises.fiche_entreprise", id=offre.entreprise_id))
|
return redirect(url_for("entreprises.fiche_entreprise", id=offre.entreprise_id))
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/add_correspondant/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/<int:id>/add_correspondant", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def add_correspondant(id):
|
def add_correspondant(id):
|
||||||
"""
|
"""
|
||||||
@ -704,7 +721,7 @@ def add_correspondant(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/edit_correspondant/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/edit_correspondant/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def edit_correspondant(id):
|
def edit_correspondant(id):
|
||||||
"""
|
"""
|
||||||
@ -749,7 +766,7 @@ def edit_correspondant(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/delete_correspondant/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/delete_correspondant/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def delete_correspondant(id):
|
def delete_correspondant(id):
|
||||||
"""
|
"""
|
||||||
@ -779,7 +796,7 @@ def delete_correspondant(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("fiche_entreprise/add_contact/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/<int:id>/add_contact", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def add_contact(id):
|
def add_contact(id):
|
||||||
"""
|
"""
|
||||||
@ -806,7 +823,7 @@ def add_contact(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("fiche_entreprise/edit_contact/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/edit_contact/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def edit_contact(id):
|
def edit_contact(id):
|
||||||
"""
|
"""
|
||||||
@ -831,7 +848,7 @@ def edit_contact(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/fiche_entreprise/contacts/<int:id>")
|
@bp.route("/fiche_entreprise/<int:id>/contacts")
|
||||||
@permission_required(Permission.RelationsEntreprisesView)
|
@permission_required(Permission.RelationsEntreprisesView)
|
||||||
def contacts(id):
|
def contacts(id):
|
||||||
"""
|
"""
|
||||||
@ -846,7 +863,7 @@ def contacts(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/add_stage_apprentissage/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/<int:id>/add_stage_apprentissage", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def add_stage_apprentissage(id):
|
def add_stage_apprentissage(id):
|
||||||
"""
|
"""
|
||||||
@ -892,7 +909,9 @@ def add_stage_apprentissage(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/edit_stage_apprentissage/<int:id>", methods=["GET", "POST"])
|
@bp.route(
|
||||||
|
"/fiche_entreprise/edit_stage_apprentissage/<int:id>", methods=["GET", "POST"]
|
||||||
|
)
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def edit_stage_apprentissage(id):
|
def edit_stage_apprentissage(id):
|
||||||
"""
|
"""
|
||||||
@ -948,7 +967,9 @@ def edit_stage_apprentissage(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/delete_stage_apprentissage/<int:id>", methods=["GET", "POST"])
|
@bp.route(
|
||||||
|
"/fiche_entreprise/delete_stage_apprentissage/<int:id>", methods=["GET", "POST"]
|
||||||
|
)
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def delete_stage_apprentissage(id):
|
def delete_stage_apprentissage(id):
|
||||||
"""
|
"""
|
||||||
@ -973,7 +994,7 @@ def delete_stage_apprentissage(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/envoyer_offre/<int:id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/envoyer_offre/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesSend)
|
@permission_required(Permission.RelationsEntreprisesSend)
|
||||||
def envoyer_offre(id):
|
def envoyer_offre(id):
|
||||||
"""
|
"""
|
||||||
@ -1082,7 +1103,7 @@ def export_entreprises():
|
|||||||
return redirect(url_for("entreprises.index"))
|
return redirect(url_for("entreprises.index"))
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/get_import_entreprises_file_sample")
|
@bp.route("/import_entreprises/get_import_entreprises_file_sample")
|
||||||
@permission_required(Permission.RelationsEntreprisesExport)
|
@permission_required(Permission.RelationsEntreprisesExport)
|
||||||
def get_import_entreprises_file_sample():
|
def get_import_entreprises_file_sample():
|
||||||
"""
|
"""
|
||||||
@ -1133,20 +1154,19 @@ def import_entreprises():
|
|||||||
ligne += 1
|
ligne += 1
|
||||||
if (
|
if (
|
||||||
are.verif_entreprise_data(entreprise_data)
|
are.verif_entreprise_data(entreprise_data)
|
||||||
and entreprise_data[0] not in siret_list
|
and entreprise_data[0].replace(" ", "") not in siret_list
|
||||||
):
|
):
|
||||||
siret_list.append(entreprise_data[0])
|
siret_list.append(entreprise_data[0].replace(" ", ""))
|
||||||
entreprise = Entreprise(
|
entreprise = Entreprise(
|
||||||
siret=entreprise_data[0].replace(" ", ""),
|
siret=entreprise_data[0].replace(" ", ""),
|
||||||
nom=entreprise_data[1],
|
nom=entreprise_data[1].strip(),
|
||||||
adresse=entreprise_data[2],
|
adresse=entreprise_data[2].strip(),
|
||||||
ville=entreprise_data[3],
|
ville=entreprise_data[3].strip(),
|
||||||
codepostal=entreprise_data[4],
|
codepostal=entreprise_data[4].strip(),
|
||||||
pays=entreprise_data[5],
|
pays=entreprise_data[5].strip(),
|
||||||
visible=True,
|
visible=True,
|
||||||
)
|
)
|
||||||
entreprises_import.append(entreprise)
|
entreprises_import.append(entreprise)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
flash(f"Erreur lors de l'importation (ligne {ligne})")
|
flash(f"Erreur lors de l'importation (ligne {ligne})")
|
||||||
return render_template(
|
return render_template(
|
||||||
@ -1217,7 +1237,7 @@ def export_correspondants():
|
|||||||
return redirect(url_for("entreprises.correspondants"))
|
return redirect(url_for("entreprises.correspondants"))
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/get_import_correspondants_file_sample")
|
@bp.route("/import_correspondants/get_import_correspondants_file_sample")
|
||||||
@permission_required(Permission.RelationsEntreprisesExport)
|
@permission_required(Permission.RelationsEntreprisesExport)
|
||||||
def get_import_correspondants_file_sample():
|
def get_import_correspondants_file_sample():
|
||||||
"""
|
"""
|
||||||
@ -1278,29 +1298,29 @@ def import_correspondants():
|
|||||||
if (
|
if (
|
||||||
are.verif_correspondant_data(correspondant_data)
|
are.verif_correspondant_data(correspondant_data)
|
||||||
and (
|
and (
|
||||||
correspondant_data[0],
|
correspondant_data[0].strip(),
|
||||||
correspondant_data[1],
|
correspondant_data[1].strip(),
|
||||||
correspondant_data[6],
|
correspondant_data[6].strip(),
|
||||||
)
|
)
|
||||||
not in correspondant_list
|
not in correspondant_list
|
||||||
):
|
):
|
||||||
correspondant_list.append(
|
correspondant_list.append(
|
||||||
(
|
(
|
||||||
correspondant_data[0],
|
correspondant_data[0].strip(),
|
||||||
correspondant_data[1],
|
correspondant_data[1].strip(),
|
||||||
correspondant_data[6],
|
correspondant_data[6].strip(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
entreprise = Entreprise.query.filter_by(
|
entreprise = Entreprise.query.filter_by(
|
||||||
siret=correspondant_data[6]
|
siret=correspondant_data[6].strip()
|
||||||
).first()
|
).first()
|
||||||
correspondant = EntrepriseCorrespondant(
|
correspondant = EntrepriseCorrespondant(
|
||||||
nom=correspondant_data[0],
|
nom=correspondant_data[0].strip(),
|
||||||
prenom=correspondant_data[1],
|
prenom=correspondant_data[1].strip(),
|
||||||
telephone=correspondant_data[2],
|
telephone=correspondant_data[2].strip(),
|
||||||
mail=correspondant_data[3],
|
mail=correspondant_data[3].strip(),
|
||||||
poste=correspondant_data[4],
|
poste=correspondant_data[4].strip(),
|
||||||
service=correspondant_data[5],
|
service=correspondant_data[5].strip(),
|
||||||
entreprise_id=entreprise.id,
|
entreprise_id=entreprise.id,
|
||||||
)
|
)
|
||||||
correspondants_import.append(correspondant)
|
correspondants_import.append(correspondant)
|
||||||
@ -1372,7 +1392,7 @@ def get_offre_file(entreprise_id, offre_id, filedir, filename):
|
|||||||
abort(404, description=f"fichier {filename} inconnu")
|
abort(404, description=f"fichier {filename} inconnu")
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/add_offre_file/<int:offre_id>", methods=["GET", "POST"])
|
@bp.route("/fiche_entreprise/add_offre_file/<int:offre_id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def add_offre_file(offre_id):
|
def add_offre_file(offre_id):
|
||||||
"""
|
"""
|
||||||
@ -1404,7 +1424,10 @@ def add_offre_file(offre_id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/delete_offre_file/<int:offre_id>/<string:filedir>", methods=["GET", "POST"])
|
@bp.route(
|
||||||
|
"/fiche_entreprise/delete_offre_file/<int:offre_id>/<string:filedir>",
|
||||||
|
methods=["GET", "POST"],
|
||||||
|
)
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def delete_offre_file(offre_id, filedir):
|
def delete_offre_file(offre_id, filedir):
|
||||||
"""
|
"""
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
{# ajout margin-bottom sur le champ pays #}
|
||||||
|
var champ_pays = document.getElementById("pays")
|
||||||
|
if (champ_pays !== null) {
|
||||||
|
var closest_form_group = champ_pays.closest(".form-group")
|
||||||
|
closest_form_group.style.marginBottom = "50px"
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById("siret").addEventListener("keyup", autocomplete);
|
document.getElementById("siret").addEventListener("keyup", autocomplete);
|
||||||
|
|
||||||
function autocomplete() {
|
function autocomplete() {
|
||||||
|
@ -16,6 +16,32 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if correspondants %}
|
||||||
|
<div>
|
||||||
|
{% for correspondant in correspondants %}
|
||||||
|
<div>
|
||||||
|
<h3>Correspondant</h3>
|
||||||
|
<div class="correspondant">
|
||||||
|
Nom : {{ correspondant.nom }}<br>
|
||||||
|
Prénom : {{ correspondant.prenom }}<br>
|
||||||
|
{% if correspondant.telephone %}
|
||||||
|
Téléphone : {{ correspondant.telephone }}<br>
|
||||||
|
{% endif %}
|
||||||
|
{% if correspondant.mail %}
|
||||||
|
Mail : {{ correspondant.mail }}<br>
|
||||||
|
{% endif %}
|
||||||
|
{% if correspondant.poste %}
|
||||||
|
Poste : {{ correspondant.poste }}<br>
|
||||||
|
{% endif %}
|
||||||
|
{% if correspondant.service %}
|
||||||
|
Service : {{ correspondant.service }}<br>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a class="btn btn-success" href="{{ url_for('entreprises.validate_entreprise', id=entreprise.id) }}">Valider</a>
|
<a class="btn btn-success" href="{{ url_for('entreprises.validate_entreprise', id=entreprise.id) }}">Valider</a>
|
||||||
<a class="btn btn-danger" href="{{ url_for('entreprises.delete_validation_entreprise', id=entreprise.id) }}">Supprimer</a>
|
<a class="btn btn-danger" href="{{ url_for('entreprises.delete_validation_entreprise', id=entreprise.id) }}">Supprimer</a>
|
||||||
|
@ -19,6 +19,20 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
{# pour les formulaires contact #}
|
||||||
|
var champ_date = document.getElementById("date")
|
||||||
|
if (champ_date !== null && champ_date.value === "") {
|
||||||
|
var maintenant = new Date()
|
||||||
|
champ_date.value = `${maintenant.getFullYear()}-${formatDate(maintenant.getMonth() + 1)}-${formatDate(maintenant.getDate())}T${formatDate(maintenant.getHours())}:${formatDate(maintenant.getMinutes())}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(value) {
|
||||||
|
if(value < 10)
|
||||||
|
return `0${value}`
|
||||||
|
else
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
{# pour les formulaires offre #}
|
{# pour les formulaires offre #}
|
||||||
var champ_depts = document.getElementById("depts")
|
var champ_depts = document.getElementById("depts")
|
||||||
if (champ_depts !== null) {
|
if (champ_depts !== null) {
|
||||||
@ -26,9 +40,10 @@
|
|||||||
closest_form_control.classList.remove("form-control")
|
closest_form_control.classList.remove("form-control")
|
||||||
}
|
}
|
||||||
|
|
||||||
if(document.getElementById("expiration_date").value === "")
|
if(document.getElementById("expiration_date") !== null && document.getElementById("expiration_date").value === "")
|
||||||
expiration()
|
expiration()
|
||||||
|
|
||||||
|
if(document.getElementById("type_offre") !== null)
|
||||||
document.getElementById("type_offre").addEventListener("change", expiration);
|
document.getElementById("type_offre").addEventListener("change", expiration);
|
||||||
|
|
||||||
function expiration() {
|
function expiration() {
|
||||||
@ -38,10 +53,10 @@
|
|||||||
if (type_offre === "Alternance") {
|
if (type_offre === "Alternance") {
|
||||||
expiration.value = `${date.getFullYear() + 1}-01-01`
|
expiration.value = `${date.getFullYear() + 1}-01-01`
|
||||||
} else {
|
} else {
|
||||||
if(date.getMonth() + 1 < 7)
|
if(date.getMonth() + 1 < 8)
|
||||||
expiration.value = `${date.getFullYear()}-07-01`
|
expiration.value = `${date.getFullYear()}-08-01`
|
||||||
else
|
else
|
||||||
expiration.value = `${date.getFullYear() + 1}-07-01`
|
expiration.value = `${date.getFullYear() + 1}-08-01`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user