From 03fbfcb73b1b4b37fc72ec7ec7b56feffcc0f25b Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 15 Jul 2022 16:47:00 +0200 Subject: [PATCH] add device placeholder only in the list of devices --- ereuse_devicehub/inventory/forms.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 65d2b5c3..b00d8181 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -136,9 +136,13 @@ class FilterForm(FlaskForm): if self.lot_id: self.lot = self.lots.filter(Lot.id == self.lot_id).one() device_ids = (d.id for d in self.lot.devices) - self.devices = Device.query.filter(Device.id.in_(device_ids)) + self.devices = Device.query.filter(Device.id.in_(device_ids)).filter( + Device.binding == None + ) else: - self.devices = Device.query.filter(Device.owner_id == g.user.id) + self.devices = Device.query.filter(Device.owner_id == g.user.id).filter( + Device.binding == None + ) if self.only_unassigned: self.devices = self.devices.filter_by(lots=None)