Skip to content

Commit

Permalink
Add PPC dataset to WMC23 pages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-griffen committed Dec 19, 2023
1 parent b30ce77 commit acf0ce2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
25 changes: 25 additions & 0 deletions hub/templates/hub/area.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,33 @@ <h3 class="h5"><a href="{% url 'area' area_type=overlap_constituency.old_area.ar
<h2 class="mb-3 text-primary">MP</h2>
{% include 'hub/area/_mp_data.html' with mp_data=mp %}
</section>
{% elif area_type == "WMC23" %}
<section id="mp" class="area-section">
<h2 class="mb-3 text-primary">MP</h2>
<div class="card flex-grow-1">
<div class="card-body">
<h5 class="card-title mb-3">Prospective Parliamentary Candidates</h5>
<table class="table mb-0">
<thead>
<tr>
<th scope="col">PPC</th>
<th scope="col">Party</th>
</tr>
</thead>
<tbody>
{% for row in PPCs %}
<tr>
<th>{{ row.person }}</th>
<td>{{ row.party }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% endif %}


{% if categories.opinion %}
<section id="opinion" class="area-section">
<h2 class="mb-3 text-primary">Public opinion</h2>
Expand Down
12 changes: 11 additions & 1 deletion hub/views/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
AreaData,
AreaType,
DataSet,
DataType,
Person,
PersonData,
UserDataSets,
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit acf0ce2

Please sign in to comment.