Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LGA-3391 - Add benefits appeal category #73

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/categories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .housing import bp as housing_bp
from .mental_capacity import bp as mental_capacity_bp
from .community_care import bp as community_care_bp
from .benefits import bp as benefits_bp
from .results import bp as results_bp

bp = Blueprint("categories", __name__)
Expand All @@ -15,5 +16,6 @@
bp.register_blueprint(results_bp)
bp.register_blueprint(asylum_immigration_bp)
bp.register_blueprint(community_care_bp)
bp.register_blueprint(benefits_bp)

from app.categories import urls # noqa: E402,F401
8 changes: 8 additions & 0 deletions app/categories/benefits/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from flask import Blueprint

bp = Blueprint(
"benefits",
__name__,
)

from app.categories.benefits import urls # noqa: E402,F401
34 changes: 34 additions & 0 deletions app/categories/benefits/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from wtforms import RadioField
from wtforms.validators import InputRequired
from flask_babel import lazy_gettext as _
from app.categories.widgets import CategoryRadioInput
from app.categories.forms import QuestionForm


FALA_REDIRECT = {
"endpoint": "find-a-legal-adviser.search",
"category": "wb",
}


class AppealQuestionForm(QuestionForm):
category = "Benefits"
title = _("Legal aid only covers appeals to the")
next_step_mapping = {
"supreme_court": FALA_REDIRECT,
"upper_tribunal": FALA_REDIRECT,
"appeal_court": FALA_REDIRECT,
"none": "categories.results.refer",
}
question = RadioField(
title,
widget=CategoryRadioInput(show_divider=True),
validators=[InputRequired(message=_("Select where the appeal will be held"))],
choices=[
("upper_tribunal", _("Upper Tribunal (Administrative Appeals Chamber)")),
("supreme_court", _("Supreme Court")),
("appeal_court", _("Court of Appeal")),
("", ""),
("none", _("None of the above")),
],
)
12 changes: 12 additions & 0 deletions app/categories/benefits/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from . import bp
from .forms import AppealQuestionForm
from ..views import QuestionPage

bp.add_url_rule(
"/benefits/appeal",
view_func=QuestionPage.as_view(
"appeal",
form_class=AppealQuestionForm,
template="categories/benefits/appeal.html",
),
)
12 changes: 9 additions & 3 deletions app/categories/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,18 @@ class QuestionPage(View):
- Routing to the next appropriate page
"""

template: str = "categories/question-page.html"
form_class: type[QuestionForm] | None = None

def __init__(self, form_class: type[QuestionForm]):
def __init__(self, form_class: type[QuestionForm], template=None):
"""Initialize the view with a form class.

Args:
form_class: The WTForms form class to use for this question page
template: The template to use for this question page
"""
self.form_class = form_class
self.template = template or self.template

def get_next_page(self, answer: str) -> redirect:
"""Determine and redirect to the next page based on the user's answer.
Expand All @@ -104,7 +107,10 @@ def get_next_page(self, answer: str) -> redirect:
if answer not in self.form_class.next_step_mapping:
raise ValueError(f"No mapping found for answer: {answer}")

return redirect(url_for(self.form_class.next_step_mapping[answer]))
next_page = self.form_class.next_step_mapping[answer]
if isinstance(next_page, dict):
return redirect(url_for(**next_page))
return redirect(url_for(next_page))

def update_session(self, answer: str | None = None) -> None:
"""
Expand Down Expand Up @@ -142,6 +148,6 @@ def dispatch_request(self):
form.question.data = previous_answer

return render_template(
"categories/question-page.html",
self.template,
form=form,
)
45 changes: 45 additions & 0 deletions app/templates/categories/benefits/appeal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% extends "base.html" %}
{%- from 'govuk_frontend_jinja/components/back-link/macro.html' import govukBackLink -%}
{%- from 'govuk_frontend_jinja/components/exit-this-page/macro.html' import govukExitThisPage -%}

{% block pageTitle %}{%- if form.errors %}Error: {% endif -%}{{ form.title }} - GOV.UK{% endblock %}

{% block beforeContent%}
{{ super() }}
{{ govukBackLink({
'href': back_link,
'text': "Back"
}) }}

{% if form.category == "Domestic Abuse" %}
{{ govukExitThisPage("Exit this page")}}
{% endif %}

{% endblock %}

{% block content %}

{{ super() }}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<h1 class="govuk-heading-xl">{% trans %}Appeal a decision about your benefits{% endtrans %}</h1>
<p class="govuk-body govuk-!-margin-bottom-0">{% trans %}Legal aid only covers appeals to the:{% endtrans %}</p>
<ul class="govuk-list govuk-list--bullet">
<li>{% trans %}Upper Tribunal (Administrative Appeals Chamber){% endtrans %}</li>
<li>{% trans %}Supreme Court{% endtrans %}</li>
<li>{% trans %}Court of Appeal{% endtrans %}</li>
</ul>
<p class="govuk-body">{% trans %}For all other benefits appeals, go to GOV.UK and read <a href="https://www.gov.uk/appeal-benefit-decision" target="_blank">Appeal a benefits decision (opens in new tab)</a>.{% endtrans %}</p>

<form class="govuk-!-margin-top-6" action="" method="get" novalidate>

{{ form.question() }}

{{ form.submit }}
</form>

</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion app/templates/categories/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h3 class="govuk-heading-m">Other problems covered by legal aid</h3>

{{ list_item_small("Benefits",
"Appeal a decision about your benefits",
url_for("categories.index")) }}
url_for("categories.benefits.appeal")) }}

{{ list_item_small("Legal action against public organisations",
"Includes schools, the police, government, prisons, NHS, the council.",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from playwright.sync_api import Page, expect
import pytest


@pytest.mark.usefixtures("live_server")
class TestAsylumAndImmigrationLandingPage:
def assert_outcome(self, page: Page, option: str) -> None:
page.get_by_label(option).check()
page.get_by_role("button", name="Continue").click()
expect(page.get_by_text("Find a legal adviser")).to_be_visible()
expect(page.get_by_text("For welfare benefits")).to_be_visible()

def test_appeal_upper_tribunal(self, page: Page):
page.get_by_role("link", name="Benefits").click()
self.assert_outcome(page, "Upper Tribunal (Administrative Appeals Chamber)")

def test_appeal_supreme_court(self, page: Page):
page.get_by_role("link", name="Benefits").click()
self.assert_outcome(page, "Supreme Court")

def test_appeal_appeal_court(self, page: Page):
page.get_by_role("link", name="Benefits").click()
self.assert_outcome(page, "Court of Appeal")

def test_appeal_none(self, page: Page):
page.get_by_role("link", name="Benefits").click()
page.get_by_label("None of the above").check()
page.get_by_role("button", name="Continue").click()
expect(page.get_by_text("Referral page")).to_be_visible()
Loading