Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit d7e711a1 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

Merge branch 'feature-s/4733-sampleSet-based-permissions' into 'dev'

Feature s/4733 sample set based permissions

Closes #4733

See merge request !938
parents 10e8e9be 6b87a0dd
Pipeline #236564 passed with stages
in 14 minutes and 32 seconds
......@@ -1084,7 +1084,7 @@ def permission():
row.perms = ', '.join(map(lambda x: x.name, permissions))
row.parent_access = ', '.join(str(value) for value in auth.get_access_groups(db[stype], request.vars['id'], group=row.id))
row.read = auth.get_group_access(sample_set.sample_type, data.id, row.id)
row.read = auth.get_group_access("sample_set", request.vars["id"] , row.id)
log.info("load permission page for sample_set (%s)" % request.vars["id"],
extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': "sample_set"})
......@@ -1102,7 +1102,6 @@ def change_permission():
ssid = request.vars["sample_set_id"]
sample_set = db.sample_set[ssid]
sample_type = sample_set.sample_type
data_id = db(db[sample_type].sample_set_id == ssid).select().first().id
error = ""
if request.vars["group_id"] == "" :
......@@ -1111,14 +1110,14 @@ def change_permission():
error += "missing sample_set_id, "
if error=="":
if auth.get_group_access(sample_type,
data_id,
if auth.get_group_access("sample_set",
ssid,
int(request.vars["group_id"])):
auth.del_permission(request.vars["group_id"], PermissionEnum.access.value, db[sample_type], data_id)
auth.del_permission(request.vars["group_id"], PermissionEnum.access.value, db["sample_set"], ssid)
res = {"message" : "access '%s' deleted to '%s'" % (PermissionEnum.access.value, db.auth_group[request.vars["group_id"]].role)}
else :
auth.add_permission(request.vars["group_id"], PermissionEnum.access.value, db[sample_type], data_id)
auth.add_permission(request.vars["group_id"], PermissionEnum.access.value, db["sample_set"], ssid)
res = {"message" : "access '%s' granted to '%s'" % (PermissionEnum.access.value, db.auth_group[request.vars["group_id"]].role)}
log.info(res, extra={'user_id': auth.user.id, 'record_id': request.vars['sample_set_id'], 'table_name': 'sample_set'})
......
......@@ -61,16 +61,14 @@ class Sample_setController(unittest.TestCase):
def test2ChangePermission(self):
patient = db.patient[permission_patient]
sample_set_id = patient.sample_set_id
request.vars["sample_set_id"] = sample_set_id
request.vars["group_id"] = fake_group_id
request.vars["sample_set_id"] = permission_sample_set
request.vars["group_id"] = permission_group_id
resp = change_permission()
self.assertFalse(auth.get_group_access('patient', patient.id, fake_group_id), "fail to remove permission")
self.assertFalse(auth.get_group_access('sample_set', permission_sample_set, permission_group_id), "fail to remove permission")
resp = change_permission()
self.assertTrue(auth.get_group_access('patient', patient.id, fake_group_id), "fail to add permission")
self.assertTrue(auth.get_group_access('sample_set', permission_sample_set, permission_group_id), "fail to add permission")
def testForm(self):
request.vars["type"] = "patient"
......
......@@ -148,16 +148,17 @@ db.auth_permission.insert(group_id = fake_group_id,
)
# for permission testing
permission_group_id = db.auth_group.insert(role="test_group_perm", description="test group perm")
permission_sample_set = db.sample_set.insert(sample_type="patient")
permission_patient = db.patient.insert(first_name="foo",
last_name="bar",
info="permission",
sample_set_id=permission_sample_set)
db.auth_permission.insert(group_id = fake_group_id,
db.auth_permission.insert(group_id = permission_group_id,
name = PermissionEnum.access.value,
table_name = "patient",
record_id = permission_patient
table_name = "sample_set",
record_id = permission_sample_set
)
fake_run_id = db.run.insert(name="foobar",
......@@ -169,8 +170,8 @@ fake_run_id = db.run.insert(name="foobar",
db.auth_permission.insert(group_id = fake_group_id,
name = PermissionEnum.access.value,
table_name = 'run',
record_id = fake_run_id)
table_name = 'sample_set',
record_id = fake_sample_set_id)
# and a fake file for this patient
fake_file_id = db.sequence_file.insert(sampling_date="1903-02-02",
......
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