mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-21 15:58:52 +00:00
* reactor: 修改工单Model,添加工单迁移文件 * reactor: 修改工单Model,添加工单迁移文件 * reactor: 重构工单模块 * reactor: 重构工单模块2 * reactor: 重构工单模块3 * reactor: 重构工单模块4 * reactor: 重构工单模块5 * reactor: 重构工单模块6 * reactor: 重构工单模块7 * reactor: 重构工单模块8 * reactor: 重构工单模块9 * reactor: 重构工单模块10 * reactor: 重构工单模块11 * reactor: 重构工单模块12 * reactor: 重构工单模块13 * reactor: 重构工单模块14 * reactor: 重构工单模块15 * reactor: 重构工单模块16 * reactor: 重构工单模块17 * reactor: 重构工单模块18 * reactor: 重构工单模块19 * reactor: 重构工单模块20 * reactor: 重构工单模块21 * reactor: 重构工单模块22 * reactor: 重构工单模块23 * reactor: 重构工单模块24 * reactor: 重构工单模块25 * reactor: 重构工单模块26 * reactor: 重构工单模块27 * reactor: 重构工单模块28 * reactor: 重构工单模块29 * reactor: 重构工单模块30 * reactor: 重构工单模块31 * reactor: 重构工单模块32 * reactor: 重构工单模块33 * reactor: 重构工单模块34 * reactor: 重构工单模块35 * reactor: 重构工单模块36 * reactor: 重构工单模块37 * reactor: 重构工单模块38 * reactor: 重构工单模块39
81 lines
2.8 KiB
Python
81 lines
2.8 KiB
Python
from django.utils.translation import ugettext_lazy as _
|
|
from rest_framework import serializers
|
|
from perms.serializers import ActionsField
|
|
from perms.models import Action
|
|
from assets.models import Asset, SystemUser
|
|
from .base import BaseTicketMetaSerializer, BaseTicketMetaApproveSerializerMixin
|
|
|
|
|
|
__all__ = [
|
|
'TicketMetaApplyAssetApplySerializer',
|
|
'TicketMetaApplyAssetApproveSerializer',
|
|
]
|
|
|
|
|
|
class TicketMetaApplyAssetSerializer(BaseTicketMetaSerializer):
|
|
# 申请信息
|
|
apply_ip_group = serializers.ListField(
|
|
child=serializers.IPAddressField(), default=list, label=_('IP group')
|
|
)
|
|
apply_hostname_group = serializers.ListField(
|
|
child=serializers.CharField(), default=list, label=_('Hostname group')
|
|
)
|
|
apply_system_user_group = serializers.ListField(
|
|
child=serializers.CharField(), default=list, label=_('System user group')
|
|
)
|
|
apply_actions = ActionsField(
|
|
choices=Action.DB_CHOICES, default=Action.ALL
|
|
)
|
|
apply_date_start = serializers.DateTimeField(
|
|
required=True, label=_('Date start')
|
|
)
|
|
apply_date_expired = serializers.DateTimeField(
|
|
required=True, label=_('Date expired')
|
|
)
|
|
# 审批信息
|
|
approve_assets = serializers.ListField(
|
|
required=True, child=serializers.UUIDField(), label=_('Approve assets')
|
|
)
|
|
approve_system_users = serializers.ListField(
|
|
required=True, child=serializers.UUIDField(), label=_('Approve system users')
|
|
)
|
|
approve_actions = ActionsField(
|
|
required=False, choices=Action.DB_CHOICES, default=Action.ALL
|
|
)
|
|
approve_date_start = serializers.DateTimeField(
|
|
required=True, label=_('Date start')
|
|
)
|
|
approve_date_expired = serializers.DateTimeField(
|
|
required=True, label=_('Date expired')
|
|
)
|
|
|
|
|
|
class TicketMetaApplyAssetApplySerializer(TicketMetaApplyAssetSerializer):
|
|
|
|
class Meta:
|
|
fields = [
|
|
'apply_ip_group', 'apply_hostname_group',
|
|
'apply_system_user_group', 'apply_actions',
|
|
'apply_date_start', 'apply_date_expired'
|
|
]
|
|
|
|
|
|
class TicketMetaApplyAssetApproveSerializer(BaseTicketMetaApproveSerializerMixin,
|
|
TicketMetaApplyAssetSerializer):
|
|
|
|
class Meta:
|
|
fields = [
|
|
'approve_assets', 'approve_system_users',
|
|
'approve_actions', 'approve_date_start',
|
|
'approve_date_expired'
|
|
]
|
|
|
|
def validate_approve_assets(self, approve_assets):
|
|
assets_id = self.filter_approve_resources(resource_model=Asset, resources_id=approve_assets)
|
|
return assets_id
|
|
|
|
def validate_approve_system_users(self, approve_system_users):
|
|
queries = {'protocol__in': SystemUser.ASSET_CATEGORY_PROTOCOLS}
|
|
system_users_id = self.filter_approve_system_users(approve_system_users, queries)
|
|
return system_users_id
|