mirror of https://github.com/jumpserver/jumpserver
perf: 优化 super ticket 的状态 (#7714)
* fix: token 系统用户增加 protocol * fix: 修复清除orphan session时同时清除对应的 session_task * perf: 修改 connection token api * fix: 修复无法获取系统角色绑定的问题 * perf: 增加 db terminal 及 magnus 组件 * perf: 修改 migrations * fix: 修复AUTHENTICATION_BACKENDS相关的逻辑 * fix: 修改判断backend认证逻辑 * fix: 修复资产账号查看密码跳过mfa * fix: 修复用户组授权权限错误 * feat: 支持COS对象存储 * feat: 升级依赖 jms_storage==0.0.42 * fix: 修复 koko api 问题 * feat: 修改存储翻译信息 * perf: 修改 ticket 权限 * fix: 修复获取资产授权系统用户 get_queryset * perf: 抽取 ticket * perf: 修改 cmd filter 的权限 * fix: 修改 ticket perm * perf: 修改工单的api Co-authored-by: Eric <xplzv@126.com> Co-authored-by: Jiangjie.Bai <bugatti_it@163.com> Co-authored-by: ibuler <ibuler@qq.com> Co-authored-by: 小冯 <xiaofeng@xiaofengdeMacBook-Pro.local> Co-authored-by: feng626 <1304903146@qq.com>pull/7718/head
parent
03afa4f974
commit
ab1024fbf4
|
@ -3,11 +3,10 @@ from rest_framework.generics import CreateAPIView
|
||||||
|
|
||||||
from common.utils import reverse, lazyproperty
|
from common.utils import reverse, lazyproperty
|
||||||
from orgs.utils import tmp_to_org
|
from orgs.utils import tmp_to_org
|
||||||
from tickets.api import GenericTicketStatusRetrieveCloseAPI
|
|
||||||
from ..models import LoginAssetACL
|
from ..models import LoginAssetACL
|
||||||
from .. import serializers
|
from .. import serializers
|
||||||
|
|
||||||
__all__ = ['LoginAssetCheckAPI', 'LoginAssetConfirmStatusAPI']
|
__all__ = ['LoginAssetCheckAPI']
|
||||||
|
|
||||||
|
|
||||||
class LoginAssetCheckAPI(CreateAPIView):
|
class LoginAssetCheckAPI(CreateAPIView):
|
||||||
|
@ -51,7 +50,7 @@ class LoginAssetCheckAPI(CreateAPIView):
|
||||||
org_id=self.serializer.org.id
|
org_id=self.serializer.org.id
|
||||||
)
|
)
|
||||||
confirm_status_url = reverse(
|
confirm_status_url = reverse(
|
||||||
view_name='api-acls:login-asset-confirm-status',
|
view_name='api-tickets:super-ticket-status',
|
||||||
kwargs={'pk': str(ticket.id)}
|
kwargs={'pk': str(ticket.id)}
|
||||||
)
|
)
|
||||||
ticket_detail_url = reverse(
|
ticket_detail_url = reverse(
|
||||||
|
@ -76,6 +75,3 @@ class LoginAssetCheckAPI(CreateAPIView):
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
return serializer
|
return serializer
|
||||||
|
|
||||||
|
|
||||||
class LoginAssetConfirmStatusAPI(GenericTicketStatusRetrieveCloseAPI):
|
|
||||||
pass
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ router.register(r'login-asset-acls', api.LoginAssetACLViewSet, 'login-asset-acl'
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('login-asset/check/', api.LoginAssetCheckAPI.as_view(), name='login-asset-check'),
|
path('login-asset/check/', api.LoginAssetCheckAPI.as_view(), name='login-asset-check'),
|
||||||
path('login-asset-confirm/<uuid:pk>/status/', api.LoginAssetConfirmStatusAPI.as_view(), name='login-asset-confirm-status')
|
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += router.urls
|
urlpatterns += router.urls
|
||||||
|
|
|
@ -8,13 +8,11 @@ from django.shortcuts import get_object_or_404
|
||||||
from common.utils import reverse
|
from common.utils import reverse
|
||||||
from common.utils import lazyproperty
|
from common.utils import lazyproperty
|
||||||
from orgs.mixins.api import OrgBulkModelViewSet
|
from orgs.mixins.api import OrgBulkModelViewSet
|
||||||
from tickets.api import GenericTicketStatusRetrieveCloseAPI
|
|
||||||
from ..models import CommandFilter, CommandFilterRule
|
from ..models import CommandFilter, CommandFilterRule
|
||||||
from .. import serializers
|
from .. import serializers
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'CommandFilterViewSet', 'CommandFilterRuleViewSet', 'CommandConfirmAPI',
|
'CommandFilterViewSet', 'CommandFilterRuleViewSet', 'CommandConfirmAPI',
|
||||||
'CommandConfirmStatusAPI'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +60,7 @@ class CommandConfirmAPI(CreateAPIView):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_response_data(ticket):
|
def get_response_data(ticket):
|
||||||
confirm_status_url = reverse(
|
confirm_status_url = reverse(
|
||||||
view_name='api-assets:command-confirm-status',
|
view_name='api-tickets:super-ticket-status',
|
||||||
kwargs={'pk': str(ticket.id)}
|
kwargs={'pk': str(ticket.id)}
|
||||||
)
|
)
|
||||||
ticket_detail_url = reverse(
|
ticket_detail_url = reverse(
|
||||||
|
@ -85,6 +83,3 @@ class CommandConfirmAPI(CreateAPIView):
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
return serializer
|
return serializer
|
||||||
|
|
||||||
|
|
||||||
class CommandConfirmStatusAPI(GenericTicketStatusRetrieveCloseAPI):
|
|
||||||
pass
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ urlpatterns = [
|
||||||
path('gateways/<uuid:pk>/test-connective/', api.GatewayTestConnectionApi.as_view(), name='test-gateway-connective'),
|
path('gateways/<uuid:pk>/test-connective/', api.GatewayTestConnectionApi.as_view(), name='test-gateway-connective'),
|
||||||
|
|
||||||
path('cmd-filters/command-confirm/', api.CommandConfirmAPI.as_view(), name='command-confirm'),
|
path('cmd-filters/command-confirm/', api.CommandConfirmAPI.as_view(), name='command-confirm'),
|
||||||
path('cmd-filters/command-confirm/<uuid:pk>/status/', api.CommandConfirmStatusAPI.as_view(), name='command-confirm-status')
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
#
|
#
|
||||||
from .ticket import *
|
from .ticket import *
|
||||||
from .comment import *
|
from .comment import *
|
||||||
from .common import *
|
from .super_ticket import *
|
||||||
from .relation import *
|
from .relation import *
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from rest_framework.response import Response
|
|
||||||
from rest_framework.generics import RetrieveDestroyAPIView
|
|
||||||
|
|
||||||
from common.utils import lazyproperty
|
|
||||||
from orgs.utils import tmp_to_root_org
|
|
||||||
from ..models import Ticket
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['GenericTicketStatusRetrieveCloseAPI']
|
|
||||||
|
|
||||||
|
|
||||||
class GenericTicketStatusRetrieveCloseAPI(RetrieveDestroyAPIView):
|
|
||||||
queryset = Ticket.objects.all()
|
|
||||||
|
|
||||||
def retrieve(self, request, *args, **kwargs):
|
|
||||||
if self.ticket.state_open:
|
|
||||||
status = 'await'
|
|
||||||
elif self.ticket.state_approve:
|
|
||||||
status = 'approved'
|
|
||||||
else:
|
|
||||||
status = 'rejected'
|
|
||||||
data = {
|
|
||||||
'status': status,
|
|
||||||
'action': self.ticket.state,
|
|
||||||
'processor': str(self.ticket.processor)
|
|
||||||
}
|
|
||||||
return Response(data=data, status=200)
|
|
||||||
|
|
||||||
def destroy(self, request, *args, **kwargs):
|
|
||||||
if self.ticket.status_open:
|
|
||||||
self.ticket.close(processor=self.ticket.applicant)
|
|
||||||
data = {
|
|
||||||
'action': self.ticket.state,
|
|
||||||
'status': self.ticket.status,
|
|
||||||
'processor': str(self.ticket.processor)
|
|
||||||
}
|
|
||||||
return Response(data=data, status=200)
|
|
||||||
|
|
||||||
@lazyproperty
|
|
||||||
def ticket(self):
|
|
||||||
with tmp_to_root_org():
|
|
||||||
return get_object_or_404(Ticket, pk=self.kwargs['pk'])
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
from rest_framework.generics import RetrieveDestroyAPIView
|
||||||
|
|
||||||
|
from orgs.utils import tmp_to_root_org
|
||||||
|
from ..serializers import SuperTicketSerializer
|
||||||
|
from ..models import SuperTicket
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ['SuperTicketStatusAPI']
|
||||||
|
|
||||||
|
|
||||||
|
class SuperTicketStatusAPI(RetrieveDestroyAPIView):
|
||||||
|
serializer_class = SuperTicketSerializer
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
with tmp_to_root_org():
|
||||||
|
return SuperTicket.objects.all()
|
||||||
|
|
||||||
|
def perform_destroy(self, instance):
|
||||||
|
ticket = self.get_object()
|
||||||
|
ticket.close(processor=ticket.applicant)
|
|
@ -17,7 +17,7 @@ from tickets.signals import post_change_ticket_action
|
||||||
from tickets.handler import get_ticket_handler
|
from tickets.handler import get_ticket_handler
|
||||||
from tickets.errors import AlreadyClosed
|
from tickets.errors import AlreadyClosed
|
||||||
|
|
||||||
__all__ = ['Ticket', 'TicketStep', 'TicketAssignee']
|
__all__ = ['Ticket', 'TicketStep', 'TicketAssignee', 'SuperTicket']
|
||||||
|
|
||||||
|
|
||||||
class TicketStep(CommonModelMixin):
|
class TicketStep(CommonModelMixin):
|
||||||
|
|
|
@ -3,3 +3,4 @@
|
||||||
from .ticket import *
|
from .ticket import *
|
||||||
from .comment import *
|
from .comment import *
|
||||||
from .relation import *
|
from .relation import *
|
||||||
|
from .super_ticket import *
|
|
@ -0,0 +1,12 @@
|
||||||
|
from rest_framework.serializers import ModelSerializer
|
||||||
|
|
||||||
|
from ..models import SuperTicket
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ['SuperTicketSerializer']
|
||||||
|
|
||||||
|
|
||||||
|
class SuperTicketSerializer(ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = SuperTicket
|
||||||
|
fields = ['id', 'status', 'state', 'processor']
|
|
@ -16,5 +16,6 @@ router.register('ticket-session-relation', api.TicketSessionRelationViewSet, 'ti
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('tickets/<uuid:ticket_id>/session/', api.TicketSessionApi.as_view(), name='ticket-sesion'),
|
path('tickets/<uuid:ticket_id>/session/', api.TicketSessionApi.as_view(), name='ticket-sesion'),
|
||||||
|
path('super-tickets/<uuid:pk>/status/', api.SuperTicketStatusAPI.as_view(), name='super-ticket-status'),
|
||||||
]
|
]
|
||||||
urlpatterns += router.urls
|
urlpatterns += router.urls
|
||||||
|
|
Loading…
Reference in New Issue