diff --git a/fala/apps/adviser/models.py b/fala/apps/adviser/models.py index 522f6d8a..c1c73afb 100644 --- a/fala/apps/adviser/models.py +++ b/fala/apps/adviser/models.py @@ -159,10 +159,12 @@ def get_context_data(self): class SingleSearchErrorState(object): - def __init__(self, form, category_display_name, category_message): + def __init__(self, form, category_display_name, category_message, category_code, search_url): self._form = form self._category_display_name = category_display_name self.category_message = category_message + self.category_code = category_code + self.search_url = search_url @property def template_name(self): @@ -185,6 +187,8 @@ def get_context_data(self): "form": self._form, "data": {}, "errorList": errorList, + "category_code": self.category_code, "category_display_name": self._category_display_name, "category_message": self.category_message, + "search_url": self.search_url, } diff --git a/fala/apps/adviser/views.py b/fala/apps/adviser/views.py index 3c3806a5..37729ca2 100644 --- a/fala/apps/adviser/views.py +++ b/fala/apps/adviser/views.py @@ -164,13 +164,20 @@ def get(self, request, *args, **kwargs): self.state = OtherJurisdictionState(region, form.cleaned_data["postcode"]) else: if self.tailored_results: - # Use CategoryMixin to access category information + # using CategoryMixin to access category_display_name & category_message, so we show this on SingleSearchErrorState view self.setup_category(request, *args, **kwargs) category_display_name = CATEGORY_DISPLAY_NAMES.get( self.category_slug, self.category_slug.replace("-", " ").title() ) category_message = CATEGORY_MESSAGES.get(self.category_slug, "") - self.state = SingleSearchErrorState(form, category_display_name, category_message) + + # this is so we can use category_code & search_url, when conducting a search from SingleSearchErrorState view + category_code = self.request.GET.get("categories", "") + search_url = reverse("search") + + self.state = SingleSearchErrorState( + form, category_display_name, category_message, category_code, search_url + ) else: self.state = ErrorState(form)