From 97f450a07c578306b4193baa6a733d14ffab9ee0 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 12 Jan 2022 20:40:57 +0100 Subject: [PATCH] ordered list of devices --- ereuse_devicehub/inventory/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index e8a280f9..a7ef5521 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -21,11 +21,13 @@ class DeviceListView(View): lot = None if id: 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 = sorted(devices, key=lambda x: x.updated, reverse=True) else: devices = Device.query.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, 'lots': lots,