mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-06 19:38:54 +00:00
perf: history account
This commit is contained in:
parent
0c15ac71f6
commit
8231f727c2
@ -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, get_object_or_404
|
from rest_framework.generics import CreateAPIView, ListAPIView
|
||||||
|
|
||||||
from orgs.mixins.api import OrgBulkModelViewSet
|
from orgs.mixins.api import OrgBulkModelViewSet
|
||||||
from rbac.permissions import RBACPermission
|
from rbac.permissions import RBACPermission
|
||||||
@ -13,7 +13,7 @@ from assets.filters import AccountFilterSet
|
|||||||
from assets.tasks.account_connectivity import test_accounts_connectivity_manual
|
from assets.tasks.account_connectivity import test_accounts_connectivity_manual
|
||||||
from assets import serializers
|
from assets import serializers
|
||||||
|
|
||||||
__all__ = ['AccountViewSet', 'AccountSecretsViewSet', 'AccountTaskCreateAPI']
|
__all__ = ['AccountViewSet', 'AccountSecretsViewSet', 'AccountTaskCreateAPI', 'AccountHistoriesSecretAPI']
|
||||||
|
|
||||||
|
|
||||||
class AccountViewSet(OrgBulkModelViewSet):
|
class AccountViewSet(OrgBulkModelViewSet):
|
||||||
@ -42,7 +42,6 @@ class AccountSecretsViewSet(RecordViewLogMixin, AccountViewSet):
|
|||||||
"""
|
"""
|
||||||
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: 记得打开
|
||||||
@ -50,14 +49,21 @@ class AccountSecretsViewSet(RecordViewLogMixin, AccountViewSet):
|
|||||||
rbac_perms = {
|
rbac_perms = {
|
||||||
'list': 'assets.view_accountsecret',
|
'list': 'assets.view_accountsecret',
|
||||||
'retrieve': 'assets.view_accountsecret',
|
'retrieve': 'assets.view_accountsecret',
|
||||||
'histories': ['assets.view_accountsecret'],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action(methods=['get'], detail=True, url_path='histories')
|
|
||||||
def histories(self, request, *args, **kwargs):
|
class AccountHistoriesSecretAPI(RecordViewLogMixin, ListAPIView):
|
||||||
account = get_object_or_404(self.get_queryset(), **kwargs)
|
model = Account.history.model
|
||||||
self.queryset = account.history.all()
|
serializer_class = serializers.AccountHistorySerializer
|
||||||
return super().list(request, *args, **kwargs)
|
http_method_names = ['get', 'options']
|
||||||
|
# Todo: 记得打开
|
||||||
|
# permission_classes = [RBACPermission, UserConfirmation.require(ConfirmType.MFA)]
|
||||||
|
rbac_perms = {
|
||||||
|
'list': 'assets.view_accountsecret',
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return self.model.objects.filter(id=self.kwargs.get('pk'))
|
||||||
|
|
||||||
|
|
||||||
class AccountTaskCreateAPI(CreateAPIView):
|
class AccountTaskCreateAPI(CreateAPIView):
|
||||||
|
@ -71,7 +71,7 @@ class Account(AbsConnectivity, BaseAccount):
|
|||||||
return self.asset.platform
|
return self.asset.platform
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{}@{}'.format(self.username, self.asset.name)
|
return '{}'.format(self.username)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_input_account(cls):
|
def get_input_account(cls):
|
||||||
|
@ -37,6 +37,7 @@ urlpatterns = [
|
|||||||
path('assets/<uuid:pk>/perm-user-groups/<uuid:perm_user_group_id>/permissions/', api.AssetPermUserGroupPermissionsListApi.as_view(), name='asset-perm-user-group-permission-list'),
|
path('assets/<uuid:pk>/perm-user-groups/<uuid:perm_user_group_id>/permissions/', api.AssetPermUserGroupPermissionsListApi.as_view(), name='asset-perm-user-group-permission-list'),
|
||||||
|
|
||||||
path('accounts/tasks/', api.AccountTaskCreateAPI.as_view(), name='account-task-create'),
|
path('accounts/tasks/', api.AccountTaskCreateAPI.as_view(), name='account-task-create'),
|
||||||
|
path('account-secrets/<uuid:pk>/histories/', api.AccountHistoriesSecretAPI.as_view(), name='account-secret-history'),
|
||||||
|
|
||||||
path('nodes/category/tree/', api.CategoryTreeApi.as_view(), name='asset-category-tree'),
|
path('nodes/category/tree/', api.CategoryTreeApi.as_view(), name='asset-category-tree'),
|
||||||
path('nodes/tree/', api.NodeListAsTreeApi.as_view(), name='node-tree'),
|
path('nodes/tree/', api.NodeListAsTreeApi.as_view(), name='node-tree'),
|
||||||
|
Loading…
Reference in New Issue
Block a user