Commit 8db87b52 authored by marc's avatar marc

models/VidjilAuth: add can_modify_subset(sampleset_type, subset_id)

can_modify_sampleset need to make a db request to find the subset type, we should use can_modify_subset if we already know the sampleset type to avoid that
parent 2ef3187e
Pipeline #108612 passed with stages
in 6 minutes and 35 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)
  • ça n'est pas un appel à la BDD ?

  •     def exists(self, object_of_action, object_id):
            if (object_of_action in self.permissions \
                and object_id in self.permissions[object_of_action]):
                return True
            return db[object_of_action][object_id] is not None

    si les permissions sont deja load, exists ne fait pas d'appel a la BDD

    Edited by Mathieu Giraud
  • Oui, mais « si ». C'est le cas ou pas ?

  • c'est bien le cas

    sample_set_list.py:39

            auth.load_permissions(PermissionEnum.admin.value, type)
            auth.load_permissions(PermissionEnum.anon.value, type)
  • ok, merci

Please register or sign in to reply
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