Commit 1b356015 authored by David Read's avatar David Read
Browse files

flake8

parent 2495afc4
import logging
import re
import ckan.plugins as p
from ckan import model
from ckan.lib.plugins import DefaultOrganizationForm
from ckan.lib.plugins import DefaultGroupForm
import ckan.logic.schema as s
from ckan.common import c, request
from ckan.common import c
from ckanext.hierarchy.logic import action
from ckanext.hierarchy import helpers
......@@ -16,6 +13,7 @@ log = logging.getLogger(__name__)
# This plugin is designed to work only these versions of CKAN
p.toolkit.check_ckan_version(min_version='2.0')
def custom_convert_from_extras(key, data, errors, context):
'''Converts values from extras, tailored for groups.'''
......@@ -27,16 +25,17 @@ def custom_convert_from_extras(key, data, errors, context):
for data_key in data.keys():
if (data_key[0] == 'extras'):
data_value = data[data_key]
if( 'key' in data_value and data_value['key'] == key[-1]):
data[key] = data_value['value']
to_remove.append(data_key)
break
if 'key' in data_value and data_value['key'] == key[-1]:
data[key] = data_value['value']
to_remove.append(data_key)
break
else:
return
for remove_key in to_remove:
del data[remove_key]
class HierarchyDisplay(p.SingletonPlugin):
p.implements(p.IConfigurer, inherit=True)
......@@ -66,11 +65,12 @@ class HierarchyDisplay(p.SingletonPlugin):
'group_tree_parents': helpers.group_tree_parents,
'group_tree_get_longname': helpers.group_tree_get_longname,
'group_tree_highlight': helpers.group_tree_highlight,
'get_allowable_parent_groups': helpers.get_allowable_parent_groups,
'is_include_children_selected': helpers.is_include_children_selected,
'get_allowable_parent_groups':
helpers.get_allowable_parent_groups,
'is_include_children_selected':
helpers.is_include_children_selected,
}
# IPackageController
def before_search(self, search_params):
......@@ -95,9 +95,9 @@ class HierarchyDisplay(p.SingletonPlugin):
# Remove the param from the fields - NB no longer works
# e.g. [('include_children', 'True')]
new_fields = set()
for field,value in c.fields:
for field, value in c.fields:
if (field != 'include_children'):
new_fields.add((field,value))
new_fields.add((field, value))
c.fields = list(new_fields)
# parse the query string to check if children are requested
......@@ -128,7 +128,7 @@ class HierarchyDisplay(p.SingletonPlugin):
' OR '.join(
'organization:{}'.format(org_name)
for org_name in [c.group_dict.get('name')] +
children_names))
children_names))
search_params['q'] = query
# add it back to fields
# c.fields += [('include_children', 'True')]
......@@ -143,7 +143,6 @@ class HierarchyForm(p.SingletonPlugin, DefaultOrganizationForm):
p.implements(p.IGroupForm, inherit=True)
# IGroupForm
def group_types(self):
......@@ -156,4 +155,5 @@ class HierarchyForm(p.SingletonPlugin, DefaultOrganizationForm):
from pylons import tmpl_context as c
group_id = data_dict.get('id')
c.allowable_parent_groups = helpers.get_allowable_parent_groups(group_id)
c.allowable_parent_groups = \
helpers.get_allowable_parent_groups(group_id)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment