forked from github/plane
dev: update patch endpoint for instance configuration
This commit is contained in:
parent
e98e26edb1
commit
96212905d1
@ -230,13 +230,18 @@ class InstanceConfigurationEndpoint(BaseAPIView):
|
|||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
def patch(self, request):
|
def patch(self, request):
|
||||||
key = request.data.get("key", False)
|
configurations = InstanceConfiguration.objects.filter(key__in=request.data.keys())
|
||||||
if not key:
|
|
||||||
return Response(
|
bulk_configurations = []
|
||||||
{"error": "Key is required"}, status=status.HTTP_400_BAD_REQUEST
|
for configuration in configurations:
|
||||||
)
|
configuration.value = request.data.get(configuration.key, configuration.value)
|
||||||
configuration = InstanceConfiguration.objects.get(key=key)
|
bulk_configurations.append(configuration)
|
||||||
configuration.value = request.data.get("value")
|
|
||||||
configuration.save()
|
InstanceConfiguration.objects.bulk_update(
|
||||||
serializer = InstanceConfigurationSerializer(configuration)
|
bulk_configurations,
|
||||||
|
["value"],
|
||||||
|
batch_size=100
|
||||||
|
)
|
||||||
|
|
||||||
|
serializer = InstanceConfigurationSerializer(configurations, many=True)
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
|
Loading…
Reference in New Issue
Block a user