Webpage for HC
Python HTML JavaScript CSS Other
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
backupjob
chemie Made image fields nullable and blankable Aug 15, 2018
emails Add email template for Bedpres and fix minor errors Jan 30, 2018
nginx Add custom error page to nginx Apr 6, 2017
requirements Minor change to requirements and init settings Apr 4, 2018
.gitignore Update gitignore and edit local settings May 2, 2018
Dockerfile
README.md Clean up requirements Feb 28, 2018
docker-compose.yml Fix production setup to new structure Mar 8, 2018
manage.py
manage_migrations.py Changed project-structure Mar 1, 2018

README.md

chemie

hc.ntnu.no / chemie.no

Development setup

Install requirements

Install PostgreSQL for your OS.

Create a virtual environment with Python 3.6+.

Run the following to install requirements for the project.

pip install -r requirements.txt

Set up database

Create a local database with default settings. Update settings file with database credentials if needed.

python manage_migrations.py

Load fixtures

Flatpages and email templates are stored in the fixtures folder. Load these:

python manage.py loaddata fixtures/*.json

Send mail (optional)

Postoffice is the mail backend in this project. All emails are queued and not sent until you run this command:

python manage.py send_queued_mail

The following environment variables must be set and you must be on eduroam or use VPN to NTNU.

EMAIL_HOST_USER=webkom@hc.ntnu.no
EMAIL_HOST=smtp.ansatt.ntnu.no

Re-create email templates

Email templates are twofold: A HTML template and a simple text template with no styling. These must be loaded into the database before use. This is done by running:

python manage.py import_emails

This requires MJML to be installed.

DevOps

Export models to json

python manage.py dumpdata --natural-foreign --exclude contenttypes app.model app2.model > my_dump.json

Production environment

Edit the .env file to suit your needs

docker-compose up -d --build

Update production

git stash && git pull --rebase && git pop && docker-compose restart

Add packages to requirements

We use pip-tools to make our requirement files easy to understand. To add a new package to the project you need to update the requirements.in file with the package and then run the line below to update the requirements.txt that is used when setting up the project.

pip-compile requirements.in > requirements.txt

Likewise with any additional production requirements.