Skip to content

Commit

Permalink
Move category templates to app/templates/categories
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMillar-MOJ committed Oct 22, 2024
1 parent e27c433 commit 6b477b6
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/categories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .domestic_abuse import bp as domestic_abuse_bp
from .discrimination import bp as discrimination_bp

bp = Blueprint("categories", __name__, template_folder="templates")
bp = Blueprint("categories", __name__)
bp.register_blueprint(domestic_abuse_bp)
bp.register_blueprint(discrimination_bp)

Expand Down
15 changes: 4 additions & 11 deletions app/categories/discrimination/routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from app.categories.discrimination import bp
from flask import render_template, url_for, flash, redirect
from flask import render_template, url_for, flash, redirect, current_app
from app.categories.discrimination.forms import (
DiscriminationWhereForm,
DiscriminationWhyForm,
Expand All @@ -14,17 +14,10 @@ def where_did_the_discrimination_happen():
items = get_items_with_divisor(form.question.choices)

if form.validate_on_submit():
if form.question.data == "work":
return redirect(
url_for(
"categories.discrimination.why_were_you_treated_differently",
where=form.question.data,
)
)
flash("End of prototype")

return render_template(
"question-page.html",
"categories/question-page.html",
form=form,
items=items,
back_link=url_for("categories.index"),
Expand All @@ -40,12 +33,12 @@ def why_were_you_treated_differently(where):
if form.validate_on_submit():
if form.question.data == "disability":
return redirect(
"https://checklegalaid.service.gov.uk/legal-aid-available?hlpas=no"
f"{current_app.config['CLA_PUBLIC_URL']}/discrimination_means"
)
flash("End of prototype")

return render_template(
"question-page.html",
"categories/question-page.html",
form=form,
items=items,
back_link=url_for(
Expand Down
8 changes: 3 additions & 5 deletions app/categories/domestic_abuse/routes.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from app.categories.domestic_abuse import bp
from flask import render_template, url_for, redirect, flash
from flask import render_template, url_for, flash
from app.categories.domestic_abuse.forms import AreYouAtRiskOfHarmForm


@bp.route("")
def index():
return render_template(
"domestic-abuse.html",
"categories/domestic-abuse.html",
back_link=url_for("categories.index"),
)

Expand All @@ -16,12 +16,10 @@ def are_you_at_immediate_risk_of_harm():
form = AreYouAtRiskOfHarmForm()

if form.validate_on_submit():
if form.question.data == "yes":
return redirect("https://checklegalaid.service.gov.uk/contact")
flash("End of prototype")

return render_template(
"question-page.html",
"categories/question-page.html",
form=form,
back_link=url_for("categories.domestic_abuse.index"),
)
4 changes: 2 additions & 2 deletions app/categories/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

@bp.route("/")
def index():
return render_template("index.html")
return render_template("categories/index.html")


@bp.route("/more-problems")
def more_problems():
return render_template("more-problems.html")
return render_template("categories/more-problems.html")
2 changes: 1 addition & 1 deletion app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
'tag': {
'text': config['SERVICE_PHASE'],
},
'html': 'This is a new service – your <a class="govuk-link" href="mailto:' + config['CONTACT_EMAIL'] + '">feedback</a> will help us to improve it.'
'html': '<a class="govuk-link" href="here">Contact us</a> if you need help or would like to give feedback to improve this service'
}) }}

<p class="watermark">Prototype</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{# These macros are used to populate the items in the category information list. #}
{% macro list_item(title, description, link) -%}
<h2 class="govuk-heading-m govuk-!-margin-bottom-1">
<a class="govuk-link govuk-link--no-visited-state" href="{{ link }}">{{ title }}</a>
<a class="govuk-link govuk-link--no-visited-state" href="{{ link|safe }}">{{ title }}</a>
</h2>
<p class="govuk-body">{{ description }}</p>
{%- endmacro %}

{% macro list_item_small(title, description, link) -%}
<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
<a class="govuk-link govuk-link--no-visited-state" href="{{ link }}">{{ title }}</a>
<a class="govuk-link govuk-link--no-visited-state" href="{{ link|safe }}">{{ title }}</a>
</h2>
<p class="govuk-body">{{ description }}</p>
{%- endmacro %}

{% macro list_item_arrow(title, description, link) -%}
<div class="govuk-grid-column-one-half govuk-!-padding-left-0 govuk-!-padding-right-6 arrow-box">
<h2 class="govuk-heading-m govuk-!-margin-bottom-1">
<a class="govuk-link govuk-link--no-visited-state" href="{{ link }}">{{ title }}</a>
<a class="govuk-link govuk-link--no-visited-state" href="{{ link|safe }}">{{ title }}</a>
</h2>
<p class="govuk-body">{{ description }}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{# This page was built as a prototype #}
{% extends "base.html" %}
{%- from 'govuk_frontend_jinja/components/back-link/macro.html' import govukBackLink -%}
{%- from 'components/list-item.html' import list_item, list_item_small -%}
{%- from 'govuk_frontend_jinja/components/exit-this-page/macro.html' import govukExitThisPage -%}
{%- from 'categories/components/list-item.html' import list_item, list_item_small -%}

{% block pageTitle %}Domestic Abuse - GOV.UK{% endblock %}

Expand All @@ -11,6 +12,9 @@
'href': url_for('categories.index'),
'text': "Back"
}) }}

{{ govukExitThisPage("Exit this page")}}

{% endblock %}

{% block content %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% extends "base.html" %}

{%- from 'govuk_frontend_jinja/components/button/macro.html' import govukButton -%}
{%- from 'components/list-item.html' import list_item, list_item_small, list_item_arrow -%}
{%- from 'categories/components/list-item.html' import list_item, list_item_small, list_item_arrow -%}


{% block content %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# This page was built as a prototype #}
{% extends "base.html" %}
{%- from 'govuk_frontend_jinja/components/back-link/macro.html' import govukBackLink-%}
{%- from 'components/list-item.html' import list_item, list_item_small -%}
{%- from 'categories/components/list-item.html' import list_item, list_item_small -%}

{% block beforeContent%}
{{ super() }}
Expand All @@ -27,8 +27,7 @@ <h1 class="govuk-heading-m">More problems covered by legal aid</h1>

{{ list_item_small("Clinical negligence in babies",
"Help if a baby has brain or nerve damage caused during pregnancy, childbirth or up to 8 weeks old.",
"https://checklegalaid.service.gov.uk/scope/refer/legal-adviser?category=clinneg&hlpas=no"
) }}
"https://checklegalaid.service.gov.uk/scope/refer/legal-adviser?category=clinneg&hlpas=no") }}

{{ list_item_small("Compensation for abuse, assault or neglect",
"Includes child abuse, sexual assault, abuse of a vulnerable adult. Claims can be against a person or an organisation.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{# This page was built as a prototype #}
{% 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 %}

Expand All @@ -10,6 +11,11 @@
'href': back_link,
'text': "Back"
}) }}

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

{% endblock %}

{% block content %}
Expand Down

0 comments on commit 6b477b6

Please sign in to comment.