Skip to content

Commit

Permalink
display recent wrans for an MP on the area page
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Sep 18, 2024
1 parent 93562fb commit 92a04d9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
36 changes: 36 additions & 0 deletions hub/templates/hub/area.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,42 @@ <h3 class="h5">Votes and EDMs</h3>
</p>
</div>
</div>

{% if mp.wrans %}
<div class="card dataset-card area-data--md area-data--featured">
<div class="card-header">
<h3 class="h5">Written Answers</h3>
</div>
<div class="card-body">
<table class="table mb-0">
<thead>
<tr>
<th scope="col">Department</th>
<th scope="col">Topic</th>
<th scope="col">Date</th>
</tr>
</thead>
<tbody>
{% for wran in mp.wrans %}
<tr>
<td>{{ wran.department }}</td>
<td>{{ wran.area }}</td>
<td><a href="{{ wran.link }}">{{ wran.date }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="card-footer">
<p class="card-text">
Data from TheyWorkForYou. Recent Written Answers to questions submitted by the MP to departments relevant to climate and nature.
{% if mp.twfyid %}
<a href="https://www.theyworkforyou.com/mp/{{ mp.twfyid }}">See this MP’s full record on TheyWorkForYou.</a>
{% endif %}
</p>
</div>
</div>
{% endif %}
{% endif %}

<div class="card dataset-card area-data--sm {% comment %} TODO: dataset-card--favourite? {% endcomment %} area-data--featured">
Expand Down
3 changes: 3 additions & 0 deletions hub/views/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ def get_context_data(self, **kwargs):
}
for item in support
]
wrans = data.filter(data_type__name="mp_wrans")
if wrans.count() > 0:
context["mp"]["wrans"] = wrans.first().value()

except Person.DoesNotExist:
context["no_mp"] = True
Expand Down

0 comments on commit 92a04d9

Please sign in to comment.