From a87b8ee9073f955f989b399ac566e80a114f598c Mon Sep 17 00:00:00 2001 From: Erwan Rouchet <rouchet@teklia.com> Date: Tue, 16 May 2023 16:31:37 +0200 Subject: [PATCH] Remove type_ordering from CreateElementParent --- arkindex/documents/api/elements.py | 15 +-------------- arkindex/documents/models.py | 2 +- arkindex/documents/serializers/elements.py | 8 +------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/arkindex/documents/api/elements.py b/arkindex/documents/api/elements.py index 41df04fa10..0f6a7cfcfb 100644 --- a/arkindex/documents/api/elements.py +++ b/arkindex/documents/api/elements.py @@ -1309,15 +1309,6 @@ class ElementNeighbors(ACLMixin, ListAPIView): post=extend_schema( operation_id='CreateElementParent', description='Link an element to a new parent', - parameters=[ - OpenApiParameter( - 'type_ordering', - type=bool, - default=True, - description='Add the child element at the last position in the parent relative to ' - 'only the elements of the same type, or to all elements.', - ) - ], ), delete=extend_schema( operation_id='DestroyElementParent', @@ -1331,12 +1322,8 @@ class ElementParent(CreateAPIView, DestroyAPIView): serializer_class = ElementParentSerializer permission_classes = (IsVerified, ) - @property - def type_ordering(self): - return self.request.query_params.get('type_ordering', 'true').lower() not in ('0', 'false') - def get_serializer_from_params(self, child=None, parent=None, **kwargs): - data = {'child': child, 'parent': parent, 'type_ordering': self.type_ordering} + data = {'child': child, 'parent': parent} kwargs['context'] = self.get_serializer_context() return ElementParentSerializer(data=data, **kwargs) diff --git a/arkindex/documents/models.py b/arkindex/documents/models.py index b4990d7dac..22f2421ffa 100644 --- a/arkindex/documents/models.py +++ b/arkindex/documents/models.py @@ -274,7 +274,7 @@ class Element(IndexableModel): Element.objects.filter(id=self.id)._raw_delete(using='default') @transaction.atomic - def add_parent(self, parent, skip_children=False, type_ordering=True): + def add_parent(self, parent, skip_children=False): ''' Add an element as ancestor ''' diff --git a/arkindex/documents/serializers/elements.py b/arkindex/documents/serializers/elements.py index 91bbbdc822..4cc609cd33 100644 --- a/arkindex/documents/serializers/elements.py +++ b/arkindex/documents/serializers/elements.py @@ -492,11 +492,6 @@ class ElementParentSerializer(serializers.Serializer): """ child = serializers.PrimaryKeyRelatedField(queryset=Element.objects.none()) parent = serializers.PrimaryKeyRelatedField(queryset=Element.objects.none()) - type_ordering = serializers.BooleanField( - default=True, - help_text='Add the child element at the last position in the parent relative to ' - 'only the elements of the same type, or to all elements.', - ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -536,9 +531,8 @@ class ElementParentSerializer(serializers.Serializer): def create(self, validated_data): child = validated_data['child'] parent = validated_data['parent'] - type_ordering = validated_data['type_ordering'] self.perform_create_checks(child, parent) - child.add_parent(parent, type_ordering=type_ordering) + child.add_parent(parent) def delete(self, validated_data): child = validated_data['child'] -- GitLab