Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/case studies redesign #739

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions democracy_club/apps/hermes/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class Meta:
fields = "__all__"

tag_values = [
("wcivf", "WCIVF"),
("who_can_i_vote_for", "WCIVF"),
("case_study", "case_study"),
("research", "research"),
("elections", "elections"),
("councils", "councils"),
("candidates", "candidates"),
("representatives", "representatives"),
("data", "data"),
("WDIV", "WDIV"),
("electionleaflets", "electionleaflets"),
("where_do_i_vote", "WDIV"),
("election_leaflets", "electionleaflets"),
("blog", "blog"),
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{% load thumbnail %}
{% load typogrify_tags %}
{% if posts %}
<h2>On the blog</h2>
{% if not hide_header %}
<h2>On the blog</h2>
{% endif %}
<ul class="post-list ds-grid">
{% for post in posts %}
<li class="ds-card">
Expand All @@ -19,5 +21,7 @@ <h3><a class="ds-card-link ds-h5" href="{{ post.get_absolute_url }}">{{ post.sub
</li>
{% endfor %}
</ul>
<a href="{% url "hermes_post_list" %}?tag={{tag}}" class="ds-cta">Our latest blog posts</a>
{% if not hide_header %}
<a href="{% url "hermes_post_list" %}?tag={{tag}}" class="ds-cta">Our latest blog posts</a>
{% endif %}
{% endif %}
3 changes: 2 additions & 1 deletion democracy_club/apps/hermes/templatetags/post_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
register = template.Library()


def posts_for_tag(tag):
def posts_for_tag(tag, hide_header=False):
posts = Post.objects.for_tag(tag)[:4]
return {
"posts": posts,
"tag": tag,
"hide_header": hide_header,
}


Expand Down
53 changes: 53 additions & 0 deletions democracy_club/apps/hermes/tests/test_blog_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from hermes import models

from . import HermesTestCase


class BlogTestCase(HermesTestCase):
def setUp(self):
# author = User.objects.create(
# username="jimhopper",
# email="[email protected]",
# first_name="Jim",
# last_name="Hopper",
# is_staff=True,
# )
self.category_1 = models.Category.objects.create(
title="Foo",
slug="foo",
)
self.category_2 = models.Category.objects.create(
title="Bar",
slug="bar",
)
self.blog_with_multiple_tags = models.Post.objects.create(
is_published=True,
subject="Foo",
slug="foo",
tags=["foo", "bar"],
category=self.category_1,
summary="Foo summary",
body="Foo body",
)
self.blog_without_tags = models.Post.objects.create(
is_published=True,
subject="Bar",
slug="bar",
category=self.category_2,
summary="Bar summary",
body="Bar body",
)
self.posts = [self.blog_with_multiple_tags, self.blog_without_tags]

def test_blog_without_tags(self):
"""Don't show the tag icon if a post doesn't have any tags"""
response = self.client.get(self.blog_without_tags.get_absolute_url())
self.assertNotContains(response, "🏷️")

def test_blog_with_tags(self):
"""Show the tag icon if a post has tags"""
response = self.client.get(
self.blog_with_multiple_tags.get_absolute_url()
)
self.assertContains(response, "🏷️")
self.assertContains(response, "foo")
8 changes: 8 additions & 0 deletions democracy_club/assets/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,11 @@ ul > li > ul {
// # show them inline rather than as a list
display: inline;
}

.unindented-list {
padding-left: 0;
list-style: none;
li {
margin-left: 0;
}
}
10 changes: 5 additions & 5 deletions democracy_club/templates/hermes/post_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ <h1>{{ post.subject }}</h1>
</address>
on <time pubdate datetime="{{post.modified_on|date:"c"}}" title="{{post.created_on|date:"jS E Y"}}">{{post.created_on|date:"jS E Y"}}</time>
{% if post.tags %}
<span aria-hidden="true">🏷️</span>
{% for tag in post.tags %}
<ul>
<ul class="unindented-list">
<span aria-hidden="true">🏷️</span>
{% for tag in post.tags %}
<li class="blog-tag"><a href="{% url 'hermes_post_list_by_tag' tag %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}</li>
</ul>
{% endfor %}
{% endfor %}
</ul>
{% endif %}
</div>

Expand Down
16 changes: 10 additions & 6 deletions democracy_club/templates/hermes/post_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ <h2 class="ds-h3"><a href="{{ post.get_absolute_url }}">{{ post.subject }}</a></
</address>
on <time pubdate datetime="{{post.modified_on|date:"c"}}" title="{{post.created_on|date:"jS E Y"}}">{{post.created_on|date:"jS E Y"}}</time>
</div>
<div>
<span aria-hidden="true">🏷️</span>
{% for tag in post.tags %}
<a href="{% url 'hermes_post_list_by_tag' tag %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</div>
{% if post.tags %}
<div>
<ul class="unindented-list">
<span aria-hidden="true">🏷️</span>
{% for tag in post.tags %}
<li class="blog-tag"><a href="{% url 'hermes_post_list_by_tag' tag %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{{ post.rendered_summary|safe|typogrify }}
<a class="ds-cta ds-cta-blue" href="{{ post.get_absolute_url }}">Read more</a>
</article>
Expand Down
3 changes: 3 additions & 0 deletions democracy_club/templates/research/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<li>
<a href="{% url "case_studies" %}">Case Studies</a>
</li>
<li>
<a href="{% url "media" %}">In the Media</a>
</li>
</ul>
</nav>

Expand Down
128 changes: 3 additions & 125 deletions democracy_club/templates/research/case_studies.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,134 +3,12 @@
{% block main_content %}

<h1>Case studies</h1>
<p>Each year, our voter information tools and elections data are used by a wide array of organisations, while our expertise is often drawn upon by journalists and researchers. Below are
<p>Each year, our voter information tools and elections data are used by a wide array of organisations. Below are
some of our favourite examples.
</p>
<p>Our data has also been used in multiple House of Commons Library research briefings. For examples of this, please see our <a href="https://democracyclub.org.uk/report_2021/#press-pr">2021 election report</a>.</p>
<p>For summaries of press coverage during individual elections, <a href="https://democracyclub.org.uk/projects/reports/">please see the relevant election report</a>.</p>
<p>To access the data yourself, please see our <a href="https://democracyclub.org.uk/data_apis/voting_information_api/">data and API pages</a>.</p>

<ul class="ds-details">
<li>
<details>
<summary>
<h2 id="data-journalism">Data Journalism</h2>
</summary>
<p>
<i>Wales Online (2022)</i>, <a href="https://www.walesonline.co.uk/news/uk-news/local-elections-2022-uks-most-23866562">'Local elections 2022: The UK's most unusual polling stations'</a>
</p>
<p>
<i>NationalWorld (2022)</i>, <a href="https://www.nationalworld.com/news/politics/local-elections-2022-candidates-3660601">'Local elections 2022: how many candidates by party, youngest and oldest, gender split and most common names'</a>
</p>
<p>
<i>The Guardian (2021)</i>, <a href="https://www.theguardian.com/politics/2021/apr/27/independents-day-the-rise-of-hyperlocal-political-parties">'"Independents" day: the rise of hyperlocal political parties'</a>
</p>
<p>
<i>The Times (2019)</i>, <a href="https://www.thetimes.co.uk/article/who-are-the-general-election-candidates-in-my-constituency-area-60btrdpxs">'Who are the general election candidates in my area?'</a>
</p>
<p>
<i>BBC News (2019)</i>, <a href="https://www.bbc.co.uk/news/uk-england-47947867">'Council elections: 'Not enough' women and minorities stand'</a>
</p>
</details>
</li>
<li>
<details>
<summary>
<h2 id="partnerships">Partnerships</h2>
</summary>
<p>
<i>In Your Area (2019)</i>, <a href="https://www.inyourarea.co.uk/news/local-elections-2019-who-you-can-vote-for-a-where/">'Local Elections 2019: Who you can vote for and where'</a>
</p>
<p>
<i>Democratic Audit (2018)</i>, <a href="https://www.democraticaudit.com/2018/04/09/englands-local-elections-2018-bridging-the-information-gap-with-the-democratic-dashboard/">'England’s local elections 2018: bridging the information gap with the Democratic Dashboard'</a>
</p>
<p>
<i>The Electoral Commission (2017)</i>, <a href="https://ukelectoralcommission.wordpress.com/2017/02/06/helping-voters-find-out-where-to-vote/">'Helping voters find out where to vote'</a>
</p>
<p>
<i>Oxford City Council (2017)</i>, <a href="http://digital.oxford.gov.uk/blog/2017/05/17/collaboration-not-reinvention">'Collaboration not reinvention'</a>
</p>
</details>
</li>
<li>
<details>
<summary>
<h2 id="articles">Articles</h2>
</summary>
<p>
<i>Nation.Cymru (2021)</i>, <a href="https://nation.cymru/opinion/if-we-want-young-people-to-turn-out-for-the-senedd-vote-we-must-make-it-an-election-fit-for-digital-natives/">'If we want young people to turn out for the Senedd vote we must make it an election fit for digital natives'</a>
</p>
<p>
<i>TBD (2017)</i>, <a href="https://www.tbd.community/en/a/democracy-club-uk">'How Technology Can Disrupt Democracy'</a>
</p>
<p>
<i>The Guardian(2017)</i>, <a href="https://www.theguardian.com/politics/2017/jun/06/democracy-theres-an-app-for-that-the-tech-upstarts-trying-to-hack-british-politics">'Democracy? There's an app for that - the tech upstarts trying to 'hack' British politics'</a>
</p>
</details>
</li>
<li>
<details>
<summary>
<h2 id="candidate-gender-analysis">Candidate gender analysis</h2>
</summary>
<p>
<i>The Scotsman (2022)</i>, <a href="https://www.scotsman.com/news/politics/council-elections-scotland-only-33-of-candidates-running-for-may-local-elections-are-female-3673344">'Council elections Scotland: Only 33% of candidates running for May local elections are female'</a>
</p>
<p>
<i>The Times (2022)</i>, <a href="https://www.thetimes.co.uk/article/local-election-analysis-says-the-typical-candidate-is-a-47-year-old-man-called-david-6txvmj9d5">'Local election analysis says the typical candidate is a 47-year-old man called David'</a>
</p>
<p>
<i>Fawcett Society (2021)</i>, <a href="https://www.fawcettsociety.org.uk/news/new-data-shows-only-a-third-of-local-election-candidates-are-women">'New data shows only a third of local election candidates are women'</a>
</p>
<p>
<i>Fawcett Society (2019)</i>, <a href="https://www.fawcettsociety.org.uk/news/lack-of-women-candidates-in-local-elections-puts-councils-behind-the-times">'Lack of women candidates in local elections "puts councils behind the times"'</a>
</p>
<p>
<i>The Daily Telegraph (2017)</i><a href="https://www.telegraph.co.uk/women/politics/general-election-2017-sees-record-level-female-candidates/">'General election 2017 sees record level of female candidates'</a>
</p>
</details>
</li>
<li>
<details>
<summary>
<h2 id="reports">Reports</h2>
</summary>
<p>
Alex Parsons & Anna Powell-Smith (2023), '<a href="https://research.mysociety.org/html/unlocking-fragmented-data/#top">Unlocking the Value of Fragmented Public Data</a>' (mySociety and the Centre for Public Data)
</p>
<p>
Public Administration and Constitutional Affairs Committee (2022), '<a href="https://committees.parliament.uk/work/375/the-work-of-the-electoral-commission/publications/">The Work of the Electoral Commission</a>'
</p>
<p>
House of Lords Democracy and Digital Technologies Select Committee (2020), '<a href="https://committees.parliament.uk/committee/407/democracy-and-digital-technologies-committee/news/115316/democracy-under-threat-from-pandemic-of-misinformation-online-say-lords-committee/">Digital Technology and the Resurrection of Trust</a>'
</p>
<p>
Flavio Grazian & Hendrik Nahr (2020), '<a href="https://ecas.org/wp-content/uploads/2021/02/Next-level-participation_0302_fin.pdf">Next Level Participation: Citizen-Driven E-Democracy Tools</a>' [PDF] (European Liberal Forum)
</p>
</details>
</li>
<li>
<details>
<summary>
<h2 id="academic-research">Academic Research</h2>
</summary>
<p>
Owen Winter (2022), '<a href="https://blogs.lse.ac.uk/politicsandpolicy/progressive-electoral-cooperation/">Did progressive electoral cooperation disproportionately hurt the Conservatives in the 2022 English local elections?</a>', <em>LSE British Politics and Policy</em>
</p>
<p>
James Weinberg (2020), '<a href="https://doi.org/10.1177/1369148120959044">Emotional labour and occupational wellbeing in political office</a>', <em>The British Journal of Politics and International Relations</em>
</p>
<p>
Genevieve Gorrell et. al. (2020), '<a href="https://doi.org/10.1140/epjds/s13688-020-00236-9">Which politicians Receive abuse? Four factors illuminated in the UK general election 2019</a>', <em>EPJ Data Science</em>
</p>
<p>
James Weinberg (2020), '<a href="https://doi.org/10.1017/S0007123419000814">Who Wants To Be a Politician? Basic Human Values and Candidate Emergence in the United Kingdom</a>', <em>British Journal of Political Science</em>
</p>
<p>
Caitlin Milazzo & Joshua Townsley (2020), '<a href="https://doi.org/10.1093/pa/gsy040">Conceived in Harlesden: Candidate-Centred Campaigning in British General Elections</a>', <em>Parliamentary Affairs</em>
</p>
</details>
</li>
</ul>
{% load post_tags %}
{% posts_for_tag "case_study" hide_header=True %}

{% endblock main_content %}
Loading