Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand docstring #100

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- run: poetry install --no-interaction
- name: run unit tests with coverage
id: fast-tests
run: poetry run pytest --cov -m 'not slow'
run: poetry run pytest --cov -m 'not slow' --doctest-modules

- name: Get Chromium version 🌐
run: |
Expand Down
18 changes: 17 additions & 1 deletion home/forms/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,23 @@ def __init__(self, *args, **kwargs):
self.initial["sort"] = "relevance"

def encode_without_filter(self, filter_name: str, filter_value: str):
"""Preformat hrefs to drop individual filters"""
"""
Generate a query string that can be used to generate "remove filter"
links.

The query string includes all submitted form parameters except
the one identified by filter_name and filter_value.

>>> formdata = {'domain': 'urn:li:domain:HMCTS', 'classifications': ['OFFICIAL']}
>>> form = SearchForm(formdata)
>>> assert form.is_valid()

>>> form.encode_without_filter('domain', 'urn:li:domain:HMCTS')
'?query=&classifications=OFFICIAL&sort=&clear_filter=False&clear_label=False'

>>> form.encode_without_filter('classifications', 'OFFICIAL')
'?query=&domain=urn%3Ali%3Adomain%3AHMCTS&subdomain=&sort=&clear_filter=False&clear_label=False'
"""
# Deepcopy the cleaned data dict to avoid modifying it inplace
query_params = deepcopy(self.cleaned_data)
value = query_params.get(filter_name)
Expand Down
Loading