def harvest_object_show(context, data_dict): model = context['model'] user = context.get('user') obj = get_obj_object(context, data_dict) if context.get('ignore_auth', False): return {'success': True} if not user: return { 'success': False, 'msg': _('Non-logged in users are not authorized to see harvest objects') } if Authorizer().is_sysadmin(user): return {'success': True} user_obj = User.get(user) if not user_obj or not obj.source.publisher_id in [ g.id for g in user_obj.get_groups(u'publisher') ]: return { 'success': False, 'msg': _('User %s not authorized to read harvest object %s') % (str(user), obj.id) } else: return {'success': True}
def harvest_object_show(context,data_dict): model = context['model'] user = context.get('user') obj = get_obj_object(context,data_dict) # Check the user is admin/editor for the publisher - i.e. has # update_dataset permission check1 = ckan.new_authz.has_user_permission_for_group_or_org( obj.source.publisher_id, user, 'update_dataset' ) if not check1: return {'success': False, 'msg': _('User %s not authorized to read harvest object %s') % (str(user), obj.id)} else: return {'success': True}
def harvest_object_show(context, data_dict): model = context['model'] user = context.get('user') obj = get_obj_object(context, data_dict) # Check the user is admin/editor for the publisher - i.e. has # update_dataset permission check1 = ckan.new_authz.has_user_permission_for_group_or_org( obj.source.publisher_id, user, 'update_dataset') if not check1: return { 'success': False, 'msg': _('User %s not authorized to read harvest object %s') % (str(user), obj.id) } else: return {'success': True}
def harvest_object_show(context,data_dict): model = context['model'] user = context.get('user') obj = get_obj_object(context,data_dict) if context.get('ignore_auth', False): return {'success': True} if not user: return {'success': False, 'msg': _('Non-logged in users are not authorized to see harvest objects')} if Authorizer().is_sysadmin(user): return {'success': True} user_obj = User.get(user) if not user_obj or not obj.source.publisher_id in [g.id for g in user_obj.get_groups(u'publisher')]: return {'success': False, 'msg': _('User %s not authorized to read harvest object %s') % (str(user),obj.id)} else: return {'success': True}