Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Include PPE product types in free text query
Browse files Browse the repository at this point in the history
Allows searching for a specific type of PPE product using the simplest possible
implementation. Can be combined with the `ppe` filter for more precision
searching.
  • Loading branch information
jwalgran committed Jul 9, 2020
1 parent a5431a4 commit 57c57aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/app/src/components/FilterSidebarSearchTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ function FilterSidebarSearchTab({
htmlFor={FACILITIES}
className="form__label"
>
Search a Facility Name or OAR ID
<FeatureFlag
flag="ppe"
alternative="Search a Facility Name or OAR ID"
>
Search a Facility Name, OAR ID, or PPE Product Type
</FeatureFlag>
</InputLabel>
<TextField
id={FACILITIES}
Expand Down
13 changes: 10 additions & 3 deletions src/django/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.utils.dateformat import format
from allauth.account.models import EmailAddress
from simple_history.models import HistoricalRecords
from waffle import switch_is_active

from api.constants import FeatureGroups
from api.countries import COUNTRY_CHOICES
Expand Down Expand Up @@ -1090,9 +1091,15 @@ def filter_by_query_params(self, params):
facilities_qs = Facility.objects.all()

if free_text_query is not None:
facilities_qs = facilities_qs \
.filter(Q(name__icontains=free_text_query) |
Q(id__icontains=free_text_query))
if switch_is_active('ppe'):
facilities_qs = facilities_qs \
.filter(Q(name__icontains=free_text_query) |
Q(id__icontains=free_text_query) |
Q(ppe_product_types__icontains=free_text_query))
else:
facilities_qs = facilities_qs \
.filter(Q(name__icontains=free_text_query) |
Q(id__icontains=free_text_query))

# `name` is deprecated in favor of `q`. We keep `name` available for
# backward compatibility.
Expand Down

0 comments on commit 57c57aa

Please sign in to comment.