From acf0ce2ec756935a8c9e2274592fe04ca323bf6b Mon Sep 17 00:00:00 2001 From: Alexander Griffen Date: Tue, 19 Dec 2023 15:23:18 +0000 Subject: [PATCH] Add PPC dataset to WMC23 pages --- hub/templates/hub/area.html | 25 +++++++++++++++++++++++++ hub/views/area.py | 12 +++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/hub/templates/hub/area.html b/hub/templates/hub/area.html index 7a0ec20df..41902aa6e 100644 --- a/hub/templates/hub/area.html +++ b/hub/templates/hub/area.html @@ -86,8 +86,33 @@

MP

{% include 'hub/area/_mp_data.html' with mp_data=mp %} + {% elif area_type == "WMC23" %} +
+

MP

+
+
+
Prospective Parliamentary Candidates
+ + + + + + + + + {% for row in PPCs %} + + + + + {% endfor %} + +
PPCParty
{{ row.person }}{{ row.party }}
+
+
{% endif %} + {% if categories.opinion %}

Public opinion

diff --git a/hub/views/area.py b/hub/views/area.py index ea0b6f1d4..d166931b9 100644 --- a/hub/views/area.py +++ b/hub/views/area.py @@ -11,6 +11,7 @@ AreaData, AreaType, DataSet, + DataType, Person, PersonData, UserDataSets, @@ -200,13 +201,22 @@ def get_context_data(self, **kwargs): context["overlap_constituencies"] = self.get_overlap_info() context["area_type"] = str(self.object.area_type) + if context["area_type"] == "WMC23": + context["PPCs"] = [ + { + "person": p, + "party": PersonData.objects.get( + person=p, data_type=DataType.objects.get(name="party") + ).value(), + } + for p in Person.objects.filter(area=self.object, person_type="PPC") + ] try: context["mp"] = { "person": Person.objects.get( area=self.object, person_type="MP", end_date__isnull=True ) } - data = PersonData.objects.filter( person=context["mp"]["person"] ).select_related("data_type")