Skip to content

Commit

Permalink
Temporarily removed object list code for performance reasons (introdu…
Browse files Browse the repository at this point in the history
…ced for #478).
  • Loading branch information
ngehlenborg committed Jun 26, 2015
1 parent 9146944 commit a1d98e8
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions refinery/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,9 @@ class Meta:
'children', 'type', 'analysis_uuid', 'subanalysis'
]
filtering = {
'uuid': ALL, 'study': ALL_WITH_RELATIONS,
'assay': ALL_WITH_RELATIONS
'uuid': ALL,
#'study': ALL_WITH_RELATIONS,
#'assay': ALL_WITH_RELATIONS
}

def prepend_urls(self):
Expand Down Expand Up @@ -603,30 +604,31 @@ def dehydrate(self, bundle):
bundle.data['file_import_status'] = file_item.get_import_status()
return bundle

def get_object_list(self, request):
"""Get all nodes that are available to the current user (via data set)
Temp workaround due to Node being not Ownable
"""
user = request.user
perm = 'read_%s' % DataSet._meta.module_name
if (user.is_authenticated()):
allowed_datasets = get_objects_for_user(user, perm, DataSet)
else:
allowed_datasets = get_objects_for_group(ExtendedGroup.objects.public_group(), perm, DataSet)
# get a list of node UUIDs that belong to all datasets available to the
# current user
all_allowed_studies = []
for dataset in allowed_datasets:
dataset_studies = dataset.get_investigation().study_set.all()
all_allowed_studies.extend([study for study in dataset_studies])
allowed_nodes = []
for study in all_allowed_studies:
allowed_nodes.extend(study.node_set.all().values('uuid'))
# filter nodes using that list
return super(NodeResource, self).get_object_list(request).filter(
uuid__in=[node['uuid'] for node in allowed_nodes])

# def get_object_list(self, request):
# """
# Temporarily removed for performance reasons (and not required without authorization)
# Get all nodes that are available to the current user (via data set)
# Temp workaround due to Node being not Ownable
#
# """
# user = request.user
# perm = 'read_%s' % DataSet._meta.module_name
# if (user.is_authenticated()):
# allowed_datasets = get_objects_for_user(user, perm, DataSet)
# else:
# allowed_datasets = get_objects_for_group(ExtendedGroup.objects.public_group(), perm, DataSet)
# # get a list of node UUIDs that belong to all datasets available to the
# # current user
# all_allowed_studies = []
# for dataset in allowed_datasets:
# dataset_studies = dataset.get_investigation().study_set.all()
# all_allowed_studies.extend([study for study in dataset_studies])
# allowed_nodes = []
# for study in all_allowed_studies:
# allowed_nodes.extend(study.node_set.all().values('uuid'))
# # filter nodes using that list
# return super(NodeResource, self).get_object_list(request).filter(
# uuid__in=[node['uuid'] for node in allowed_nodes])

class NodeSetResource(ModelResource):
# https://github.com/toastdriven/django-tastypie/pull/538
Expand Down

0 comments on commit a1d98e8

Please sign in to comment.