mirror of https://github.com/jumpserver/jumpserver
fix: 推送账号 不填写home 推送失败
parent
a7c06f62f6
commit
4311e52681
|
@ -63,15 +63,17 @@ class AutomationExecutionSerializer(serializers.ModelSerializer):
|
|||
|
||||
@staticmethod
|
||||
def get_snapshot(obj):
|
||||
tp = obj.snapshot['type']
|
||||
tp = obj.snapshot.get('type', '')
|
||||
type_display = tp if not hasattr(AutomationTypes, tp) \
|
||||
else getattr(AutomationTypes, tp).label
|
||||
snapshot = {
|
||||
'type': tp,
|
||||
'name': obj.snapshot['name'],
|
||||
'comment': obj.snapshot['comment'],
|
||||
'accounts': obj.snapshot['accounts'],
|
||||
'node_amount': len(obj.snapshot['nodes']),
|
||||
'asset_amount': len(obj.snapshot['assets']),
|
||||
'type_display': getattr(AutomationTypes, tp).label,
|
||||
'name': obj.snapshot.get('name'),
|
||||
'comment': obj.snapshot.get('comment'),
|
||||
'accounts': obj.snapshot.get('accounts'),
|
||||
'node_amount': len(obj.snapshot.get('nodes', [])),
|
||||
'asset_amount': len(obj.snapshot.get('assets', [])),
|
||||
'type_display': type_display,
|
||||
}
|
||||
return snapshot
|
||||
|
||||
|
|
|
@ -55,8 +55,13 @@ class BasePlaybookManager:
|
|||
return {}
|
||||
|
||||
data = self.params.get(method_id)
|
||||
default_data = serializer().data
|
||||
if not data:
|
||||
data = automation_params.get(method_id, {})
|
||||
data = automation_params.get(method_id, default_data)
|
||||
|
||||
for k, v in default_data.items():
|
||||
data.setdefault(k, v)
|
||||
|
||||
params = serializer(data).data
|
||||
return {
|
||||
field_name: automation_params.get(field_name, '')
|
||||
|
|
|
@ -51,14 +51,14 @@ class AutomationExecutionSerializer(serializers.ModelSerializer):
|
|||
from assets.const import AutomationTypes as AssetTypes
|
||||
from accounts.const import AutomationTypes as AccountTypes
|
||||
tp_dict = dict(AssetTypes.choices) | dict(AccountTypes.choices)
|
||||
tp = obj.snapshot['type']
|
||||
tp = obj.snapshot.get('type', '')
|
||||
snapshot = {
|
||||
'type': {'value': tp, 'label': tp_dict.get(tp, tp)},
|
||||
'name': obj.snapshot['name'],
|
||||
'comment': obj.snapshot['comment'],
|
||||
'accounts': obj.snapshot['accounts'],
|
||||
'node_amount': len(obj.snapshot['nodes']),
|
||||
'asset_amount': len(obj.snapshot['assets']),
|
||||
'name': obj.snapshot.get('name'),
|
||||
'comment': obj.snapshot.get('comment'),
|
||||
'accounts': obj.snapshot.get('accounts'),
|
||||
'node_amount': len(obj.snapshot.get('nodes', [])),
|
||||
'asset_amount': len(obj.snapshot.get('assets', [])),
|
||||
}
|
||||
return snapshot
|
||||
|
||||
|
|
Loading…
Reference in New Issue