from django.db.models import Q
from rest_framework.generics import ListAPIView, RetrieveAPIView
from apis_core.apis_relations.models import TempTriple
from apis_core.history.serializers import (
HistoryLogSerializer,
HistoryObjectSerializer,
)
[docs]
class EntityHistoryLogs(ListAPIView):
serializer_class = HistoryLogSerializer
[docs]
def get_queryset(self):
return (
self.kwargs.get("contenttype")
.model_class()
.history.filter(id=self.kwargs.get("pk"))
)
[docs]
class TempTripleHistoryLogs(ListAPIView):
serializer_class = HistoryLogSerializer
[docs]
def get_queryset(self):
id = self.kwargs.get("pk")
return TempTriple.history.filter(Q(subj_id=id) | Q(obj_id=id))
[docs]
class GenericHistoryLog(RetrieveAPIView):
serializer_class = HistoryObjectSerializer
[docs]
def get_queryset(self):
return self.kwargs.get("contenttype").model_class().objects.all()