Skip to content

Commit

Permalink
fix: use RootObject instead of TempEntityClass in GetEntityGeneric
Browse files Browse the repository at this point in the history
TempEntityClass will be dropped at some point, so we change the
serializer to use the RootObject instead

Closes: #380
  • Loading branch information
b1rger committed Nov 8, 2023
1 parent e4480f3 commit d03fad5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions apis_core/apis_entities/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
from rest_framework.settings import api_settings
from rest_framework.views import APIView

from apis_core.apis_entities.models import TempEntityClass
from apis_core.apis_metainfo.models import Uri
from apis_core.apis_metainfo.models import Uri, RootObject
from .api_renderers import (
EntityToTEI,
EntityToCIDOCXML,
Expand All @@ -39,7 +38,7 @@ class StandardResultsSetPagination(PageNumberPagination):

class GetEntityGeneric(GenericAPIView):
serializer_class = EntitySerializer
queryset = TempEntityClass.objects.all()
queryset = RootObject.objects.all()
renderer_classes = tuple(api_settings.DEFAULT_RENDERER_CLASSES) + (
EntityToTEI,
EntityToCIDOCXML,
Expand All @@ -58,13 +57,11 @@ class GetEntityGeneric(GenericAPIView):

def get_object(self, pk, request):
try:
return TempEntityClass.objects_inheritance.get_subclass(pk=pk)
except TempEntityClass.DoesNotExist:
return RootObject.objects_inheritance.get_subclass(pk=pk)
except RootObject.DoesNotExist:
uri2 = Uri.objects.filter(uri=request.build_absolute_uri())
if uri2.count() == 1:
return TempEntityClass.objects_inheritance.get_subclass(
pk=uri2[0].entity_id
)
return RootObject.objects_inheritance.get_subclass(pk=uri2[0].entity_id)
else:
raise Http404

Expand Down

0 comments on commit d03fad5

Please sign in to comment.