Skip to content

Commit

Permalink
[#3385] organization_list_for_user: include_dataset_count parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Jan 12, 2017
1 parent 17f6ba0 commit 41a586b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ckan/lib/helpers.py
Expand Up @@ -1664,12 +1664,15 @@ def groups_available(am_member=False):


@core_helper
def organizations_available(permission='manage_group'):
def organizations_available(
permission='manage_group', include_dataset_count=False):
'''Return a list of organizations that the current user has the specified
permission for.
'''
context = {'user': c.user}
data_dict = {'permission': permission}
data_dict = {
'permission': permission,
'include_dataset_count': include_dataset_count}
return logic.get_action('organization_list_for_user')(context, data_dict)


Expand Down
5 changes: 4 additions & 1 deletion ckan/logic/action/get.py
Expand Up @@ -628,6 +628,9 @@ def organization_list_for_user(context, data_dict):
returned organizations, for example ``"read"`` or ``"create_dataset"``
(optional, default: ``"manage_group"``)
:type permission: string
:param include_dataset_count: include the package_count in each org
(optional, default: ``False``)
:type include_dataset_count: boolean
:returns: list of organizations that the user has the given permission for
:rtype: list of dicts
Expand Down Expand Up @@ -697,7 +700,7 @@ def organization_list_for_user(context, data_dict):

context['with_capacity'] = True
orgs_list = model_dictize.group_list_dictize(orgs_and_capacities, context,
with_package_counts=False)
with_package_counts=asbool(data_dict.get('include_dataset_count')))
return orgs_list


Expand Down
3 changes: 2 additions & 1 deletion ckan/templates/user/dashboard_organizations.html
Expand Up @@ -10,7 +10,8 @@

{% block primary_content_inner %}
<h2 class="hide-heading">{{ _('My Organizations') }}</h2>
{% set organizations = h.organizations_available(permission='manage_group') %}
{% set organizations = h.organizations_available(permission='manage_group',
include_dataset_count=True) %}
{% if organizations %}
<div class="wide">
{% snippet "organization/snippets/organization_list.html", organizations=organizations, show_capacity=True %}
Expand Down

0 comments on commit 41a586b

Please sign in to comment.