Data source and configuration to power a view for one or more resources.
Requires CKAN 2.3+
To install ckanext-powerview:
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
Install the ckanext-powerview Python package into your virtual environment:
pip install ckanext-powerview
Install dependencies:
pip install -r requirements.txt
Create the database tables:
paster --plugin=ckanext-powerview powerview init --config=production.ini
- Add
powerview
to theckan.plugins
setting in your CKAN config file (by default the config file is located at/etc/ckan/default/production.ini
). Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
To install ckanext-powerview for development, activate your CKAN virtualenv and do:
git clone https://github.com/OCHA-DAP/ckanext-powerview.git
cd ckanext-powerview
python setup.py develop
pip install -r requirements.txt
pip install -r dev-requirements.txt
Optional configuration settings:
# If True, all logged in users will be able to create, delete and update
# their own Powerviews. Default is ``False``.
ckanext.powerview.allow_user_create = true
All actions in the PowerView extension are available in the CKAN Action API.
PowerView actions:
- create a new powerview (sysadmins only)
curl -X POST http://127.0.0.1:5000/api/3/action/powerview_create -H "Authorization:{YOUR-API-KEY}" -d '{"title": "My New View", "view_type": "my-view-type"}'
- update an existing powerview (sysadmins only)
curl -X POST http://127.0.0.1:5000/api/3/action/powerview_update -H "Authorization:{YOUR-API-KEY}" -d '{"id":"my-powerview-id", "title": "My Updated Title", "view_type": "my-view-type"}'
- delete a powerview (sysadmins only)
curl -X POST http://127.0.0.1:5000/api/3/action/powerview_delete -H "Authorization:{YOUR-API-KEY}" -d '{"id": "my-powerview-id"}'
- show a powerview
curl http://127.0.0.1:5000/api/3/action/powerview_show -d '{"id": "my-powerview-id"}'
- list resources in a powerview
curl http://127.0.0.1:5000/api/3/action/powerview_resource_list -d '{"id": "my-powerview-id"}'
- add a resource to an existing powerview (sysadmins only)
curl -X POST http://127.0.0.1:5000/api/3/action/powerview_add_resource -d '{"id": "my-powerview-id", "resource_id": "my-resource-id"}'
- remove a resource to an existing powerview (sysadmins only)
curl -X POST http://127.0.0.1:5000/api/3/action/powerview_remove_resource -d '{"id": "my-powerview-id", "resource_id": "my-resource-id"}'
- list of powerviews available to user (public, unrestricted and authorized for user). ``limit``, ``offset``, and ``id`` are optional.
curl http://127.0.0.1:5000/api/3/action/powerview_list -H "Authorization:{YOUR-API-KEY}" -d '{"limit":<int>, "offset":<int>, "id": <user id or name>}'
To run the tests, do:
nosetests --nologcapture --with-pylons=test.ini
To run the tests and produce a coverage report, first make sure you have coverage installed in your virtualenv (pip install coverage
) then run:
nosetests --nologcapture --with-pylons=test.ini --with-coverage --cover-package=ckanext.powerview --cover-inclusive --cover-erase --cover-tests
ckanext-powerview should be availabe on PyPI as https://pypi.python.org/pypi/ckanext-powerview. If that link doesn't work, then you can register the project on PyPI for the first time by following these steps:
Create a source distribution of the project:
python setup.py sdist
Register the project:
python setup.py register
Upload the source distribution to PyPI:
python setup.py sdist upload
Tag the first release of the project on GitHub with the version number from the
setup.py
file. For example if the version number insetup.py
is 0.0.1 then do:git tag 0.0.1 git push --tags
ckanext-powerview is availabe on PyPI as https://pypi.python.org/pypi/ckanext-powerview. To publish a new version to PyPI follow these steps:
- Update the version number in the
setup.py
file. See PEP 440 for how to choose version numbers. Create a source distribution of the new version:
python setup.py sdist
Upload the source distribution to PyPI:
python setup.py sdist upload
Tag the new release of the project on GitHub with the version number from the
setup.py
file. For example if the version number insetup.py
is 0.0.2 then do:git tag 0.0.2 git push --tags