[ckan-changes] [okfn/ckan] 3f97ad: [bug] Fix to extraneous fields in context for memb...
GitHub
noreply at github.com
Thu May 3 16:07:24 UTC 2012
Branch: refs/heads/release-v1.7
Home: https://github.com/okfn/ckan
Commit: 3f97ad65195828bc26e94944ce01deca31e16a88
https://github.com/okfn/ckan/commit/3f97ad65195828bc26e94944ce01deca31e16a88
Author: Ross Jones <rossdjones at gmail.com>
Date: 2012-05-03 (Thu, 03 May 2012)
Changed paths:
M ckan/logic/action/create.py
M ckan/logic/action/delete.py
M ckan/logic/action/get.py
M ckan/tests/logic/test_member.py
Log Message:
-----------
[bug] Fix to extraneous fields in context for member api
diff --git a/ckan/logic/action/create.py b/ckan/logic/action/create.py
index aee73a3..e6be5a3 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 c806a51..4dd5c70 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 b2afe94..b0cb640 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 04af59d..3d6294e 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 }
================================================================
More information about the ckan-changes
mailing list