Skip to content

Commit

Permalink
Merge pull request #65 from ckan/avoid_ckan_2.10_deprecation
Browse files Browse the repository at this point in the history
Avoid CKAN 2.10 deprecation
  • Loading branch information
pdelboca authored Aug 22, 2023
2 parents bc6e8ad + 0688b63 commit 9d3a2f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ckanext/hierarchy/groups_hierarchy/group/read.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
(_('Last Modified'), 'metadata_modified desc'),
(_('Popular'), 'views_recent desc') if g.tracking_enabled else (false, false) ]
%}
{% snippet 'snippets/search_form.html', form_id='group-datasets-search-form', type='dataset', query=q, sorting=sorting, sorting_selected=sort_by_selected, count=page.item_count, facets=facets, placeholder=_('Search datasets...'), show_empty=request.params, fields=fields, include_children_option=true %}
{% snippet 'snippets/search_form.html', form_id='group-datasets-search-form', type='dataset', query=q, sorting=sorting, sorting_selected=sort_by_selected, count=page.item_count, facets=facets, placeholder=_('Search datasets...'), show_empty=request.args, fields=fields, include_children_option=true %}
{% endblock %}
13 changes: 10 additions & 3 deletions ckanext/hierarchy/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ckan.plugins as p
import ckan.model as model
from ckan.common import request, is_flask_request
from ckan.common import request


def group_tree(organizations=[], type_='organization'):
Expand Down Expand Up @@ -115,7 +115,14 @@ def get_allowable_parent_groups(group_id):

def is_include_children_selected():
include_children_selected = False
if is_flask_request():
if request.params.get('include_children'):

if p.toolkit.check_ckan_version(min_version="2.10"):
is_flask = True
else:
from ckan.common import is_flask_request
is_flask = is_flask_request()

if is_flask:
if request.args.get('include_children'):
include_children_selected = True
return include_children_selected
2 changes: 1 addition & 1 deletion ckanext/hierarchy/templates/organization/read.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
(_('Last Modified'), 'metadata_modified desc'),
(_('Popular'), 'views_recent desc') if g.tracking_enabled else (false, false) ]
%}
{% snippet 'snippets/search_form.html', form_id='organization-datasets-search-form', type='dataset', query=q, sorting=sorting, sorting_selected=sort_by_selected, count=page.item_count, facets=facets, placeholder=_('Search datasets...'), show_empty=request.params, fields=fields, include_children_option=true %}
{% snippet 'snippets/search_form.html', form_id='organization-datasets-search-form', type='dataset', query=q, sorting=sorting, sorting_selected=sort_by_selected, count=page.item_count, facets=facets, placeholder=_('Search datasets...'), show_empty=request.args, fields=fields, include_children_option=true %}
{% endblock %}

0 comments on commit 9d3a2f0

Please sign in to comment.