Skip to content

Commit

Permalink
Ckan test helper - minor core fixes needed
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Apr 10, 2013
1 parent ca64b63 commit b957645
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
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)
3 changes: 2 additions & 1 deletion ckanext/example_itemplatehelpers/plugin.py
Expand Up @@ -5,7 +5,8 @@ def example_helper():
'''An example template helper function.'''

# Just return some example text.
return 'This is some example text.'
html = '<span class="example_itemplate">This is some example text.</span>'
return plugins.toolkit.literal(html)

class ExampleITemplateHelpersPlugin(plugins.SingletonPlugin):
'''An example that shows how to use the ITemplateHelpers plugin interface.
Expand Down

0 comments on commit b957645

Please sign in to comment.