Name: D4S2
Owner: Duke Center for Genomic and Computational Biology
Description: Web service to facilitate notification and transfer of projects in DukeDS
Created: 2016-03-16 16:45:50.0
Updated: 2016-11-23 17:10:50.0
Pushed: 2018-01-10 14:35:40.0
Homepage: null
Size: 382
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Web service to facilitate notification and transfer of projects in DukeDS
Clone the repository
Install dependencies
pip install -r requirements.txt
Create a settings.py
file:
cp d4s2/settings.template d4s2/settings.py
Create the database schema:
$ python manage.py migrate
Create a superuser (A user account is required for making authenticated API requests)
$ python manage.py createsuperuser
6 . Register an application with a Duke DS instance and create a DDSEndpoint with the URLs, agent key, and provider id
$ python manage.py createddsendpoint \
endpoint-name \
https://api.dataservice.duke.edu/api/v1 \
registered-application-agent-key \
https://dataservice.duke.edu \
openid-provider-id
Start the app:
$ python manage.py runserver
Start the background task runner:
$ python manage.py process_tasks
The server is running and the API can be explored at http://127.0.0.1:8000/api/v1/
Clone the repository
Create a d4s2.env
file
cp d4s2.env.sample d4s2.env
Edit the d4s2.env
file to populate the your DukeDS API details, a django key, and a database username/password to use:
D4S2_SECRET_KEY=some-random-string
D4S2_DDSCLIENT_URL=https://dataservice-host/api/v1
POSTGRES_USER=d4s2_user
POSTGRES_PASSWORD=some-random-password
POSTGRES_DB=d4s2_db
Create the database schema:
$ docker-compose run web python manage.py migrate
Create a superuser (A user account is required for making authenticated API requests)
$ docker-compose run web python manage.py createsuperuser
Start the app:
$ docker-compose up
The server is running and the API can be explored at http://your-docker-host:8000/api/v1/
D4S2 sends emails to notify recipients of data deliveries and other actions. To share or deliver data using D4S2, sending users must belong to groups. Each group must have a set of email templates registered for the actions its users will perform (share, delivery, accept, decline, etc).
The email templates are intended to be specific to a group of users (such as a data-generating core facility), so there is no default group.
Groups and users can be registered with a manage.py command. To register user with NetID ba123 and add to group informatics, use the following:
python manage.py registeruser ba123@duke.edu informatics
Groups, users, and Email templates can also be administered via the Django Admin application:
Login to admin at http://127.0.0.1:8000/admin (using your superuser account)
Create email templates manually for each action and group or load the samples:
python manage.py loaddata emailtemplates.json
Sample templates included are linked to the group with id 1 and the user with id 1.
Sharing a project is done by granting permissions to additional users, then notifying those users via email.
This application is responsible for sending emails to the recipients, based on the roles they are given.
Create a Django group, add django user to group. Must correspond to
Create an email template, associate with group and role
Create a Share:
$ curl -X POST \
-H "Authorization: X-DukeDS-Authorization <JWT from DukeDS>"
-H "Content-Type: application/json" \
-d '{"project_id": "project-dds-uuid", "from_user_id": "from-user-uuid", "to_user_id": "to-user-uuid", "role": "file_downloader" } \
http://127.0.0.1:8000/api/v1/shares/
{"id":1,"url":"http://127.0.0.1:8000/api/v1/shares/1/","project_id":"xxxx","from_user_id":"xxxx","to_user_id":"xxxx","state":0}
Send the email (Without changing settings.py to activate a real email backend, emails will only be printed to the django console)
$ curl -X POST http://127.0.0.1:8000/api/v1/shares/1/send/
{"id":1,"url":"http://127.0.0.1:8000/api/v1/shares/1/","project_id":"xxxx","from_user_id":"xxxx","to_user_id":"xxxx","state":1}
Notice the state change, and the running django server should print out the email to the console