Skip to content

Commit

Permalink
- pass through category_code & search_url to SingleSearchErrorSta…
Browse files Browse the repository at this point in the history
…te view
  • Loading branch information
MazOneTwoOne committed Dec 12, 2024
1 parent a3e8815 commit 90d4375
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion fala/apps/adviser/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
}
11 changes: 9 additions & 2 deletions fala/apps/adviser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 90d4375

Please sign in to comment.