Skip to content

Commit

Permalink
Merge pull request #240 from UKGovernmentBEIS/staging
Browse files Browse the repository at this point in the history
Merge staging into main
  • Loading branch information
chidin194 authored Oct 23, 2023
2 parents f4324a8 + d3aa5bb commit 77bcc05
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 60 deletions.
7 changes: 7 additions & 0 deletions help_to_heat/frontdoor/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def _get_supplier(self):
def _is_bulb(self):
return self._get_supplier() == "Bulb, now part of Octopus Energy"

def _is_utility_warehouse(self):
return self._get_supplier() == "Utility Warehouse"

def get_supplier_on_general_pages(self):
supplier = self._get_supplier()
if self._is_bulb():
Expand All @@ -142,11 +145,15 @@ def get_supplier_on_success_page(self):
supplier = self._get_supplier()
if self._is_bulb():
return "Octopus Energy"
if self._is_utility_warehouse():
return "E.ON Next"
return supplier

def replace_in_session_data(self, session_data):
if self._is_bulb():
session_data["supplier"] = "Octopus Energy"
if self._is_utility_warehouse():
session_data["supplier"] = "E.ON Next"
return session_data


Expand Down
1 change: 1 addition & 0 deletions help_to_heat/frontdoor/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ class SessionSchema(Schema):
validate=validate.OneOf(tuple(item["value"] for item in loft_insulation_validation_options_map))
)
supplier = fields.String(validate=validate.OneOf(tuple(item["value"] for item in supplier_options)))
user_selected_supplier = fields.String(validate=validate.OneOf(tuple(item["value"] for item in supplier_options)))
first_name = fields.String(validate=validate.Length(max=128))
last_name = fields.String(validate=validate.Length(max=128))
contact_number = fields.String(
Expand Down
23 changes: 21 additions & 2 deletions help_to_heat/frontdoor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
}

# to be updated when we get full list of excluded suppliers
converted_suppliers = ["Bulb, now part of Octopus Energy"]
unavailable_suppliers = ["British Gas", "Utility Warehouse"]
converted_suppliers = ["Bulb, now part of Octopus Energy", "Utility Warehouse"]
unavailable_suppliers = ["British Gas"]


def unavailable_supplier_redirect(session_id):
Expand Down Expand Up @@ -622,8 +622,13 @@ def handle_post(self, request, session_id, page_name, data, is_change_page):
prev_page_name, next_page_name = get_prev_next_page_name(page_name)
request_data = dict(request.POST.dict())
request_supplier = request_data.get("supplier")
# to be updated when we get full list of excluded suppliers
converted_suppliers = ["Bulb, now part of Octopus Energy", "Utility Warehouse"]
unavailable_suppliers = ["British Gas"]
if request_supplier == "Bulb, now part of Octopus Energy":
next_page_name = "bulb-warning-page"
if request_supplier == "Utility Warehouse":
next_page_name = "utility-warehouse-warning-page"
if request_supplier in unavailable_suppliers:
next_page_name = "applications-closed"

Expand All @@ -635,6 +640,13 @@ def handle_post(self, request, session_id, page_name, data, is_change_page):
next_page_name = schemas.change_page_lookup[page_name]
return redirect("frontdoor:page", session_id=session_id, page_name=next_page_name)

def save_data(self, request, session_id, page_name, *args, **kwargs):
data = dict(request.POST.dict())
request_supplier = data.get("supplier")
data["user_selected_supplier"] = request_supplier
data = interface.api.session.save_answer(session_id, page_name, data)
return data


@register_page("bulb-warning-page")
class BulbWarningPageView(PageView):
Expand All @@ -643,6 +655,13 @@ def get_context(self, session_id, *args, **kwargs):
return {"supplier": supplier}


@register_page("utility-warehouse-warning-page")
class UtilityWarehousePageView(PageView):
def get_context(self, session_id, *args, **kwargs):
supplier = interface.api.session.get_answer(session_id, "supplier")["supplier"]
return {"supplier": supplier}


