From 4dfae3e9957e0662d48c64946bd71c0b007254a6 Mon Sep 17 00:00:00 2001 From: Virginia Dooley Date: Wed, 4 Oct 2023 15:39:24 +0100 Subject: [PATCH 1/3] Rename Case Studies page to Media page --- democracy_club/templates/research/base.html | 3 + democracy_club/templates/research/media.html | 135 +++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 democracy_club/templates/research/media.html diff --git a/democracy_club/templates/research/base.html b/democracy_club/templates/research/base.html index 0be18426..72bee797 100644 --- a/democracy_club/templates/research/base.html +++ b/democracy_club/templates/research/base.html @@ -10,6 +10,9 @@
  • Case Studies
  • +
  • + In the Media +
  • diff --git a/democracy_club/templates/research/media.html b/democracy_club/templates/research/media.html new file mode 100644 index 00000000..bd75d85a --- /dev/null +++ b/democracy_club/templates/research/media.html @@ -0,0 +1,135 @@ +{% extends "research/base.html" %} +{% block page_title %}In the Media{% endblock %} +{% block main_content %} + +

    In the Media

    + +

    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 some of our favourite examples.

    +

    Our data has also been used in multiple House of Commons Library research briefings. For examples of this, please see our 2021 election report.

    +

    For summaries of press coverage during individual elections, please see the relevant election report.

    +

    To access the data yourself, please see our data and API pages.

    + + + +{% endblock main_content %} From 92895a35b5921e40d03becef9c7569571fffb0df Mon Sep 17 00:00:00 2001 From: Virginia Dooley Date: Wed, 4 Oct 2023 15:40:11 +0100 Subject: [PATCH 2/3] Render case_study posts --- .../templates/hermes/posts_for_tag.html | 8 +- .../apps/hermes/templatetags/post_tags.py | 3 +- .../templates/research/case_studies.html | 128 +----------------- 3 files changed, 11 insertions(+), 128 deletions(-) diff --git a/democracy_club/apps/hermes/templates/hermes/posts_for_tag.html b/democracy_club/apps/hermes/templates/hermes/posts_for_tag.html index 707533d8..e72ca96f 100644 --- a/democracy_club/apps/hermes/templates/hermes/posts_for_tag.html +++ b/democracy_club/apps/hermes/templates/hermes/posts_for_tag.html @@ -1,7 +1,9 @@ {% load thumbnail %} {% load typogrify_tags %} {% if posts %} -

    On the blog

    + {% if not hide_header %} +

    On the blog

    + {% endif %} - Our latest blog posts + {% if not hide_header %} + Our latest blog posts + {% endif %} {% endif %} diff --git a/democracy_club/apps/hermes/templatetags/post_tags.py b/democracy_club/apps/hermes/templatetags/post_tags.py index 35cd233f..476c0154 100644 --- a/democracy_club/apps/hermes/templatetags/post_tags.py +++ b/democracy_club/apps/hermes/templatetags/post_tags.py @@ -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, } diff --git a/democracy_club/templates/research/case_studies.html b/democracy_club/templates/research/case_studies.html index 91e922d7..f361efda 100644 --- a/democracy_club/templates/research/case_studies.html +++ b/democracy_club/templates/research/case_studies.html @@ -3,134 +3,12 @@ {% block main_content %}

    Case studies

    -

    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 +

    Each year, our voter information tools and elections data are used by a wide array of organisations. Below are some of our favourite examples.

    -

    Our data has also been used in multiple House of Commons Library research briefings. For examples of this, please see our 2021 election report.

    -

    For summaries of press coverage during individual elections, please see the relevant election report.

    To access the data yourself, please see our data and API pages.

    - + {% load post_tags %} + {% posts_for_tag "case_study" hide_header=True %} {% endblock main_content %} From 19ffe084385acc6d82820791d843206418430eaf Mon Sep 17 00:00:00 2001 From: Virginia Dooley Date: Mon, 9 Oct 2023 11:28:29 +0100 Subject: [PATCH 3/3] Reformat blog tags from https://github.com/DemocracyClub/Website/pull/738 - Rename blog tags - Add custom css for tags in a list - Refactor conditional when tags exist --- democracy_club/apps/hermes/admin.py | 6 +-- .../apps/hermes/tests/test_blog_tags.py | 53 +++++++++++++++++++ democracy_club/assets/scss/styles.scss | 8 +++ .../templates/hermes/post_detail.html | 10 ++-- .../templates/hermes/post_list.html | 16 +++--- 5 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 democracy_club/apps/hermes/tests/test_blog_tags.py diff --git a/democracy_club/apps/hermes/admin.py b/democracy_club/apps/hermes/admin.py index 305d1ac9..f3941608 100644 --- a/democracy_club/apps/hermes/admin.py +++ b/democracy_club/apps/hermes/admin.py @@ -10,7 +10,7 @@ class Meta: fields = "__all__" tag_values = [ - ("wcivf", "WCIVF"), + ("who_can_i_vote_for", "WCIVF"), ("case_study", "case_study"), ("research", "research"), ("elections", "elections"), @@ -18,8 +18,8 @@ class Meta: ("candidates", "candidates"), ("representatives", "representatives"), ("data", "data"), - ("WDIV", "WDIV"), - ("electionleaflets", "electionleaflets"), + ("where_do_i_vote", "WDIV"), + ("election_leaflets", "electionleaflets"), ("blog", "blog"), ] diff --git a/democracy_club/apps/hermes/tests/test_blog_tags.py b/democracy_club/apps/hermes/tests/test_blog_tags.py new file mode 100644 index 00000000..689f6a28 --- /dev/null +++ b/democracy_club/apps/hermes/tests/test_blog_tags.py @@ -0,0 +1,53 @@ +from hermes import models + +from . import HermesTestCase + + +class BlogTestCase(HermesTestCase): + def setUp(self): + # author = User.objects.create( + # username="jimhopper", + # email="jim@mac.com", + # 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") diff --git a/democracy_club/assets/scss/styles.scss b/democracy_club/assets/scss/styles.scss index efae4a12..5f911f09 100644 --- a/democracy_club/assets/scss/styles.scss +++ b/democracy_club/assets/scss/styles.scss @@ -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; + } +} diff --git a/democracy_club/templates/hermes/post_detail.html b/democracy_club/templates/hermes/post_detail.html index 51bb5f3f..6c205e9f 100644 --- a/democracy_club/templates/hermes/post_detail.html +++ b/democracy_club/templates/hermes/post_detail.html @@ -33,12 +33,12 @@

    {{ post.subject }}

    on {% if post.tags %} - - {% for tag in post.tags %} -
      +
        + + {% for tag in post.tags %}
      • {{ tag }}{% if not forloop.last %}, {% endif %}
      • -
      - {% endfor %} + {% endfor %} +
    {% endif %} diff --git a/democracy_club/templates/hermes/post_list.html b/democracy_club/templates/hermes/post_list.html index cdb26565..577a7ccc 100644 --- a/democracy_club/templates/hermes/post_list.html +++ b/democracy_club/templates/hermes/post_list.html @@ -24,12 +24,16 @@

    {{ post.subject }} on -
    - - {% for tag in post.tags %} - {{ tag }}{% if not forloop.last %}, {% endif %} - {% endfor %} -
    + {% if post.tags %} +
    +
      + + {% for tag in post.tags %} +
    • {{ tag }}{% if not forloop.last %}, {% endif %}
    • + {% endfor %} +
    +
    + {% endif %} {{ post.rendered_summary|safe|typogrify }} Read more