Skip to content

Commit

Permalink
Allow the author of a resource (revision) to call task_status_update …
Browse files Browse the repository at this point in the history
…and not just sysadm
  • Loading branch information
rossjones committed Jan 9, 2012
1 parent a4013bc commit 69792aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ckan/controllers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def upload_handle(self):
abort(400, "No file stream.")
del params['file']
params['filename-original'] = stream.filename
params['_owner'] = c.userobj.name if c.userobj else ""
#params['_owner'] = c.userobj.name if c.userobj else ""
params['uploaded-by'] = c.userobj.name if c.userobj else ""

self.ofs.put_stream(bucket_id, label, stream.file, params)
Expand Down
11 changes: 10 additions & 1 deletion ckan/logic/auth/update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ckan.logic import check_access_old, NotFound
from ckan.logic.auth import get_package_object, get_group_object, get_authorization_group_object, \
from ckan.logic.auth import get_package_object, get_resource_object, get_group_object, get_authorization_group_object, \
get_user_object, get_resource_object
from ckan.logic.auth.create import check_group_auth, package_relationship_create
from ckan.authz import Authorizer
Expand Down Expand Up @@ -153,6 +153,15 @@ def task_status_update(context, data_dict):
if 'ignore_auth' in context and context['ignore_auth']:
return {'success': True}

try:
resource = get_resource_object(context, data_dict)
except:
id = data_dict.get('entity_id',None)
resource = model.Resource.get(id)

if resource.revision.author == user:
return {'success': True}

authorized = Authorizer().is_sysadmin(unicode(user))
if not authorized:
return {'success': False, 'msg': _('User %s not authorized to update task_status table') % str(user)}
Expand Down

0 comments on commit 69792aa

Please sign in to comment.