From 7abf9c617971bc548f84d30ca1045962d7e7e9d2 Mon Sep 17 00:00:00 2001 From: Toby Date: Thu, 21 Jun 2012 14:14:01 +0100 Subject: [PATCH] [#2375] change auth function for create_resource so can add as non user --- ckan/logic/auth/create.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ckan/logic/auth/create.py b/ckan/logic/auth/create.py index d62faafe49d..84fc6e87dff 100644 --- a/ckan/logic/auth/create.py +++ b/ckan/logic/auth/create.py @@ -32,12 +32,17 @@ def resource_create(context, data_dict): # check users eligibility to add resource to package here. model = context['model'] user = context['user'] - userobj = model.User.get(user) + check1 = logic.check_access_old(model.System(), model.Action.PACKAGE_CREATE, context) - if userobj: - return {'success': True} - return {'success': False, - 'msg': _('You must be logged in to create a resource')} + if not check1: + return {'success': False, 'msg': _('User %s not authorized to create packages') % str(user)} + else: + + check2 = _check_group_auth(context,data_dict) + if not check2: + return {'success': False, 'msg': _('User %s not authorized to edit these groups') % str(user)} + + return {'success': True} def package_relationship_create(context, data_dict): model = context['model']