From 612379e7e2c40fb1d378dbfa48f9e3bbe9699da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E4=BA=8C=E7=8C=9B?= Date: Fri, 6 Dec 2019 00:46:30 +0800 Subject: [PATCH] A api update --- spug_api/apps/alarm/models.py | 2 +- spug_api/apps/monitor/scheduler.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spug_api/apps/alarm/models.py b/spug_api/apps/alarm/models.py index 8a02cf8..92465c1 100644 --- a/spug_api/apps/alarm/models.py +++ b/spug_api/apps/alarm/models.py @@ -25,7 +25,7 @@ class Alarm(models.Model, ModelMixin): def to_dict(self, *args, **kwargs): tmp = super().to_dict(*args, **kwargs) - tmp['notify_mode'] = json.loads(self.notify_mode) + tmp['notify_mode'] = ','.join(dict(self.MODES)[x] for x in json.loads(self.notify_mode)) tmp['notify_grp'] = json.loads(self.notify_grp) tmp['status_alias'] = self.get_status_display() return tmp diff --git a/spug_api/apps/monitor/scheduler.py b/spug_api/apps/monitor/scheduler.py index 774ec52..ec44242 100644 --- a/spug_api/apps/monitor/scheduler.py +++ b/spug_api/apps/monitor/scheduler.py @@ -26,7 +26,7 @@ class Scheduler: duration = seconds_to_human(time.time() - obj.latest_fault_time) Alarm.objects.create( name=obj.name, - type=obj.type, + type=obj.get_type_display(), status=status, duration=duration, notify_grp=obj.notify_grp,