mirror of https://github.com/jumpserver/jumpserver
perf: 平台创建自动化设置默认值
parent
47195e2c44
commit
046342ceee
|
@ -51,8 +51,9 @@ class PlatformProtocolSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PlatformProtocol
|
model = PlatformProtocol
|
||||||
fields = [
|
fields = [
|
||||||
"id", "name", "port", "port_from_addr", "primary",
|
"id", "name", "port", "port_from_addr",
|
||||||
"required", "default", "public", "secret_types", "setting",
|
"primary", "required", "default", "public",
|
||||||
|
"secret_types", "setting",
|
||||||
]
|
]
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
"primary": {
|
"primary": {
|
||||||
|
@ -154,6 +155,18 @@ class PlatformSerializer(WritableNestedModelSerializer):
|
||||||
"domain_default": {"label": _('Default Domain')},
|
"domain_default": {"label": _('Default Domain')},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.set_initial_value()
|
||||||
|
|
||||||
|
def set_initial_value(self):
|
||||||
|
if not hasattr(self, 'initial_data'):
|
||||||
|
return
|
||||||
|
if self.instance:
|
||||||
|
return
|
||||||
|
if not self.initial_data.get('automation'):
|
||||||
|
self.initial_data['automation'] = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def platform_category_type(self):
|
def platform_category_type(self):
|
||||||
if self.instance:
|
if self.instance:
|
||||||
|
@ -199,8 +212,9 @@ class PlatformSerializer(WritableNestedModelSerializer):
|
||||||
|
|
||||||
def validate_automation(self, automation):
|
def validate_automation(self, automation):
|
||||||
automation = automation or {}
|
automation = automation or {}
|
||||||
automation = 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
|
||||||
return automation
|
return automation
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue