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

Commit

Permalink
Merge pull request #1045 from open-apparel-registry/feature/jcw/searc…
Browse files Browse the repository at this point in the history
…h-ppe-types

Include PPE product types in free text query
  • Loading branch information
jwalgran committed Jul 9, 2020
2 parents a2dff70 + f762c55 commit 6156bb7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add PPE-related model fields and API support [#1037](https://github.com/open-apparel-registry/open-apparel-registry/pull/1037)
- Show PPE fields on facility detail and include in CSV downloads [#1041](https://github.com/open-apparel-registry/open-apparel-registry/pull/1041)
- Add PPE filter checkbox to the facility search page [#1044](https://github.com/open-apparel-registry/open-apparel-registry/pull/1044)
- Include PPE product types in free text query [#1045](https://github.com/open-apparel-registry/open-apparel-registry/pull/1045)

### Changed

Expand Down
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 6156bb7

Please sign in to comment.