Skip to content

Commit

Permalink
Merge pull request #3781 from uktrade/develop
Browse files Browse the repository at this point in the history
UAT / PROD Release
  • Loading branch information
sebs-code authored Jan 13, 2025
2 parents 48dad27 + 448da9d commit 5f66d8a
Show file tree
Hide file tree
Showing 17 changed files with 294 additions and 203 deletions.
6 changes: 6 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import search.urls
import sso.urls
import sso_profile.urls
from core.views import WagtailServeDocument

urlpatterns = []

Expand Down Expand Up @@ -85,6 +86,11 @@
path(
'documents/', decorator_include(nocache_page, wagtaildocs_urls)
), # NB: doesn't skip GA as we may analytics on this
path(
'document/<str:document_title>/',
nocache_page(WagtailServeDocument.as_view()),
name='wagtail_serve_documents',
),
path('great-cms-sso/', include(sso.urls)),
path('search/', include(search.urls, namespace='search')),
path('activity-stream/', decorator_include(nocache_page, activitystream.urls, namespace='activitystream')),
Expand Down
20 changes: 19 additions & 1 deletion core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (
Expand Down Expand Up @@ -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):
try:
document = Document.objects.get(title=document_title)
except Document.DoesNotExist:
return HttpResponseBadRequest(())
else:
return HttpResponseRedirect(redirect_to=document.file.url)
1 change: 0 additions & 1 deletion find_a_buyer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def send_update_error_to_sentry(sso_user, api_response):

