diff --git a/envergo/moulinette/templatetags/moulinette.py b/envergo/moulinette/templatetags/moulinette.py index cab9b1567..96c4cbfc1 100644 --- a/envergo/moulinette/templatetags/moulinette.py +++ b/envergo/moulinette/templatetags/moulinette.py @@ -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 @@ -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 diff --git a/envergo/templates/haie/moulinette/result_base.html b/envergo/templates/haie/moulinette/result_base.html index 7619c3729..08fa6bf1c 100644 --- a/envergo/templates/haie/moulinette/result_base.html +++ b/envergo/templates/haie/moulinette/result_base.html @@ -41,7 +41,7 @@