Commit ec308f16 authored by Ryan Herbert's avatar Ryan Herbert
Browse files

file.py split group_ids for autocomplete into two

We now have group_ids which are the groups for which the user can create
sample_sets, used for tag autocompletion. And upload_group_ids which
represent sets for which the user can upload files, used for
autocompleting sets when uploading files
parent 6a37031b
......@@ -183,7 +183,8 @@ def form():
myfile = {}
myfile['sets'] = get_set_list(relevant_ids, helpers)
group_ids = [int(gid) for gid in group_ids]
upload_group_ids = [int(gid) for gid in get_upload_group_ids(auth)]
group_ids = [int(g['id']) for g in get_default_creation_group(auth)[0]]
pre_process_list = get_pre_process_list()
source_module_active = hasattr(defs, 'FILE_SOURCE') and hasattr(defs, 'FILE_TYPES')
......@@ -192,7 +193,8 @@ def form():
files = [myfile],
sample_type = sample_type,
source_module_active = source_module_active,
group_ids = group_ids)
group_ids = group_ids,
upload_group_ids = upload_group_ids)
#TODO check data
def submit():
......@@ -274,13 +276,17 @@ def submit():
else:
source_module_active = hasattr(defs, 'FILE_SOURCE') and hasattr(defs, 'FILE_TYPES')
response.view = 'file/form.html'
upload_group_ids = [int(gid) for gid in get_upload_group_ids(auth)]
group_ids = [int(g['id']) for g in get_default_creation_group(auth)[0]]
pre_process_list = get_pre_process_list()
return dict(message=T("an error occured"),
pre_process_list = pre_process_list,
sets = sets,
files = data['file'],
sample_type = sample_type,
source_module_active = source_module_active,
group_ids = group_ids)
group_ids = group_ids,
upload_group_ids = upload_group_ids)
def upload():
session.forget(response)
......
......@@ -34,6 +34,20 @@ def get_default_creation_group(auth):
groups = [{'id': group_dict[key]['id'], 'name': group_dict[key]['name']} for key in group_dict]
return (groups, max_group)
def get_upload_group_ids(auth):
db = auth.db
group_ids = []
group_list = get_group_list()
for group in group_list:
if (auth.is_admin()
or auth.has_permission(PermissionEnum.upload.value, 'sample_set', 0, group_id = group.id)):
parents = auth.get_group_parent(group.id)
if (len(parents) > 0):
group_ids.append(parents[0].id)
else:
group_ids.append(group.id)
return group_ids
def get_involved_groups():
'''
Returns all the groups that are related to the user. This includes all groups
......
......@@ -71,7 +71,7 @@
new Tokeniser().setup(this, document.getElementById('set_div_{{=i}}'), document.getElementById('file_set_list_{{=i}}'));"
data-needs-atwho="true"
data-needs-tokeniser="true"
data-group-ids="{{=group_ids}}"
data-group-ids="{{=upload_group_ids}}"
data-keys='["generic", "patient", "run"]'
type="text">
</div>
......
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