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: compatibility with DRF manage.py generateschema (#1440) #1441

Merged
merged 3 commits into from
Jun 21, 2024
Merged
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
6 changes: 6 additions & 0 deletions projectroles/views_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""REST API views for the projectroles app"""

import sys

from ipaddress import ip_address, ip_network

from django.conf import settings
Expand Down Expand Up @@ -281,6 +283,8 @@ class APIProjectContextMixin(ProjectAccessMixin):

def get_serializer_context(self, *args, **kwargs):
context = super().get_serializer_context(*args, **kwargs)
if sys.argv[1:2] == ['generateschema']:
return context
context['project'] = self.get_project(request=context['request'])
return context

Expand Down Expand Up @@ -573,6 +577,8 @@ class ProjectUpdateAPIView(

def get_serializer_context(self, *args, **kwargs):
context = super().get_serializer_context(*args, **kwargs)
if sys.argv[1:2] == ['generateschema']:
return context
project = self.get_project(request=context['request'])
context['parent'] = (
str(project.parent.sodar_uuid) if project.parent else None
Expand Down
Loading