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 committed Jun 20, 2024
1 parent be012e5 commit d44a575
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions projectroles/views_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""REST API views for the projectroles app"""

import re
import sys

from ipaddress import ip_address, ip_network

Expand Down Expand Up @@ -257,6 +258,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 @@ -502,6 +505,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 d44a575

Please sign in to comment.