Skip to content

Commit

Permalink
Extract cards into partials
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Feb 25, 2021
1 parent dfa315b commit 0149d1f
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 197 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% load humanize %}

{% if object.current_or_future_candidacies %}
<section class="ds-card">
<div class="ds-card-body">
<h3>That's all we know! Will you help us find more about this candidate?</h3>
<p>Our volunteers have been working hard to add information on as many
candidates as possible, but they need help.
</p>

{% if object.should_show_email_cta %}
<p>Thousands of voters will rely on this site.
{% else %}
<p>
{% endif %}
If you can add information that should be on this page

{% if object.cta_example_details %}
- such as {{ object.name }}'s
{{ object.cta_example_details|join:", " }} -
{% endif %}
please use our crowdsourcing website to add it.</p>
<a href="{{ object.get_ynr_url }}update/" class="ds-cta ds-cta-blue">
Add or edit details &raquo;
</a>
{% if object.should_show_email_cta %}
<p>You can also email {{ object.name }} directly to ask them to add information to this page.
<p>
<a href="{% url 'email_person_view' pk=object.pk ignored_slug=person.name|slugify %}"
class="ds-cta ds-cta-blue">Ask the
candidate for more information &raquo;</a>
</p>
{% endif %}

<h4>Upload your leaflets</h4>
<p>If you've received election leaflets from {{ object.name }}, please take a photo
of them and upload them to ElectionLeaflets.org</p>
<p><a class="ds-button ds-cta ds-cta-blue" type="button" href="https://electionleaflets.org/">Add leaflets</a>
</p>
</div>
</section>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load humanize %}

{% if object.postelection.husting_set.exists and object.current_or_future_candidacies %}
<section class="ds-card ds-stack-smaller">
<div class="ds-card-body">
<h3>Local hustings</h3>
<p>You can meet candidates and question them at local hustings. Here are hustings where {{ object.name }} may
be
appearing.
</p>
{% include "elections/includes/_hustings_list.html" with hustings=object.postelection.husting_set.all %}
</div>
</section>
{% endif %}
104 changes: 104 additions & 0 deletions wcivf/apps/people/templates/people/includes/_person_policy_card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{% load humanize %}
{% load markdown_deux_tags %}

{% if object.statement_to_voters or object.manifestos or object.leaflet_set.exists or object.twfy_id %}
<section class="ds-card">
<div class="ds-card-body">
<h2 class="ds-candidate-name ds-h3">
{{ object.name }}'s policies
</h2>

{% if object.statement_to_voters %}
<h4>Statement to voters</h4>
{% if object.long_statement %}
<ul class="ds-details">
<blockquote>{{ object.statement_intro }}</blockquote>
<details>
<summary>Full statement</summary>
<blockquote>{{ object.statement_remainder|linebreaksbr }}</blockquote>
</details>
</ul>
{% else %}
<blockquote>{{ object.statement_to_voters|linebreaks }}</blockquote>
{% endif %}
<p class="small">This statement was added by {{ object.name }}, their team, or by a <a
href="https://candidates.democracyclub.org.uk/person/{{ object.ynr_id }}">Democracy Club volunteer</a>,
based on
information published by the candidate elsewhere.</p>
{% endif %}

<!-- manifestos -->
{% if object.manifestos %}
{% with object.personpost.party as party %}

{% if party.emblem %}
<a href="{{ s.0.web_url }}"><img src="{{ party.emblem.url }}" alt="{{ party.name}} emblem"
class="manifesto_image"></a>
<a href="{{ object.manifestos.0.web_url }}"><img src="{{ party.emblem.url }}" alt="{{ party.name}} emblem"
class="manifesto_image"></a>
<a href="{{ object.manifestos.0.web_url }}"><img src="{{ party.emblem.url }}" alt="{{ party.name}} emblem"
class="manifesto_image"></a>
{% endif %}
<h4>Party manifesto</h4>
<h4>Party manifesto</h4>
<h4>Party manifesto</h4>
<p>
{{ object.name }} {{ object.personpost.election.in_past|yesno:"was,is" }} the {{ party.party_name }}
candidate.
Find out more about their policies in the {{ party.party_name }} manifesto.
</p>
<ul>
{% for manifesto in object.manifestos %}
{% include "parties/single_manifesto.html" %}
{% endfor %}
</ul>
{% endwith %}
{% endif %}

<!-- leaflets -->
{% if object.leaflet_set.exists %}
<h4>
Recent leaflets from {{ object.name }}
</h4>
{% for leaflet in object.leaflet_set.latest_four %}
{% if leaflet.thumb_url %}
<a href="https://electionleaflets.org/leaflets/{{ leaflet.leaflet_id }}">}
<img src="{{ leaflet.thumb_url }}" alt="Thumbnail of leaflet from {{ object.name }}" />
</a>
{% endif %}
<p>
Uploaded {{ leaflet.date_uploaded_to_electionleaflets|naturalday:"j M Y" }}<br />
<a href="https://electionleaflets.org/leaflets/{{ leaflet.leaflet_id }}" class="cta">See leaflet</a>
</p>
{% endfor %}
<p class="text" style="clear:both;padding-top:1em">
<a class="link-button" href="https://electionleaflets.org/person/{{ object.ynr_id }}">More leaflets from {{
object.name }}</a>
<a class="link-button" href="https://electionleaflets.org/leaflets/add/front/">Upload a leaflet</a>
</p>
{% endif %}

<!-- pledges -->
{% if object.pledges.exists %}
<h4>Candidate pledges</h4>
<p>Hope Not Hate, a London-based charity, canvassed local residents and community organisations to establish
the
following questions to the candidates in this ward.
</p>
{% for pledge in object.pledges.all %}
<h4>{{ pledge.question }}</h4>
<blockquote>{{ pledge.answer|markdown }}</blockquote>
{% endfor %}
{% endif %}

<!-- TWFY -->
{% if object.twfy_id %}
<h4>Record in office</h4>
<p>See this candidate's <a href="https://www.theyworkforyou.com/mp/{{ object.twfy_id }}">record on
TheyWorkForYou</a> -
their speeches, voting history and more.
</p>
{% endif %}
</div>
</section>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% load humanize %}

{% if object.past_not_current_candidacies %}
<section class="ds-card">
<div class="ds-table">
<table>
<caption style="font-style: normal;">
<h3 class="ds-padded">Previous Elections</h3>
</caption>
<tr>
<th>Date</th>
<th>Election</th>
<th>Party</th>
<th>Results</th>
</tr>
<tr>
{% for person_post in object.past_not_current_candidacies %}
{{ person_post.post_election.short_cancelled_message_html }}
{{ person_post.post_election.short_cancelled_message_html }}
{{ person_post.post_election.short_cancelled_message_html }}
<td>{{ person_post.election.election_date|date:"Y" }}</td>
<td>{{ person_post.post.label }}: {{ person_post.election }}</td>
<td>{{ person_post.party.party_name }}</td>
{% if person_post.elected %}
<td>{{ person_post.votes_cast|intcomma }} votes (elected)</td>
{% else %}
<td>{{ person_post.votes_cast|intcomma }} votes</td>
{% endif %}
</tr>
{% endfor %}
</table>
</div>
</section>
{% endif %}
Loading

0 comments on commit 0149d1f

Please sign in to comment.