From 87c9f1520a2d733606f887c673479540c1c0ed24 Mon Sep 17 00:00:00 2001 From: MazOneTwoOne <76905544+MazOneTwoOne@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:42:22 +0100 Subject: [PATCH 01/29] update view based on flag --- fala/apps/adviser/views.py | 1 + fala/templates/base.html | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fala/apps/adviser/views.py b/fala/apps/adviser/views.py index 2d945fc4..fd4d8ef2 100644 --- a/fala/apps/adviser/views.py +++ b/fala/apps/adviser/views.py @@ -22,6 +22,7 @@ def get(self, request, *args, **kwargs): "current_url": current_url, "GOOGLE_MAPS_API_KEY": settings.GOOGLE_MAPS_API_KEY, "LAALAA_API_HOST": settings.LAALAA_API_HOST, + "FEATURE_FLAG_NO_MAP": settings.FEATURE_FLAG_NO_MAP, } ) diff --git a/fala/templates/base.html b/fala/templates/base.html index 6ea4e8cb..35fd7063 100644 --- a/fala/templates/base.html +++ b/fala/templates/base.html @@ -105,10 +105,16 @@
Search for a legal adviser or family mediator with a legal aid contract in England and Wales.
From af5355764fbb3fd3dc6adbde9bf22062fca8849b Mon Sep 17 00:00:00 2001 From: MazOneTwoOne <76905544+MazOneTwoOne@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:55:53 +0100 Subject: [PATCH 02/29] make feature flag live in staging --- kubernetes_deploy/staging/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes_deploy/staging/deployment.yml b/kubernetes_deploy/staging/deployment.yml index 86f78a59..b5091c02 100644 --- a/kubernetes_deploy/staging/deployment.yml +++ b/kubernetes_deploy/staging/deployment.yml @@ -68,4 +68,4 @@ spec: name: s3 key: bucket_name - name: FEATURE_FLAG_NO_MAP - value: "false" + value: "true" From 8ca5a0720d891128e25aa6989ca2e20dca879fa4 Mon Sep 17 00:00:00 2001 From: MazOneTwoOne <76905544+MazOneTwoOne@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:14:14 +0100 Subject: [PATCH 03/29] update --- fala/apps/adviser/forms.py | 4 +- fala/apps/adviser/forms_old.py | 100 +++++++++++++ fala/apps/adviser/views.py | 11 +- fala/templates/adviser/search.html | 22 ++- fala/templates/adviser/search_old.html | 76 ++++++++++ fala/templates/base.html | 77 ---------- fala/templates/base_old.html | 189 +++++++++++++++++++++++++ 7 files changed, 393 insertions(+), 86 deletions(-) create mode 100644 fala/apps/adviser/forms_old.py create mode 100644 fala/templates/adviser/search_old.html create mode 100644 fala/templates/base_old.html diff --git a/fala/apps/adviser/forms.py b/fala/apps/adviser/forms.py index c9289cc0..0b9d5424 100644 --- a/fala/apps/adviser/forms.py +++ b/fala/apps/adviser/forms.py @@ -27,9 +27,9 @@ class AdviserSearchForm(forms.Form): page = forms.IntegerField(required=False, widget=forms.HiddenInput()) postcode = forms.CharField( - label=_("Enter postcode"), + label=_("Postcode"), max_length=30, - help_text=_("For example, SW1H 9AJ"), + help_text=_("For example, SW1H"), required=False, widget=FalaTextInput(), ) diff --git a/fala/apps/adviser/forms_old.py b/fala/apps/adviser/forms_old.py new file mode 100644 index 00000000..c9289cc0 --- /dev/null +++ b/fala/apps/adviser/forms_old.py @@ -0,0 +1,100 @@ +# coding=utf-8 +from django import forms +from django.utils.translation import gettext_lazy as _ + +import laalaa.api as laalaa +import re + +SEARCH_TYPE_CHOICES = [("location", _("Location")), ("organisation", _("Organisation"))] + +ORGANISATION_TYPES_CHOICES = [ + ("Charity or Voluntary Org", "Charity or Voluntary Organisations"), + ("Mediation", "Mediation Service"), + ("Private Company", "Private Company"), + ("Solicitor", "Solicitor"), +] + + +class FalaTextInput(forms.TextInput): + def __init__(self, attrs={}): + class_attr = " ".join([c for c in ["govuk-input govuk-!-width-one-third", attrs.get("class")] if c]) + attrs.update({"class": class_attr}) + + super(FalaTextInput, self).__init__(attrs) + + +class AdviserSearchForm(forms.Form): + page = forms.IntegerField(required=False, widget=forms.HiddenInput()) + + postcode = forms.CharField( + label=_("Enter postcode"), + max_length=30, + help_text=_("For example, SW1H 9AJ"), + required=False, + widget=FalaTextInput(), + ) + + name = forms.CharField(label=_("Organisation name"), max_length=100, required=False, widget=FalaTextInput()) + + type = forms.MultipleChoiceField( + label=_("Organisation type"), + choices=ORGANISATION_TYPES_CHOICES, + widget=forms.CheckboxSelectMultiple(), + required=False, + ) + + categories = forms.MultipleChoiceField( + label=_("Category"), + choices=laalaa.PROVIDER_CATEGORY_CHOICES, + widget=forms.CheckboxSelectMultiple(), + required=False, + ) + + def __init__(self, *args, **kwargs): + kwargs.setdefault("label_suffix", "") + super(AdviserSearchForm, self).__init__(*args, **kwargs) + + def clean(self): + data = self.cleaned_data + if not data.get("postcode") and not data.get("name"): + raise forms.ValidationError(_("Enter a postcode or an organisation name")) + else: + postcodeNoSpace = data.get("postcode").replace(" ", "") + msg1 = "This service does not cover " + msg2 = "Try a postcode, town or city in England or Wales." + region = "England or Wales. " + if re.search(r"^BT[0-9]", postcodeNoSpace, flags=re.IGNORECASE): + region = "Northern Ireland. " + elif re.search(r"^IM[0-9]", postcodeNoSpace, flags=re.IGNORECASE): + region = "the Isle of Man. " + elif re.search(r"^JE[0-9]", postcodeNoSpace, flags=re.IGNORECASE): + region = "Jersey. " + elif re.search(r"^GY[1][0]", postcodeNoSpace, flags=re.IGNORECASE): + region = "Sark or Guernsey. " + elif re.search(r"^GY[9]", postcodeNoSpace, flags=re.IGNORECASE): + region = "Alderney or Guernsey. " + elif re.search(r"^GY[0-8]", postcodeNoSpace, flags=re.IGNORECASE): + region = "Guernsey. " + if region != "England or Wales. ": + self.add_error("postcode", "%s %s" % (_(" ".join((msg1, region))), _(msg2))) + return data + + def search(self): + if self.is_valid(): + try: + data = laalaa.find( + postcode=self.cleaned_data.get("postcode"), + categories=self.cleaned_data.get("categories"), + page=self.cleaned_data.get("page", 1), + organisation_types=self.cleaned_data.get("type"), + organisation_name=self.cleaned_data.get("name"), + ) + if "error" in data: + self.add_error("postcode", (data["error"])) + return {} + return data + except laalaa.LaaLaaError: + self.add_error( + "postcode", "%s %s" % (_("Error looking up legal advisers."), _("Please try again later.")) + ) + return {} diff --git a/fala/apps/adviser/views.py b/fala/apps/adviser/views.py index fd4d8ef2..724591fc 100644 --- a/fala/apps/adviser/views.py +++ b/fala/apps/adviser/views.py @@ -3,11 +3,18 @@ from django.urls import resolve, reverse from django.views.generic import TemplateView -from .forms import AdviserSearchForm +if settings.FEATURE_FLAG_NO_MAP: + from .forms import AdviserSearchForm +else: + from .forms_old import AdviserSearchForm class AdviserView(TemplateView): - template_name = "adviser/search.html" + # https://docs.djangoproject.com/en/5.0/topics/class-based-views/#usage-in-your-urlconf - this is how `template_name` + if settings.FEATURE_FLAG_NO_MAP: + template_name = "adviser/search.html" + else: + template_name = "adviser/search-old.html" def get(self, request, *args, **kwargs): context = self.get_context_data(**kwargs) diff --git a/fala/templates/adviser/search.html b/fala/templates/adviser/search.html index 2fc64fb0..1c2b9294 100644 --- a/fala/templates/adviser/search.html +++ b/fala/templates/adviser/search.html @@ -7,6 +7,14 @@ {% import "macros/element.html" as Element %} {% import "macros/forms.html" as Form %} +{% block content %} +You need to provide information about your finances to find out if you qualify for legal aid.
+ +If you are a provider and your details are incorrect, please contact your contract manager.
+You need to provide information about your finances to find out if you qualify for legal aid.
- +