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