Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for checking the dataset object perms. #2445

Merged
merged 2 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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