mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-18 17:01:31 +00:00
fix: Account tempale cannot push params (#13671)
Co-authored-by: feng <1304903146@qq.com>
This commit is contained in:
parent
bb6d077645
commit
cf727d22c0
@ -81,7 +81,7 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
|
|||||||
def get_template_attr_for_account(template):
|
def get_template_attr_for_account(template):
|
||||||
# Set initial data from template
|
# Set initial data from template
|
||||||
field_names = [
|
field_names = [
|
||||||
'name', 'username', 'secret',
|
'name', 'username', 'secret', 'push_params',
|
||||||
'secret_type', 'privileged', 'is_active'
|
'secret_type', 'privileged', 'is_active'
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -90,6 +90,9 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
|
|||||||
value = getattr(template, name, None)
|
value = getattr(template, name, None)
|
||||||
if value is None:
|
if value is None:
|
||||||
continue
|
continue
|
||||||
|
if name == 'push_params':
|
||||||
|
attrs['params'] = value
|
||||||
|
else:
|
||||||
attrs[name] = value
|
attrs[name] = value
|
||||||
attrs['secret'] = template.get_secret()
|
attrs['secret'] = template.get_secret()
|
||||||
return attrs
|
return attrs
|
||||||
@ -225,7 +228,7 @@ class AccountSerializer(AccountCreateUpdateSerializerMixin, BaseAccountSerialize
|
|||||||
fields = BaseAccountSerializer.Meta.fields + [
|
fields = BaseAccountSerializer.Meta.fields + [
|
||||||
'su_from', 'asset', 'version',
|
'su_from', 'asset', 'version',
|
||||||
'source', 'source_id', 'connectivity',
|
'source', 'source_id', 'connectivity',
|
||||||
] + list(set(AccountCreateUpdateSerializerMixin.Meta.fields) - {'params'})
|
] + AccountCreateUpdateSerializerMixin.Meta.fields
|
||||||
read_only_fields = BaseAccountSerializer.Meta.read_only_fields + [
|
read_only_fields = BaseAccountSerializer.Meta.read_only_fields + [
|
||||||
'connectivity'
|
'connectivity'
|
||||||
]
|
]
|
||||||
|
@ -323,7 +323,9 @@ class AssetSerializer(BulkOrgResourceModelSerializer, ResourceLabelsMixin, Writa
|
|||||||
template_id = data.get('template', None)
|
template_id = data.get('template', None)
|
||||||
if template_id:
|
if template_id:
|
||||||
template = AccountTemplate.objects.get(id=template_id)
|
template = AccountTemplate.objects.get(id=template_id)
|
||||||
if template and template.su_from:
|
template.push_params = data.pop('push_params', {})
|
||||||
|
data['params'] = template.push_params
|
||||||
|
if template.su_from:
|
||||||
su_from_name_username_secret_type_map[template.name] = (
|
su_from_name_username_secret_type_map[template.name] = (
|
||||||
template.su_from.username, template.su_from.secret_type
|
template.su_from.username, template.su_from.secret_type
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user