Skip to content

Commit

Permalink
Merge branch 'feature-1607-dgu-maintentance-refactor' of https://gith…
Browse files Browse the repository at this point in the history
…ub.com/okfn/ckan into feature-1607-dgu-maintentance-refactor
  • Loading branch information
rossjones committed Feb 24, 2012
2 parents 3cc1f22 + 2eda2fc commit 93f72e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions ckan/logic/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ def group_id_exists(group_id, context):
raise Invalid(_("That group ID does not exist."))
return group_id

def group_id_or_name_exists(reference, context):
"""
Raises Invalid if a group identified by the name or id cannot be found.
"""
model = context['model']
result = model.Group.get(reference)
if not result:
raise Invalid(_('That group name or ID does not exist.'))
return reference

def activity_type_exists(activity_type):
"""Raises Invalid if there is no registered activity renderer for the
given activity_type. Otherwise returns the given activity_type.
Expand Down
4 changes: 2 additions & 2 deletions ckan/templates/facets.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
py:strip=""
>

<py:def function="facet_sidebar(code, limit=5, label=lambda n: n, title=h.facet_title, if_empty=None)">
<py:def function="facet_sidebar(code, limit=5, label=lambda n: n, title=h.facet_title, if_empty=None, count_label=lambda c: ' (%d)'%c)">
<div py:if="if_empty is not None or len(h.facet_items(c, code, limit=limit))" class="facet-box">
<h2>${title(code)}</h2>
<ul class="facet-options">
<li py:for="name, count in h.facet_items(c, code, limit=limit)"
py:if="not (code, name) in c.fields">
<a href="${c.drill_down_url(**{code: name})}">${label(name)}</a> (${count})
<a href="${c.drill_down_url(**{code: name})}">${label(name)}</a>${count_label(count)}
</li>
</ul>
<p py:if="not len(h.facet_items(c, code, limit=limit))">${if_empty}</p>
Expand Down

0 comments on commit 93f72e3

Please sign in to comment.