ckanext-datasetversions
This CKAN extension adds support for different versions of a dataset. Sometimes it is desirable to store and display together different versions of a dataset, for example a daily situation report-style map during a humanitarian crisis.
How It Works
The plugin models dataset versions internally by creating a parent dataset with minimal metadata and no resources. A child dataset is created for each version.
Actions
The plugin provides an action dataset_version_create:
toolkit.get_action('dataset_version_create')(
context, {
'id': dataset['id'],
'base_name': base_name,
'owner_org': owner_org
}
)
dataset_version_create will create a parent-child relationship between the dataset specified by base_name and that specified by id. If the dataset specified by base_name does not exist, it will be created.
Package Show Override
Note that this plugin overrides CKAN’s package_show action. The original package_show is made available as ckan_package_show.
For datasets with different versions, the overridden package_show will return:
- The latest, public, active version of the dataset if the parent name or id is specified
- A specific version of the dataset if the child name or id is specified
The version ordering is determined by the integer value of version in the dataset metadata.
In addition, package_show will return a list of the names and URLs of all active versions as _versions in the dictionary.
Templates
The plugin provides templates to list versions of a dataset alongside that currently viewed and to warn the user if they are looking at an old version of a dataset.
Requirements
This plugin will not work ‘out of the box’. You will need to write code to call the dataset_version_create action. A site-specific example is available at https://github.com/aptivate/ckanext-mapactionimporter
This is known to work with CKAN 2.5.2, though note there are problems when purging datasets with relationships.
Installation
- Activate your CKAN virtual environment:
. /usr/lib/ckan/default/bin/activate
- Install the ckanext-datasetversions Python package:
pip install ckanext-datasetversions
Add datasetversions to the ckan.plugins setting in your CKAN config file.
Restart CKAN.
Config Settings
None
About
Copyright (c) 2016 MapAction. Developed by Aptivate.
Development of v1 of this plugin was funded by ECHO (European Commission Humanitarian Aid).
License
This extension is licensed under the AGPL-3.0 license.