Skip to content

Commit

Permalink
[bug] Fix to extraneous fields in context for member api
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed May 3, 2012
1 parent a2fd245 commit e2af388
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
5 changes: 3 additions & 2 deletions ckan/logic/action/create.py
Expand Up @@ -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
Expand Down Expand Up @@ -196,15 +197,14 @@ 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
capacity - The capacity with which to add this object
"""
model = context['model']
user = context['user']
group = context['group']

rev = model.repo.new_revision()
rev.author = user
Expand All @@ -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']
Expand Down
5 changes: 2 additions & 3 deletions ckan/logic/action/delete.py
Expand Up @@ -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']

Expand Down
5 changes: 2 additions & 3 deletions ckan/logic/action/get.py
Expand Up @@ -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)

Expand Down
6 changes: 2 additions & 4 deletions ckan/tests/logic/test_member.py
Expand Up @@ -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 }
Expand Down

0 comments on commit e2af388

Please sign in to comment.