Skip to content

Commit

Permalink
Merge pull request #3761 from uktrade/develop
Browse files Browse the repository at this point in the history
Release PR
  • Loading branch information
davidu1975 authored Jan 2, 2025
2 parents f332f82 + 7567528 commit 8ed1205
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
23 changes: 9 additions & 14 deletions international_online_offer/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ def get_spend_choices_by_currency(currency):


def get_current_step(user_data, triage_data):
# Steps in the triage and associated required fields.
# If any of these fields are empty, return the view to
# allow the user to continue where they left off.
if not user_data:
return 'about-your-business'
if not triage_data:
return 'business-sector'

find_your_company_step = ['company_name']
if not user_data.duns_number:
find_your_company_step.append('address_line_1')
find_your_company_step.append('town')
find_your_company_step += ['address_line_1', 'town']

triage_steps = {
'business-headquarters': ['company_location'],
Expand All @@ -197,17 +198,11 @@ def get_current_step(user_data, triage_data):

for view_name, fields in triage_steps.items():
for field in fields:
value = None
if hasattr(user_data, field):
value = getattr(user_data, field, None)
elif hasattr(triage_data, field):
value = getattr(triage_data, field, None)

# Check for None explicitly to handle boolean fields correctly
if value is None or value == '' or value == []:
value = getattr(user_data, field, getattr(triage_data, field, None))
if value in (None, '', []):
return view_name

return None # Cannot get current step as triage is completed
return None # All steps are completed


def is_triage_complete(user_data, triage_data):
Expand Down
13 changes: 7 additions & 6 deletions international_online_offer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ def serve(self, request, *args, **kwargs):
triage_data = get_triage_data_for_user(request)

# Determine the current step view name
current_step_view = helpers.get_current_step(user_data, triage_data)
if current_step_view:
response = redirect(f'international_online_offer:{current_step_view}')
if request.GET.get('login'):
response['Location'] += '?resume=true'
return response
if not request.user.is_superuser:
current_step_view = helpers.get_current_step(user_data, triage_data)
if current_step_view:
response = redirect(f'international_online_offer:{current_step_view}')
if request.GET.get('login'):
response['Location'] += '?resume=true'
return response

context = self.get_context(request, user_data=user_data, triage_data=triage_data)

Expand Down
22 changes: 21 additions & 1 deletion international_online_offer/templates/eyb/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@
{% block head_css %}{{ block.super }}{% endblock %}
{% block content %}
<div class="great-container">
{% if request.user.is_superuser %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full govuk-grid-column-two-thirds-from-desktop">
<div class="govuk-notification-banner govuk-notification-banner--error"
role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title"
id="govuk-notification-banner-title">Error</h2>
</div>
<div class="govuk-notification-banner__content">
<h3 class="govuk-notification-banner__heading">
You are logged in as a wagtail user, please logout and user another account for EYB
</h3>
</div>
</div>
</div>
</div>
{% endif %}
{% if request.GET.signup %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full govuk-grid-column-two-thirds-from-desktop">
Expand Down Expand Up @@ -249,7 +269,7 @@ <h3 class="govuk-heading-m">{{ page.article_title }}</h3>
<section id="hcsat_section"
class="great-bg-white clearfix govuk-!-margin-top-0 govuk-!-padding-bottom-6 great-inline-feedback__container">
<div class="container">
<div class="great-container ">
<div class="great-container">
{% include 'core/includes/hcsat.html' with hcsat_form=hcsat_form hcsat_stage=hcsat_form_stage leading_text="To help us improve our service, we'd like to know more about your experience today. It will only take a minute to complete." %}
</div>
</div>
Expand Down

0 comments on commit 8ed1205

Please sign in to comment.