Skip to content

daviddavidgit/tq-website

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tanzquotient (TQ) Website

The website is built using Django, and uses redis for caching and celery as a task queue.

Users can find a user documentation here.

The main repository lives on the ETH Gitlab and is mirrored to Github.

The repository contains the needed configurations to deploy to SIP.

Local Setup

⚠️ Windows (including WSL) is no supported. Please use Linux or MacOS. ⚠️

  1. Make sure Docker is installed.
  2. Clone this repo: git clone <repo-url>
  3. Create a python environment using python >= 3.9. You can for example set it up with a venv.
    1. python3 -m venv venv
    2. source venv/bin/activate
  4. Initialize the project: ./scripts/initialize_project.sh (this will install the requirements and start the Docker containers)
  5. Run the project: python manage.py runserver (from within your venv!)
  6. Find the website at localhost:8000
  7. Import a database dump (see below)

When you are done developing, stop the containers again: docker compose down.

Using Intellij or PyCharm

Useful resources:

Configuration

All configuration lives in an environment file: .env. The following elaborate scheme of scripts is used to generate it.

The file variables.yml is the single source of truth by defining all environment variables needed for this project to run. The file is checked into the git repository. Do not modify variables.yml unless you want to define new env variables or remove outdated ones.

The file overrides.yml contains custom values for your setup. A basic version will be generated when initializing the project. This file is ignored by git. Do not add it to the repository. The file is machine specific and could potentially contain secrets.

Both need to be of the following form:

# General form for an entry
<NAME_OF_VARIABLE>: <value>

# Example
COMPOSE_FILE: docker-compose.yml
TQ_DEBUG: true

Generate Environment

Run ./scripts/generate_env.py [--sip] [--overrides FILE] to generate the environment.

  • Without arguments it will create a .env file for Docker Compose and Django to use.
  • --sip will read the variables provided by SIP and create a .env file
  • To use a different overrides file specify --overrides

Restore Database dump

Get a database dump from the IT board member of Tanzquotient or use one of the dumps on the Google Drive in the IT folder.

Restore the database:

# Wipe the old database
docker exec -i tq-postgres psql -U root -d postgres -c "DROP DATABASE tq_prod_website_tq_website;"
docker exec -i tq-postgres psql -U root -d postgres -c "CREATE DATABASE tq_prod_website_tq_website;"

# Restore the dump
docker exec -i tq-postgres pg_restore --no-privileges --no-owner --format=c --schema='public' --create --dbname tq_prod_website_tq_website < dbfilename.sql

# Run the migrations (just in case, e.g. if the SQL dump is old)
python manage.py migrate

Maybe required if the database name in the prod dump differs from your local database name: Rename the database to the local name:

DROP DATABASE tq_website;
ALTER DATABASE tq_prod_website_tq_website RENAME TO tq_website;

Documentation

Releases

No releases published

Packages

No packages published

Languages

  • Python 71.7%
  • HTML 23.8%
  • JavaScript 3.7%
  • Other 0.8%