Sustain and Gain is a mobile web app where users compete to earn points by completing sustainable tasks.
Install pipenv
pip install pipenv
Set values in .env
Enter virtual environment
pipenv shell
Install dependencies
pipenv sync
Migrate database
python manage.py migrate
Create an admin user
python manage.py createsuperuser
Initialise Sustainability Steve
python manage.py create_sustainability_steve
Install PyTorch and Transformers with pip.
Change the value of AI in .env
to 1
.
Run local email server and Redis with the following
docker compose up
You can now view emails by going to http://localhost:8025
If you do not want to verify emails, you can set
ACCOUNT_EMAIL_VERIFICATION = 'none'
insustainability/settings.py
python manage.py runserver 8000
celery -A sustainability worker -l INFO -B
Sending emails uses a Rust worker. To run this, first install Rust.
You will also need to configure the app to use Postgres which is already setup by Docker.
Set the following values in .env
:
DATABASE_URL=postgres://sustain:sustain@localhost:5432/sustain
You will need to remigrate the database to use Postgres:
python manage.py migrate
python manage.py createsuperuser
python manage.py create_sustainability_steve
Then run the worker:
cd worker && cargo run --release
The test suite can be run using the default Django test command:
python manage.py test
This discovers and runs all tests in files with names like *test.py
.
Additionally, the test suite is automatically run via GitHub actions for pushes, merges and pull requests.
Each Django app has a tests
folder containing the tests for that app - read more about project structure
below.
The project is set up as a typical Django project. Most directories are Django apps, which handle different parts of the application's functionality.
Most of our project's directories are Django apps. A typical Django app is set up like this:
│ admin.py Defines which models in this app are editable from the admin page.
│ forms.py Define forms which are relevant to this app's models.
│ models.py Models contain essential fields and behaviors of the data stored, typically mapped to a database
│ signals.py Signals notify another Django app when some behaviour takes place.
│ urls.py Map website URLs to Django views.
│ views.py Define the web responses to give a user based on a web request.
│
├───migrations Generated information used to build the models database.
│
└───tests Tests for each Django app are within that app.
factories.py Allow the building of 'default' models to make writing tests easier.
test_models.py A test file automatically run when the test suite is run.
Below is the overall product structure. Most directories are Django apps (see above) - where directories are not Django apps, an explanation has been provided.
├───.github Contains GitHub-specific information
│ └───workflows Actions automatically run on GitHub pushes (running tests, deployment)
│
├───about A Django app that manages the 'about' page containing contact information and policies (see above for Django app structure)
│
├───accounts A Django app that manages accounts and authentication (see above for Django app structure)
│
├───feed A Django app that manages the home feed users see (see above for Django app structure)
│
├───friends A Django app that manages the friend system (see above for Django app structure)
│
├───imagenet An imported AI solution for automatically validating tasks.
│
├───leagues A Django app that manages leagues users compete in (see above for Django app structure)
│
├───media Stores media such as user profile pictures and uploaded images.
│
├───static Contains static resources which need to be loaded elsewhere like the favicon.
│
├───sustainability The base Django app, containing settings and configuration.
│
├───tasks A Django app that manages tasks (see above for Django app structure)
│
├───templates Contains the Django HTML templates displayed to users via views
│
└───worker Contains the Rust background worker which handles automatic emailing, bomb task countdowns etc.
Code is commented with Python docstrings.
We have a user-focused documentation website which explains the app's features, as well as promotional documents in the 'promotional things' folder including a site overview, logo designs and images.
Additionally, we have a Kanban board on Trello to manage the agile process.
For general concerns, please email contact@sustainandgain.fun
If you need to contact the developers directly, our emails are listed below.