Skip to content

Commit 1e2b819

Browse files
authored
Fmd 452 add feature switch - remove sort (#515)
* add waffle to settings * add switch `search-sort-radio-buttons` to search template * add command to create radio button switch * add section for feature switches to README * update poetry with django-waffle * do not need sort selenium tests * switches info
1 parent 8282577 commit 1e2b819

File tree

7 files changed

+40
-4
lines changed

7 files changed

+40
-4
lines changed

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
4646
RUN python manage.py collectstatic --noinput
4747
RUN python manage.py migrate
4848

49+
# create switch with default setting
50+
RUN ./manage.py waffle_switch search-sort-radio-buttons off --create
51+
4952
# Use a non-root user
5053
RUN addgroup --gid 31337 --system appuser \
5154
&& adduser --uid 31337 --system appuser --ingroup appuser

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ and run `npm install -g chromedriver chromedriver@latest` to install the latest
7373

7474
If making changes to the scss, to ensure your changes are reflected in local deployments, run:
7575
`npm run dependencies` to update the css files. If you have `DEBUG=False` you will then need to rerun `poetry run python manage.py collectstatic`.
76+
77+
## Feature Switches
78+
79+
We have enabled feature switches in `find-moj-data`. These have been enabled using a package called [django-waffle](https://github.com/jazzband/django-waffle).
80+
81+
Switches can be managed via the [cli](https://waffle.readthedocs.io/en/stable/usage/cli.html#usage-cli) or via the [django admin page](https://docs.djangoproject.com/en/dev/ref/contrib/admin/).
82+
83+
Our switches are created via the cli; the commands can be seen in the Dockerfile.
84+
85+
Current swicthes and default settings:
86+
87+
- `search-sort-radio-buttons` off - switches on/off radio selection buttons for sort order of search results.

core/settings.py

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"home.apps.HomeConfig",
4343
"django_prometheus",
4444
"users",
45+
"waffle",
4546
]
4647

4748
MIDDLEWARE = [
@@ -55,6 +56,7 @@
5556
"django.contrib.messages.middleware.MessageMiddleware",
5657
"django.middleware.clickjacking.XFrameOptionsMiddleware",
5758
"core.middleware.CustomErrorMiddleware",
59+
"waffle.middleware.WaffleMiddleware",
5860
# Prometheus needs to be the last middleware in the list.
5961
# Avoid appending to this list and rather insert into -1.
6062
"django_prometheus.middleware.PrometheusAfterMiddleware",

poetry.lock

+16-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ nltk = "^3.8.1"
1919
sentry-sdk = { extras = ["django"], version = "^2.5.1" }
2020
ministryofjustice-data-platform-catalogue = { path = "lib/datahub-client", develop = true }
2121
django-azure-auth = "^2.0.0"
22+
django-waffle = "^4.1.0"
2223

2324
[tool.poetry.group.dev.dependencies]
2425
black = "^24.4.0"

templates/search.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{% load static %}
33
{% load markdown %}
44
{% load humanize %}
5+
{% load waffle_tags %}
56

67
{% block content %}
78
<div class="govuk-grid-row">
@@ -47,7 +48,9 @@ <h2 class="govuk-heading-l govuk-!-display-inline-block" id="result-count">{{tot
4748
{% else %}
4849
{% include "partial/no_results.html" %}
4950
{% endif %}
50-
{% include "partial/sort.html" %}
51+
{% switch 'search-sort-radio-buttons' %}
52+
{% include "partial/sort.html" %}
53+
{% endswitch %}
5154
{% include "partial/search_result.html" %}
5255
{% include "partial/pagination.html" %}
5356
</div>

tests/selenium/test_search_controls.py

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def test_pagination(self):
6363
self.click_previous_page()
6464
self.verify_page("1")
6565

66+
@pytest.mark.skip(reason="search sort is currently switched off")
6667
def test_sorting(self):
6768
"""
6869
Interact with the sort control. Note: without javascript, this requires
@@ -78,6 +79,7 @@ def test_sorting(self):
7879
self.verify_i_have_results()
7980
self.verify_sort_selected("Ascending")
8081

82+
@pytest.mark.skip(reason="search sort is currently switched off")
8183
def test_filters_query_and_sort_persist(self):
8284
"""
8385
Search settings persist as the user continues to

0 commit comments

Comments
 (0)