forked from ScoDoc/DocScoDoc
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):
|
||||
"""
|
||||
Verifie les données d'une ligne Excel (correspondant)
|
||||
correspondant_data[0]: nom
|
||||
correspondant_data[1]: prenom
|
||||
correspondant_data[2]: telephone
|
||||
correspondant_data[3]: mail
|
||||
correspondant_data[4]: poste
|
||||
correspondant_data[5]: service
|
||||
correspondant_data[6]: entreprise_siret
|
||||
correspondant_data[0]: civilite
|
||||
correspondant_data[1]: nom
|
||||
correspondant_data[2]: prenom
|
||||
correspondant_data[3]: telephone
|
||||
correspondant_data[4]: mail
|
||||
correspondant_data[5]: poste
|
||||
correspondant_data[6]: service
|
||||
correspondant_data[7]: origine
|
||||
correspondant_data[8]: notes
|
||||
correspondant_data[9]: entreprise_siret
|
||||
"""
|
||||
# champs obligatoires
|
||||
if (
|
||||
correspondant_data[0].strip() == ""
|
||||
or correspondant_data[1].strip() == ""
|
||||
or correspondant_data[6].strip() == ""
|
||||
or correspondant_data[2].strip() == ""
|
||||
or correspondant_data[9].strip() == ""
|
||||
):
|
||||
return False
|
||||
|
||||
# civilite entre H ou F
|
||||
if correspondant_data[0].strip() not in ["H", "F"]:
|
||||
return False
|
||||
|
||||
# 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:
|
||||
return False
|
||||
|
||||
# correspondant possède le meme nom et prénom dans la meme entreprise
|
||||
correspondant = EntrepriseCorrespondant.query.filter_by(
|
||||
nom=correspondant_data[0].strip(),
|
||||
prenom=correspondant_data[1].strip(),
|
||||
nom=correspondant_data[1].strip(),
|
||||
prenom=correspondant_data[2].strip(),
|
||||
entreprise_id=entreprise.id,
|
||||
).first()
|
||||
if correspondant is not None:
|
||||
return False
|
||||
|
||||
if (
|
||||
correspondant_data[2].strip() == "" and correspondant_data[3].strip() == ""
|
||||
correspondant_data[3].strip() == "" and correspondant_data[4].strip() == ""
|
||||
): # 1 moyen de contact
|
||||
return False
|
||||
|
||||
|
@ -66,12 +66,15 @@ class EntrepriseCorrespondant(db.Model):
|
||||
def to_dict(self):
|
||||
entreprise = Entreprise.query.filter_by(id=self.entreprise_id).first()
|
||||
return {
|
||||
"civilite": self.civilite,
|
||||
"nom": self.nom,
|
||||
"prenom": self.prenom,
|
||||
"telephone": self.telephone,
|
||||
"mail": self.mail,
|
||||
"poste": self.poste,
|
||||
"service": self.service,
|
||||
"origine": self.origine,
|
||||
"notes": self.notes,
|
||||
"entreprise_siret": entreprise.siret,
|
||||
}
|
||||
|
||||
|
@ -1287,12 +1287,15 @@ def export_correspondants():
|
||||
)
|
||||
if correspondants:
|
||||
keys = [
|
||||
"civilite",
|
||||
"nom",
|
||||
"prenom",
|
||||
"telephone",
|
||||
"mail",
|
||||
"poste",
|
||||
"service",
|
||||
"origine",
|
||||
"notes",
|
||||
"entreprise_siret",
|
||||
]
|
||||
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
|
||||
"""
|
||||
keys = [
|
||||
"civilite",
|
||||
"nom",
|
||||
"prenom",
|
||||
"telephone",
|
||||
"mail",
|
||||
"poste",
|
||||
"service",
|
||||
"origine",
|
||||
"notes",
|
||||
"entreprise_siret",
|
||||
]
|
||||
titles = keys[:]
|
||||
@ -1350,12 +1356,15 @@ def import_correspondants():
|
||||
correspondant_list = []
|
||||
ligne = 0
|
||||
titles = [
|
||||
"civilite",
|
||||
"nom",
|
||||
"prenom",
|
||||
"telephone",
|
||||
"mail",
|
||||
"poste",
|
||||
"service",
|
||||
"origine",
|
||||
"notes",
|
||||
"entreprise_siret",
|
||||
]
|
||||
if data[1][0] != titles:
|
||||
@ -1370,29 +1379,32 @@ def import_correspondants():
|
||||
if (
|
||||
are.verif_correspondant_data(correspondant_data)
|
||||
and (
|
||||
correspondant_data[0].strip(),
|
||||
correspondant_data[1].strip(),
|
||||
correspondant_data[6].strip(),
|
||||
correspondant_data[2].strip(),
|
||||
correspondant_data[9].strip(),
|
||||
)
|
||||
not in correspondant_list
|
||||
):
|
||||
correspondant_list.append(
|
||||
(
|
||||
correspondant_data[0].strip(),
|
||||
correspondant_data[1].strip(),
|
||||
correspondant_data[6].strip(),
|
||||
correspondant_data[2].strip(),
|
||||
correspondant_data[9].strip(),
|
||||
)
|
||||
)
|
||||
entreprise = Entreprise.query.filter_by(
|
||||
siret=correspondant_data[6].strip()
|
||||
siret=correspondant_data[9].strip()
|
||||
).first()
|
||||
correspondant = EntrepriseCorrespondant(
|
||||
nom=correspondant_data[0].strip(),
|
||||
prenom=correspondant_data[1].strip(),
|
||||
telephone=correspondant_data[2].strip(),
|
||||
mail=correspondant_data[3].strip(),
|
||||
poste=correspondant_data[4].strip(),
|
||||
service=correspondant_data[5].strip(),
|
||||
civilite=correspondant_data[0].strip(),
|
||||
nom=correspondant_data[1].strip(),
|
||||
prenom=correspondant_data[2].strip(),
|
||||
telephone=correspondant_data[3].strip(),
|
||||
mail=correspondant_data[4].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,
|
||||
)
|
||||
correspondants_import.append(correspondant)
|
||||
|
@ -48,7 +48,7 @@
|
||||
}
|
||||
let newFieldName = `correspondants-${Math.max(...correspondantInputIds) + 1}`;
|
||||
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 %}
|
||||
<table class="table">
|
||||
<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>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>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>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>
|
||||
{% endif %}
|
||||
|
||||
@ -40,6 +43,7 @@
|
||||
{% for correspondant in correspondants_import %}
|
||||
<div class="correspondant">
|
||||
<div>
|
||||
Civilité : {{ correspondant.civilite|get_civilité }}<br>
|
||||
Nom : {{ correspondant.nom }}<br>
|
||||
Prénom : {{ correspondant.prenom }}<br>
|
||||
{% if correspondant.telephone %}
|
||||
@ -54,7 +58,13 @@
|
||||
{% if correspondant.service %}
|
||||
Service : {{ correspondant.service }}<br>
|
||||
{% 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>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user