hc.ntnu.no
Install PostgreSQL for your OS.
Create a virtual environment with Python 3.6+. Note that the project is incompatible with Python versions above 3.10 and the tests are run in Python 3.7.
Run the following to install requirements for the project.
pip install -r requirements/development.txt
On newer Mac architectures, you might have to run the following in your terminal before installing the project dependencies:
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib $LDFLAGS"
Note that the path to openssl/lib
might vary depending on how it's been installed.
Create a local database with default settings. Update settings file with database credentials if needed.
python manage_migrations.py
Flatpages and email templates are stored in the fixtures folder. Load these:
python manage.py loaddata chemie/fixtures/*.json
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
Email templates are twofold: A HTML template and a simple text template with no styling. The simple text template serves as a default fallback for email clients not supporting HTML. The HTML templates contained in the emails folder are generated from their corresponding MJML file and should not be edited manually. Changes have to be applied to both the simple text template and MJML file. Changes done to these files are not automatically loaded in to the database and the chemie/fixtures/email-templates.json file. This is done by running:
python manage.py import_emails
This requires node.js and MJML to be installed. Run the following command to install MJML globally on your production PC (Not the server).
npm install -g mjml
Warning: There is an issue with the import_emails program which leads to all of the templates being deleted without any new ones being created to replace them. This happens when the emails/mjml-transpile.sh script can not find the mjml command. Make sure to fix this and test it locally before attempting to use this program.
python manage.py dumpdata --natural-foreign --exclude contenttypes app.model app2.model > my_dump.json
Edit the .env
file to suit your needs
docker-compose up -d --build
git stash && git pull --rebase && git pop && docker-compose restart
Run this in the terminal
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
We use pip-tools to make our requirement files easy to understand. To
add a new package to the project you need to update either of the files
requirements/base.in
, requirements/development.in
or
requirements/production.in
with the package and then run the line below
to update the files requirements/base.txt
, requirements/development.txt
and requirements/production.txt
that is used when setting up the project.
pip-compile requirements/base.in > requirements/base.txt
pip-compile requirements/development.in > requirements/development.txt
pip-compile requirements/production.in > requirements/production.txt