add all devices as option in the select of filter

This commit is contained in:
Cayo Puigdefabregas 2022-03-08 10:15:53 +01:00
parent 62f42e9e05
commit a983ebd6cf
1 changed files with 17 additions and 7 deletions

View File

@ -57,7 +57,9 @@ class DeviceListMix(View):
if lot_id:
lot = lots.filter(Lot.id == lot_id).one()
devices = [dev for dev in lot.devices if dev.type in filter_types]
devices = lot.devices
if filter_types:
devices = [dev for dev in lot.devices if dev.type in filter_types]
devices = sorted(devices, key=lambda x: x.updated, reverse=True)
form_new_action = NewActionForm(lot=lot.id)
form_new_allocate = AllocateForm(lot=lot.id)
@ -68,12 +70,20 @@ class DeviceListMix(View):
user_from=g.user.email,
)
else:
devices = (
Device.query.filter(Device.owner_id == current_user.id)
.filter(Device.type.in_(filter_types))
.filter_by(lots=None)
.order_by(Device.updated.desc())
)
if "All" in filter_types:
devices = (
Device.query.filter(Device.owner_id == current_user.id)
.filter_by(lots=None)
.order_by(Device.updated.desc())
)
else:
devices = (
Device.query.filter(Device.owner_id == current_user.id)
.filter_by(lots=None)
.filter(Device.type.in_(filter_types))
.order_by(Device.updated.desc())
)
form_new_action = NewActionForm()
form_new_allocate = AllocateForm()
form_new_datawipe = DataWipeForm()