Skip to content

Commit

Permalink
Display deselected message with source if True
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Sep 25, 2023
1 parent 5abd8a8 commit 88a8ff6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ynr/apps/elections/uk/templates/candidates/person-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ <h2>Candidacies:</h2>
{% else %}
Contesting the {{ election_data.name }} ({{ election_data.election_date }})
{% endif %}</dt>

<dd>{{ person|post_in_election:election_data }}</dd>
{% for membership in person.memberships.all %}
{% if membership.deselected %}
<dd>This candidate has been deselected by their party, but will remain on the ballot paper. <a href="{{ membership.deselected_source }}">Learn more<a>.</dd>
{% endif %}
{% endfor %}

{% empty %}
<p>No candidacies known at the moment.</p>
Expand Down
9 changes: 9 additions & 0 deletions ynr/apps/people/tests/test_person_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,12 @@ def test_previous_party_affiliations(self):
self.assertContains(
response, self.membership.previous_party_affiliations.all()[0].name
)

def test_deselected_membership(self):
membership = self.person.memberships.first()
membership.deselected = True
membership.deselected_source = "https://www.electoralcommission.org.uk/"
membership.save()
response = self.app.get(self.person.get_absolute_url())
deselected_text = """<dd>This candidate has been deselected by their party, but will remain on the ballot paper. <a href="https://www.electoralcommission.org.uk/">Learn more<a>.</dd>"""
self.assertContains(response, deselected_text)

0 comments on commit 88a8ff6

Please sign in to comment.