From 3619007a5b2b4ae56b27b573251118bd7afeb211 Mon Sep 17 00:00:00 2001 From: Zarino Zappia Date: Wed, 28 Jun 2023 16:00:59 +0100 Subject: [PATCH] Handle situation where council or twin has no plans --- caps/models.py | 8 +++ .../caps/council_cards/council-documents.html | 2 +- caps/templates/caps/twins.html | 52 +++++++++++++++---- caps/views.py | 1 - 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/caps/models.py b/caps/models.py index acab24aca..ed5ec1712 100755 --- a/caps/models.py +++ b/caps/models.py @@ -39,6 +39,7 @@ ) from django.db.models.expressions import RawSQL from django.forms import Select, TextInput +from django.utils.http import urlencode from django.utils.text import slugify from simple_history.models import HistoricalRecords from caps.filters import DefaultSecondarySortFilter @@ -580,6 +581,13 @@ def foe_slug(self): return slug + @property + def feedback_form_url(self): + return "{}?{}".format( + settings.FEEDBACK_FORM, + urlencode({"usp": "pp_url", "entry.393810903": self.name}), + ) + @classmethod def country_description(cls, country_code): codes_to_descriptions = dict( diff --git a/caps/templates/caps/council_cards/council-documents.html b/caps/templates/caps/council_cards/council-documents.html index f46131b58..9dd05fe34 100644 --- a/caps/templates/caps/council_cards/council-documents.html +++ b/caps/templates/caps/council_cards/council-documents.html @@ -65,7 +65,7 @@

Climate documents

Are these plans out of date?

- Fill in this form to let us know where to find the latest plans from this council. + Fill in this form to let us know where to find the latest plans from this council. {% endblock cardbody %} diff --git a/caps/templates/caps/twins.html b/caps/templates/caps/twins.html index 0391e2dbe..2330774f7 100644 --- a/caps/templates/caps/twins.html +++ b/caps/templates/caps/twins.html @@ -62,28 +62,40 @@

Similarity index

{{ council.short_name }}’s climate plans

+ {% if council.plandocument_set.all %}
+ {% if twin.plandocument_set.all %}

Topics covered by {{ council.short_name }}’s plans on CAPE but not by {{ twin.short_name}}’s:

+ {% else %} +

Some of the topics covered by {{ council.short_name }}’s plans on CAPE:

+ {% endif %} {% if twin.plan_overlap.just_in_a %} {% else %} -

+

(No terms appear in just {{ twin.short_name }}’s plans.)

{% endif %} + {% if twin.plan_overlap.overlap %}

Examples of topics that appear in both councils’ plans include:

+ {% endif %}
- {% if council.plandocument_set.all %}
@@ -99,6 +111,10 @@

{{ council.short_name }}’s climate plans

+ {% else %} +
+

We haven’t found any climate plans or documents for {{ council.name }}. If you know where to find them, please let us know.

+
{% endif %} @@ -107,27 +123,39 @@

{{ council.short_name }}’s climate plans

{{ twin.short_name }}’s climate plans

+ {% if twin.plandocument_set.all %}
+ {% if council.plandocument_set.all %}

Topics covered by {{ twin.short_name }}’s plans on CAPE but not by {{ council.short_name }}’s:

+ {% else %} +

Some of the topics covered by {{ twin.short_name }}’s plans on CAPE:

+ {% endif %} {% if twin.plan_overlap.just_in_b %} {% else %} -

+

(No terms appear in just {{ council.short_name }}’s plans.)

{% endif %} + {% if twin.plan_overlap.overlap %}

Examples of topics that appear in both councils’ plans include:

+ {% endif %}
- {% if twin.plandocument_set.all %}
@@ -143,6 +171,10 @@

{{ twin.short_name }}’s climate plans

+ {% else %} +
+

We haven’t found any climate plans or documents for {{ council.name }}. If you know where to find them, please let us know.

+
{% endif %} diff --git a/caps/views.py b/caps/views.py index 99e450ad5..7042574eb 100755 --- a/caps/views.py +++ b/caps/views.py @@ -231,7 +231,6 @@ def get_context_data(self, **kwargs): context["project_stats"] = project_stats context["page_title"] = council.name - context["feedback_form_url"] = settings.FEEDBACK_FORM if council.emergencydeclaration_set.count() > 0: context["declared_emergency"] = council.emergencydeclaration_set.all()[0]