From b14ca141207c05b462e1a45e5773eefef6e7e774 Mon Sep 17 00:00:00 2001 From: xinwen Date: Thu, 11 Jun 2020 20:30:59 +0800 Subject: [PATCH] [Fix] ops.models.adhoc (#4096) --- apps/ops/models/adhoc.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/ops/models/adhoc.py b/apps/ops/models/adhoc.py index 433d1c498..e8923df1b 100644 --- a/apps/ops/models/adhoc.py +++ b/apps/ops/models/adhoc.py @@ -128,13 +128,15 @@ class Task(PeriodTaskModelMixin, OrgModelMixin): def _last_adhocexecution(self, is_success, key): obj = AdHocExecution.objects.filter(task_id=self.id, is_success=is_success).order_by('-date_finished').first() - body = obj.summary.get(key) + body = obj.summary and obj.summary.get(key) + if body: asset, body = body.popitem() - action, body = body.popitem() - return asset, action, body.get('msg', '') - else: - return '', '', '' + if body: + action, body = body.popitem() + return asset, action, (body or '') and body.get('msg', '') + return asset, '', '' + return '', '', '' def __str__(self): return self.name + '@' + str(self.org_id)