2013-01-09 18:26:48 +01:00
|
|
|
from ckan.plugins import toolkit as pt
|
2012-03-01 13:02:16 +01:00
|
|
|
|
2013-01-09 18:26:48 +01:00
|
|
|
|
|
|
|
def harvest_source_update(context, data_dict):
|
|
|
|
'''
|
|
|
|
Authorization check for harvest source deletion
|
|
|
|
|
|
|
|
It forwards the checks to package_delete, which will check for
|
|
|
|
organization membership, whether if sysadmin, etc according to the
|
|
|
|
instance configuration.
|
|
|
|
'''
|
|
|
|
model = context.get('model')
|
2012-03-01 13:02:16 +01:00
|
|
|
user = context.get('user')
|
2013-01-09 18:26:48 +01:00
|
|
|
source_id = data_dict['id']
|
2012-03-01 13:02:16 +01:00
|
|
|
|
2013-01-09 18:26:48 +01:00
|
|
|
pkg = model.Package.get(source_id)
|
|
|
|
if not pkg:
|
|
|
|
raise pt.ObjectNotFound(pt._('Harvest source not found'))
|
2012-03-01 13:02:16 +01:00
|
|
|
|
2013-01-09 18:26:48 +01:00
|
|
|
context['package'] = pkg
|
|
|
|
|
|
|
|
try:
|
|
|
|
pt.check_access('package_delete', context, data_dict)
|
|
|
|
return {'success': True}
|
2013-01-16 13:56:58 +01:00
|
|
|
except pt.NotAuthorized:
|
2013-01-09 18:26:48 +01:00
|
|
|
return {'success': False,
|
|
|
|
'msg': pt._('User {0} not authorized to delete harvest source {1}').format(user, source_id)}
|