mirror of https://github.com/jumpserver/jumpserver
parent
09f9775eab
commit
af733ecbad
|
@ -1,6 +1,7 @@
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from rest_framework.validators import UniqueValidator
|
||||||
|
|
||||||
from common.serializers import (
|
from common.serializers import (
|
||||||
WritableNestedModelSerializer, type_field_map, MethodSerializer,
|
WritableNestedModelSerializer, type_field_map, MethodSerializer,
|
||||||
|
@ -123,6 +124,10 @@ class PlatformSerializer(WritableNestedModelSerializer):
|
||||||
("super", "super 15"),
|
("super", "super 15"),
|
||||||
("super_level", "super level 15")
|
("super_level", "super level 15")
|
||||||
]
|
]
|
||||||
|
id = serializers.IntegerField(
|
||||||
|
label='ID', required=False,
|
||||||
|
validators=[UniqueValidator(queryset=Platform.objects.all())]
|
||||||
|
)
|
||||||
charset = LabeledChoiceField(choices=Platform.CharsetChoices.choices, label=_("Charset"), default='utf-8')
|
charset = LabeledChoiceField(choices=Platform.CharsetChoices.choices, label=_("Charset"), default='utf-8')
|
||||||
type = LabeledChoiceField(choices=AllTypes.choices(), label=_("Type"))
|
type = LabeledChoiceField(choices=AllTypes.choices(), label=_("Type"))
|
||||||
category = LabeledChoiceField(choices=Category.choices, label=_("Category"))
|
category = LabeledChoiceField(choices=Category.choices, label=_("Category"))
|
||||||
|
@ -213,7 +218,7 @@ class PlatformSerializer(WritableNestedModelSerializer):
|
||||||
def validate_automation(self, automation):
|
def validate_automation(self, automation):
|
||||||
automation = automation or {}
|
automation = automation or {}
|
||||||
ansible_enabled = automation.get('ansible_enabled', False) \
|
ansible_enabled = automation.get('ansible_enabled', False) \
|
||||||
and self.constraints['automation'].get('ansible_enabled', False)
|
and self.constraints['automation'].get('ansible_enabled', False)
|
||||||
automation['ansible_enable'] = ansible_enabled
|
automation['ansible_enable'] = ansible_enabled
|
||||||
return automation
|
return automation
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue