Commit b0dc4889 authored by Ryan Herbert's avatar Ryan Herbert Committed by Mikaël Salson

fix admin permissions in sample_set list

parent addb8ffa
......@@ -227,6 +227,16 @@ def all():
f = time.time()
slist = SampleSetList(helper, page, step, tags, search)
log.debug("list loaded (%.3fs)" % (time.time() - f))
mid = time.time()
set_ids = set([s.sample_set_id for s in slist.result])
admin_permissions = [s.id for s in db(auth.vidjil_accessible_query(PermissionEnum.admin.value, db.sample_set)).select(db.sample_set.id)]
admin_permissions = list(set(admin_permissions) & set_ids)
log.debug("permission load (%.3fs)" % (time.time() - mid))
# failsafe if filtered display all results
step = len(slist) if step is None else step
page = 0 if page is None else page
......@@ -254,6 +264,7 @@ def all():
fields = fields,
helper = helper,
group_ids = group_ids,
admin_permissions = admin_permissions,
isAdmin = isAdmin,
reverse = reverse,
step = step,
......
......@@ -23,13 +23,6 @@ class SampleSetList():
db.auth_group.on(
(db.generic_perm.group_id == db.auth_group.id)),
db.auth_membership.on(db.auth_group.id == db.auth_membership.group_id),
db.auth_permission.with_alias('anon_permission').on(
(db.anon_permission.table_name == self.type) &
(db.anon_permission.name == "anon") &
(db.anon_permission.record_id == s_table.id) &
(db.auth_group.id == db.anon_permission.group_id ) &
(db.auth_membership.user_id == auth.user_id) &
(db.auth_membership.group_id == db.auth_group.id)),
db.auth_user.on(
db.auth_user.id == s_table.creator)
]
......@@ -64,7 +57,6 @@ class SampleSetList():
s_table.info.with_alias('info'),
db.auth_user.last_name.with_alias('creator'),
group_file_sizes,
db.anon_permission.name.with_alias('has_permission'),
group_configs,
group_config_ids,
group_config_names,
......
......@@ -49,7 +49,7 @@
{{ total_file_count += file_count ; total_size += size }}
{{if isAdmin:}} <td onclick="db.call('sample_set/permission', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-key" title="set permissions"></i> </td> {{else:}} <td></td> {{pass}}
{{if data.has_permission:}}
{{if data.sample_set_id in admin_permissions:}}
<td onclick="db.call('sample_set/form', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-pencil-2" title="{{='edit %s information' % 'sample_set'}}"></i> </td>
<td onclick="db.call('sample_set/confirm', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-erase" title="{{='delete %s' % helper.get_type_display()}}"></i> </td>
{{else:}} <td></td><td></td>{{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