Skip to content

Commit

Permalink
Hotfix for regulation grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault committed Jan 29, 2025
1 parent 9f2e279 commit c873630
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 14 additions & 15 deletions envergo/moulinette/templatetags/moulinette.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,16 @@ def show_haie_plantation_evaluation(context, plantation_evaluation):
return content


def get_display_result(regulation):
other_results = [
RESULTS.systematique,
RESULTS.cas_par_cas,
RESULTS.action_requise,
RESULTS.a_verifier,
RESULTS.iota_a_verifier,
RESULTS.non_soumis,
RESULTS.non_concerne,
RESULTS.non_disponible,
]

return regulation.result if regulation.result not in other_results else "autre"
def get_result_group_key(regulation):
"""Get the grouping key for the regulation result."""

group_keys = {
RESULTS.interdit: RESULTS.interdit,
RESULTS.soumis: RESULTS.soumis,
RESULTS.derogation_inventaire: RESULTS.soumis,
RESULTS.derogation_simplifiee: RESULTS.soumis,
}
return group_keys.get(regulation.result, "autre")


@register.simple_tag
Expand All @@ -323,11 +320,13 @@ def group_regulations_for_display(moulinette):
"autre",
]

regulations_list.sort(key=lambda reg: result_cascade.index(get_display_result(reg)))
regulations_list.sort(
key=lambda reg: result_cascade.index(get_result_group_key(reg))
)

# Group the regulations by their result
grouped = {
key: list(group)
for key, group in groupby(regulations_list, key=get_display_result)
for key, group in groupby(regulations_list, key=get_result_group_key)
}
return grouped
2 changes: 1 addition & 1 deletion envergo/templates/haie/moulinette/result_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<h3>Réglementations interdisant le projet</h3>
{% elif result == "soumis" and moulinette.result != "soumis" %}
<h3>Autres réglementations concernant le projet</h3>
{% elif result != "autre" %}
{% elif result == "soumis" %}
<h3>Réglementations concernant le projet</h3>
{% else %}
<h3>Autres réglementations</h3>
Expand Down

0 comments on commit c873630

Please sign in to comment.