Skip to content

Commit

Permalink
[#1060] Action function updates so using correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jun 28, 2013
1 parent a84aa81 commit 7cef08d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions ckan/logic/action/create.py
Expand Up @@ -703,6 +703,7 @@ def organization_create(context, data_dict):
return _group_or_org_create(context, data_dict, is_org=True)


@logic.auth_audit_exempt
def rating_create(context, data_dict):
'''Rate a dataset (package).
Expand Down
18 changes: 9 additions & 9 deletions ckan/logic/action/get.py
Expand Up @@ -810,6 +810,8 @@ def resource_status_show(context, data_dict):

return result_list


@logic.auth_audit_exempt
def revision_show(context, data_dict):
'''Return the details of a revision.
Expand Down Expand Up @@ -992,7 +994,7 @@ def user_show(context, data_dict):

revisions_list = []
for revision in revisions_q.limit(20).all():
revision_dict = revision_show(context,{'id':revision.id})
revision_dict = logic.get_action('revision_show')(context,{'id':revision.id})
revision_dict['state'] = revision.state
revisions_list.append(revision_dict)
user_dict['activity'] = revisions_list
Expand All @@ -1004,7 +1006,7 @@ def user_show(context, data_dict):

for dataset in dataset_q:
try:
dataset_dict = package_show(context, {'id': dataset.id})
dataset_dict = logic.get_action('package_show')(context, {'id': dataset.id})
except logic.NotAuthorized:
continue
user_dict['datasets'].append(dataset_dict)
Expand Down Expand Up @@ -2537,9 +2539,10 @@ def display_name(followee):

# Get the followed objects.
# TODO: Catch exceptions raised by these *_followee_list() functions?
# FIXME should we be changing the context like this it seems dangerous
followee_dicts = []
context['skip_validation'] = True
context['skip_authorization'] = True
context['ignore_auth'] = True
for followee_list_function, followee_type in (
(user_followee_list, 'user'),
(dataset_followee_list, 'dataset'),
Expand Down Expand Up @@ -2574,8 +2577,7 @@ def user_followee_list(context, data_dict):
:rtype: list of dictionaries
'''
if not context.get('skip_authorization'):
_check_access('user_followee_list', context, data_dict)
_check_access('user_followee_list', context, data_dict)

if not context.get('skip_validation'):
schema = context.get('schema') or (
Expand Down Expand Up @@ -2605,8 +2607,7 @@ def dataset_followee_list(context, data_dict):
:rtype: list of dictionaries
'''
if not context.get('skip_authorization'):
_check_access('dataset_followee_list', context, data_dict)
_check_access('dataset_followee_list', context, data_dict)

if not context.get('skip_validation'):
schema = context.get('schema') or (
Expand Down Expand Up @@ -2637,8 +2638,7 @@ def group_followee_list(context, data_dict):
:rtype: list of dictionaries
'''
if not context.get('skip_authorization'):
_check_access('group_followee_list', context, data_dict)
_check_access('group_followee_list', context, data_dict)

if not context.get('skip_validation'):
schema = context.get('schema',
Expand Down
3 changes: 3 additions & 0 deletions ckan/logic/auth/get.py
Expand Up @@ -252,14 +252,17 @@ def followee_list(context, data_dict):
return _followee_list(context, data_dict)


@logic.auth_audit_exempt
def user_followee_list(context, data_dict):
return _followee_list(context, data_dict)


@logic.auth_audit_exempt
def dataset_followee_list(context, data_dict):
return _followee_list(context, data_dict)


@logic.auth_audit_exempt
def group_followee_list(context, data_dict):
return _followee_list(context, data_dict)

Expand Down

0 comments on commit 7cef08d

Please sign in to comment.