Skip to content

Commit

Permalink
fix: Health provider not accessible by name in API
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Feb 4, 2025
1 parent d4c4aaa commit f9dc15f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/features/feature_health/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class FeatureHealthProviderViewSet(
serializer_class = FeatureHealthProviderSerializer
pagination_class = None # set here to ensure documentation is correct
model_class = FeatureHealthProvider
lookup_field = "name"

def get_permissions(self) -> list[BasePermission]:
return [NestedProjectPermissions()]
Expand All @@ -68,6 +69,13 @@ def get_queryset(self) -> QuerySet[FeatureHealthProvider]:
project = get_object_or_404(Project, pk=self.kwargs["project_pk"])
return self.model_class.objects.filter(project=project)

def get_object(self) -> FeatureHealthProvider:
return get_object_or_404(

Check warning on line 73 in api/features/feature_health/views.py

View check run for this annotation

Codecov / codecov/patch

api/features/feature_health/views.py#L73

Added line #L73 was not covered by tests
self.model_class.objects,
project_id=self.kwargs["project_pk"],
name__iexact=self.kwargs["provider_name"],
)

@swagger_auto_schema(
request_body=CreateFeatureHealthProviderSerializer,
responses={status.HTTP_201_CREATED: FeatureHealthProviderSerializer()},
Expand Down

0 comments on commit f9dc15f

Please sign in to comment.