@register_page("applications-closed")
class ApplicationsClosedView(PageView):
def get_context(self, session_id, *args, **kwargs):
Expand Down
Binary file modified help_to_heat/locale/cy/LC_MESSAGES/django.mo
Binary file not shown.
58 changes: 31 additions & 27 deletions help_to_heat/locale/cy/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-02 09:27+0000\n"
"POT-Creation-Date: 2023-10-19 09:28+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -409,19 +409,19 @@ msgstr "Ansicr / Amherthnasol"
msgid "Please enter a valid UK postcode"
msgstr "Rhowch god post dilys yn y Deyrnas Unedig"

#: help_to_heat/frontdoor/schemas.py:692
#: help_to_heat/frontdoor/schemas.py:693
msgid "Invalid contact number"
msgstr "Rhif ffôn annilys"

#: help_to_heat/frontdoor/schemas.py:700
#: help_to_heat/frontdoor/schemas.py:701
msgid "Invalid email format"
msgstr "Fformat ebost annilys"

#: help_to_heat/frontdoor/schemas.py:711
#: help_to_heat/frontdoor/schemas.py:712
msgid "Energy Company Obligation 4"
msgstr "Rhwymedigaeth Cwmni Ynni 4"

#: help_to_heat/frontdoor/schemas.py:712
#: help_to_heat/frontdoor/schemas.py:713
msgid "Great British Insulation Scheme"
msgstr "Cynllun Inswleiddio Mawr Prydain"

Expand Down Expand Up @@ -878,43 +878,25 @@ msgstr ""
"cyn hir"

#: help_to_heat/templates/frontdoor/applications-closed.html:14
#: help_to_heat/templates/frontdoor/applications-closed.html:23
#: help_to_heat/templates/frontdoor/applications-closed.html:19
msgid "You can check back again soon."
msgstr "Gallwch ddod yn ôl eto yn fuan."

#: help_to_heat/templates/frontdoor/applications-closed.html:17
msgid "Utility Warehouse are not taking referrals just now"
msgstr "Dyw Utility Warehouse ddim yn cymryd atgyfeiriadau ar hyn o bryd"

#: help_to_heat/templates/frontdoor/applications-closed.html:18
msgid ""
"You are not able to apply to Utility Warehouse using this service just now "
"but if you email your name and Utility Warehouse account number to <a href="
"\"mailto:gbis@uw.co.uk\" class=\"govuk-link govuk-link--no-visited-state"
"\">gbis@uw.co.uk</a> you will be notified as soon as the referral process is "
"open. "
msgstr ""
"Allwch chi ddim gwneud cais i Utility Warehouse drwy ddefnyddio’r gwasanaeth "
"yma ar hyn o bryd ond os anfonwch chi’ch enw a’ch rhif cyfrif Utility "
"Warehouse at <a href=\"mailto:gbis@uw.co.uk\" class=\"govuk-link govuk-link--"
"no-visited-state\">gbis@uw.co.uk</a> fe gewch chi’ch hysbysu cyn gynted ag y "
"bydd y broses atgyfeirio wedi agor."

#: help_to_heat/templates/frontdoor/applications-closed.html:21
#, python-format
msgid "%(supplier)s are not taking referrals just now"
msgstr "Dyw %(supplier)s ddim yn cymryd atgyfeiriadau ar hyn o bryd"

#: help_to_heat/templates/frontdoor/applications-closed.html:22
#: help_to_heat/templates/frontdoor/applications-closed.html:18
#, python-format
msgid "You are not able to apply to %(supplier)s using this service just now."
msgstr ""

#: help_to_heat/templates/frontdoor/applications-closed.html:26
#: help_to_heat/templates/frontdoor/applications-closed.html:22
msgid "If you are a home owner in England and Wales, "
msgstr "Os ydych chi'n berchennog cartref yng Nghymru a Lloegr, "

