Skip to content

Commit

Permalink
change auth to resource update
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Jul 29, 2012
1 parent 981cf79 commit ac3d261
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions ckanext/datastore/logic/action/create.py
Expand Up @@ -34,6 +34,12 @@ def datastore_create(context, data_dict):

_get_or_bust(data_dict, 'resource_id')

#schema = ckanext.datastore.logic.schema.default_datastore_create_schema()
#data, errors = _validate(data_dict, schema, context)
#if errors:
# model.Session.rollback()
# raise p.toolkit.ValidationError(errors)

data_dict['connection_url'] = pylons.config['ckan.datastore_write_url']

return db.create(context, data_dict)
14 changes: 7 additions & 7 deletions ckanext/datastore/logic/auth/create.py
@@ -1,15 +1,15 @@
import ckan.plugins as p
import ckan.logic as logic
from ckan.lib.base import _

_check_access = logic.check_access


def datastore_create(context, data_dict):
model = context['model']
user = context['user']
userobj = model.User.get(user)
data_dict['id'] = data_dict.get('resource_id')

authorized = _check_access('resource_update', context, data_dict)

if userobj:
if not authorized:
return {'success': False, 'msg': _('User %s not authorized to read edit %s') % (str(user), resource.id)}
else:
return {'success': True}
return {'success': False,
'msg': p.toolkit._('You must be logged in to use the datastore.')}

0 comments on commit ac3d261

Please sign in to comment.