ordered list of devices

This commit is contained in:
Cayo Puigdefabregas 2022-01-12 20:40:57 +01:00
parent bdc518b949
commit 97f450a07c
1 changed files with 3 additions and 1 deletions

View File

@ -21,11 +21,13 @@ class DeviceListView(View):
lot = None lot = None
if id: if id:
lot = lots.filter(Lot.id == id).one() lot = lots.filter(Lot.id == id).one()
# import pdb; pdb.set_trace()
devices = [dev for dev in lot.devices if dev.type in 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)
else: else:
devices = Device.query.filter( devices = Device.query.filter(
Device.owner_id == current_user.id).filter( Device.owner_id == current_user.id).filter(
Device.type.in_(filter_types)).filter(Device.lots == None) Device.type.in_(filter_types)).filter(Device.lots == None).order_by('id', 'updated')
context = {'devices': devices, context = {'devices': devices,
'lots': lots, 'lots': lots,