Skip to content

Commit

Permalink
FLS-901:
Browse files Browse the repository at this point in the history
- Eligibility button text and color updated
- Show either Continue button to take the user to the fund round page to view existing applications if they have existing applications otherwise show a "Start a new application" button that redirects them to the eligibility form
  • Loading branch information
hamzabinkhalid committed Jan 6, 2025
1 parent 4b90500 commit 02eb485
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def create_app() -> Flask: # noqa: C901
csrf.exempt(fund_store_bp)
csrf.exempt(application_store_bp)
csrf.exempt(assessment_store_bp)
csrf.exempt(eligibility_bp)
for bp, _ in assessment_store_bp._blueprints:
csrf.exempt(bp)

Expand Down
3 changes: 1 addition & 2 deletions apply/templates/apply/partials/eligibility-check-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<input type="hidden" name="round_id" value="{{ round_id }}">

{{ govukButton({
'text': gettext('Check eligibility'),
'classes': 'govuk-button--secondary'
'text': gettext('Start a new application')
}) }}
</form>
{% endmacro %}
18 changes: 18 additions & 0 deletions authenticator/frontend/magic_links/routes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import json
import uuid

from flask import abort, current_app, g, redirect, render_template, request, url_for
from fsd_utils.authentication.decorators import login_requested

from apply.default.data import get_applications_for_account
from authenticator.frontend.magic_links.forms import EmailForm
from authenticator.models.account import AccountError, AccountMethods
from authenticator.models.data import get_round_data
Expand Down Expand Up @@ -80,6 +82,19 @@ def landing(link_id):
all_questions_url=f"{Config.APPLICANT_FRONTEND_HOST}/all_questions/{fund_short_name}/{round_short_name}"
)
round_prospectus = round_data.prospectus if round_data.prospectus else None

redirect_to_eligibility = False

# Check if the applicant has previous applications in HSRA
if link_hash:
account_id = json.loads(link_hash.decode("utf-8"))["accountId"]
search_params = {
"account_id": account_id,
}
previous_applications = get_applications_for_account(**search_params)

redirect_to_eligibility = not previous_applications

return render_template(
"authenticator/magic_links/landing_eoi.html"
if round_data.is_expression_of_interest
Expand All @@ -96,6 +111,9 @@ def landing(link_id):
migration_banner_enabled=Config.MIGRATION_BANNER_ENABLED,
support_desk_apply=Config.SUPPORT_DESK_APPLY,
link_to_contact_us_page=round_data.reference_contact_page_over_email,
redirect_to_eligibility=redirect_to_eligibility, # Pass the flag to the template
fund_id=fund_data.identifier,
round_id=round_data.id,
)
return redirect(
url_for(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{%- from "govuk_frontend_jinja/components/button/macro.html" import govukButton
-%}
{% from "authenticator/partials/migration_banner.html" import migration_banner %}
{% from "authenticator/partials/eligibility-check-button.html" import eligibilityCheckButton %}
{% extends "authenticator/base.html" %}

{% block content %}
Expand All @@ -21,11 +22,15 @@ <h1 class="govuk-heading-xl">
</p>

<div data-qa="claim_magic_link">
{{ govukButton({
"text":gettext("Continue"),
"href": url_for('api_magic_links.use', link_id=link_id, fund=fund_short_name, round=round_short_name),
"isStartButton": true })
}}
{% if redirect_to_eligibility %}
{{ eligibilityCheckButton(form, url_for('eligibility_routes.launch_eligibility', fund_id=fund_id, round_id=round_id)) }}
{% else %}
{{ govukButton({
"text": gettext("Continue"),
"href": url_for('api_magic_links.use', link_id=link_id, fund=fund_short_name, round=round_short_name),
"isStartButton": true })
}}
{% endif %}
</div>

<h2 class="govuk-heading-m">{% trans %}How to complete your application{% endtrans %}</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{%- from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%}

{% macro eligibilityCheckButton(form, url, fund_id, round_id) %}
<form method="post" action="{{ url }}" >
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="account_id" value="{{ account_id }}">
<input type="hidden" name="fund_id" value="{{ fund_id }}">
<input type="hidden" name="round_id" value="{{ round_id }}">

{{ govukButton({
'text': gettext('Start a new application')
}) }}
</form>
{% endmacro %}
6 changes: 5 additions & 1 deletion authenticator/models/round.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ class Round:
application_guidance: str = ""
is_expression_of_interest: bool = False
reference_contact_page_over_email: bool = False
has_eligibility: bool = False

@classmethod
def from_dict(cls, d: dict):
# Filter unknown fields from JSON dictionary
return cls(**{k: v for k, v in d.items() if k in inspect.signature(cls).parameters})
return cls(
**{k: v for k, v in d.items() if k in inspect.signature(cls).parameters},
has_eligibility=d["eligibility_config"]["has_eligibility"],
)

0 comments on commit 02eb485

Please sign in to comment.