Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix swagger for some views #2325

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions safe_transaction_service/account_abstraction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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"]
)
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down
14 changes: 7 additions & 7 deletions safe_transaction_service/safe_messages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")