You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/apps/acls/serializers/command_acl.py

30 lines
1.1 KiB

2 years ago
from django.utils.translation import ugettext_lazy as _
from acls.models import CommandGroup, CommandFilterACL
from common.drf.fields import ObjectRelatedField, LabeledChoiceField
2 years ago
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from .base import BaseUserAssetAccountACLSerializerMixin as BaseSerializer
2 years ago
__all__ = ["CommandFilterACLSerializer", "CommandGroupSerializer"]
2 years ago
class CommandGroupSerializer(BulkOrgResourceModelSerializer):
type = LabeledChoiceField(
choices=CommandGroup.TypeChoices.choices, default=CommandGroup.TypeChoices.command,
label=_('Type')
)
class Meta:
model = CommandGroup
fields = ['id', 'name', 'type', 'content', 'ignore_case', 'comment']
class CommandFilterACLSerializer(BaseSerializer, BulkOrgResourceModelSerializer):
command_groups = ObjectRelatedField(
queryset=CommandGroup.objects, many=True, required=False, label=_('Command group')
)
2 years ago
class Meta(BaseSerializer.Meta):
2 years ago
model = CommandFilterACL
fields = BaseSerializer.Meta.fields + ['command_groups']