Cafesys is the Django application driving the website of Sektionscafé Baljan. It features staff management and the fantastic Blipp system for coffee.
Note: This guide requires that you have installed Python, Docker and Docker Compose (see https://docs.docker.com/compose/install/).
If you are using Windows as OS, start by downloading WSL.
Install the Heroku client:
# WSL/Linux:
curl https://cli-assets.heroku.com/install.sh | bash
# macOS:
brew tap heroku/brew && brew install herokuIf your machine has make available, you can run:
make setupOtherwise, follow the steps below:
- Setup a Python virtual environment
python3 -m venv .venv
. .venv/bin/activate
pip install ruff pre-commit
pre-commit install- Login to heroku through the terminal by running:
heroku login- Create a backup of the PostgreSQL database by running:
heroku pg:backups:capture --app baljan- Download a dump of the database to the current directory:
heroku pg:backups:download --app baljan -o docker-entrypoint-initdb.d/latest.dump-
Copy
.env.tmplto.env
Before starting the project, fill in the missing values. You can find them in Bitwarden, or on Heroku! -
Build the Cafesys image
docker compose build web- Create a superuser for the admin
docker compose run --rm web ./manage.py createsuperuserThen you're ready to go!
To start the project, run:
make start
# or
docker compose up --build -d web workerThis part requires Buildpacks to be installed
If you want to test the build process that Heroku uses, you can follow the steps defined here.
TLDR: Running pack build baljan/cafesys:heroku will create an image named baljan/cafesys:heroku
From here you can also test the image. Buildpacks creates a normal Docker image that you can start, but you may have to tweak some environment variables.
Instead of adding a Heroku Release Phase to run migrations, which they do not recommend, they suggest using transactions to run migrations.
You do this by running:
heroku run -a baljan python manage.py migrateThis should be done everytime a change to the database is introduced, either if its through a third party app or through a new model.
Firstly, you need to install Stripe CLI on your machine.
After that, run stripe login to login using Stripe.
Lastly, simply run the following command and keep it running in a terminal:
stripe listen --forward-to localhost:8000/stripe/eventsThis command will spit out a signing secret which you will need to paste into your environment file. Go to the Stripe Dashboard, and select the sandbox instance, not the production instance. From there you need to get the sandbox private API-key which you also need to add to the environment file.
Every text element should have a translation.
To generate translations, run:
django-admin makemessages -l svThen, find the string that you've added and edit the translation to your liking. Then run:
django-admin compilemessages -l svMan behöver python3-devel och libpq-devel för att installera requiemnets lokalt