ckan / ckanext-hierarchy Goto Github PK
View Code? Open in Web Editor NEWOrganization hierarchy - CKAN extension
License: GNU Affero General Public License v3.0
Organization hierarchy - CKAN extension
License: GNU Affero General Public License v3.0
What is the parameter step to create the parent via api?
With ckanext-hierarchy installed, from an organization page, clicking on the 'Activity Stream' tab returns error: 404
Affects CKAN versions to 2.4.2. Was fixed on CKAN master here: ckan/ckan#2354 and will go into CKAN 2.5, scheduled to be released in a month's time.
A temporary fix is provided by @fara in #10 - the change in plugin.py, although that may affect the ability to use groups as well as organizations.
Make Organizations hierarchically is such a great idea. Can we reproduce this with groups?
The pagination breaks the tree as someone mentioned before me. Has there been a solution to this issue in the meantime, as this was 3 years ago? Someone suggested to increase the number of datasets shown per page as a workaround, hoewever where can I set this?
While attempting to run ckanext-hierarchy master (roughly here) with CKAN master ('2.10.0a0'), I'm getting an exception on the template tag resource
being used in [hierarchy_resource.html](https://github.com/ckan/ckanext-hierarchy/blob/master/ckanext/hierarchy/templates/hierarchy/snippets/hierarchy_resource.html)
, where CKAN 2.10 apparently requires asset
.
File "/usr/lib/ckan/venv/src/ckanext-hierarchy/ckanext/hierarchy/templates/hierarchy/snippets/hierarchy_resource.html", line 1, in template
{% resource 'hierarchy/hierarchy_theme.css' %}
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'resource'.
It seems that the template organization_tree.html
does actually toggle between resource
and asset
but gets the wrong CKAN version on my end.
{% set type = 'asset' if h.ckan_version() > '2.9' else 'resource' %}
{% include 'hierarchy/snippets/hierarchy_' ~ type ~ '.html' %}
The debugger console tells me my CKAN version is
from ckan.lib.helpers import ckan_version
>>> ckan_version()
'2.10.0a0'
resource
to asset
.ckan.lib.helpers.ckan_version
or add new functionMake h.ckan_version() > '2.9'
robust against versions '2.10.0a0'
, e.g. only compare major.minor and drop patch/dev:
@core_helper
def ckan_version() -> str:
'''Return CKAN version'''
# Option1: regex
import re
return re.match(r"^([\d]\.[\d]+)", str(ckan.__version__)).group()
# Option 2: join/split/subset
return ".".join(str(ckan.__version__).split(".", 2)[:2])
# Default: returns the version as int or string
return ckan.__version__
This would break anything depending on the patch number/string of the version string.
Seeing that ckan.lib.app_lobals.py
defines Globals including major version as __ckan_base_version__
, and the full version as __version__
, maybe an unobtrusive option would be to add the major/minor version as global, e.g. __ckan_majorminor__
.
check_ckan_version
Use ckan.plugins.toolkit.check_ckan_version()
as template helper.
This works with v "2.10.0a0":
t.check_ckan_version(min_version="2.10") == True
t.check_ckan_version(min_version="2.11") == False
Edit: PR sent.
When I browse an Organization page and there is paging, I get something like
/group/organization?q=&page=2 instead of /organization/organization-name?q=&page=2
I tested it with hierarchy_form as the only plugin.
The {% resource <FILE> %}
jinja tag is no longer available in CKAN 2.10 and the assets
vs resource
tag detection is failing
CKAN 2.10 try to load the hierarchy/snippets/hierarchy_resource.html
file
Hi. I have a CKAN 2.8.1 installation with the plugin. In the log it does not show error, but when accessing to the CKAN's home page it shows an error 500 with the message "Internal server error", although it lets you navigate without problems, create organizations, datasets, groups...
Installing ckanext-hierarchy with:
pip install -e 'git+https://github.com/datagovuk/ckanext-hierarchy#egg=ckanext-hierarchy'
and enabling it on configuration I got a error when start ckan:
from ckan.logic.validators import no_loops_in_hierarchy
ImportError: cannot import name no_loops_in_hierarchy
Consulting the ckan's documentation, I saw that ckan.logic.validators don't have this "no_loops_in_hierarchy"[1]
[1]http://docs.ckan.org/en/943-writing-extensions-tutorial/extensions/validators.html
We install ckanext-hierarchy on CKAN 2.9.5, on accessing organization page, we are getting error
2022-08-12 19:25:50,676 ERROR [ckan.config.middleware.flask_app] Helper 'check_ckan_version' has not been defined.
Traceback (most recent call last):
File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 97, in __getitem__
value = super(HelperAttributeDict, self).__getitem__(key)
KeyError: 'check_ckan_version'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware/../../views/group.py", line 211, in index
_get_group_template(u'index_template', group_type), extra_vars)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 151, in render
return flask_render_template(template_name, **extra_vars)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/templating.py", line 140, in render_template
ctx.app,
File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/lib/ckan/default/src/ckan/ckan/templates/organization/index.html", line 1, in top-level template code
{% extends "page.html" %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 1, in top-level template code
{% extends "base.html" %}
File "/usr/lib/ckan/default/src/ckanext-harvest/ckanext/harvest/plugin/../templates/base.html", line 1, in top-level template code
{% ckan_extends %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/base.html", line 106, in top-level template code
{%- block page %}{% endblock -%}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 19, in block "page"
{%- block content %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 22, in block "content"
{% block main_content %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 74, in block "main_content"
{% block primary %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 87, in block "primary"
{% block primary_content %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 107, in block "primary_content"
{% block primary_content_inner %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/organization/index.html", line 22, in block "primary_content_inner"
{% block organizations_list %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/organization/index.html", line 25, in block "organizations_list"
{% snippet "organization/snippets/organization_list.html", organizations=page.items %}
File "/usr/lib/ckan/default/src/ckan/ckan/lib/jinja_extensions.py", line 274, in _call
return base.render_snippet(*args, **kwargs)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 95, in render_snippet
output = render(template_name, extra_vars=kw)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 151, in render
return flask_render_template(template_name, **extra_vars)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/templating.py", line 140, in render_template
ctx.app,
File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/home/angela/ckanext-hierarchy/ckanext/hierarchy/templates/organization/snippets/organization_list.html", line 19, in top-level template code
{% snippet 'organization/snippets/organization_tree.html', top_nodes=top_nodes, use_longnames=True %}
File "/usr/lib/ckan/default/src/ckan/ckan/lib/jinja_extensions.py", line 274, in _call
return base.render_snippet(*args, **kwargs)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 95, in render_snippet
output = render(template_name, extra_vars=kw)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 151, in render
return flask_render_template(template_name, **extra_vars)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/templating.py", line 140, in render_template
ctx.app,
File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/home/angela/ckanext-hierarchy/ckanext/hierarchy/templates/organization/snippets/organization_tree.html", line 17, in top-level template code
{% set type = 'asset' if h.check_ckan_version(min_version='2.9') else 'resource' %}
File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 434, in getattr
return obj[attribute]
File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 101, in __getitem__
key=key
ckan.exceptions.HelperError: Helper 'check_ckan_version' has not been defined
We are using
(default) angela@angela:~$ python --version
Python 3.6.9
(default) angela@angela:~$ pip --version
pip 21.3.1 from /usr/lib/ckan/default/lib/python3.6/site-packages/pip (python 3.6)
(default) angela@angela:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
(default) angela@angela:~$
Can you please help!
Noticed that this seems to be live in http://data.gov.uk/publisher with the Javascript tree navigation.
Any chance this repo will be updated to reflect this?
I am unsure what the expected behavior of hierarchy_display is when searching for organizations, but I see some top level organizations displayed with all their children, none of which are highlighted, which I believe would indicate that none matched the search query. I would expect matching organizations to be highlighted and their parents & children (not siblings) displayed. I have observed this behavior with CKAN 2.7 and 2.8
Hey,
thanks for publishing this extension, very useful. Quick question: is it possible to control the hierarchy via the CKAN API? If, do you have an example?
Thanks!
Not sure whether it is just me but I observe a performance hit with the latest merge. Clicking "Organization" waits for 1.5 sec instead of ~320 ms before (development desktop, debug mode, 32 organizations)
Hi,
I have installed your extension in a fresh CKAN 2.5.0a copy (http://data.datalook.io/). I followed all the steps for installing it and I had no problem at all.
Once I try to create an organisation I get this exception:
Exception: menu item organization_activity
need parameter offset
Here the full stack:
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/templates/base.html', line 103 in top-level template code
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] {%- block page %}{% endblock -%}
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 19 in block "page"
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] {%- block content %}
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 22 in block "content"
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] {% block main_content %}
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 57 in block "main_content"
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] {% block primary %}
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 70 in block "primary"
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] {% block primary_content %}
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 72 in block "primary_content"
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] {% block page_header %}
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 80 in block "page_header"
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] {% block content_primary_nav %}{% endblock %}
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/templates/organization/read_base.html', line 18 in block "content_primary_nav"
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] {{ h.build_nav_icon('organization_activity', _('Activity Stream'), id=c.group_dict.name) }}
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py', line 524 in build_nav_icon
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] return _make_menu_item(menu_item, title, **kw)
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] File '/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py', line 587 in _make_menu_item
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] % (menu_item, need))
[Thu Jul 09 15:06:50 2015] [error] [client 217.110.228.210] Exception: menu item organization_activity
need parameter offset
What I am missing?
Cheers,
Vicens.
Master was recently bumped to version 1.2.0, could you please push the v1.1.0 tag?
The v1.0.3 tag also seems incorrect, pointing to a v1.1.0 commit.
Hi I have a CKAN installation with the plugin installed and not giving errors that won't display the org hierarchy.
The plugins installed are the standard ones and the datastore extension.
any hints?
Hello,
I want to manually order the parent organizations (based on their importance for our catalog). Is there any way to do this? how?
best regards
Mani
I want to export my organizations to copy them from one host to another. I dumped the groups folder (this is where the organizations are stored in the ckandb database) and imported it on my other host. However, only the organizations were imported but not the tree structure (all the organizations are top level now). This leads me to my question, where the hierarchy structure is stored, or what table to I have to export to get the organizations including the tree structure?
Hi
This is a fantastic plugin but as you know, the current graphic of the organizations list is unappealing, not that there is any problem with the functionality. Is there any way to add a switch button so the user can switch between current view and the original ckan view?
I see this behavior on both CKAN 2.7 and 2.8. I have 32 organizations 5 top-level that each have 4-7 sub-organizations. This many organizations causes the interface to add a pager, which breaks the display of all organizations with some child organizations being displayed individually & repeated with the proper hierarchy on the 2nd page. A simple solution for my case could be to disable paging / allow more items per page, but I am unsure where this is changed.
Hello all,
Ckan v = 2.8
I have two difficulties:
when I go to the page of one of my parent organisations: I have the checkbox "Inlclude sub.organization" which doesn not do anything whether i check it or not.
So what is its purpose in general and why it does not work?
Anyway I assume when this option is check I will recieve the datasets from children organization in the page of a parent organization? am I right?
If yes eventhough I checked it in helperpy to True (probably not the right place) and in the UI it is checked still nothing happens different from unchecked option.
My requirement is to have some parent organisations which are only being used to categorise my organisation and in fact these parent organisations have no data. But I need to list the dataset from all sub-organisations / childer in the parent page. How this can happen using ckanext-Hierarchy?
Many thanks in advance
Mani
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.