From 1bbeac55251f78f212f0be53e275f09f6f8a5716 Mon Sep 17 00:00:00 2001 From: Will Clarke Date: Fri, 22 Nov 2024 10:15:37 +0000 Subject: [PATCH] display categry name in H1 add next steps content --- fala/apps/adviser/views.py | 15 ++- .../adviser/single_category_results.html | 46 +++++++ .../adviser/single_category_search.html | 122 +++++++++--------- fala/urls.py | 14 +- 4 files changed, 127 insertions(+), 70 deletions(-) create mode 100644 fala/templates/adviser/single_category_results.html diff --git a/fala/apps/adviser/views.py b/fala/apps/adviser/views.py index 94b69f76..df0e2998 100644 --- a/fala/apps/adviser/views.py +++ b/fala/apps/adviser/views.py @@ -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" @@ -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) @@ -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" diff --git a/fala/templates/adviser/single_category_results.html b/fala/templates/adviser/single_category_results.html new file mode 100644 index 00000000..f455c608 --- /dev/null +++ b/fala/templates/adviser/single_category_results.html @@ -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 %} +
+
+
+
+ {% if data.count < 1 %} +

No search results

+

There are no results for your criteria.

+ {% else %} +

SINGLE Search results

+ {% endif %} +
+ {% if form.region|string == "Region.SCOTLAND" %} + {% include 'adviser/_scotland_warning.html' %} + {% endif %} +
+
+
    + {% if form.postcode.value() %} +
  • Postcode: {{ form.postcode.value() }}
  • + {% endif %} + {% if form|category_selection %} +
  • Category: {{ form|category_selection }}
  • + {% endif %} +
+
+
+ {% 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 %} \ No newline at end of file diff --git a/fala/templates/adviser/single_category_search.html b/fala/templates/adviser/single_category_search.html index fe6cef18..7fb44bbf 100644 --- a/fala/templates/adviser/single_category_search.html +++ b/fala/templates/adviser/single_category_search.html @@ -18,76 +18,76 @@ "errorList": errorList }) }} {% endif %} -

Find a legal aid adviser or family mediator

-

You need to provide information about your finances to find out if you qualify for legal aid.

-

Check if you qualify for legal aid (opens in a new tab)

+

Find a legal aid adviser for {{ category_display_name|lower }}

+

Search for official legal aid advisers in England and Wales.

{% block search_form %} -
-
+
-
- {% set errorMessage = {'err': ""} %} + + {% 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 %} +

Next steps

+
    +
  1. We'll show you a list of legal advisers.
  2. +
  3. When you contact the adviser they'll ask about your problem and finances to work out if you can get legal aid.
  4. +
- {{ 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" }) }} -
-
+ {% 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" + }) }} +
{% endblock %} -
-

If you are a provider and your details are incorrect, please contact your contract manager.

-
{% endblock %} \ No newline at end of file diff --git a/fala/urls.py b/fala/urls.py index 45fdd666..7b5f65f1 100644 --- a/fala/urls.py +++ b/fala/urls.py @@ -1,4 +1,4 @@ -# urls.py +# coding=utf-8 from django.conf import settings from django.urls import re_path from adviser.views import ( @@ -10,6 +10,7 @@ RobotsTxtView, SecurityTxtView, SingleCategorySearchView, + SingleCategoryResultsView, ) from django.views.static import serve @@ -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[\w-]+)$", SingleCategorySearchView.as_view(), name="single_category_search"), + re_path( + r"^single-category-search/(?P[\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.*)$", serve, {"document_root": settings.STATIC_ROOT})] \ No newline at end of file + re_path( + r"^single-category-results$", SingleCategoryResultsView.as_view(), name="single_category_results" + ), # Add the new URL pattern +] + [re_path(r"^static/(?P.*)$", serve, {"document_root": settings.STATIC_ROOT})]