Commit 9f44ea1a authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-s/auth.can_modify_subset' into 'dev'

models/VidjilAuth: add can_modify_subset(sampleset_type, subset_id)

See merge request !562
parents 95ab932a 8db87b52
Pipeline #110685 failed with stages
in 6 minutes and 49 seconds
......@@ -281,6 +281,12 @@ class VidjilAuth(Auth):
and (self.get_permission(PermissionEnum.admin.value, 'run', run_id, user=user)\
or self.is_admin(user))
def can_modify_subset(self, type, subset_id, user = None) :
exists = self.exists(type, subset_id)
return exists\
and (self.get_permission(PermissionEnum.admin.value, type, subset_id, user=user)\
or self.is_admin(user))
def can_modify_sample_set(self, sample_set_id, user = None) :
sample_set = db.sample_set[sample_set_id]
if sample_set is None:
......
......@@ -43,16 +43,17 @@ class SampleSetList():
key = row[type]
else:
key = row
self.elements[key.id] = key
self.elements[key.id].file_count = 0
self.elements[key.id].size = 0
self.elements[key.id].conf_list = []
self.elements[key.id].conf_id_list = [-1]
self.elements[key.id].most_used_conf = ""
self.elements[key.id].groups = ""
self.elements[key.id].group_list = []
self.elements[key.id].has_permission = auth.can_modify_sample_set(key.sample_set_id)
self.elements[key.id].anon_allowed = auth.can_view_info(type, key.id)
self.elements[key.sample_set_id] = key
self.elements[key.sample_set_id].file_count = 0
self.elements[key.sample_set_id].size = 0
self.elements[key.sample_set_id].conf_list = []
self.elements[key.sample_set_id].conf_id_list = [-1]
self.elements[key.sample_set_id].most_used_conf = ""
self.elements[key.sample_set_id].groups = ""
self.elements[key.sample_set_id].group_list = []
#self.elements[key.id].has_permission = auth.can_modify_sample_set(key.sample_set_id)
self.elements[key.sample_set_id].has_permission = auth.can_modify_subset(type, key.id)
self.elements[key.sample_set_id].anon_allowed = auth.can_view_info(type, key.id)
self.element_ids = self.elements.keys()
......
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