Skip to content

Commit

Permalink
Merge pull request #1172 from okfn/1172-groups-list-use-dictization
Browse files Browse the repository at this point in the history
Auth aware group and org list action functions should return dictized objects
  • Loading branch information
kindly committed Aug 8, 2013
2 parents 7085138 + 069c244 commit 01a3c05
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions ckan/logic/action/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ def group_list_authz(context, data_dict):
(optional, default: False)
:type am-member: boolean
:returns: the names of groups that the user is authorized to edit
:rtype: list of strings
:returns: list of dictized groups that the user is authorized to edit
:rtype: list of dicts
'''
model = context['model']
Expand Down Expand Up @@ -469,12 +469,8 @@ def group_list_authz(context, data_dict):
if package:
groups = set(groups) - set(package.get_groups())

return [{'id': group.id,
'name': group.name,
'title': group.title,
'display_name': group.display_name,
'image_url': group.image_url,
'type': group.type} for group in groups]
group_list = model_dictize.group_list_dictize(groups, context)
return group_list

def organization_list_for_user(context, data_dict):
'''Return the list of organizations that the user is a member of.
Expand All @@ -483,8 +479,8 @@ def organization_list_for_user(context, data_dict):
(optional, default: ``edit_group``)
:type permission: string
:returns: the names of organizations the user is authorized to do specific permission
:rtype: list of strings
:returns: list of dictized organizations that the user is authorized to edit
:rtype: list of dicts
'''
model = context['model']
Expand Down Expand Up @@ -524,12 +520,8 @@ def organization_list_for_user(context, data_dict):

orgs_q = orgs_q.filter(model.Group.id.in_(group_ids))

return [{'id': org.id,
'name': org.name,
'title': org.title,
'display_name': org.display_name,
'image_url': org.image_url,
'type': org.type} for org in orgs_q.all()]
orgs_list = model_dictize.group_list_dictize(orgs_q.all(), context)
return orgs_list

def group_revision_list(context, data_dict):
'''Return a group's revisions.
Expand Down

0 comments on commit 01a3c05

Please sign in to comment.