Skip to content

Commit

Permalink
fix: compatibility with DRF manage.py generateschema (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored and mikkonie committed Jun 21, 2024
1 parent 00adfbb commit 16acb7d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions projectroles/views_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""REST API views for the projectroles app"""

import re
import sys

from ipaddress import ip_address, ip_network

from django.conf import settings
Expand Down Expand Up @@ -281,6 +284,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 +578,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

0 comments on commit 16acb7d

Please sign in to comment.