|
36 | 36 | AdvancedSearchSerializer,
|
37 | 37 | EntryAttributeValueRestoreSerializer,
|
38 | 38 | EntryAliasRetrieveSerializer,
|
| 39 | + EntryAliasUpdateSerializer, |
39 | 40 | EntryBaseSerializer,
|
40 | 41 | EntryCopySerializer,
|
41 | 42 | EntryExportSerializer,
|
@@ -85,6 +86,7 @@ def get_serializer_class(self):
|
85 | 86 | "update": serializers.Serializer,
|
86 | 87 | "copy": EntryCopySerializer,
|
87 | 88 | "list": EntryHistoryAttributeValueSerializer,
|
| 89 | + "list_alias": AliasListAPI, |
88 | 90 | }
|
89 | 91 | return serializer.get(self.action, EntryBaseSerializer)
|
90 | 92 |
|
@@ -174,6 +176,15 @@ def copy(self, request: Request, *args, **kwargs) -> Response:
|
174 | 176 |
|
175 | 177 | return Response({}, status=status.HTTP_200_OK)
|
176 | 178 |
|
| 179 | + def list_alias(self, request: Request, *args, **kwargs) -> Response: |
| 180 | + print("[onix/view.list_alias(00)]") |
| 181 | + user: User = self.request.user |
| 182 | + entry: Entry = self.get_object() |
| 183 | + |
| 184 | + self.queryset = AliasEntry.objects.filter(entry=entry, entry__is_active=True) |
| 185 | + |
| 186 | + return super(EntryAPI, self).list(request, *args, **kwargs) |
| 187 | + |
177 | 188 | # histories view
|
178 | 189 | def list(self, request: Request, *args, **kwargs) -> Response:
|
179 | 190 | user: User = self.request.user
|
@@ -829,12 +840,25 @@ def delete(self, request: Request, *args, **kwargs) -> Response:
|
829 | 840 | return Response(status=status.HTTP_204_NO_CONTENT)
|
830 | 841 |
|
831 | 842 |
|
832 |
| -class AliasEntryAPI(viewsets.ModelViewSet): |
833 |
| - #queryset = AliasEntry.objects.all() |
| 843 | +class AliasListAPI(viewsets.ModelViewSet): |
834 | 844 | permission_classes = [IsAuthenticated & EntryPermission]
|
835 | 845 | pagination_class = LimitOffsetPagination
|
836 | 846 | serializer_class = EntryAliasRetrieveSerializer
|
837 | 847 |
|
838 | 848 | def get_queryset(self, *args, **kwargs):
|
839 |
| - # get all AliasEntry items that are associated with specified EntryID |
840 |
| - return AliasEntry.objects.filter(entry__id=self.kwargs["pk"]) |
| 849 | + # get all aliasentry items that are associated with specified entryid |
| 850 | + return aliasentry.objects.filter(entry__id=self.kwargs["pk"]) |
| 851 | + |
| 852 | +class AliasUpdateAPI(viewsets.ModelViewSet): |
| 853 | + # permission_classes = [IsAuthenticated & EntryPermission] |
| 854 | + permission_classes = [IsAuthenticated] |
| 855 | + pagination_class = LimitOffsetPagination |
| 856 | + queryset = AliasEntry.objects.filter(entry__is_active=True) |
| 857 | + |
| 858 | + def get_serializer_class(self): |
| 859 | + print("[onix/view/get_serializer_class(00)] action: %s" % str(self.action)) |
| 860 | + serializer = { |
| 861 | + "create": EntryAliasUpdateSerializer, |
| 862 | + "destroy": EntryAliasUpdateSerializer, |
| 863 | + } |
| 864 | + return serializer.get(self.action, EntryAliasRetrieveSerializer) |
0 commit comments