perf: 修改支持 AD (#10926)

* stash

* perf: 修改支持 AD

* perf: 优化 default

---------

Co-authored-by: ibuler <ibuler@qq.com>
pull/11408/head^2
fit2bot 1 year ago committed by GitHub
parent 61078ee2ed
commit 9607ab5164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,11 +62,12 @@ class Protocol(ChoicesMixin, models.TextChoices):
'label': _('Security'),
'help_text': _("Security layer to use for the connection")
},
# 'ad_domain': {
# 'type': 'str',
# "required": False,
# 'label': _('AD domain')
# }
'ad_domain': {
'type': 'str',
'required': False,
'default': '',
'label': _('AD domain')
}
}
},
cls.vnc: {

@ -350,7 +350,7 @@ class AllTypes(ChoicesMixin):
for d in platform_datas:
name = d['name']
# print("\t - Platform: {}".format(name))
print("\t - Platform: {}".format(name))
_automation = d.pop('automation', {})
_protocols = d.pop('_protocols', [])
_protocols_setting = d.pop('protocols_setting', {})
@ -363,7 +363,7 @@ class AllTypes(ChoicesMixin):
setting = _protocols_setting.get(p['name'], {})
p['required'] = setting.pop('required', False)
p['default'] = setting.pop('default', False)
p['setting'] = {**p.get('setting', {}), **setting}
p['setting'] = {**p.get('setting', {}).get('default', ''), **setting}
platform_data = {
**default_platform_data, **d,

@ -51,8 +51,8 @@ def create_serializer_class(serializer_name, fields_info):
field_type = data.pop('type', 'str')
# 用户定义 default 和 required 可能会冲突, 所以要处理一下
default = data.get('default', '')
if default not in ['', None]:
default = data.get('default', None)
if default is not None:
data['required'] = False
else:
data.pop('default', None)

Loading…
Cancel
Save