Skip to content

Commit

Permalink
display categry name in H1
Browse files Browse the repository at this point in the history
add next steps content
  • Loading branch information
willc-work committed Nov 22, 2024
1 parent 1a96774 commit 1bbeac5
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 70 deletions.
15 changes: 9 additions & 6 deletions fala/apps/adviser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def get_context_data(self, **kwargs):
}
)
return context
from django.shortcuts import redirect
from .utils import get_category_display_name


class SingleCategorySearchView(CommonContextMixin, TemplateView):
template_name = "adviser/single_category_search.html"
Expand All @@ -63,13 +62,15 @@ def get(self, request, *args, **kwargs):
if category_code:
category_slug = get_category_display_name(category_code)
if category_slug:
return redirect('single_category_search', category=category_slug)
return redirect("single_category_search", category=category_slug)
else:
return redirect('search')
return redirect("search")

category_slug = kwargs.get("category")
if not category_slug:
return redirect('search')
return redirect("search")

category_display_name = category_slug.replace("-", " ").title()

context = self.get_context_data(**kwargs)
form = AdviserRootForm(data=request.GET or None)
Expand All @@ -78,13 +79,15 @@ def get(self, request, *args, **kwargs):
{
"form": form,
"category_slug": category_slug,
"category_display_name": category_slug.replace("-", " ").title(),
"category_display_name": category_display_name,
"current_url": request.path,
"CHECK_LEGAL_AID_URL": settings.CHECK_LEGAL_AID_URL,
}
)

return self.render_to_response(context)


class AdviserView(CommonContextMixin, TemplateView):
template_name = "adviser/search.html"

Expand Down
46 changes: 46 additions & 0 deletions fala/templates/adviser/single_category_results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% extends 'adviser/adviser_base.html' %}

{% block pageTitle %}Search results{% endblock %}

{%- from 'govuk_frontend_jinja/components/pagination/macro.html' import govukPagination %}

{% block content %}
<div class="govuk-grid-column-full">
<div id="google_translate_element" class="govuk-!-margin-bottom-6 govuk-!-display-none-print"></div>
</div>
<div class="govuk-grid-column-full">
{% if data.count < 1 %}
<h1 class="govuk-heading-xl govuk-!-margin-bottom-5">No search results</h1>
<p class="govuk-body-m" id="no-results-info">There are no results for your criteria.</p>
{% else %}
<h1 class="govuk-heading-xl">SINGLE Search results</h1>
{% endif %}
</div>
{% if form.region|string == "Region.SCOTLAND" %}
{% include 'adviser/_scotland_warning.html' %}
{% endif %}
<div class="govuk-grid-column-two-thirds">
<div class="laa-fala__grey-box govuk-!-margin-bottom-6">
<ul class="govuk-list" role="list">
{% if form.postcode.value() %}
<li class="govuk-body" role="listitem">Postcode:<span class="notranslate"> {{ form.postcode.value() }}</span></li>
{% endif %}
{% if form|category_selection %}
<li class="govuk-body" role="listitem">Category:<span class="notranslate"> {{ form|category_selection }}</span></li>
{% endif %}
</ul>
</div>
</div>
{% if data.paginator.num_pages > 1 %}
{{ govukPagination({
"previous": {
"href": data.previous_page_url,
"text": "Previous"
},
"next": {
"href": data.next_page_url,
"text": "Next"
}
}) }}
{% endif %}
{% endblock %}
122 changes: 61 additions & 61 deletions fala/templates/adviser/single_category_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,76 +18,76 @@
"errorList": errorList
}) }}
{% endif %}
<h1 class="govuk-heading-xl"> Find a legal aid adviser or family mediator </h1>
<p class="govuk-body">You need to provide information about your finances to find out if you qualify for legal aid.</p>
<p class="govuk-body"><a class="govuk-link" href="{{ CHECK_LEGAL_AID_URL }}" target="_blank" rel="noopener">Check if you qualify for legal aid (opens in a new tab)</a></p>
<h1 class="govuk-heading-xl"> Find a legal aid adviser for {{ category_display_name|lower }} </h1>
<p class="govuk-body">Search for official legal aid advisers in England and Wales.</p>
</div>

{% block search_form %}
<div class="govuk-grid-column-full">
<div class="laa-fala__grey-box">
<div class="govuk-grid-column-two-thirds">

<form action="search" id="fala_questions">
{% set errorMessage = {'err': ""} %}
<form action="search" id="fala_questions">
{% set errorMessage = {'err': ""} %}