#: help_to_heat/templates/frontdoor/applications-closed.html:28
#: help_to_heat/templates/frontdoor/applications-closed.html:24
msgid ""
"you can find other ways to save energy using the find ways to save energy "
"service (opens in a new tab)"
Expand Down Expand Up @@ -2829,6 +2811,28 @@ msgstr ""
"Os ydych chi'n byw mewn aelwyd mewn parc ac yn prynu'ch ynni o'r safle, "
"dewiswch y cyflenwr ynni sy'n cyflenwi'r safle."

#: help_to_heat/templates/frontdoor/utility-warehouse-warning-page.html:5
msgid "Your referral will be sent to E.ON Next"
msgstr "welsh"

#: help_to_heat/templates/frontdoor/utility-warehouse-warning-page.html:10
msgid "Referral requests from UW customers will be managed by E.ON Next"
msgstr ""
"Bydd ceisiadau am atgyfeiriad gan gwsmeriaid UW yn cael eu rheoli gan E.ON "
"Next"

#: help_to_heat/templates/frontdoor/utility-warehouse-warning-page.html:11
msgid ""
"If, after using this service, you are eligible for the Great British "
"Insulation Scheme and you choose to create a referral, your referral will be "
"sent to E.ON Next, who are accepting referrals and delivering the Great "
"British Insulation Scheme on behalf of Utility Warehouse."
msgstr ""
"Os ydych chi, ar ôl defnyddio'r gwasanaeth hwn, yn gymwys ar gyfer Cynllun "
"Inswleiddio Mawr Prydain a'ch bod yn dewis creu atgyfeiriad, bydd eich "
"atgyfeiriad yn cael ei anfon at E.ON Next, sy'n derbyn atgyfeiriadau ac yn "
"darparu Cynllun Inswleiddio Mawr Prydain ar ran Utility Warehouse."

#: help_to_heat/templates/frontdoor/wall-insulation.html:5
msgid ""
"Do your walls have insulation? - Check eligibility for Great British "
Expand Down
2 changes: 2 additions & 0 deletions help_to_heat/portal/download_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"loft_insulation",
"Property main heat source",
"supplier",
"user_selected_supplier",
"submission_date",
"submission_time",
)
Expand All @@ -69,6 +70,7 @@
"loft_insulation",
"Property main heat source",
"supplier",
"user_selected_supplier",
"submission_date",
"submission_time",
)
Expand Down
2 changes: 1 addition & 1 deletion help_to_heat/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def show_toolbar(request):
SESSION_COOKIE_SECURE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_AGE = 60 * 10 # 10 minutes
SESSION_COOKIE_AGE = 60 * 15 # 15 minutes
SESSION_COOKIE_SAMESITE = "Strict"
CSRF_COOKIE_SECURE = True

Expand Down
2 changes: 1 addition & 1 deletion help_to_heat/templates/allauth/account/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1 class="govuk-fieldset__heading">

<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="id_remember" name="remember" type="checkbox">
<label class="govuk-label govuk-checkboxes__label" for="remember">
<label class="govuk-label govuk-checkboxes__label" for="id_remember">
Remember me
</label>
</div>
Expand Down
4 changes: 0 additions & 4 deletions help_to_heat/templates/frontdoor/applications-closed.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
{% if supplier == 'British Gas' %}
<h1 class="govuk-heading-l">{{_("British Gas are not taking referrals right now but they will be shortly")}}</h1>
<p class="govuk-body">{{_("You can check back again soon.")}}</p>

{% elif supplier == 'Utility Warehouse' %}
<h1 class="govuk-heading-l">{{_("Utility Warehouse are not taking referrals just now")}}</h1>
<p class="govuk-body">{{_('You are not able to apply to Utility Warehouse using this service just now but if you email your name and Utility Warehouse account number to <a href="mailto:gbis@uw.co.uk" class="govuk-link govuk-link--no-visited-state">gbis@uw.co.uk</a> you will be notified as soon as the referral process is open. ') | safe}}</p>

