From 6bec7e1485355317a041bf9ea0c3ac0a23d0192c Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 8 Jan 2024 15:16:24 +0000 Subject: [PATCH] fix issues with turning range data sets into single item Add a check to avoid mistakenly selecting the first element of range/opinion datasets. --- hub/views/area.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hub/views/area.py b/hub/views/area.py index 2953b0ec6..8510d6696 100644 --- a/hub/views/area.py +++ b/hub/views/area.py @@ -253,9 +253,15 @@ def get_context_data(self, **kwargs): if data.get("data", None) is not None: if data_set.category is not None: - if not isinstance(data["data"], AreaData): + if ( + data_set.category != "opinion" + and not data_set.is_range + and not isinstance(data["data"], AreaData) + ): if len(data["data"]) == 1: data["data"] = data["data"][0] + if data_set.category == "opinion" or data_set.is_range: + data["do_not_shorten"] = True categories[data_set.category].append(data) else: categories["place"].append(data) @@ -272,7 +278,9 @@ def get_context_data(self, **kwargs): else: if len(data_points) != 0: data_set_name = data_points[0].data_type.data_set.name - if len(data_points) == 1: + if len(data_points) == 1 and not data_item.get( + "do_not_shorten", False + ): data["data"] = data_points[0] else: data_set_name = None