Commit bb15f8c9 authored by HERBERT Ryan's avatar HERBERT Ryan Committed by Mikaël Salson

Add patient/run group list reduced

Reduced the group list when adding a patient or run to include only the
user's personal group and parents of the user's other groups
parent b90f54d7
......@@ -255,12 +255,21 @@ def add():
if (auth.is_admin()):
groups = db(db.auth_group).select(db.auth_group.id, db.auth_group.role)
else:
groups = auth.get_user_groups()
master_group = auth.user_group()
for row in groups:
if row.role == 'Lille':
master_group = row.id
return dict(message=T('add patient'), groups=groups, master_group=master_group)
groups = [{'name': 'Personnal Group', 'id': auth.user_group()}]
group_list = auth.get_user_group_parents()
max_elements = 0
max_group = auth.user_group()
for group in group_list:
groups.append({'id': group.id, 'name': group.role})
elements = db(
(db.auth_permission.group_id == group.id) &
(db.auth_permission.table_name.belongs('patient', 'run', 'sample_set')) &
(db.auth_permission.record_id > 0)
).count()
if (elements > max_elements):
max_elements = elements
max_group = group.id
return dict(message=T('add patient'), groups=groups, master_group=max_group)
else :
res = {"message": ACCESS_DENIED}
log.error(res)
......
......@@ -181,15 +181,24 @@ def add():
if (auth.is_admin()):
groups = db(db.auth_group).select(db.auth_group.id, db.auth_group.role)
else:
groups = auth.get_user_groups()
master_group = auth.user_group()
for row in groups:
if row.role == 'Lille':
master_group = row.id
groups = [{'name': 'Personnal Group', 'id': auth.user_group()}]
group_list = auth.get_user_group_parents()
max_elements = 0
max_group = auth.user_group()
for group in group_list:
groups.append({'id': group.id, 'name': group.role})
elements = db(
(db.auth_permission.group_id == group.id) &
(db.auth_permission.table_name.belongs('patient', 'run', 'sample_set')) &
(db.auth_permission.record_id > 0)
).count()
if (elements > max_elements):
max_elements = elements
max_group = group.id
return dict(message=T('add run'),
sequencer_list = sequencer_list,
pcr_list = pcr_list, groups=groups, master_group=master_group)
pcr_list = pcr_list, groups=groups, master_group=max_group)
else :
res = {"message": ACCESS_DENIED}
log.error(res)
......
......@@ -11,7 +11,7 @@
<tr class='devel-mode'>
<td><label for="patient_group" id="patient_group__label">Owner Group: </label></td>
<td>
{{= SELECT(*[OPTION(g.role, _value=g.id) for g in groups], _name="patient_group", _value=master_group, value=master_group) }}
{{= SELECT(*[OPTION(g['name'], _value=g['id']) for g in groups], _name="patient_group", _value=master_group, value=master_group) }}
</td>
<td></td>
</tr>
......
......@@ -21,7 +21,7 @@
<tr class='devel-mode'>
<td><label for="run_group" id="run_group__label">Owner Group: </label></td>
<td>
{{= SELECT(*[OPTION(g.role, _value=g.id) for g in groups], _name="run_group", _value=master_group, value=master_group) }}
{{= SELECT(*[OPTION(g['name'], _value=g['id']) for g in groups], _name="run_group", _value=master_group, value=master_group) }}
</td>
<td></td>
</tr>
......
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