{% else %}
<h1 class="govuk-heading-l">{{_("%(supplier)s are not taking referrals just now")% { "supplier": supplier }}}</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "frontdoor/base.html" %}
{% import "macros.html" as macros with context %}

{% block title %}
<title>{{_("Your referral will be sent to E.ON Next")}}</title>
{% endblock %}

{% block content %}
{% call macros.form_wrapper(prev_url) -%}
<h1 class="govuk-heading-l">{{_("Referral requests from UW customers will be managed by E.ON Next")}}</h1>
<p class="govuk-body">{{_("If, after using this service, you are eligible for the Great British Insulation Scheme and you choose to create a referral, your referral will be sent to E.ON Next, who are accepting referrals and delivering the Great British Insulation Scheme on behalf of Utility Warehouse.")}}</p>
{%- endcall %}
{% endblock %}
45 changes: 21 additions & 24 deletions tests/test_frontdoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,6 @@ def test_british_gas_unavailable():
assert page.has_one("h1:contains('Select your home energy supplier from the list below')")


def test_utility_warehouse_unavailable():
client = utils.get_client()
page = client.get("/start")
assert page.status_code == 302
page = page.follow()

assert page.status_code == 200
session_id = page.path.split("/")[1]
assert uuid.UUID(session_id)

form = page.get_form()
form["country"] = "England"
page = form.submit().follow()

form = page.get_form()
form["supplier"] = "Utility Warehouse"
page = form.submit().follow()

assert page.has_text("Utility Warehouse are not taking referrals just now")

page = page.click(contains="Back")
assert page.has_one("h1:contains('Select your home energy supplier from the list below')")


@unittest.mock.patch("help_to_heat.frontdoor.interface.OSApi", MockOSApi)
def _answer_house_questions(page, session_id, benefits_answer, epc_rating="D", supplier="Utilita"):
"""Answer main flow with set answers"""
Expand All @@ -144,6 +120,10 @@ def _answer_house_questions(page, session_id, benefits_answer, epc_rating="D", s
form = page.get_form()
assert page.has_text("Your referral will be sent to Octopus Energy")
page = form.submit().follow()
if supplier == "Utility Warehouse":
form = page.get_form()
assert page.has_text("Your referral will be sent to E.ON Next")
page = form.submit().follow()

assert page.has_text("Do you own the property?")
page = _check_page(page, "own-property", "own_property", "Yes, I own my property and live in it")
Expand Down Expand Up @@ -284,6 +264,8 @@ def _do_happy_flow(supplier="EON"):
supplier_shown = supplier
if supplier == "Bulb, now part of Octopus Energy":
supplier_shown = "Octopus Energy"
if supplier == "Utility Warehouse":
supplier_shown = "E.ON Next"

assert page.has_one(f"h1:contains('Your details have been submitted to {supplier_shown}')")

Expand Down Expand Up @@ -1008,3 +990,18 @@ def test_bulb_to_octopus():
referral = models.Referral.objects.get(session_id=session_id)
assert referral.supplier.name == "Octopus Energy"
referral.delete()


@unittest.mock.patch("help_to_heat.frontdoor.interface.OSApi", MockOSApi)
@utils.mock_os_api
def test_utility_warehouse_to_eon():
supplier = "Utility Warehouse"

session_id = _do_happy_flow(supplier=supplier)

referral_email_text = utils.get_latest_email_text("freddy.flibble@example.com")
assert "Your details have been submitted to E.ON Next." in referral_email_text

referral = models.Referral.objects.get(session_id=session_id)
assert referral.supplier.name == "E.ON Next"
referral.delete()
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_csv():
text = csv_page.content.decode("utf-8")
lines = text.splitlines()
assert len(lines) == 2
assert len(lines[0].split(",")) == 29, len(lines[0].split(","))
assert len(lines[0].split(",")) == 30, len(lines[0].split(","))

rows = list(csv.DictReader(lines))
data = rows[0]
Expand Down

0 comments on commit 77bcc05

Please sign in to comment.