Commit 7bd16e6f authored by Mikael Salson's avatar Mikael Salson Committed by Vidjil

sample_set.py: Update previous/next sample_set mechanism

With the update in how the rights are managed we need to change how we search for the next/previous sample set.
Actually we just need to get the next/previous sample set of the same type for which we have the permissions.

Closes #3140.
parent 1a06d7ef
......@@ -23,19 +23,17 @@ def next_sample_set():
if 'next' in request.vars:
try:
sample_type = db.sample_set[request.vars["id"]].sample_type
for row in db( db[sample_type].sample_set_id == request.vars["id"] ).select() :
current_id = row.id
sample_set_id = int(request.vars['id'])
go_next = int(request.vars['next'])
if go_next > 0:
res = db((db[sample_type].id > current_id) & (auth.vidjil_accessible_query(PermissionEnum.read.value, db[sample_type]))).select(
db[sample_type].id, db[sample_type].sample_set_id, orderby=db[sample_type].id, limitby=(0,1))
res = db((db.sample_set.id > sample_set_id) & (db.sample_set.sample_type == sample_type) & (auth.vidjil_accessible_query(PermissionEnum.read.value, db.sample_set))).select(
db.sample_set.id, orderby=db.sample_set.id, limitby=(0,1))
else:
res = db((db[sample_type].id < current_id) & (auth.vidjil_accessible_query(PermissionEnum.read.value, db[sample_type]))).select(
db[sample_type].id, db[sample_type].sample_set_id, orderby=~db[sample_type].id, limitby=(0,1))
res = db((db.sample_set.id < sample_set_id) & (db.sample_set.sample_type == sample_type) & (auth.vidjil_accessible_query(PermissionEnum.read.value, db.sample_set))).select(
db.sample_set.id, orderby=~db.sample_set.id, limitby=(0,1))
if (len(res) > 0):
request.vars["id"] = str(res[0].sample_set_id)
request.vars["id"] = str(res[0].id)
except:
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment