fixed bug for use filters from the website
This commit is contained in:
parent
abe7783b93
commit
9b25132c29
|
@ -146,7 +146,7 @@ class DeviceView(View):
|
||||||
)
|
)
|
||||||
|
|
||||||
def query(self, args):
|
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)
|
search_p = args.get('search', None)
|
||||||
if search_p:
|
if search_p:
|
||||||
properties = DeviceSearch.properties
|
properties = DeviceSearch.properties
|
||||||
|
@ -156,17 +156,8 @@ class DeviceView(View):
|
||||||
).order_by(
|
).order_by(
|
||||||
search.Search.rank(properties, search_p) + search.Search.rank(tags, search_p)
|
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'])
|
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):
|
class DeviceMergeView(View):
|
||||||
"""View for merging two devices
|
"""View for merging two devices
|
||||||
|
|
Reference in New Issue