diff --git a/ckan/logic/action/create.py b/ckan/logic/action/create.py index aee73a32aa4..e6be5a391eb 100644 --- a/ckan/logic/action/create.py +++ b/ckan/logic/action/create.py @@ -11,6 +11,7 @@ import ckan.lib.dictization.model_dictize as model_dictize import ckan.lib.dictization.model_save as model_save import ckan.lib.navl.dictization_functions +import ckan.logic.auth as auth # FIXME this looks nasty and should be shared better from ckan.logic.action.update import _update_package_relationship @@ -196,7 +197,7 @@ def member_create(context, data_dict=None): user - The name of the current user data_dict: - group - The ID of the group to which we want to add a new object + id - The ID of the group to which we want to add a new object object - The ID of the object being added as a member object_type - The name of the type being added, all lowercase, e.g. package, or user @@ -204,7 +205,6 @@ def member_create(context, data_dict=None): """ model = context['model'] user = context['user'] - group = context['group'] rev = model.repo.new_revision() rev.author = user @@ -213,6 +213,7 @@ def member_create(context, data_dict=None): else: rev.message = _(u'REST API: Create member object %s') % data_dict.get("name", "") + group = model.Group.get(data_dict.get('id', '')) obj_id = data_dict['object'] obj_type = data_dict['object_type'] capacity = data_dict['capacity'] diff --git a/ckan/logic/action/delete.py b/ckan/logic/action/delete.py index c806a5113cd..4dd5c701a4d 100644 --- a/ckan/logic/action/delete.py +++ b/ckan/logic/action/delete.py @@ -90,16 +90,15 @@ def member_delete(context, data_dict=None): user - The name of the current user data_dict: - group - The ID of the group to which we want to remove object + id - The ID of the group from which we want to remove object object - The ID of the object being removed as a member object_type - The name of the type being removed, all lowercase, e.g. package, or user """ model = context['model'] user = context['user'] - group = context['group'] - group_id = data_dict['group'] + group = model.Group.get(data_dict.get('id')) obj_id = data_dict['object'] obj_type = data_dict['object_type'] diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py index b2afe947171..b0cb640802c 100644 --- a/ckan/logic/action/get.py +++ b/ckan/logic/action/get.py @@ -179,16 +179,15 @@ def member_list(context, data_dict=None): user - The name of the current user data_dict: - group - The ID of the group to which we want to list members + id - The ID of the group to which we want to list members object_type - The optional name of the type being added, all lowercase, e.g. package, or user capacity - The optional capacity of objects that we want to retrieve """ model = context['model'] user = context['user'] - group = context['group'] - group_id = data_dict['group'] + group = model.Group.get(data_dict.get('id','')) obj_type = data_dict.get('object_type', None) capacity = data_dict.get('capacity', None) diff --git a/ckan/tests/logic/test_member.py b/ckan/tests/logic/test_member.py index 04af59d53c8..3d6294e2913 100644 --- a/ckan/tests/logic/test_member.py +++ b/ckan/tests/logic/test_member.py @@ -21,14 +21,12 @@ def teardown_class(cls): model.repo.rebuild_db() def _build_context( self, obj, obj_type, capacity='public'): - grp = model.Group.by_name(self.groupname) ctx = { 'model': model, 'session': model.Session, - 'user':self.username, - 'group': grp, + 'user':self.username } dd = { - 'group': grp, + 'id': self.groupname, 'object': obj, 'object_type': obj_type, 'capacity': capacity }