From 57ba86eb39adfed262f9574d6db676c857b9c955 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 11 Aug 2022 10:21:45 +0200 Subject: [PATCH] add actions in placeholder model --- ereuse_devicehub/resources/device/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index a50d1593..1a95c3b3 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -924,6 +924,17 @@ class Placeholder(Thing): ) owner = db.relationship(User, primaryjoin=owner_id == User.id) + @property + def actions(self): + actions = list(self.device.actions) or [] + + if self.binding: + actions.extend(list(self.binding.actions)) + + actions = sorted(actions, key=lambda x: x.created) + actions.reverse() + return actions + class Computer(Device): """A chassis with components inside that can be processed