Code Monkey home page Code Monkey logo

ckanext-userdatasets's Introduction

ckanext-userdatasets

Tests Coveralls CKAN Python Docs

A CKAN extension that allows organisation members to create datasets, and edit or delete the datasets they have created.

Overview

This extension changes the permissions of users with the 'Member' role in an organisation, allowing them to create datasets, and to edit or delete the datasets they have created. Unlike users with the 'Editor' role, they cannot edit or delete datasets created by other users.

Notes:

  • This applies to the existing 'Member' role rather than creating a new one as it is currently not possible to add new roles from an extension;
  • The plugin works with custom dataset types, however it will not work with other plugins which override package/resource update/create/delete authorization functions, and package_create/update actions.

Warning: This plugin modifies CKAN's permission system. The current implementation cannot be considered fully safe and should only be used AT YOUR OWN RISK in a trusted environment. Ensure you run the tests with your plugins enabled.

Installation

Path variables used below:

  • $INSTALL_FOLDER (i.e. where CKAN is installed), e.g. /usr/lib/ckan/default
  • $CONFIG_FILE, e.g. /etc/ckan/default/development.ini

Installing from PyPI

pip install ckanext-userdatasets

Installing from source

  1. Clone the repository into the src folder:

    cd $INSTALL_FOLDER/src
    git clone https://github.com/NaturalHistoryMuseum/ckanext-userdatasets.git
  2. Activate the virtual env:

    . $INSTALL_FOLDER/bin/activate
  3. Install via pip:

    pip install $INSTALL_FOLDER/src/ckanext-userdatasets

Installing in editable mode

Installing from a pyproject.toml in editable mode (i.e. pip install -e) requires setuptools>=64; however, CKAN 2.9 requires setuptools==44.1.0. See our CKAN fork for a version of v2.9 that uses an updated setuptools if this functionality is something you need.

Post-install setup

  1. Add 'userdatasets' to the list of plugins in your $CONFIG_FILE:
    ckan.plugins = ... userdatasets

Configuration

There are no configuration options for this extension.

Usage

Actions

No new actions are defined in this extension; three are overridden to modify validators and permissions.

package_create

package_update

organization_list_for_user

Testing

There is a Docker compose configuration available in this repository to make it easier to run tests. The ckan image uses the Dockerfile in the docker/ folder.

To run the tests against ckan 2.9.x on Python3:

  1. Build the required images:

    docker-compose build
  2. Then run the tests. The root of the repository is mounted into the ckan container as a volume by the Docker compose configuration, so you should only need to rebuild the ckan image if you change the extension's dependencies.

    docker-compose run ckan

ckanext-userdatasets's People

Contributors

aliceh75 avatar alycejenni avatar benscott avatar github-actions[bot] avatar jrdh avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ckanext-userdatasets's Issues

AttributeError: 'Resource' object has no attribute 'resource_group'

Hello!
I am newbie in Ckan. I am using CKAN 2.4.1. I have downloaded the git repository of this plugin in my local and running the setup.py manually. After the successful installation in my development enviroment, I proceed to test the functionality creating a new dataset and adding resources. The dataset was created fine but when I went to the resource visualization page, this exception was thrown:

File '/home/facundo/ckan/lib/default/src/ckanext-userdatasets/ckanext/userdatasets/logic/auth/create.py', line 48 in resource_view_create
  if user_owns_package_as_member(user, resource.resource_group.package):
AttributeError: 'Resource' object has no attribute 'resource_group'

Here is the full error traceback if want to see.

What could it be happening? I read that this plugin was made for CKAN 2.2. Could it be a change in the datamodel used by CKAN from the 2.2 to the 2.4.1 version? I have to run a SQL updating?

Thanks for any help!

ImportError: No module named new_authz

Im running CKAN 2.6.1. getting the following error after installing the plugin. Any help ?

File "/root/ckan/lib/default/src/ckan/ckan/config/environment.py", line 280, in update_config logic.get_action('get_site_user')({'ignore_auth': True}, None) File "/root/ckan/lib/default/src/ckan/ckan/logic/__init__.py", line 394, in get_action for name, auth_function in plugin.get_actions().items(): File "/root/ckan/lib/default/src/ckan/ckanext-userdatasets/ckanext/userdatasets/plugin.py", line 48, in get_actions uds_module = importlib.import_module('ckanext.userdatasets.logic.action.' + override[0]) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/root/ckan/lib/default/src/ckan/ckanext-userdatasets/ckanext/userdatasets/logic/action/create.py", line 10, in <module> from ckanext.userdatasets.logic.validators import owner_org_validator as uds_oov File "/root/ckan/lib/default/src/ckan/ckanext-userdatasets/ckanext/userdatasets/logic/validators.py", line 2, in <module> from ckan.new_authz import users_role_for_group_or_org ImportError: No module named new_authz

AttributeError: 'functools.partial' object has no attribute '__module__'

This was reported on the CKAN dev list.

Rather than work out what the difference is between the two setups, I will rewrite the code not to use partials. The change is trivial, and I expect this issue will keep creeping up otherwise as CKAN use's it's own wrappers and decorators a lot.

License Info

Maybe it's not related with any technical aspect of this extension... but it's very important to me (and probably for another githubers): which license applies to this awesome extension? Can't find any information. Could you update it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.