Skip to content

Commit

Permalink
[#2558] groups_available helper function added
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jun 22, 2012
1 parent f96bd46 commit d0506f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions ckan/lib/helpers.py
Expand Up @@ -1152,6 +1152,14 @@ def popular(type_, number, min=1, title=None):
raise Exception('popular() did not recieve a valid type_ or title')
return snippet('snippets/popular.html', title=title, number=number, min=min)

def groups_available():
''' return a list of available groups '''
import ckan.logic as logic
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
data_dict = {'available_only': True}
return logic.get_action('group_list_authz')(context, data_dict)

# these are the functions that will end up in `h` template helpers
# if config option restrict_template_vars is true
__allowed_functions__ = [
Expand Down Expand Up @@ -1220,6 +1228,7 @@ def popular(type_, number, min=1, title=None):
'follow_count',
'remove_url_param',
'add_url_param',
'groups_available',
# imported into ckan.lib.helpers
'literal',
'link_to',
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/new_package_metadata.html
Expand Up @@ -4,4 +4,4 @@

{% block stages %}{{ h.snippet('package/snippets/stages.html', stage=3) }}{% endblock %}

{% block form %}{{ h.snippet('package/snippets/package_metadata_form.html', data=data, errors=errors, groups_available=c.groups_available, include_metadata=false) }}{% endblock %}
{% block form %}{{ h.snippet('package/snippets/package_metadata_form.html', data=data, errors=errors, include_metadata=false) }}{% endblock %}
@@ -1,5 +1,6 @@
{% import 'macros/form.html' as form %}

{% set groups_available = h.groups_available() %}
{% if groups_available %}
<div class="control-group">
{% set groups = data.groups or [] %}
Expand Down

0 comments on commit d0506f3

Please sign in to comment.