Skip to content

Commit

Permalink
PC-584: add reference number correctly to page & email
Browse files Browse the repository at this point in the history
  • Loading branch information
samyou-softwire committed Jan 22, 2024
1 parent 42d628f commit e6ab813
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion help_to_heat/frontdoor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
unavailable_suppliers = []


def format_referral_id(referral_id):
return f"GBIS{referral_id:07}"


def unavailable_supplier_redirect(session_id):
session_data = interface.api.session.get_session(session_id)
supplier = session_data["supplier"]
Expand Down Expand Up @@ -840,7 +844,8 @@ class SuccessView(PageView):
def get_context(self, session_id, *args, **kwargs):
supplier = SupplierConverter(session_id).get_supplier_on_success_page()
session = interface.api.session.get_session(session_id)
return {"supplier": supplier, "safe_to_cache": True, "referral_id": session.get("referral_id")}
referral_id = format_referral_id(session.get("referral_id"))
return {"supplier": supplier, "safe_to_cache": True, "referral_id": referral_id}


class FeedbackView(utils.MethodDispatcher):
Expand Down
4 changes: 3 additions & 1 deletion help_to_heat/portal/email_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.urls import reverse
from django.utils import timezone

from help_to_heat.frontdoor import views
from help_to_heat.portal import models

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -127,7 +128,8 @@ def send_referral_confirmation_email(session_data, language_code):
else:
data = EMAIL_MAPPING["referral-confirmation"]
data["subject"] = f"Referral to {session_data.get('supplier')} successful"
context = {"supplier_name": session_data.get("supplier")}
referral_id = views.format_referral_id(session_data["referral_id"])
context = {"supplier_name": session_data.get("supplier"), "referral_id": referral_id}
return _send_normal_email(to_address=session_data.get("email"), context=context, **data)


Expand Down
2 changes: 1 addition & 1 deletion help_to_heat/templates/frontdoor/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h1 class="govuk-panel__title">
{{_("Your details have been submitted to %(supplier)s") % { "supplier": supplier }}}
</h1>
<p>{{_("Your referral ID is %(referral_id)s") % { "referral_id": referral_id }}}</p>
<div class="govuk-panel__body">{{_("Your reference number is %(referral_id)s") % { "referral_id": referral_id }}}</div>
</div>
<p class="govuk-body">{{_("If you provided an email address in your referral then we have sent you a confirmation email.")}}</p>
<p class="govuk-body" data-show-if-can-print="true" hidden>{{_("You can ")}}<a href="#" class="govuk-link" data-print="true">{{_("save or print a copy of your referral")}}</a>.</p>
Expand Down
2 changes: 2 additions & 0 deletions help_to_heat/templates/portal/email/referral-confirmation.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Hi,

Your reference number is {{referral_id}}

Your details have been submitted to {{supplier_name}}.

# What happens next?
Expand Down

0 comments on commit e6ab813

Please sign in to comment.