This repository contains code for running the invest_game
study and supporting questionnaires. It also contains (deprecated!) non-invest_game
code designed to run other game experiments. This functionality is siloed in its own Django app but could be restored in the future.
This application uses virtualenv
to manage the local development environment. Follow the steps below to set up your environment:
- If you do not have
pip
installed, follow the instructions here. - Install
virtualenv
:pip3 install virtualenv
- Set up you virtual environment. From the root directory of this repository, run:
virtualenv --python=$(which python3) env
- Enter your new virtual environment:
source ./env/bin/activate
- Install dependencies:
pip install -r requirements.txt
- If running the app for the first time, build the database:
python manage.py migrate
In development, we use sqlite
as the database backend for convenience. In production, we use Postgres.
Start Django's development server with the following command:
python manage.py runserver
You can then run the application at localhost:8000?id=<some_id>
.
To leave your virtual environment when you've finished working on the project, run: deactivate
.
If any changes are made to Django models, you'll need to make a migrations file and run migrations locally to see those changes reflected in the database. To make a new migrations file, run:
python manage.py makemigrations
To apply new migrations, run:
python manage.py migrate
In the production environment, new migrations will be automatically applied.
In the local environment, you can create a superuser that will have access to the admin panel. Run:
python manage.py createsuperuser
and follow the prompts.
The application is configured to be deployed to an Elastic Beanstalk environment in AWS. This readme assumes that the EB environment is already set up. The environment should have a Postgres database instance connected to it. Database configuration can be managed via the Elastic Beanstalk console.
Assuming such an environment exists, the application can be deployed by running:
eb deploy <environment_name>
where <environment_name>
is the name of the EB environment. If no <environment_name>
is supplied, the deployment will default to an environment called Online-Study-Game
. It's intended that the default environment name be used for the production application.
If you need to create an environment, use the eb create
command, documented here.
The production application will deploy automatically when new commits are merged and pushed to the master
branch of the umsi/Online-Study-Game
repository.
The standard Django admin application can be accessed at <application_url>/admin
. The username and password are set using a database fixture found in games/invest_game/fixtures/users.json
.
From the admin panel, you can export study data to a CSV file.
Run tests with:
python manage.py test