diff --git a/safe_transaction_service/account_abstraction/views.py b/safe_transaction_service/account_abstraction/views.py index 8d9b6f310..27118cf11 100644 --- a/safe_transaction_service/account_abstraction/views.py +++ b/safe_transaction_service/account_abstraction/views.py @@ -35,6 +35,9 @@ class SafeOperationsView(ListCreateAPIView): pagination_class = pagination.DefaultPagination def get_queryset(self): + if getattr(self, "swagger_fake_view", False): + return SafeOperation.objects.none() + safe = self.kwargs["address"] return ( SafeOperation.objects.filter(user_operation__sender=safe) @@ -44,9 +47,6 @@ def get_queryset(self): def get_serializer_context(self): context = super().get_serializer_context() - if getattr(self, "swagger_fake_view", False): - return context - context["safe_address"] = self.kwargs["address"] return context @@ -101,6 +101,9 @@ class SafeOperationConfirmationsView(ListCreateAPIView): pagination_class = pagination.DefaultPagination def get_queryset(self): + if getattr(self, "swagger_fake_view", False): + return SafeOperationConfirmation.objects.none() + return SafeOperationConfirmation.objects.filter( safe_operation__hash=self.kwargs["safe_operation_hash"] ) @@ -172,6 +175,9 @@ class UserOperationsView(ListAPIView): serializer_class = serializers.UserOperationWithSafeOperationResponseSerializer def get_queryset(self): + if getattr(self, "swagger_fake_view", False): + return UserOperation.objects.none() + safe = self.kwargs["address"] return ( UserOperation.objects.filter(sender=safe) @@ -181,9 +187,6 @@ def get_queryset(self): def get_serializer_context(self): context = super().get_serializer_context() - if getattr(self, "swagger_fake_view", False): - return context - context["safe_address"] = self.kwargs["address"] return context diff --git a/safe_transaction_service/safe_messages/views.py b/safe_transaction_service/safe_messages/views.py index b147bc36f..45f085166 100644 --- a/safe_transaction_service/safe_messages/views.py +++ b/safe_transaction_service/safe_messages/views.py @@ -71,11 +71,15 @@ class SafeMessagesView(ListCreateAPIView): parser_classes = (DisableCamelCaseForMessageParser,) renderer_classes = (DisableCamelCaseForMessageRenderer,) - def get_serializer_context(self): - context = super().get_serializer_context() + def get_queryset(self): if getattr(self, "swagger_fake_view", False): - return context + return SafeMessage.objects.none() + + safe = self.kwargs["address"] + return SafeMessage.objects.filter(safe=safe).prefetch_related("confirmations") + def get_serializer_context(self): + context = super().get_serializer_context() context["safe_address"] = self.kwargs["address"] return context @@ -132,7 +136,3 @@ def post(self, request, address, *args, **kwargs): serializer.is_valid(raise_exception=True) self.perform_create(serializer) return Response(status=status.HTTP_201_CREATED) - - def get_queryset(self): - safe = self.kwargs["address"] - return SafeMessage.objects.filter(safe=safe).prefetch_related("confirmations")