From 9b25132c29b40021916b18662adf59e8286969c5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 4 Nov 2020 17:30:12 +0100 Subject: [PATCH] fixed bug for use filters from the website --- ereuse_devicehub/resources/device/views.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/ereuse_devicehub/resources/device/views.py b/ereuse_devicehub/resources/device/views.py index 8f16b12d..2638bafb 100644 --- a/ereuse_devicehub/resources/device/views.py +++ b/ereuse_devicehub/resources/device/views.py @@ -146,7 +146,7 @@ class DeviceView(View): ) def query(self, args): - query = Device.query.distinct() # todo we should not force to do this if the query is ok + query = Device.query.filter((Device.owner_id == g.user.id)).distinct() search_p = args.get('search', None) if search_p: properties = DeviceSearch.properties @@ -156,17 +156,8 @@ class DeviceView(View): ).order_by( search.Search.rank(properties, search_p) + search.Search.rank(tags, search_p) ) - query = self.visibility_filter(query) return query.filter(*args['filter']).order_by(*args['sort']) - def visibility_filter(self, query): - filterqs = request.args.get('filter', None) - if (filterqs and - 'lot' not in filterqs): - query = query.filter((Computer.id == Device.id), (Computer.owner_id == g.user.id)) - pass - return query - class DeviceMergeView(View): """View for merging two devices