forked from ScoDoc/ScoDoc
changement import/export correspondants, formulaires
This commit is contained in:
parent
ff228aef4e
commit
2349114eb3
@ -131,38 +131,46 @@ def send_email_notifications_entreprise(subject, entreprise: Entreprise):
|
|||||||
def verif_correspondant_data(correspondant_data):
|
def verif_correspondant_data(correspondant_data):
|
||||||
"""
|
"""
|
||||||
Verifie les données d'une ligne Excel (correspondant)
|
Verifie les données d'une ligne Excel (correspondant)
|
||||||
correspondant_data[0]: nom
|
correspondant_data[0]: civilite
|
||||||
correspondant_data[1]: prenom
|
correspondant_data[1]: nom
|
||||||
correspondant_data[2]: telephone
|
correspondant_data[2]: prenom
|
||||||
correspondant_data[3]: mail
|
correspondant_data[3]: telephone
|
||||||
correspondant_data[4]: poste
|
correspondant_data[4]: mail
|
||||||
correspondant_data[5]: service
|
correspondant_data[5]: poste
|
||||||
correspondant_data[6]: entreprise_siret
|
correspondant_data[6]: service
|
||||||
|
correspondant_data[7]: origine
|
||||||
|
correspondant_data[8]: notes
|
||||||
|
correspondant_data[9]: entreprise_siret
|
||||||
"""
|
"""
|
||||||
# champs obligatoires
|
# champs obligatoires
|
||||||
if (
|
if (
|
||||||
correspondant_data[0].strip() == ""
|
correspondant_data[0].strip() == ""
|
||||||
or correspondant_data[1].strip() == ""
|
or correspondant_data[1].strip() == ""
|
||||||
or correspondant_data[6].strip() == ""
|
or correspondant_data[2].strip() == ""
|
||||||
|
or correspondant_data[9].strip() == ""
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# civilite entre H ou F
|
||||||
|
if correspondant_data[0].strip() not in ["H", "F"]:
|
||||||
|
return False
|
||||||
|
|
||||||
# entreprise_id existant
|
# entreprise_id existant
|
||||||
entreprise = Entreprise.query.filter_by(siret=correspondant_data[6].strip()).first()
|
entreprise = Entreprise.query.filter_by(siret=correspondant_data[9].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].strip(),
|
nom=correspondant_data[1].strip(),
|
||||||
prenom=correspondant_data[1].strip(),
|
prenom=correspondant_data[2].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].strip() == "" and correspondant_data[3].strip() == ""
|
correspondant_data[3].strip() == "" and correspondant_data[4].strip() == ""
|
||||||
): # 1 moyen de contact
|
): # 1 moyen de contact
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -66,12 +66,15 @@ class EntrepriseCorrespondant(db.Model):
|
|||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
entreprise = Entreprise.query.filter_by(id=self.entreprise_id).first()
|
entreprise = Entreprise.query.filter_by(id=self.entreprise_id).first()
|
||||||
return {
|
return {
|
||||||
|
"civilite": self.civilite,
|
||||||
"nom": self.nom,
|
"nom": self.nom,
|
||||||
"prenom": self.prenom,
|
"prenom": self.prenom,
|
||||||
"telephone": self.telephone,
|
"telephone": self.telephone,
|
||||||
"mail": self.mail,
|
"mail": self.mail,
|
||||||
"poste": self.poste,
|
"poste": self.poste,
|
||||||
"service": self.service,
|
"service": self.service,
|
||||||
|
"origine": self.origine,
|
||||||
|
"notes": self.notes,
|
||||||
"entreprise_siret": entreprise.siret,
|
"entreprise_siret": entreprise.siret,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1287,12 +1287,15 @@ def export_correspondants():
|
|||||||
)
|
)
|
||||||
if correspondants:
|
if correspondants:
|
||||||
keys = [
|
keys = [
|
||||||
|
"civilite",
|
||||||
"nom",
|
"nom",
|
||||||
"prenom",
|
"prenom",
|
||||||
"telephone",
|
"telephone",
|
||||||
"mail",
|
"mail",
|
||||||
"poste",
|
"poste",
|
||||||
"service",
|
"service",
|
||||||
|
"origine",
|
||||||
|
"notes",
|
||||||
"entreprise_siret",
|
"entreprise_siret",
|
||||||
]
|
]
|
||||||
titles = keys[:]
|
titles = keys[:]
|
||||||
@ -1316,12 +1319,15 @@ def get_import_correspondants_file_sample():
|
|||||||
Permet de récupérer un fichier exemple vide pour pouvoir importer des correspondants
|
Permet de récupérer un fichier exemple vide pour pouvoir importer des correspondants
|
||||||
"""
|
"""
|
||||||
keys = [
|
keys = [
|
||||||
|
"civilite",
|
||||||
"nom",
|
"nom",
|
||||||
"prenom",
|
"prenom",
|
||||||
"telephone",
|
"telephone",
|
||||||
"mail",
|
"mail",
|
||||||
"poste",
|
"poste",
|
||||||
"service",
|
"service",
|
||||||
|
"origine",
|
||||||
|
"notes",
|
||||||
"entreprise_siret",
|
"entreprise_siret",
|
||||||
]
|
]
|
||||||
titles = keys[:]
|
titles = keys[:]
|
||||||
@ -1350,12 +1356,15 @@ def import_correspondants():
|
|||||||
correspondant_list = []
|
correspondant_list = []
|
||||||
ligne = 0
|
ligne = 0
|
||||||
titles = [
|
titles = [
|
||||||
|
"civilite",
|
||||||
"nom",
|
"nom",
|
||||||
"prenom",
|
"prenom",
|
||||||
"telephone",
|
"telephone",
|
||||||
"mail",
|
"mail",
|
||||||
"poste",
|
"poste",
|
||||||
"service",
|
"service",
|
||||||
|
"origine",
|
||||||
|
"notes",
|
||||||
"entreprise_siret",
|
"entreprise_siret",
|
||||||
]
|
]
|
||||||
if data[1][0] != titles:
|
if data[1][0] != titles:
|
||||||
@ -1370,29 +1379,32 @@ def import_correspondants():
|
|||||||
if (
|
if (
|
||||||
are.verif_correspondant_data(correspondant_data)
|
are.verif_correspondant_data(correspondant_data)
|
||||||
and (
|
and (
|
||||||
correspondant_data[0].strip(),
|
|
||||||
correspondant_data[1].strip(),
|
correspondant_data[1].strip(),
|
||||||
correspondant_data[6].strip(),
|
correspondant_data[2].strip(),
|
||||||
|
correspondant_data[9].strip(),
|
||||||
)
|
)
|
||||||
not in correspondant_list
|
not in correspondant_list
|
||||||
):
|
):
|
||||||
correspondant_list.append(
|
correspondant_list.append(
|
||||||
(
|
(
|
||||||
correspondant_data[0].strip(),
|
|
||||||
correspondant_data[1].strip(),
|
correspondant_data[1].strip(),
|
||||||
correspondant_data[6].strip(),
|
correspondant_data[2].strip(),
|
||||||
|
correspondant_data[9].strip(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
entreprise = Entreprise.query.filter_by(
|
entreprise = Entreprise.query.filter_by(
|
||||||
siret=correspondant_data[6].strip()
|
siret=correspondant_data[9].strip()
|
||||||
).first()
|
).first()
|
||||||
correspondant = EntrepriseCorrespondant(
|
correspondant = EntrepriseCorrespondant(
|
||||||
nom=correspondant_data[0].strip(),
|
civilite=correspondant_data[0].strip(),
|
||||||
prenom=correspondant_data[1].strip(),
|
nom=correspondant_data[1].strip(),
|
||||||
telephone=correspondant_data[2].strip(),
|
prenom=correspondant_data[2].strip(),
|
||||||
mail=correspondant_data[3].strip(),
|
telephone=correspondant_data[3].strip(),
|
||||||
poste=correspondant_data[4].strip(),
|
mail=correspondant_data[4].strip(),
|
||||||
service=correspondant_data[5].strip(),
|
poste=correspondant_data[5].strip(),
|
||||||
|
service=correspondant_data[6].strip(),
|
||||||
|
origine=correspondant_data[7].strip(),
|
||||||
|
notes=correspondant_data[8].strip(),
|
||||||
entreprise_id=entreprise.id,
|
entreprise_id=entreprise.id,
|
||||||
)
|
)
|
||||||
correspondants_import.append(correspondant)
|
correspondants_import.append(correspondant)
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
}
|
}
|
||||||
let newFieldName = `correspondants-${Math.max(...correspondantInputIds) + 1}`;
|
let newFieldName = `correspondants-${Math.max(...correspondantInputIds) + 1}`;
|
||||||
allCorrepondantsFieldWrapper.insertAdjacentHTML('beforeend',`
|
allCorrepondantsFieldWrapper.insertAdjacentHTML('beforeend',`
|
||||||
<li><label for="${newFieldName}">Correspondants-${Math.max(...correspondantInputIds) + 1}</label> <table id="${newFieldName}"><tr><th><label for="${newFieldName}-nom">Nom (*)</label></th><td><input class="form-control" id="${newFieldName}-nom" name="${newFieldName}-nom" required type="text" value=""></td></tr><tr><th><label for="${newFieldName}-prenom">Prénom (*)</label></th><td><input class="form-control" id="${newFieldName}-prenom" name="${newFieldName}-prenom" required type="text" value=""></td></tr><tr><th><label for="${newFieldName}-telephone">Téléphone (*)</label></th><td><input class="form-control" id="${newFieldName}-telephone" name="${newFieldName}-telephone" type="text" value=""></td></tr><tr><th><label for="${newFieldName}-mail">Mail (*)</label></th><td><input class="form-control" id="${newFieldName}-mail" name="${newFieldName}-mail" type="text" value=""></td></tr><tr><th><label for="${newFieldName}-poste">Poste</label></th><td><input class="form-control" id="${newFieldName}-poste" name="${newFieldName}-poste" type="text" value=""></td></tr><tr><th><label for="${newFieldName}-service">Service</label></th><td><input class="form-control" id="${newFieldName}-service" name="${newFieldName}-service" type="text" value=""></td></tr></table><input id="${newFieldName}-csrf_token" name="${newFieldName}-csrf_token" type="hidden" value=${csrf_token}></li>
|
<li><label for="${newFieldName}">Correspondants-${Math.max(...correspondantInputIds) + 1}</label> <table id="${newFieldName}"><tr><th><label for="${newFieldName}-civilite">Civilité (*)</label></th><td><select class="form-control" id="${newFieldName}-civilite" name="${newFieldName}-civilite" required><option value="H">Monsieur</option><option value="F">Madame</option></select></td></tr><tr><th><label for="${newFieldName}-nom">Nom (*)</label></th><td><input class="form-control" id="${newFieldName}-nom" name="${newFieldName}-nom" required type="text" value=""></td></tr><tr><th><label for="${newFieldName}-prenom">Prénom (*)</label></th><td><input class="form-control" id="${newFieldName}-prenom" name="${newFieldName}-prenom" required type="text" value=""></td></tr><tr><th><label for="${newFieldName}-telephone">Téléphone (*)</label></th><td><input class="form-control" id="${newFieldName}-telephone" name="${newFieldName}-telephone" type="text" value=""></td></tr><tr><th><label for="${newFieldName}-mail">Mail (*)</label></th><td><input class="form-control" id="${newFieldName}-mail" name="${newFieldName}-mail" type="text" value=""></td></tr><tr><th><label for="${newFieldName}-poste">Poste</label></th><td><input class="form-control" id="${newFieldName}-poste" name="${newFieldName}-poste" type="text" value=""></td></tr><tr><th><label for="${newFieldName}-service">Service</label></th><td><input class="form-control" id="${newFieldName}-service" name="${newFieldName}-service" type="text" value=""></td></tr><tr><th><label for="${newFieldName}-origine">Origine</label></th><td><input class="form-control" id="${newFieldName}-origine" name="${newFieldName}-origine" type="text" value=""></td></tr><tr><th><label for="${newFieldName}-notes">Notes</label></th><td><input class="form-control" id="${newFieldName}-notes" name="${newFieldName}-notes" type="text" value=""></td></tr></table><input id="${newFieldName}-csrf_token" name="${newFieldName}-csrf_token" type="hidden" value=${csrf_token}></li>
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,16 @@
|
|||||||
{% if not correspondants_import %}
|
{% if not correspondants_import %}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead><tr><td><b>Attribut</b></td><td><b>Type</b></td><td><b>Description</b></td></tr></thead>
|
<thead><tr><td><b>Attribut</b></td><td><b>Type</b></td><td><b>Description</b></td></tr></thead>
|
||||||
|
<tr><td>civilite</td><td>text</td><td>civilite du correspondant (H ou F)</td></tr>
|
||||||
<tr><td>nom</td><td>text</td><td>nom du correspondant</td></tr>
|
<tr><td>nom</td><td>text</td><td>nom du correspondant</td></tr>
|
||||||
<tr><td>prenom</td><td>text</td><td>prenom du correspondant</td></tr>
|
<tr><td>prenom</td><td>text</td><td>prenom du correspondant</td></tr>
|
||||||
<tr><td>telephone</td><td>text</td><td>telephone du correspondant</td></tr>
|
<tr><td>telephone</td><td>text</td><td>telephone du correspondant</td></tr>
|
||||||
<tr><td>mail</td><td>text</td><td>mail du correspondant</td></tr>
|
<tr><td>mail</td><td>text</td><td>mail du correspondant</td></tr>
|
||||||
<tr><td>poste</td><td>text</td><td>poste du correspondant</td></tr>
|
<tr><td>poste</td><td>text</td><td>poste du correspondant</td></tr>
|
||||||
<tr><td>service</td><td>text</td><td>service dans lequel travaille le correspondant</td></tr>
|
<tr><td>service</td><td>text</td><td>service dans lequel travaille le correspondant</td></tr>
|
||||||
<tr><td>entreprise_siret</td><td>integer</td><td>SIRET de l'entreprise</td></tr>
|
<tr><td>origine</td><td>text</td><td>origine du correspondant</td></tr>
|
||||||
|
<tr><td>notes</td><td>text</td><td>notes sur le correspondant</td></tr>
|
||||||
|
<tr><td>entreprise_siret</td><td>text</td><td>SIRET de l'entreprise</td></tr>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@ -40,6 +43,7 @@
|
|||||||
{% for correspondant in correspondants_import %}
|
{% for correspondant in correspondants_import %}
|
||||||
<div class="correspondant">
|
<div class="correspondant">
|
||||||
<div>
|
<div>
|
||||||
|
Civilité : {{ correspondant.civilite|get_civilité }}<br>
|
||||||
Nom : {{ correspondant.nom }}<br>
|
Nom : {{ correspondant.nom }}<br>
|
||||||
Prénom : {{ correspondant.prenom }}<br>
|
Prénom : {{ correspondant.prenom }}<br>
|
||||||
{% if correspondant.telephone %}
|
{% if correspondant.telephone %}
|
||||||
@ -54,7 +58,13 @@
|
|||||||
{% if correspondant.service %}
|
{% if correspondant.service %}
|
||||||
Service : {{ correspondant.service }}<br>
|
Service : {{ correspondant.service }}<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{ url_for('entreprises.fiche_entreprise', id=correspondant.entreprise_id )}}">lien vers l'entreprise</a>
|
{% if correspondant.origine %}
|
||||||
|
Origine : {{ correspondant.origine }}<br>
|
||||||
|
{% endif %}
|
||||||
|
{% if correspondant.notes %}
|
||||||
|
Notes : {{ correspondant.notes }}<br>
|
||||||
|
{% endif %}
|
||||||
|
<a href="{{ url_for('entreprises.fiche_entreprise', id=correspondant.entreprise_id )}}" target="_blank">lien vers l'entreprise</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user