Skip to content

Commit

Permalink
[ec] Creation of datasets within joined organizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
icmurray committed Oct 25, 2012
1 parent 05505a5 commit bd95619
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ckan/logic/auth/publisher/create.py
Expand Up @@ -14,10 +14,26 @@ def package_create(context, data_dict=None):
user = context['user']
userobj = model.User.get( user )

if Authorizer().is_sysadmin(unicode(user)):
return { 'success': True }

if userobj:
return {'success': True}
user_groups = [ g.name for g in userobj.get_groups('organization') ]
if data_dict and data_dict.get('published_by', None) in user_groups:
return {'success': True}
elif data_dict is None and user_groups:
# In this case, a package isn't being created. This authorization
# function is being used to determine whether the User could
# potentially created datasets. This is the case only if the User
# belongs to at least one organization.
return {'success': True}
else:
return {'success': False,
'msg': _('User %s not authorized to edit packages in these groups') % str(user)
}

return {'success': False, 'msg': 'You must be logged in to create a package'}
else:
return {'success': False, 'msg': 'You must be logged in to create a package'}


def related_create(context, data_dict=None):
Expand Down

0 comments on commit bd95619

Please sign in to comment.