def done(self, *args, **kwargs):
data = self.serialize_form_data()
data['is_verification_letter_sent'] = True # Mixin only used in SendVerificationLetterView
response = api_client.company.profile_update(sso_session_id=self.request.user.session_id, data=data)
try:
response.raise_for_status()
Expand Down
141 changes: 68 additions & 73 deletions international/templates/international/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,91 +23,86 @@
{% endblock %}
{% block content %}
<div class="great-container">
{% if request.GET.success %}
<div class="govuk-grid-row" id="complete_contact_form_message">
<div class="govuk-grid-column-two-thirds">{% include './includes/contact_success.html' with back_url=back_url %}</div>
{% if form.errors and not form.non_field_errors %}
<div class="govuk-error-summary restrict-width"
aria-labelledby="error-summary-title"
role="alert"
tabindex="-1"
data-module="error-summary">
<h2 class="govuk-error-summary__title" id="error-summary-title">There is a problem</h2>
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
{% for field in form %}
{% if field.errors %}
{% for error in field.errors %}
<li>
<a href="#{{ field.auto_id }}">{{ error }}</a>
</li>
{% endfor %}
{% endif %}
{% endfor %}
</ul>
</div>
</div>
{% else %}
{% if form.errors and not form.non_field_errors %}
<div class="govuk-error-summary restrict-width"
aria-labelledby="error-summary-title"
role="alert"
tabindex="-1"
data-module="error-summary">
<h2 class="govuk-error-summary__title" id="error-summary-title">There is a problem</h2>
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
{% for field in form %}
{% if field.errors %}
{% for error in field.errors %}
<li>
<a href="#{{ field.auto_id }}">{{ error }}</a>
</li>
{% endfor %}
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">Get help using great.gov.uk/international</h1>
<p class="govuk-body">This form is for issues with the great.gov.uk/international website.</p>
<p class="govuk-body">You can use it to report a problem to the great.gov.uk team.</p>
<div class="govuk-inset-text">
We cannot put you in touch with investment advisers, nor reply to you with investment advice.
</div>
{% endif %}
</div>
</div>
<form method="post" novalidate action="{{ request.build_absolute_uri }}">
{% csrf_token %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">Get help using great.gov.uk/international</h1>
<p class="govuk-body">This form is for issues with the great.gov.uk/international website.</p>
<p class="govuk-body">You can use it to report a problem to the great.gov.uk team.</p>
<div class="govuk-inset-text">
We cannot put you in touch with investment advisers, nor reply to you with investment advice.
</div>
</div>
</div>
<form method="post" novalidate action="{{ request.build_absolute_uri }}">
{% csrf_token %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-character-count"
data-module="govuk-character-count"
data-maxlength="1000">
<div class="govuk-form-group{% if form.how_we_can_help.errors %} govuk-form-group--error{% endif %}">
<label class="govuk-label govuk-label--s"
for="{{ form.how_we_can_help.id_for_label }}">
{{ form.how_we_can_help.label }}
</label>
<div id="more-detail-hint" class="govuk-hint">{{ form.how_we_can_help.help_text }}</div>
{% for error in form.how_we_can_help.errors %}
<p class="govuk-error-message" role="alert">
<span class="govuk-visually-hidden">Error:</span> {{ error }}
</p>
{% endfor %}
{{ form.how_we_can_help }}
</div>
<div id="id_how_we_can_help-info"
class="govuk-hint govuk-character-count__message">
You can enter up to 1000 characters
</div>
<div class="govuk-character-count"
data-module="govuk-character-count"
data-maxlength="1000">
<div class="govuk-form-group{% if form.how_we_can_help.errors %} govuk-form-group--error{% endif %}">
<label class="govuk-label govuk-label--s"
for="{{ form.how_we_can_help.id_for_label }}">
{{ form.how_we_can_help.label }}
</label>
<div id="more-detail-hint" class="govuk-hint">{{ form.how_we_can_help.help_text }}</div>
{% for error in form.how_we_can_help.errors %}
<p class="govuk-error-message" role="alert">
<span class="govuk-visually-hidden">Error:</span> {{ error }}
</p>
{% endfor %}
{{ form.how_we_can_help }}
</div>
</div>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-bottom-3">
<div class="{% if form.full_name.errors %} govuk-form-group--error{% endif %}">
{% include 'international/includes/form_field.html' with field=form.full_name %}
<div id="id_how_we_can_help-info"
class="govuk-hint govuk-character-count__message">
You can enter up to 1000 characters
</div>
</div>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-top-4 govuk-!-margin-bottom-3">
<div class="{% if form.email.errors %} govuk-form-group--error{% endif %}">
{% include 'international/includes/form_field.html' with field=form.email %}
</div>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-bottom-3">
<div class="{% if form.full_name.errors %} govuk-form-group--error{% endif %}">
{% include 'international/includes/form_field.html' with field=form.full_name %}
</div>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-top-4 govuk-!-margin-bottom-4">
{% include 'international/includes/submit_button.html' with button_text='Send message' %}
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-top-4 govuk-!-margin-bottom-3">
<div class="{% if form.email.errors %} govuk-form-group--error{% endif %}">
{% include 'international/includes/form_field.html' with field=form.email %}
</div>
</div>
</form>
{% endif %}
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-top-4 govuk-!-margin-bottom-4">
{% include 'international/includes/submit_button.html' with button_text='Send message' %}
</div>
</div>
</form>

</div>
{% endblock content %}
{% block feedback_reporter %}
Expand Down
30 changes: 30 additions & 0 deletions international/templates/international/contact_success.html
Original file line number Diff line number Diff line change
@@ -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 %}
<div class="great-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<a href="{{ back_url }}" class="govuk-back-link govuk-!-margin-bottom-4">Back</a>
</div>
</div>
</div>
{% endblock %}
{% endif %}
{% block css_layout_class %}
govuk-main-wrapper
{{ block.super }}
{% endblock %}
{% block content %}
<div class="great-container">
<div class="govuk-grid-row" id="complete_contact_form_message">
<div class="govuk-grid-column-two-thirds">{% include './includes/contact_success.html' with back_url=back_url %}</div>
</div>
</div>
{% endblock content %}
4 changes: 4 additions & 0 deletions international/url_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,8 @@
r'^international/content/investment/how-we-can-help/open-a-uk-business-bank-account/$',
PermanentQuerystringRedirectView.as_view(url='/international/expand-your-business-in-the-uk/'),
),
re_path(
r'^international/content/invest/how-to-setup-in-the-uk/.*$',
PermanentQuerystringRedirectView.as_view(url='/international/expand-your-business-in-the-uk/'),
),
]
7 changes: 6 additions & 1 deletion international/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@
'site-help/',
views.ContactView.as_view(),
name='contact',
)
),
path(
'site-help/success/',
views.ContactSuccessView.as_view(),
name='contact-success',
),
]
30 changes: 28 additions & 2 deletions international/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ <h2 class="govuk-heading-m">Download our ebook: 5 reasons to buy from the UK</h2
<p class="govuk-body-m">
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.
</p>
<a class="govuk-button"
href="https://directory-cms.london.cloudapps.digital/documents/107/5_Reasons_To_Buy_From_the_UK_RElQ4Ie.pdf">
Download
</a>
<a class="govuk-button" href="/document/Five reasons to buy from the UK">Download</a>
</div>
</div>
</div>
Expand Down
8 changes: 2 additions & 6 deletions international_buy_from_the_uk/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion international_online_offer/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_step_guide_accordion_items():
f'</p>'
f'<p class="govuk-body">'
f'<a class="govuk-link" href="/international/expand-your-business-in-the-uk/guide/'
f'detailed-guides/open-a-business-bank-account">'
f'detailed-guides/how-to-choose-and-set-up-a-uk-bank-account/">'
f'Read our guide on business banking'
f'</a>'
f'</p>'
Expand Down
Loading

0 comments on commit 5f66d8a

Please sign in to comment.