diff --git a/.env.sample b/.env.sample
index 9ecf7e9..4279947 100644
--- a/.env.sample
+++ b/.env.sample
@@ -1,4 +1,23 @@
-DATABASE_URL=postgres:///myurl
+################################
+# #
+# THIS IS A SECRET FILE!!! #
+# #
+# Do not add your .env to git! #
+# #
+################################
+
+# SECRET_KEY encrypts things. In production it should be a random string.
SECRET_KEY=mysecretshouldnotbeongit
-OH_CLIENT_ID=myclientidshouldnotbeongit
-OH_CLIENT_SECRET=myclientsecretshouldnotbeongit
+
+# ADMIN_PASSWORD is how you log in to manage this app and configuration.
+ADMIN_PASSWORD=''
+
+# Optional, but you probably want this for logging and debugging.
+PYTHONUNBUFFERED='true'
+
+# Set DATABASE_URL to use something other than the default SQLite.
+# DATABASE_URL=postgres:///myurl
+
+# Set app base URL. If unset, defaults to http://127.0.0.1:5000 local,
+# and herokuapp.com URL on Heroku.
+# APP_BASE_URL='http://127.0.0.1:5000'
diff --git a/LICENSE b/LICENSE
index 0d8f1c3..8a0d8f9 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2018 Bastian Greshake Tzovaras
+Copyright (c) 2018 Bastian Greshake Tzovaras, Mad Price Ball
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Procfile b/Procfile
index 0bc58d7..063f11a 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1,2 @@
+release: python manage.py migrate
web: gunicorn oh_data_uploader.wsgi --log-file=-
diff --git a/README.md b/README.md
index 21ac247..2658bc3 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@
> *it's like Jekyll for Open Humans*
or something along the lines.
+[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
+
Ultimately this should be an easy to deploy Django project that functions as a
file uploader for individual *Open Humans* projects. It should be easy deploy to
*heroku* and the configuration/styling of the project website should be done more
@@ -24,17 +26,23 @@ conda create -n oh_uploader python=3.6
pip install -r requirements.txt
```
-*Step 2: Install heroku-CLI & PostgreSQL*
+*Step 2: Install Heroku Command Line Interface (CLI)*
+
+You should install the Heroku CLI to run this app. Heroku has [installation instructions for MacOS, Windows, and Linux](https://devcenter.heroku.com/articles/heroku-cli#download-and-install).
-If you are running MacOS the easiest way to do this is using [Homebrew](https://brew.sh/). If you are on a Linux machine you [should be able to do the same things using Linuxbrew](https://virtualenv.pypa.io/en/stable/). After installing Homebrew/Linuxbrew
-you can do:
+If you are running MacOS the easiest way to do this is using [Homebrew](https://brew.sh/). After installing Homebrew you can do:
```
-brew install postgres
brew install heroku/brew/heroku
```
-Once this is done you can start the setup of your *Open Humans uploader* by copying the example `.env` file (`cp .env.sample .env`) and entering at least your database URL. Once this is done you can migrate your database using `heroku local:run python manage.py migrate`. Afterwards you can start the webserver of your local heroku environment using `heroku local`.
+Once this is done you can complete minimal setup by:
+* Create an `.env` file from the example: `cp .env.sample .env`)
+* Edit `.env` to set a random string for `DJANGO_SECRET`
+* Migrate your database using `heroku local:run python manage.py migrate`
+* Initialize config with `heroku local:run python manage.py init_proj_config`
+
+Now you can run the webserver of your local heroku environment using `heroku local`.
To fully set up your uploader you will have to modify some files, as described below.
@@ -97,7 +105,7 @@ prominently on the front page.
```
# Give the path to the logo of your project.
-logo: ' static/example_logo.png'
+logo: ' static/default_logo.png'
# Is there a larger project website where more info might be located?
more_info_link: http://www.github.com/gedankenstuecke/oh_data_uploader
diff --git a/_descriptions/index.md b/_descriptions/index.md
index 5bde8b5..05b99df 100644
--- a/_descriptions/index.md
+++ b/_descriptions/index.md
@@ -1,16 +1,17 @@
# What does my project do?
This tool allows you to easily setup your own *Open Humans* project that wants
-to collect data. You just need to set up some configuration files before you
-can deploy it *heroku*.
+to collect data.
-The configuration files are:
+The configuration for this project is in:
-- `config.yaml` in the main directory of this git repository. This contains details
-on your project that aren't secret like the title, description, where the logo can be found etc.
-- The `.env` contains the secret details that shouldn't be shared. E.g. your database setup,
-your *Open Humans* API keys etc.
-- The texts that should be displayed on this project website. In `_descriptions` you can find the
-markdown files needed to customize this template. E.g. this page is written in `_descriptions/index.md`.
+- **Environment variables:** If you deploy to Heroku, you'll probably be
+prompted to provide these, and they can be modified in the the app. Locally,
+your `.env` file defines these. These are secret details that should not be
+shared. (Be sure not to add this to your git repository!)
+- **Project configuration:** The [Project Admin page](/project-admin) can be
+used to configure other aspects of your site. Log in with the `ADMIN_PASSWORD`
+you set in environment variables.
-Use this page to inform your users about what your project is about and what it tries to do. It's the first
-page they will see, so be verbose!
+As you configure the project, replace this "front page" text to inform
+users what your project is about and what it tries to do. It's the first page
+they will see, so be verbose!
diff --git a/app.json b/app.json
new file mode 100644
index 0000000..971805c
--- /dev/null
+++ b/app.json
@@ -0,0 +1,23 @@
+{
+ "name": "Open Humans Data Uploader",
+ "description": "A web app to support data uploads to an Open Humans project",
+ "repository": "https://github.com/madprime/oh_data_uploader",
+ "keywords": ["django"],
+ "scripts": {
+ "postdeploy": "python manage.py init_proj_config"
+ },
+ "env": {
+ "HEROKUCONFIG_APP_NAME": {
+ "description": "Heroku \"App name\" (copy/paste what you set above)",
+ "required": true
+ },
+ "ADMIN_PASSWORD": {
+ "description": "You'll use this password to manage configuring this app.",
+ "required": true
+ },
+ "SECRET_KEY": {
+ "description": "This is set for you and is used to encrypt data.",
+ "generator": "secret"
+ }
+ }
+}
diff --git a/config.yaml b/config.yaml
deleted file mode 100644
index 8809993..0000000
--- a/config.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-# REQUIRED: What's the name of your project?
-project_title: My Open Humans Project
-
-# REQUIRED: Will be displayed on the front page of the uploader
-project_description: This template demonstrates how you can run your own Open Humans data upload project.
-
-# REQUIRED: Where can we find your project on Open Humans
-oh_activity_page: https://www.openhumans.org/activity/your-project-url/
-
-# REQUIRED: which URL will lead to your Open Humans uploader
-app_base_url: http://127.0.0.1:5000
-
-# REQUIRED: Tell Open Humans what kind of data is being uploaded
-file_description: This is an example file that doesnt have any meaning.
-
-# REQUIRED: Tags to add to your file uploads
-file_tags:
-- tags
-- 'are a good way to'
-- 'describe the files you are uploading'
-
-# Give the path to the logo of your project.
-logo: 'static/example_logo.png'
-
-# Is there a larger project website where more info might be located?
-more_info_link: http://www.github.com/gedankenstuecke/oh_data_uploader
diff --git a/oh_connection/context_processors.py b/oh_connection/context_processors.py
index 0e27dae..d0d4326 100644
--- a/oh_connection/context_processors.py
+++ b/oh_connection/context_processors.py
@@ -1,7 +1,9 @@
-from django.conf import settings
+from project_admin.models import ProjectConfiguration
def read_config(request):
- context = {'yaml_config': settings.YAML_CONFIG,
- 'oh_proj_page': settings.YAML_CONFIG['oh_activity_page']}
+ config = ProjectConfiguration.objects.get(id=1)
+ context = {'config': config,
+ 'is_admin': request.user.username == 'admin',
+ 'oh_proj_page': config.oh_activity_page}
return context
diff --git a/oh_connection/templates/oh_connection/application.html b/oh_connection/templates/oh_connection/application.html
index b01996a..9b41f82 100644
--- a/oh_connection/templates/oh_connection/application.html
+++ b/oh_connection/templates/oh_connection/application.html
@@ -5,7 +5,7 @@
-
Log in or create an Open Humans account
- You can upload your data for {{yaml_config.project_title}}
+ You can upload your data for {{config.project_title}}
once you have done this.
-
Authorize {{yaml_config.project_title}} on Open Humans
+
Authorize {{config.project_title}} on Open Humans
This authorizes us to deposit your archive into your Open Humans account.