Skip to content

Commit

Permalink
Fix property search endpoint in Swagger (#4579)
Browse files Browse the repository at this point in the history
add org_id to the query param
  • Loading branch information
nllong authored Mar 21, 2024
1 parent d608221 commit 03f0973
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions seed/views/v3/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ class PropertyViewSet(generics.GenericAPIView, viewsets.ViewSet, OrgMixin, Profi
# For the Swagger page, GenericAPIView asserts a value exists for `queryset`
queryset = PropertyView.objects.none()

@swagger_auto_schema(
manual_parameters=[
AutoSchemaHelper.query_org_id_field(required=True),
]
)
@has_perm_class('requires_viewer')
@action(detail=False, filter_backends=[PropertyViewFilterBackend])
def search(self, request):
Expand All @@ -200,9 +205,11 @@ def search(self, request):
property__access_level_instance__lft__gte=ali.lft,
property__access_level_instance__rgt__lte=ali.rgt
).order_by('-state__id')

# this is the entrypoint to the filtering backend
# https://www.django-rest-framework.org/api-guide/filtering/#custom-generic-filtering
qs = self.filter_queryset(qs)

# converting QuerySet to list b/c serializer will only use column list profile this way
return JsonResponse(
PropertyViewAsStateSerializer(list(qs), context={'request': request}, many=True).data,
Expand Down

0 comments on commit 03f0973

Please sign in to comment.