{% if form.errors %}
{% call Element.errorText() %}
{% for k, error in form.errors.items() %}
{% if errorMessage.update({'err': error | striptags}) %}{% endif %}
{% endfor %}
{% endcall %}
{% endif %}
{% if form.errors %}
{% call Element.errorText() %}
{% for k, error in form.errors.items() %}
{% if errorMessage.update({'err': error | striptags}) %}{% endif %}
{% endfor %}
{% endcall %}
{% endif %}

{% if 'postcode' in form.errors or form.errors['__all__'] %}
{{ govukInput({
'label': {
'text': "Postcode",
'classes': 'govuk-label--s',
},
'value': form.postcode.value(),
'errorMessage': { 'text': form.errors['postcode'][0] },
'hint': {
'text' : "For example, NE31 1SF",
},
'attributes': {
'maxLength': 30,
},
'id': 'id_postcode',
'classes': 'govuk-input--width-10',
'name': "postcode"
}) }}
{% else %}
{{ govukInput({
'label': {
'text': "Postcode",
'classes': 'govuk-label--s',
},
'value': form.postcode.value(),
'hint': {
'text' : "For example, NE31 1SF",
},
'attributes': {
'maxLength': 30,
},
'id': 'id_postcode',
'classes': 'govuk-input--width-10',
'name': "postcode"
}) }}
{% endif %}
<p class="govuk-body govuk-!-font-weight-bold">Next steps</p>
<ol class="govuk-list govuk-list--number">
<li>We'll show you a list of legal advisers.</li>
<li>When you contact the adviser they'll ask about your problem and finances to work out if you can get legal aid.</li>
</ol>

{{ govukButton({
'text': "Search",
'type': "submit",
'classes': "govuk-!-margin-bottom-2",
'id': "searchButton",
'name': "search"
{% if 'postcode' in form.errors or form.errors['__all__'] %}
{{ govukInput({
'label': {
'text': "What is your postcode?",
'classes': 'govuk-label--s',
},
'value': form.postcode.value(),
'errorMessage': { 'text': form.errors['postcode'][0] },
'hint': {
'text' : "For example, SW1H 9AJ",
},
'attributes': {
'maxLength': 30,
},
'id': 'id_postcode',
'classes': 'govuk-input--width-10',
'name': "postcode"
}) }}
</form>
</div>
{% else %}
{{ govukInput({
'label': {
'text': "What is your postcode?",
'classes': 'govuk-label--s',
},
'value': form.postcode.value(),
'hint': {
'text' : "For example, SW1H 9AJ",
},
'attributes': {
'maxLength': 30,
},
'id': 'id_postcode',
'classes': 'govuk-input--width-10',
'name': "postcode"
}) }}
{% endif %}

{{ govukButton({
'text': "Search",
'type': "submit",
'classes': "govuk-!-margin-bottom-2",
'id': "searchButton",
'name': "search"
}) }}
</form>
</div>
{% endblock %}

<div class="govuk-grid-column-full">
<p class="govuk-body govuk-!-margin-top-5">If you are a provider and your details are incorrect, please contact your contract manager.</p>
</div>
{% endblock %}
14 changes: 11 additions & 3 deletions fala/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# urls.py
# coding=utf-8
from django.conf import settings
from django.urls import re_path
from adviser.views import (
Expand All @@ -10,6 +10,7 @@
RobotsTxtView,
SecurityTxtView,
SingleCategorySearchView,
SingleCategoryResultsView,
)
from django.views.static import serve

Expand All @@ -21,6 +22,13 @@
re_path(r"^search$", SearchView.as_view(), name="search"),
re_path(r"^robots\.txt$", RobotsTxtView.as_view(), name="robots_txt"),
re_path(r"^security\.txt$", SecurityTxtView.as_view(), name="security_txt"),
re_path(r"^single-category-search/(?P<category>[\w-]+)$", SingleCategorySearchView.as_view(), name="single_category_search"),
re_path(
r"^single-category-search/(?P<category>[\w-]+)$",
SingleCategorySearchView.as_view(),
name="single_category_search",
),
re_path(r"^single-category-search$", SingleCategorySearchView.as_view(), name="single_category_search_query"),
] + [re_path(r"^static/(?P<path>.*)$", serve, {"document_root": settings.STATIC_ROOT})]
re_path(
r"^single-category-results$", SingleCategoryResultsView.as_view(), name="single_category_results"
), # Add the new URL pattern
] + [re_path(r"^static/(?P<path>.*)$", serve, {"document_root": settings.STATIC_ROOT})]

0 comments on commit 1bbeac5

Please sign in to comment.