Give individuals access to S3-hosted data files, also exportable to Open Humans.
Individuals are managed according to their email addresses. The email is what the account is initialized for, files are returned to that address, and login tokens go to it.
- Use
virtualenv
and install requirements with pip (pip install requirements.txt
). - Have
foreman
installed. Foreman is used to load environment variables, which is how you'll store your private AWS keys. - Migrations:
python manage.py migrate
- Use 'createsuperuser' to create a new admin account for yourself with
python manage.py createsuperuser
- Use this account to log in to the admin site at
/admin
.- Edit the "Site" object so the "domain name" and "display name" are the names you would like to use for this site.
- Create a "SiteConfig" object for the "Site" object and enter the explanatory text you would like to have on the data return page into the 'Data page explanation' field. You can use Markdown to format this text.
- Create an "OpenHumansConfig" object for the "Site" object. For the
'source name' enter the name of the corresponding app for this study in the
Open Humans site. (Check how it's represented in
open-humans/studies/
and the correspondingapps.py
).
- Follow instructions for "Loading files into S3"
- Create user accounts with associated data by running:
foreman run python manage.py load_data
- (Or if the site is on Heroku, you do:
heroku run python manage.py load_data
)
- (Or if the site is on Heroku, you do:
- To invite users to their data accounts...
- You can use the
send_invites
management command. The email subject and content can be customized in the SiteConfig object. - Or you can download a CSV listing your users (by email address) and a fresh
set of associated login tokens by visiting
/admin/user_tokens
. These tokens can be incorporated via mail merge software.
- You can use the
- Copy
env.example
to.env
and add info needed for using AWS S3 - Create a CSV format document with these features (see example):
- No header
- Column 1: Recipient.
The recipient's email address. - Column 2: Type.
There are two different types of data return:file
orlink
. - Column 3: Path to file.
- for
link
: URL to return. - for
file
: local file that will be loaded onto S3.
(Note: the version of this file uploaded onto S3 will have this field replaced with the S3 key name.)
- for
- Column 4: Name.
- for
file
: the basename to use for the file on S3. - for
link
: a name to use when displaying the link.
- for
- Column 5: Description.
Description of this item.
- To load these files onte S3, use foreman to run
scripts/load_files.py
, e.g.:foreman run python scripts/load_files.py FILELIST.CSV --localpath FILE/PATH/
For example, running the following in the project's base directory (which uses the example list "examplelist.csv" and data in the "exampledata" directory:
foreman run python scripts/load_files.py example/examplelist.csv --localpath example/exampledata
...results in:
- an S3 file loaded with the key
datareturn/862f0de367ce252edd509bd25a3505c91d0e145a/photo.jpg
- a slightly modified version of
examplelist.csv
loaded to S3 with the keydatareturn_info.csv