Coverage for apis_core/history/api_views.py: 76%

17 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-16 07:42 +0000

1from django.db.models import Q 

2from rest_framework.generics import ListAPIView, RetrieveAPIView 

3 

4from apis_core.apis_relations.models import TempTriple 

5from apis_core.history.serializers import ( 

6 HistoryLogSerializer, 

7 HistoryObjectSerializer, 

8) 

9 

10 

11class EntityHistoryLogs(ListAPIView): 

12 serializer_class = HistoryLogSerializer 

13 

14 def get_queryset(self): 

15 return ( 

16 self.kwargs.get("contenttype") 

17 .model_class() 

18 .history.filter(id=self.kwargs.get("pk")) 

19 ) 

20 

21 

22class TempTripleHistoryLogs(ListAPIView): 

23 serializer_class = HistoryLogSerializer 

24 

25 def get_queryset(self): 

26 id = self.kwargs.get("pk") 

27 return TempTriple.history.filter(Q(subj_id=id) | Q(obj_id=id)) 

28 

29 

30class GenericHistoryLog(RetrieveAPIView): 

31 serializer_class = HistoryObjectSerializer 

32 

33 def get_queryset(self): 

34 return self.kwargs.get("contenttype").model_class().objects.all()