-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #463 from MTES-MCT/feature/multi-sage-results
Anomalie cadre rose quand deux SAGE
- Loading branch information
Showing
18 changed files
with
414 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,9 @@ def moulinette_url(footprint): | |
return f"https://envergo.beta.gouv.fr?{url}" | ||
|
||
|
||
def fake_moulinette(url, lse, n2000, evalenv, sage, **eval_kwargs): | ||
def fake_moulinette( | ||
url, lse, n2000, evalenv, sage, sage_results_by_perimeter=None, **eval_kwargs | ||
): | ||
"""Create a moulinette with custom regulation results.""" | ||
|
||
eval_params = { | ||
|
@@ -79,6 +81,7 @@ def fake_moulinette(url, lse, n2000, evalenv, sage, **eval_kwargs): | |
|
||
# We create mocks based on a real regulation, so it's easier to fake results | ||
regulation = RegulationFactory() | ||
sage_perimeter = Mock(contact_email="[email protected]") | ||
moulinette.regulations = [ | ||
Mock( | ||
regulation, | ||
|
@@ -105,11 +108,14 @@ def fake_moulinette(url, lse, n2000, evalenv, sage, **eval_kwargs): | |
regulation, | ||
wraps=regulation, | ||
result=sage, | ||
perimeters=Mock( | ||
all=MagicMock(return_value=[Mock(contact_email="[email protected]")]) | ||
), | ||
perimeters=Mock(all=MagicMock(return_value=[sage_perimeter])), | ||
slug="sage", | ||
do_not_call_in_templates=True, | ||
results_by_perimeter=( | ||
sage_results_by_perimeter | ||
if sage_results_by_perimeter | ||
else {sage_perimeter: sage} | ||
), | ||
), | ||
] | ||
|
||
|
@@ -650,3 +656,47 @@ def test_n2000_ein_out_of_n2000_site_no_bcc(rf, moulinette_url): | |
eval_email = eval.get_evaluation_email() | ||
email = eval_email.get_email(req) | ||
assert "[email protected]" not in email.bcc | ||
|
||
|
||
@pytest.mark.parametrize("footprint", [1200]) | ||
def test_multiple_sage(rf, moulinette_url): | ||
"""Test email when evalreq is: | ||
- created by an instructor | ||
- the eval result is "soumis" | ||
- there is multiple Sage perimeter impacted with different results | ||
""" | ||
eval_kwargs = { | ||
"user_type": USER_TYPES.instructor, | ||
"moulinette_url": moulinette_url, | ||
"send_eval_to_project_owner": True, | ||
} | ||
eval, moulinette = fake_moulinette( | ||
moulinette_url, | ||
"soumis", | ||
"soumis", | ||
"systematique", | ||
"soumis", | ||
sage_results_by_perimeter={ | ||
Mock(contact_email="[email protected]"): "interdit", | ||
Mock(contact_email="[email protected]"): "action_requise", | ||
Mock(contact_email="[email protected]"): "non_disponible", | ||
}, | ||
**eval_kwargs, | ||
) | ||
|
||
req = rf.get("/") | ||
eval_email = eval.get_evaluation_email() | ||
email = eval_email.get_email(req) | ||
assert email.to == ["[email protected]", "[email protected]"] | ||
assert email.cc == ["[email protected]"] | ||
|
||
assert email.bcc == [ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
|
||
body = email.body | ||
assert "À transmettre au porteur" not in body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
envergo/templates/moulinette/sage/_result_multiple_perimeters.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% for perimeter, result in regulation.results_by_perimeter.items %} | ||
{% if result == "interdit" %} | ||
{% include 'moulinette/sage/result_interdit_single_perimeter.html' %} | ||
|
||
{% elif result == "action_requise" %} | ||
{% include 'moulinette/sage/result_action_requise_single_perimeter.html' %} | ||
|
||
{% elif result == "a_verifier" %} | ||
{% include 'moulinette/sage/result_a_verifier_single_perimeter.html' %} | ||
|
||
{% elif result == "non_soumis" %} | ||
{% include 'moulinette/sage/result_non_soumis_single_perimeter.html' %} | ||
|
||
{% elif result == "non_concerne" %} | ||
{% include 'moulinette/sage/result_non_concerne_single_perimeter.html' %} | ||
|
||
{% elif result == "non_disponible" %} | ||
{% include 'moulinette/sage/result_non_disponible_single_perimeter.html' %} | ||
|
||
{% else %} | ||
{% include 'moulinette/sage/result_non_active.html' %} | ||
|
||
{% endif %} | ||
|
||
{% if not forloop.last %}<hr>{% endif %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1 @@ | ||
<p> | ||
Le projet est <strong>susceptible d'être interdit</strong>. | ||
</p> | ||
|
||
<p> | ||
En effet, le règlement de SAGE interdit tout projet soumis à la Loi sur l'eau qui impacterait une zone humide. | ||
Or, le projet se situe sur une zone humide référencée et au vu des informations saisies, il est susceptible d'être soumis à la Loi sur l’eau (<a href="#regulation_loi_sur_leau">voir section « Loi sur l’eau »)</a>. | ||
</p> | ||
|
||
<h3>Marche à suivre</h3> | ||
|
||
<p> | ||
Pour déterminer si le projet est autorisé, le porteur doit mener les études pour établir s'il est soumis à la Loi sur l'eau. | ||
</p> | ||
|
||
{% include 'moulinette/_read_more_btn.html' with aria_controls=regulation.slug %} | ||
|
||
<div class="more fr-collapse" id="read-more-{{ regulation.slug }}"> | ||
|
||
<p>Il convient de :</p> | ||
|
||
<p> | ||
<strong>1/ Se rapprocher d'un bureau d'études disposant d'une expertise environnementale et lui communiquer ces éléments.</strong> | ||
</p> | ||
|
||
<p> | ||
Les études pourront révéler que le projet est interdit en l’état, qui devra donc être modifié pour respecter le règlement de SAGE. | ||
</p> | ||
|
||
<p> | ||
<strong>2/ Se rapprocher de la structure en charge de l’animation du SAGE</strong> | ||
</p> | ||
|
||
{% for perimeter in regulation.perimeters.all %}{{ perimeter.contact }}{% endfor %} | ||
|
||
<h4 class="fr-h4">Sanctions en cas d'omission</h4> | ||
|
||
<div class="fr-alert fr-alert--info fr-my-3w"> | ||
<p> | ||
S'il s'avère que le projet est réalisé sans respecter le règlement de SAGE, le responsable s'expose à des sanctions administratives et pénales, qui peuvent aller jusqu'à : | ||
</p> | ||
|
||
<ul class="fr-mb-0"> | ||
<li> | ||
<strong>obligation de remettre le terrain en son état initial ;</strong> | ||
</li> | ||
<li> | ||
amende de catégorie 5 : 1 500 € (<a href="https://www.legifrance.gouv.fr/codes/article_lc/LEGIARTI000006836872/" | ||
target="_blank" | ||
rel="noopener">article R.212-48 du code de l'environnement</a>). | ||
</li> | ||
</ul> | ||
|
||
</div> | ||
|
||
{% include 'moulinette/_read_more_btn.html' with aria_controls=regulation.slug %} | ||
|
||
</div> | ||
{% include 'moulinette/sage/_result_multiple_perimeters.html' %} |
Oops, something went wrong.