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

[WIP] for comment: Ckan test helper #748

Closed
wants to merge 2 commits into from
Closed
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 ckan/logic/action/create.py
Expand Up @@ -773,7 +773,7 @@ def user_create(context, data_dict):

activity_create_context = {
'model': model,
'user': context['user'],
'user': context.get('user'),
'defer_commit': True,
'session': session
}
Expand Down
10 changes: 5 additions & 5 deletions ckan/logic/auth/create.py
Expand Up @@ -5,8 +5,8 @@


def package_create(context, data_dict=None):
user = context['user']
if not new_authz.auth_is_registered_user():
user = context.get('user')
if not user:
check1 = new_authz.check_config_permission('anon_create_dataset')
else:
check1 = new_authz.check_config_permission('create_dataset_if_not_in_organization') \
Expand All @@ -23,8 +23,8 @@ def package_create(context, data_dict=None):
return {'success': True}

def file_upload(context, data_dict=None):
user = context['user']
if not new_authz.auth_is_registered_user():
user = context.get('user')
if not user:
return {'success': False, 'msg': _('User %s not authorized to create packages') % user}
return {'success': True}

Expand Down Expand Up @@ -96,10 +96,10 @@ def rating_create(context, data_dict):
return {'success': True}

def user_create(context, data_dict=None):
user = context['user']

if ('api_version' in context
and not new_authz.check_config_permission('create_user_via_api')):
user = context['user']
return {'success': False, 'msg': _('User %s not authorized to create users') % user}
else:
return {'success': True}
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/auth/update.py
Expand Up @@ -23,7 +23,7 @@ def package_update(context, data_dict):
)
else:
# If dataset is not owned then we can edit if config permissions allow
if new_authz.auth_is_registered_user():
if user:
check1 = new_authz.check_config_permission(
'create_dataset_if_not_in_organization')
else:
Expand Down
10 changes: 0 additions & 10 deletions ckan/new_authz.py
Expand Up @@ -292,13 +292,3 @@ def check_config_permission(permission):
if permission in CONFIG_PERMISSIONS:
return CONFIG_PERMISSIONS[permission]
return False



def auth_is_registered_user():
''' Do we have a logged in user '''
try:
context_user = c.user
except TypeError:
context_user = None
return bool(context_user)