Skip to content

Commit

Permalink
Add search functionality to DeviceViewSet with registered_name and us…
Browse files Browse the repository at this point in the history
…er_friendly_name filters
  • Loading branch information
Rishith25 committed Feb 27, 2025
1 parent 3d654e9 commit 3397572
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion care/emr/api/viewsets/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django_filters import rest_framework as filters
from pydantic import UUID4, BaseModel
from rest_framework.decorators import action
from rest_framework import filters as drf_filters
from rest_framework.exceptions import PermissionDenied, ValidationError
from rest_framework.generics import get_object_or_404
from rest_framework.response import Response
Expand Down Expand Up @@ -56,7 +57,8 @@ class DeviceViewSet(EMRModelViewSet):
pydantic_read_model = DeviceListSpec
pydantic_retrieve_model = DeviceRetrieveSpec
filterset_class = DeviceFilters
filter_backends = [filters.DjangoFilterBackend]
filter_backends = (filters.DjangoFilterBackend, drf_filters.SearchFilter)
search_fields = ["registered_name", "user_friendly_name"]

def get_facility_obj(self):
return get_object_or_404(
Expand Down

0 comments on commit 3397572

Please sign in to comment.