mirror of https://github.com/jumpserver/jumpserver
perf: histories account
parent
41ee6a64bd
commit
796758cbb2
|
@ -1,6 +1,6 @@
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.generics import CreateAPIView
|
from rest_framework.generics import CreateAPIView, get_object_or_404
|
||||||
|
|
||||||
from orgs.mixins.api import OrgBulkModelViewSet
|
from orgs.mixins.api import OrgBulkModelViewSet
|
||||||
from rbac.permissions import RBACPermission
|
from rbac.permissions import RBACPermission
|
||||||
|
@ -41,7 +41,8 @@ class AccountSecretsViewSet(RecordViewLogMixin, AccountViewSet):
|
||||||
因为可能要导出所有账号,所以单独建立了一个 viewset
|
因为可能要导出所有账号,所以单独建立了一个 viewset
|
||||||
"""
|
"""
|
||||||
serializer_classes = {
|
serializer_classes = {
|
||||||
'default': serializers.AccountSecretSerializer
|
'default': serializers.AccountSecretSerializer,
|
||||||
|
'histories': serializers.AccountHistorySerializer,
|
||||||
}
|
}
|
||||||
http_method_names = ['get', 'options']
|
http_method_names = ['get', 'options']
|
||||||
# Todo: 记得打开
|
# Todo: 记得打开
|
||||||
|
@ -52,12 +53,11 @@ class AccountSecretsViewSet(RecordViewLogMixin, AccountViewSet):
|
||||||
'histories': ['assets.view_accountsecret'],
|
'histories': ['assets.view_accountsecret'],
|
||||||
}
|
}
|
||||||
|
|
||||||
@action(methods=['get'], detail=True, url_path='histories', serializer_class=serializers.AccountHistorySerializer)
|
@action(methods=['get'], detail=True, url_path='histories')
|
||||||
def histories(self, request, *args, **kwargs):
|
def histories(self, request, *args, **kwargs):
|
||||||
account = self.get_object()
|
account = get_object_or_404(self.get_queryset(), **kwargs)
|
||||||
histories = account.history.all()
|
self.queryset = account.history.all()
|
||||||
serializer = serializers.AccountHistorySerializer(histories, many=True)
|
return super().list(request, *args, **kwargs)
|
||||||
return Response(serializer.data)
|
|
||||||
|
|
||||||
|
|
||||||
class AccountTaskCreateAPI(CreateAPIView):
|
class AccountTaskCreateAPI(CreateAPIView):
|
||||||
|
|
Loading…
Reference in New Issue