-
-
- {% include 'international/includes/form_field.html' with field=form.email %}
-
+
+
+
+
+ {% include 'international/includes/form_field.html' with field=form.full_name %}
-
-
- {% include 'international/includes/submit_button.html' with button_text='Send message' %}
+
+
+
+
+ {% include 'international/includes/form_field.html' with field=form.email %}
-
- {% endif %}
+
+
+
+ {% include 'international/includes/submit_button.html' with button_text='Send message' %}
+
+
+
+
{% endblock content %}
{% block feedback_reporter %}
diff --git a/international/templates/international/contact_success.html b/international/templates/international/contact_success.html
new file mode 100644
index 0000000000..30fce64969
--- /dev/null
+++ b/international/templates/international/contact_success.html
@@ -0,0 +1,30 @@
+{% extends './base.html' %}
+{% load static %}
+{% block head_title %}
+ {% if form.errors %}Error:{% endif %}
+ Get help using great.gov.uk/international
+ {{ block.super }}
+{% endblock %}
+{% block page_title %}Get help using great.gov.uk/international {{ block.super }}{% endblock %}
+{% if not request.GET.success %}
+ {% block breadcrumb_region %}
+
+ {% endblock %}
+{% endif %}
+{% block css_layout_class %}
+ govuk-main-wrapper
+ {{ block.super }}
+{% endblock %}
+{% block content %}
+
+{% endblock content %}
\ No newline at end of file
diff --git a/international/urls.py b/international/urls.py
index c2b1eeac69..90c87ed577 100644
--- a/international/urls.py
+++ b/international/urls.py
@@ -9,5 +9,10 @@
'site-help/',
views.ContactView.as_view(),
name='contact',
- )
+ ),
+ path(
+ 'site-help/success/',
+ views.ContactSuccessView.as_view(),
+ name='contact-success',
+ ),
]
diff --git a/international/views.py b/international/views.py
index f96b6a4695..4d0e9f48c0 100644
--- a/international/views.py
+++ b/international/views.py
@@ -4,6 +4,7 @@
from directory_forms_api_client.helpers import Sender
from django.http import HttpResponseBadRequest, HttpResponseRedirect, JsonResponse
from django.urls import reverse, reverse_lazy
+from django.views.generic import TemplateView
from django.views.generic.edit import FormView
from great_components.mixins import GA360Mixin # /PS-IGNORE
from wagtailcache.cache import WagtailCacheMixin
@@ -37,9 +38,9 @@ def get_back_url(self):
return back_url
def get_success_url(self):
- success_url = reverse_lazy('international:contact') + '?success=true'
+ success_url = reverse_lazy('international:contact-success')
if self.request.GET.get('next'):
- success_url = success_url + '&next=' + check_url_host_is_safelisted(self.request)
+ success_url = success_url + '?next=' + check_url_host_is_safelisted(self.request)
return success_url
def is_find_a_supplier_submission(self):
@@ -155,3 +156,28 @@ def form_valid(self, form):
else:
self.submit_feedback(form)
return super().form_valid(form)
+
+
+class ContactSuccessView(WagtailCacheMixin, GA360Mixin, TemplateView): # /PS-IGNORE
+ template_name = 'international/contact_success.html'
+ subject = 'Great.gov.uk International contact form success'
+
+ cache_control = 'no-cache'
+
+ def __init__(self):
+ super().__init__()
+ self.set_ga360_payload(
+ page_id='Contact',
+ business_unit='Great.gov.uk International',
+ site_section='contact',
+ )
+
+ def get_back_url(self):
+ back_url = '/international/'
+ if self.request.GET.get('next'):
+ back_url = check_url_host_is_safelisted(self.request)
+ return back_url
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs, back_url=self.get_back_url())
+ return context
diff --git a/tests/unit/international/test_views.py b/tests/unit/international/test_views.py
index c088e91683..090e208b6d 100644
--- a/tests/unit/international/test_views.py
+++ b/tests/unit/international/test_views.py
@@ -31,3 +31,10 @@ def test_contact_submit(mock_action_class, client, settings):
},
)
assert response.status_code == 302
+
+
+@pytest.mark.django_db
+def test_contact_success(client, settings):
+ url = reverse('international:contact-success')
+ response = client.get(url)
+ assert response.status_code == 200
From 5105071bcf72b2b62ef7abf1fa335f1069cadbe5 Mon Sep 17 00:00:00 2001
From: davidu1975
Date: Fri, 10 Jan 2025 10:32:45 +0000
Subject: [PATCH 11/20] rollback change to document tag
---
.../templates/buy_from_the_uk/index.html | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/international_buy_from_the_uk/templates/buy_from_the_uk/index.html b/international_buy_from_the_uk/templates/buy_from_the_uk/index.html
index fc094c9cb5..82c965077d 100644
--- a/international_buy_from_the_uk/templates/buy_from_the_uk/index.html
+++ b/international_buy_from_the_uk/templates/buy_from_the_uk/index.html
@@ -1,6 +1,5 @@
{% extends './base.html' %}
{% load static %}
-{% load get_document_link from document_tags %}
{% block head_title %}Buy from the UK {{ block.super }}{% endblock %}
{% block meta_title %}Buy from the UK {{ block.super }}{% endblock %}
{% block head_css %}
@@ -57,9 +56,8 @@ Download our ebook: 5 reasons to buy from the UK
Our ebook, 5 Reasons to buy from the UK, gives insight into how the unique combination of innovation, creativity, infrastructure, robust regulatory framework, and access to capital makes the UK one of the top markets to find a supplier.
- {% get_document_link "5_Reasons_To_Buy_From_the_UK_RElQ4Ie" "pdf" as document_link %}
+ href="https://directory-cms.london.cloudapps.digital/documents/107/5_Reasons_To_Buy_From_the_UK_RElQ4Ie.pdf">
Download
From b6cdbdcda48991d9027f6bc217ea3410c71b35be Mon Sep 17 00:00:00 2001
From: Bobby Stearman <80459294+bobby-didcoding@users.noreply.github.com>
Date: Fri, 10 Jan 2025 10:49:16 +0000
Subject: [PATCH 12/20] Update views.py to use new redirect url
---
international_buy_from_the_uk/views.py | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/international_buy_from_the_uk/views.py b/international_buy_from_the_uk/views.py
index 5cf7e37f5b..63f595185d 100644
--- a/international_buy_from_the_uk/views.py
+++ b/international_buy_from_the_uk/views.py
@@ -35,9 +35,7 @@ def __init__(self):
)
def get_success_url(self):
- success_url = (
- reverse_lazy('international:contact') + '?success=true' + '&next=' + '/international/buy-from-the-uk'
- )
+ success_url = reverse_lazy('international:contact-success') + '?next=' + '/international/buy-from-the-uk'
return success_url
def send_agent_email(self, form):
@@ -246,9 +244,7 @@ def __init__(self):
)
def get_success_url(self):
- success_url = (
- reverse_lazy('international:contact') + '?success=true' + '&next=' + '/international/buy-from-the-uk'
- )
+ success_url = reverse_lazy('international:contact-success') + '&next=' + '/international/buy-from-the-uk'
return success_url
def send_email(self, form):
From c08415785cd4065ba463e4b8ee930adaf43c0ca7 Mon Sep 17 00:00:00 2001
From: Bobby Stearman <80459294+bobby-didcoding@users.noreply.github.com>
Date: Fri, 10 Jan 2025 10:52:52 +0000
Subject: [PATCH 13/20] reformatted
---
exportplan/forms.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/exportplan/forms.py b/exportplan/forms.py
index bfdc35093d..5a46313fb5 100644
--- a/exportplan/forms.py
+++ b/exportplan/forms.py
@@ -122,9 +122,9 @@ def set_country_specific_text(self, country_name):
self.fields['demand'].label = f'Describe the consumer demand for your product in the {country_name}'
self.fields['competitors'].label = f'Who are your competitors in the {country_name}?'
self.fields['trend'].label = f'What are the product trends in the {country_name}?'
- self.fields[
- 'unqiue_selling_proposition'
- ].label = f'What’s your unique selling proposition for the {country_name}?'
+ self.fields['unqiue_selling_proposition'].label = (
+ f'What’s your unique selling proposition for the {country_name}?'
+ )
self.fields['average_price'].label = f'What’s the avg price for your product in the {country_name}?'
self.fields['trend'].widget.attrs['description'] = (
f'Describe what you know about the product market in the {country_name}. '
From 8429ae4ed2c94abc4018cbc77ea5fd592bc9ce79 Mon Sep 17 00:00:00 2001
From: Bobby Stearman <80459294+bobby-didcoding@users.noreply.github.com>
Date: Fri, 10 Jan 2025 10:53:11 +0000
Subject: [PATCH 14/20] reformatted
---
exportplan/context.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/exportplan/context.py b/exportplan/context.py
index 7b2c1dc429..df08a43055 100644
--- a/exportplan/context.py
+++ b/exportplan/context.py
@@ -75,15 +75,15 @@ def get_context_provider_data(self, request, **kwargs):
age_group_population_data[section] = {}
age_groups = self.export_plan.data['ui_options'].get(section, {}).get('target_ages', [])
age_group_population_data[section]['target_ages'] = age_groups
- age_group_population_data[section][
- 'male_target_age_population'
- ] = helpers.total_population_by_gender_age(
- dataset=population_dataset, age_filter=age_groups, gender='male'
+ age_group_population_data[section]['male_target_age_population'] = (
+ helpers.total_population_by_gender_age(
+ dataset=population_dataset, age_filter=age_groups, gender='male'
+ )
)
- age_group_population_data[section][
- 'female_target_age_population'
- ] = helpers.total_population_by_gender_age(
- dataset=population_dataset, age_filter=age_groups, gender='female'
+ age_group_population_data[section]['female_target_age_population'] = (
+ helpers.total_population_by_gender_age(
+ dataset=population_dataset, age_filter=age_groups, gender='female'
+ )
)
age_group_population_data[section]['total_target_age_population'] = int(
age_group_population_data[section]['male_target_age_population']
From 59af26a0997c5f44447e02a818c4e8a3ac74e950 Mon Sep 17 00:00:00 2001
From: davidu1975
Date: Fri, 10 Jan 2025 11:02:10 +0000
Subject: [PATCH 15/20] add path to serve individual document
---
config/urls.py | 6 ++++++
core/views.py | 20 ++++++++++++++++++-
.../templates/buy_from_the_uk/index.html | 3 ++-
.../templatetags/document_tags.py | 2 +-
requirements.txt | 2 +-
requirements_test.txt | 2 +-
6 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/config/urls.py b/config/urls.py
index c4185016f0..24d5b26471 100644
--- a/config/urls.py
+++ b/config/urls.py
@@ -36,6 +36,7 @@
import search.urls
import sso.urls
import sso_profile.urls
+from core.views import WagtailServeDocument
urlpatterns = []
@@ -82,6 +83,11 @@
),
),
path('admin/', decorator_include([skip_ga360, nocache_page], wagtailadmin_urls)),
+ path(
+ 'document///',
+ nocache_page(WagtailServeDocument.as_view()),
+ name='wagtail_serve_documents',
+ ),
path(
'documents/', decorator_include(nocache_page, wagtaildocs_urls)
), # NB: doesn't skip GA as we may analytics on this
diff --git a/core/views.py b/core/views.py
index d6bbd7a643..7fadc21f21 100644
--- a/core/views.py
+++ b/core/views.py
@@ -9,7 +9,13 @@
from django.conf import settings
from django.contrib.sitemaps import Sitemap as DjangoSitemap
from django.core.files.storage import default_storage
-from django.http import Http404, HttpResponse, HttpResponseRedirect, JsonResponse
+from django.http import (
+ Http404,
+ HttpResponse,
+ HttpResponseBadRequest,
+ HttpResponseRedirect,
+ JsonResponse,
+)
from django.shortcuts import get_object_or_404, redirect
from django.template.loader import render_to_string
from django.template.response import TemplateResponse
@@ -27,6 +33,7 @@
from rest_framework.response import Response
from storages.backends.s3boto3 import S3Boto3Storage
from wagtail.contrib.sitemaps import Sitemap as WagtailSitemap
+from wagtail.documents.models import Document
from wagtail.images import get_image_model
from wagtail.images.views import chooser
from wagtail.images.views.chooser import (
@@ -1018,3 +1025,14 @@ def get_context_data(self, **kwargs):
ukea_events=ukea_events,
market_guide=market_guide,
)
+
+
+class WagtailServeDocument(View):
+
+ def get(self, request, document_title, document_type):
+ try:
+ document = Document.objects.get(title=document_title)
+ except Document.DoesNotExist:
+ return HttpResponseBadRequest(())
+ else:
+ return HttpResponseRedirect(redirect_to=document.url)
diff --git a/international_buy_from_the_uk/templates/buy_from_the_uk/index.html b/international_buy_from_the_uk/templates/buy_from_the_uk/index.html
index 3c8db96bd2..585787e81b 100644
--- a/international_buy_from_the_uk/templates/buy_from_the_uk/index.html
+++ b/international_buy_from_the_uk/templates/buy_from_the_uk/index.html
@@ -58,7 +58,8 @@ Download our ebook: 5 reasons to buy from the UK
{% get_document_link "5_Reasons_To_Buy_From_the_UK_RElQ4Ie" "pdf" as document_link %}
- Download
+ Download