add device placeholder only in the list of devices

This commit is contained in:
Cayo Puigdefabregas 2022-07-15 16:47:00 +02:00
parent 1fa6e7512c
commit 03fbfcb73b
1 changed files with 6 additions and 2 deletions

View File

@ -136,9 +136,13 @@ class FilterForm(FlaskForm):
if self.lot_id: if self.lot_id:
self.lot = self.lots.filter(Lot.id == self.lot_id).one() self.lot = self.lots.filter(Lot.id == self.lot_id).one()
device_ids = (d.id for d in self.lot.devices) 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: 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: if self.only_unassigned:
self.devices = self.devices.filter_by(lots=None) self.devices = self.devices.filter_by(lots=None)