CKAN extension that allows users to ask for datasets that are not already published in the CKAN instance. In this way we can set up a Data Market, not only with data supplies but also with data demands.
You have two ways for creating, updating, deleting, viewing and closing a datarequest: you can use the graphical interface or the programatic API.
If you prefer to use the graphical interface, you should click on the “Data Requests” section that will appear in the header of your CKAN instance. In this section you’ll be able to view the current data requests. In addition, there will be a button that will allow you to create a new data request. In the form that will appear, you will have to introduce the following information:
Once that you have created your data request, you can view it by clicking on the link provided when you created it. When you are the owner of a data request, you will also be able to:
On the other hand, you can also use the API. To access this API, you should POST the following URL (as you do for other actions):
http[s]://[CKAN_HOST]:[CKAN_PORT]/api/action/[ACTION_NAME]
Here you have a brief description of all the implemented actions:
create_datarequest(context, data_dict)
Action to create a new data request. This function checks the access
rights of the user before creating the data request. If the user is not
allowed, a NotAuthorized
exception will be risen.
In addition, you should note that the parameters will be checked and an
exception (ValidationError
) will be risen if some of these parameters
are not valid.
data_dict
):title
(string): the title of the data requestdescription
(string): a brief description for your data
requestorganization_id
(string): The ID of the organization you want
to asign the data request (optional).A dict with the data request (id
, user_id
, title
,
description
,organization_id
, open_time
, accepted_dataset
,
close_time
, closed
, followers
).
show_datarequest(context, data_dict)
Action to retrieve the information of a data request. The only required
parameter is the id
of the data request. A NotFound
exception will
be risen if the id
is not found.
Access rights will be checked before returning the information and an
exception will be risen (NotAuthorized
) if the user is not authorized.
data_dict
):id
(string): the ID of the datarequest to be returned.A dict with the data request (id
, user_id
, title
,
description
,organization_id
, open_time
, accepted_dataset
,
close_time
, closed
, followers
).
update_datarequest(context, data_dict)
Action to update a data request. The function checks the access rights
of the user before updating the data request. If the user is not
allowed, a NotAuthorized
exception will be risen
In addition, you should note that the parameters will be checked and an
exception (ValidationError
) will be risen if some of these parameters
are not valid.
data_dict
):id
(string): the ID of the datarequest to be updatedtitle
(string): the updated title of the data requestdescription
(string): a updated brief description for your
data requestorganization_id
(string): The ID of the organization you want
to asign the data request (optional).A dict with the data request (id
, user_id
, title
,
description
,organization_id
, open_time
, accepted_dataset
,
close_time
, closed
, followers
).
list_datarequests(context, data_dict)
Returns a list with the existing data requests. Rights access will be
checked before returning the results. If the user is not allowed, a
NotAuthorized
exception will be risen
data_dict
):organization_id
(string) (optional): to filter the result by
organizationuser_id
(string) (optional): to filter the result by userclosed
(string) (optional): to filter the result by state
(True
: Closed, False
: Open)offset
(int) (optional) (default 0
): the first element to be
returnedlimit
(int) (optional) (default 10
): The max number of data
requests to be returnedq
(string) (optional): to filter the result using a free-text.sort
(string) (optional) (default asc
): desc
to order data
requests in a descending way. asc
to order data requests in an
ascending way.A dict with three fields: result
(a list of data requests), facets
(a list of the facets that can be used) and count
(the total number of
existing data requests)
delete_datarequest(context, data_dict)
Action to delete a new data request. The function checks the access
rights of the user before deleting the data request. If the user is not
allowed, a NotAuthorized
exception will be risen.
data_dict
):id
(string): the ID of the datarequest to be deletedA dict with the data request (id
, user_id
, title
,
description
,organization_id
, open_time
, accepted_dataset
,
close_time
, closed
, followers
).
close_datarequest(context, data_dict)
Action to close a data request. Access rights will be checked before
closing the data request. If the user is not allowed, a NotAuthorized
exception will be risen
data_dict
):id
(string): the ID of the datarequest to be closedaccepted_dataset
(string): The ID of the dataset accepted as
solution for the data requestA dict with the data request (id
, user_id
, title
,
description
,organization_id
, open_time
, accepted_dataset
,
close_time
, closed
, followers
).
comment_datarequest(context, data_dict)
Action to create a comment in a data request. Access rights will be
checked before creating the comment and a NotAuthorized
exception will
be risen if the user is not allowed to create the comment
data_dict
):datarequest_id
(string): the ID of the datarequest to be
commentedcomment
(string): The comment to be added to the data requestA dict with the data request comment (id
, user_id
, datarequest_id
,
time
and comment
)
show_datarequest_comment(context, data_dict)
Action to retrieve a comment. Access rights will be checked before
getting the comment and a NotAuthorized
exception will be risen if the
user is not allowed to get the comment
data_dict
):id
(string): The ID of the comment to be retrievedA dict with the following fields: id
, user_id
, datarequest_id
,
time
and comment
list_datarequest_comments(context, data_dict)
Action to retrieve all the comments of a data request. Access rights
will be checked before getting the comments and a NotAuthorized
exception will be risen if the user is not allowed to read the comments
data_dict
):datarequest_id
(string): The ID of the datarequest whose
comments want to be retrievedsort
(string) (optional) (default asc
): desc
to order
comments in a descending way. asc
to order comments in an
ascending way.A list with all the comments of a data request. Every comment is a dict
with the following fields: id
, user_id
, datarequest_id
, time
and
comment
update_datarequest_comment(context, data_dict)
Action to update a comment of a data request. Access rights will be
checked before updating the comment and a NotAuthorized
exception will
be risen if the user is not allowed to update the comment
data_dict
):id
(string): The ID of the comment to be updatedcomment
(string): The new commentA dict with the data request comment (id
, user_id
, datarequest_id
,
time
and comment
)
delete_datarequest_comment(context, data_dict)
Action to delete a comment of a data request. Access rights will be
checked before deleting the comment and a NotAuthorized
exception will
be risen if the user is not allowed to delete the comment
data_dict
):id
(string): The ID of the comment to be deletedA dict with the data request comment (id
, user_id
, datarequest_id
,
time
and comment
)
follow_datarequest(context, data_dict)
Action to follow a data request. Access rights will be cheked before
following a datarequest and a NotAuthorized
exception will be risen if
the user is not allowed to follow the given datarequest.
ValidationError
will be risen if the datarequest ID is not included or
if the user is already following the datarequest. ObjectNotFound
will
be risen if the given datarequest does not exist.
data_dict
):id
(string): The ID of the datarequest to be followedTrue
unfollow_datarequest(context, data_dict)
Action to unfollow a data request. Access rights will be cheked before
unfollowing a datarequest and a NotAuthorized exception will be risen if
the user is not allowed to unfollow the given datarequest.
ValidationError
will be risen if the datarequest ID is not included in
the request. ObjectNotFound
will be risen if the user is not following
the given datarequest.
data_dict
):id
(string): The ID of the datarequest to be unfollowedTrue
Install this extension in your CKAN instance is as easy as install any other CKAN extension.
. /usr/lib/ckan/default/bin/activate
pip install ckanext-datarequests
Note: If you prefer, you can also download the source code and install the extension manually. To do so, execute the following commands:
$ git clone https://github.com/conwetlab/ckanext-datarequests.git $ cd ckanext-datarequests $ python setup.py install
/etc/ckan/default/production.ini
) and add datarequests
in the
ckan.plugins
property.ckan.plugins = datarequests <OTHER_PLUGINS>
ckan.datarequests.comments
property in the configuration file (by
default, the comments system is enabled).ckan.datarequests.comments = [true|false]
ckan.datarequests.show_datarequests_badge
property in the configuration file (by default, the badge is not
shown).ckan.datarequests.show_datarequests_badge = [true|false]
sudo service apache2 restart
Help us to translate this extension so everyone can create data
requests. Currently, the extension is translated to English, Spanish,
German and Brazilian Portuguese. If you want to contribute with your
translation, the first step is to clone this repo and move to the
develop
branch. Then, create the locale for your translation by
executing:
python setup.py init_catalog -l <YOUR_LOCALE>
This will generate a file called
i18n/YOUR_LOCALE/LC_MESSAGES/ckanext-datarequests.po
. This file
contains all the untranslated strings. You can manually add a
translation for it by editing the msgstr
section:
msgid "This is an untranslated string"
msgstr "This is a itranslated string"
Once the translation files (po
) have been updated, compile them by
running:
python setup.py compile_catalog
This will generate the required mo
file. Once this file has been
generated, commit your changes and create a Pull Request (to the
develop
branch).
This sofware contains a set of test to detect errors and failures. You can run this tests by running the following command (this command will generate coverage reports):
python setup.py nosetests
Note: The test.ini
file contains a link to the CKAN
test-core.ini
file. You will need to change that link to the real path
of the file in your system (generally
/usr/lib/ckan/default/src/ckan/test-core.ini
).
Note 2: When creating a PR that includes code changes, please, ensure your new code is tested. No PR will be merged until the Travis CI system marks it as valid.
datarequest_create
:arrow_right: create_datarequest
datarequest_show
:arrow_right: show_datarequest
datarequest_update
:arrow_right: update_datarequest
datarequest_index
:arrow_right: list_datarequests
datarequest_delete
:arrow_right: delete_datarequest
datarequest_close
:arrow_right: close_datarequest
datarequest_comment
:arrow_right: comment_datarequest
datarequest_comment_show
:arrow_right:
show_datarequest_comment
datarequest_comment_list
:arrow_right:
list_datarequest_comments
datarequest_comment_update
:arrow_right:
update_datarequest_comment
datarequest_comment_delete
:arrow_right:
delete_datarequest_comment