diff --git a/arkindex/documents/api/elements.py b/arkindex/documents/api/elements.py index bfe88f6e024905531683a5eb8c3a91b517776387..d71eeeace96f0f1a857c7a8e9d2511cd5ed8103d 100644 --- a/arkindex/documents/api/elements.py +++ b/arkindex/documents/api/elements.py @@ -1,10 +1,8 @@ from django.conf import settings from django.db.models import Q, Prefetch, prefetch_related_objects, Count from rest_framework.exceptions import ValidationError, NotFound -from rest_framework.generics import ( - ListAPIView, CreateAPIView, RetrieveAPIView, UpdateAPIView, DestroyAPIView, - ListCreateAPIView, RetrieveUpdateDestroyAPIView -) +from rest_framework.generics import \ + ListAPIView, CreateAPIView, DestroyAPIView, ListCreateAPIView, RetrieveUpdateDestroyAPIView from rest_framework import status from rest_framework.response import Response from arkindex_common.enums import TranscriptionType @@ -20,7 +18,7 @@ from arkindex.documents.serializers.elements import ( from arkindex.project.openapi import AutoSchema from arkindex.documents.serializers.light import CorpusAllowedMetaDataSerializer from arkindex.documents.serializers.ml import TranscriptionSerializer -from arkindex.project.mixins import CorpusACLMixin, DeprecatedMixin +from arkindex.project.mixins import CorpusACLMixin from arkindex.project.pagination import PageNumberPagination from arkindex.project.permissions import IsVerified, IsVerifiedOrReadOnly, IsAuthenticated from arkindex.project.triggers import corpus_delete @@ -393,21 +391,6 @@ class ElementChildren(ElementsListMixin, ListAPIView): return Element.objects.get_descending(self.kwargs['pk']) -class RelatedElementsList(DeprecatedMixin, ListAPIView): - """ - List all parents and children of a single element - """ - serializer_class = ElementListSerializer - openapi_overrides = { - 'operationId': 'ListRelatedElements', - 'security': [], - 'tags': ['elements'] - } - deprecation_message = \ - 'This endpoint has been deprecated. ' \ - 'Use ListElementParents and ListElementChildren instead to get parent and child elements separately.' - - class ElementRetrieve(RetrieveUpdateDestroyAPIView): """ Retrieve a single element @@ -697,20 +680,6 @@ class ElementTranscriptions(ListAPIView): return queryset -class ElementRegions(DeprecatedMixin, ListAPIView): - """ - List all regions on an element. - """ - openapi_overrides = { - 'operationId': 'ListElementRegions', - 'security': [], - 'tags': ['elements'], - } - deprecation_message = \ - 'This endpoint has been deprecated. ' \ - 'Regions have been migrated to children elements with classifications. Use ListElementChildren to access them.' - - class ElementsCreate(CreateAPIView): """ Create a new element @@ -723,50 +692,6 @@ class ElementsCreate(CreateAPIView): } -class RegionDetails(DeprecatedMixin, RetrieveAPIView): - """ - Retrieve detailed information about a region. - """ - openapi_overrides = { - 'operationId': 'RetrieveRegion', - 'security': [], - 'tags': ['ml'], - } - deprecation_message = \ - 'This endpoint has been deprecated. ' \ - 'Regions have been migrated to children elements with classifications. Use ListElementChildren to access them.' - - -class RegionCreate(DeprecatedMixin, CreateAPIView): - """ - Create a region on an element. - """ - permission_classes = (IsVerified, ) - openapi_overrides = { - 'operationId': 'CreateRegion', - 'tags': ['ml'], - } - deprecation_message = \ - 'This endpoint has been deprecated. ' \ - 'Regions have been migrated to children elements with classifications. Use ListElementChildren to access them.' - - -class RegionBulkCreate(DeprecatedMixin, CreateAPIView, UpdateAPIView): - """ - Add new regions from a machine learning tool. - """ - permission_classes = (IsVerified, ) - # Force DRF to ignore PATCH - http_method_names = ['post', 'put', 'head', 'options', 'trace'] - # Cannot override operationId or description here because openapi_overrides does not handle multiple HTTP methods - openapi_overrides = { - 'tags': ['ml'], - } - deprecation_message = \ - 'This endpoint has been deprecated. ' \ - 'Regions have been migrated to children elements with classifications. Use ListElementChildren to access them.' - - class ElementMetadata(CreateAPIView): """ Create a metadata on an existing element. diff --git a/arkindex/documents/tests/test_elements_api.py b/arkindex/documents/tests/test_elements_api.py index 0e1acb2ac436cbbbac0fa5272951f2bf245b84bd..ed673e909787e29a99656394c58e9ee8feb9481d 100644 --- a/arkindex/documents/tests/test_elements_api.py +++ b/arkindex/documents/tests/test_elements_api.py @@ -780,11 +780,6 @@ class TestElementsAPI(FixtureAPITestCase): expected, ) - def test_related_elements(self): - act = self.corpus.elements.get(name='Act 1') - response = self.client.get(reverse('api:related-elements', kwargs={'pk': str(act.id)})) - self.assertEqual(response.status_code, status.HTTP_410_GONE) - def test_list_with_children_count(self): with self.assertNumQueries(9): response = self.client.get(reverse('api:elements'), data={'with_children_count': True}) diff --git a/arkindex/project/api_v1.py b/arkindex/project/api_v1.py index 7f13c44493e98f5542a63a22b030c2cc18e0bcdf..e36624fac0e2c13f4d14f8aee8c118b663c99674 100644 --- a/arkindex/project/api_v1.py +++ b/arkindex/project/api_v1.py @@ -6,10 +6,9 @@ from arkindex.project.openapi import SchemaGenerator import arkindex from arkindex.documents.api.elements import ( - ElementsList, RelatedElementsList, ElementRetrieve, CorpusList, CorpusRetrieve, ElementTranscriptions, - ElementsCreate, ElementRegions, RegionDetails, RegionCreate, RegionBulkCreate, ElementNeighbors, + ElementsList, ElementsCreate, ElementRetrieve, ElementTranscriptions, ElementNeighbors, ElementParent, ElementParents, ElementChildren, ElementMetadata, MetadataEdit, ManageSelection, - CorpusAllowedMetaData + CorpusList, CorpusRetrieve, CorpusAllowedMetaData ) from arkindex.documents.api.search import ElementSearch, EntitySearch from arkindex.documents.api.ml import ( @@ -45,7 +44,6 @@ api = [ path('elements/<uuid:pk>/neighbors/', ElementNeighbors.as_view(), name='elements-neighbors'), path('elements/<uuid:pk>/parents/', ElementParents.as_view(), name='elements-parents'), path('elements/<uuid:pk>/children/', ElementChildren.as_view(), name='elements-children'), - path('elements/<uuid:pk>/', RelatedElementsList.as_view(), name='related-elements'), path('elements/selection/', ManageSelection.as_view(), name='elements-selection'), path('elements/', ElementsList.as_view(), name='elements'), path('elements/create/', ElementsCreate.as_view(), name='elements-create'), @@ -53,8 +51,6 @@ api = [ path('element/<uuid:pk>/metadata/', ElementMetadata.as_view(), name='element-metadata'), path('element/<uuid:pk>/entities/', ElementEntities.as_view(), name='element-entities'), path('element/<uuid:pk>/links/', ElementLinks.as_view(), name='element-links'), - path('element/<uuid:pk>/regions/', ElementRegions.as_view(), name='element-regions'), - path('element/<uuid:pk>/region/', RegionCreate.as_view(), name='region-create'), path('element/<uuid:pk>/transcriptions/', ElementTranscriptions.as_view(), name='element-transcriptions'), path('element/<uuid:pk>/ml-stats/', ElementMLStats.as_view(), name='element-ml-stats'), path('element/<uuid:child>/parent/<uuid:parent>/', ElementParent.as_view(), name='element-parent'), @@ -63,8 +59,6 @@ api = [ PageXmlTranscriptionsImport.as_view(), name='pagexml-transcriptions', ), - path('region/bulk/', RegionBulkCreate.as_view(), name='region-bulk'), - path('region/<uuid:pk>/', RegionDetails.as_view(), name='region-details'), # Corpora path('corpus/', CorpusList.as_view(), name='corpus'), diff --git a/arkindex/project/openapi/patch.yml b/arkindex/project/openapi/patch.yml index 660a1fbde78e635f09b186837eb6c24755f8077e..df79bc41f18005666abf33d3c138239a1b9edd71 100644 --- a/arkindex/project/openapi/patch.yml +++ b/arkindex/project/openapi/patch.yml @@ -323,12 +323,6 @@ paths: format: uri description: URL to the authorization endpoint. readOnly: true - /api/v1/region/bulk/: - post: - operationId: CreateRegions - put: - operationId: UpdateRegions - description: Add new regions from a machine learning tool; if this tool already has any regions on this element, they are deleted. /api/v1/transcription/bulk/: put: description: >-