From 16acb7d2f89574914277ddbbe1f0f2e3694fb380 Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Thu, 20 Jun 2024 11:29:30 +0200 Subject: [PATCH] fix: compatibility with DRF manage.py generateschema (#1440) --- projectroles/views_api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/projectroles/views_api.py b/projectroles/views_api.py index d2975e79..a7e0b4b6 100644 --- a/projectroles/views_api.py +++ b/projectroles/views_api.py @@ -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 @@ -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 @@ -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