Backend API for the Norwegian public access TV channel Frikanalen.
The backend is configured using environment variables.
- ALLOWED_HOSTS - comma-separated list of permitted domains
- DATABASE_USER - postgres username
- DATABASE_NAME - postgres db name
- DATABASE_PASS - postgres password
- SMTP_SERVER - smtp server for outgoing email
This package builds on push as frikanalen/django-backend. To build a local copy:
docker build -t frikanalen/django-backend .
Then you can run it thus:
docker run -p 8080:8080 frikanalen/django-backend
sudo apt install python3-virtualenv python3-pip
python3 -m venv env
source env/bin/activate
pip install -r requirements-dev.txt
# Spin up PostgreSQL in Docker; web interface now at localhost:8082
docker-compose up -d
# Initialize the database
./manage.py migrate
# Load necessary fixtures (eg. content categories) into the database:
./manage.py loaddata frikanalen
EITHER Load the testing users and organizations:
./manage.py loaddata test-users
OR Create a new admin user:
./manage.py createsuperuser
Start the webserver:
./manage.py runserver
Point your browser to http://127.0.0.1:8000/admin and log in.
In addition to the HTTP API, the following commands are executed periodically as Kubernetes cron jobs in our cluster:
./manage.py fill_next_weeks_agenda
This job will fill the next week's schedule with videos as defined by the WeeklySlot model. This will generally be entries like "Fill Mondays 12-13 with the latest videos from NUUG".
./manage.py fill_agenda_with_jukebox
This job will fill the remaining unpopulated areas with videos as randomly selected from the set of all videos marked with is_filler=True.
As a convenience a test data file has been supplied, eg. for integration testing.
It contains the following organizations:
- dev-org1
- dev-org2
Additionally, the following users:
- [email protected] site administrator
- [email protected] administrator for org1
- [email protected] member of org1
- [email protected] administrator for org2
For more advanced things you'd want to check our infrastructure Ansible setup.