diff --git a/app/entreprises/app_relations_entreprises.py b/app/entreprises/app_relations_entreprises.py index c47000ce..6f060616 100644 --- a/app/entreprises/app_relations_entreprises.py +++ b/app/entreprises/app_relations_entreprises.py @@ -144,7 +144,12 @@ def verif_entreprise_data(entreprise_data): siret = entreprise_data[0].strip() # vérification sur le siret if re.match("^\d{14}$", siret) is None: return False - req = requests.get(f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret}") + try: + req = requests.get( + f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret}" + ) + except requests.ConnectionError: + print("no internet") if req.status_code != 200: return False entreprise = Entreprise.query.filter_by(siret=siret).first() diff --git a/app/entreprises/forms.py b/app/entreprises/forms.py index 7bc1a102..ca74da26 100644 --- a/app/entreprises/forms.py +++ b/app/entreprises/forms.py @@ -102,9 +102,12 @@ class EntrepriseCreationForm(FlaskForm): siret = siret.data.strip() if re.match("^\d{14}$", siret) is None: raise ValidationError("Format incorrect") - req = requests.get( - f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret}" - ) + try: + req = requests.get( + f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret}" + ) + except requests.ConnectionError: + print("no internet") if req.status_code != 200: raise ValidationError("SIRET inexistant") entreprise = Entreprise.query.filter_by(siret=siret).first() diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index 547d2051..43cef4a3 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -364,7 +364,7 @@ def edit_entreprise(id): form.ville.data = entreprise.ville form.pays.data = entreprise.pays return render_template( - "entreprises/form.html", + "entreprises/form_modification_entreprise.html", title="Modification entreprise", form=form, ) diff --git a/app/static/css/entreprises.css b/app/static/css/entreprises.css index d2dc5cf5..fac9d11b 100644 --- a/app/static/css/entreprises.css +++ b/app/static/css/entreprises.css @@ -85,4 +85,10 @@ .offre-recue { display: flex; justify-content: space-between; +} + +#sirene-data { + border: solid 2px; + border-radius: 10px; + padding: 10px; } \ No newline at end of file diff --git a/app/templates/entreprises/ajout_entreprise.html b/app/templates/entreprises/ajout_entreprise.html index c593335b..fe597c55 100644 --- a/app/templates/entreprises/ajout_entreprise.html +++ b/app/templates/entreprises/ajout_entreprise.html @@ -20,7 +20,6 @@ function autocomplete() { var input = document.getElementById("siret").value; - data = null if(input.length == 14) { fetch("https://entreprise.data.gouv.fr/api/sirene/v1/siret/" + input) .then(response => { @@ -40,7 +39,6 @@ document.getElementById("adresse").value = response.etablissement.l4_normalisee document.getElementById("codepostal").value = response.etablissement.code_postal document.getElementById("ville").value = response.etablissement.libelle_commune - document.getElementById("pays").value = 'FRANCE' } function emptyForm() { @@ -48,7 +46,6 @@ document.getElementById("adresse").value = '' document.getElementById("codepostal").value = '' document.getElementById("ville").value = '' - document.getElementById("pays").value = '' } } diff --git a/app/templates/entreprises/form_modification_entreprise.html b/app/templates/entreprises/form_modification_entreprise.html new file mode 100644 index 00000000..c77cc12f --- /dev/null +++ b/app/templates/entreprises/form_modification_entreprise.html @@ -0,0 +1,65 @@ +{# -*- mode: jinja-html -*- #} +{% extends 'base.html' %} +{% import 'bootstrap/wtf.html' as wtf %} + +{% block styles %} +{{super()}} +{% endblock %} + +{% block app_content %} +