Skip to content

Commit

Permalink
Bug fix for checking the dataset object perms. (#2445)
Browse files Browse the repository at this point in the history
* Bug fix for checking the dataset object perms.

* For analysis get, user needs data set read_meta perms.
  • Loading branch information
jkmarx committed Dec 19, 2017
1 parent d343c89 commit 1ae6f01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion refinery/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ def dehydrate(self, bundle):

def get_object_list(self, request, **kwargs):
user = request.user
perm = 'read_%s' % DataSet._meta.model_name
perm = 'read_meta_%s' % DataSet._meta.model_name
if (user.is_authenticated()):
allowed_datasets = get_objects_for_user(user, perm, DataSet)
else:
Expand Down
11 changes: 10 additions & 1 deletion refinery/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,11 +1005,20 @@ def get_resources_for_user(user, resource_type):
return get_objects_for_user(
user if user.is_authenticated()
else get_anonymous_user(),
which_default_read_perm(resource_type)
which_default_read_perm(resource_type),
accept_global_perms=accept_global_perms(resource_type)
)


def which_default_read_perm(resource_type):
if resource_type == 'dataset':
return 'core.read_meta_dataset'
return 'core.read_%s' % resource_type


# False, accept_global_perms will be ignored, which means that only object
# permissions will be checked.
def accept_global_perms(resource_type):
if resource_type == 'dataset':
return False
return True

0 comments on commit 1ae6f01

Please sign in to comment.