Skip to content

Commit

Permalink
[#646] Add type. Fix username param
Browse files Browse the repository at this point in the history
* Add type to all the function parameters.
* Refer to function with `func`.
* Fix _group_or_org_member_delete to use username instead of user_id
  so it's consistent with the other functions.
  • Loading branch information
nigelbabu committed Jun 17, 2013
1 parent 686bbe9 commit 4ac43d1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
14 changes: 10 additions & 4 deletions ckan/logic/action/create.py
Expand Up @@ -1140,10 +1140,13 @@ def group_member_create(context, data_dict):
You must be authorized to edit the group.
:param id: the id or name of the group
:param username: name or id of the user to be made member of the group
:param id: the id or name of the group.
:type id: string
:param username: name or id of the user to be made member of the group.
:type username: string
:param role: role of the user in the group. One of ``member``, ``editor``,
or ``admin``.
:type role: string
:returns: the newly created (or updated) membership
:rtype: dictionary
Expand All @@ -1156,11 +1159,14 @@ def organization_member_create(context, data_dict):
You must be authorized to edit the organization.
:param id: the id or name of the organization
:param id: the id or name of the organization.
:type id: string
:param username: name or id of the user to be made member of the
organization
organization.
:type username: string
:param role: role of the user in the organization. One of ``member``,
``editor``, or ``admin``.
:type role: string
:returns: the newly created (or updated) membership
:rtype: dictionary
Expand Down
18 changes: 11 additions & 7 deletions ckan/logic/action/delete.py
Expand Up @@ -418,7 +418,7 @@ def _group_or_org_member_delete(context, data_dict=None):

group_id = data_dict.get('id')
group = model.Group.get(group_id)
user_id = data_dict.get('user_id')
user_id = data_dict.get('username')
member_dict = {
'id': group.id,
'object': user_id,
Expand All @@ -433,23 +433,27 @@ def _group_or_org_member_delete(context, data_dict=None):


def group_member_delete(context, data_dict=None):
'''Remove a user from a group
'''Remove a user from a group.
You must be authorized to edit the group.
:param id: the id or name of the group
:param username: name or id of the user to be removed
:param id: the id or name of the group.
:type id: string
:param username: name or id of the user to be removed.
:type username: string
'''
return _group_or_org_member_delete(context, data_dict)

def organization_member_delete(context, data_dict=None):
'''Remove a user from a organization
'''Remove a user from a organization.
You must be authorized to edit the organization.
:param id: the id or name of the organization
:param username: name or id of the user to be removed
:param id: the id or name of the organization.
:type id: string
:param username: name or id of the user to be removed.
:type username: string
'''
return _group_or_org_member_delete(context, data_dict)
Expand Down
11 changes: 7 additions & 4 deletions ckan/logic/action/get.py
Expand Up @@ -658,10 +658,13 @@ def user_list(context, data_dict):
def package_relationships_list(context, data_dict):
'''Return a dataset (package)'s relationships.
:param id: the id or name of the first package
:param id2: the id or name of the second package
:param rel: relationship as string see ``package_relationship_create()``
for the relationship types (optional)
:param id: the id or name of the first package.
:type id: string
:param id2: the id or name of the second package.
:type id: string
:param rel: relationship as string see
:func:`ckan.logic.action.create.package_relationship_create()` for the
relationship types (optional).
:rtype: list of dictionaries
Expand Down

0 comments on commit 4ac43d1

Please sign in to comment.