From 14ce3892acf58088e87a4631591b91b2a69a076b Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 22 Dec 2022 18:39:59 +0100 Subject: [PATCH] add new filter in actions for show only active snapshots --- ereuse_devicehub/resources/device/models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 54d1fa98..735b68a0 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -264,16 +264,18 @@ class Device(Thing): """ actions_multiple = copy.copy(self.actions_multiple) actions_one = copy.copy(self.actions_one) + actions = [] for ac in actions_multiple: ac.real_created = ac.actions_device[0].created + actions.append(ac) for ac in actions_one: ac.real_created = ac.created + if ac.type != 'Snapshot' or ac.active: + actions.append(ac) - return sorted( - chain(actions_multiple, actions_one), key=lambda x: x.real_created - ) + return sorted(actions, key=lambda x: x.real_created) @property def problems(self):