Skip to content

Commit

Permalink
Switch area page to use person.party
Browse files Browse the repository at this point in the history
  • Loading branch information
zarino authored and struan committed Jun 17, 2024
1 parent fd38f8f commit ef01ffa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
14 changes: 7 additions & 7 deletions hub/templates/hub/area.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ <h2 class="mb-2 mb-sm-0 me-auto text-primary">MP</h2>
</div>
<div class="flex-grow-1 ms-3">
<h3 class="h4 mb-0 text-primary" id="mp_name">{{ mp.person.name }}</h3>
{% if mp.party %}
<p class="mb-0 text-muted">{{ mp.party }}</p>
{% if mp.person.party %}
<p class="mb-0 text-muted">{{ mp.person.party }}</p>
{% endif %}
</div>
</div>
Expand Down Expand Up @@ -364,17 +364,17 @@ <h3 class="h5">Term ended</h3>
<h2 class="text-primary">Prospective Parliamentary Candidates</h2>
<p style="max-width: 37em;" class="mb-4">These are the candidates standing for election in this constituency on 4th June.</p>
<div class="area-data-grid">
{% for row in PPCs %}
{% for person in PPCs %}
<div class="card dataset-card area-data--sm area-data--featured">
<div class="card-body">
<div class="d-flex align-items-center">
<div class="flex-shrink-0">
{% include 'hub/includes/person-photo.html' with person=row.person %}
{% include 'hub/includes/person-photo.html' with person=person %}
</div>
<div class="flex-grow-1 ms-3">
<h3 class="h4 mb-0 text-primary">{{ row.person }}</h3>
{% if row.party %}
<p class="mb-0 text-muted">{{ row.party }}</p>
<h3 class="h4 mb-0 text-primary">{{ person.name }}</h3>
{% if person.party %}
<p class="mb-0 text-muted">{{ person.party }}</p>
{% endif %}
</div>
</div>
Expand Down
10 changes: 1 addition & 9 deletions hub/views/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,7 @@ def get_context_data(self, **kwargs):
context["slug"] = slugify(self.object.name)

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")
]
context["PPCs"] = Person.objects.filter(area=self.object, person_type="PPC")
try:
context["mp"] = {
"person": Person.objects.get(
Expand Down

0 comments on commit ef01ffa

Please sign in to comment.