Skip to content

Latest commit

 

History

History
134 lines (91 loc) · 5.3 KB

README.md

File metadata and controls

134 lines (91 loc) · 5.3 KB

directory-cms

circle-ci-image codecov-image gitflow-image calver-image

CMS for the GREAT platform - the Department for International Trade (DIT)


Development

Installing

$ git clone https://github.com/uktrade/directory-cms
$ cd directory-cms
$ [create and activate virtual environment]
$ make install_requirements
$ make manage migrate

Requirements

Python 3.6

Postgres 9.5

Redis

Configuration

Secrets such as API keys and environment specific configurations are placed in conf/env/secrets-do-not-commit - a file that is not added to version control. To create a template secrets file with dummy values run make secrets.

Commands

Command Description
make clean Delete pyc files
make pytest Run all tests
make pytest test_foo.py Run all tests in file called test_foo.py
make pytest -- --last-failed` Run the last tests to fail
make pytest -- -k foo Run the test called foo
make pytest -- Run arbitrary pytest command
make flake8 Run linting
make manage Run arbitrary management command
make webserver Run the development web server
make requirements Compile the requirements file
make install_requirements Installed the compile requirements file
make css Compile scss to css
make secrets Create your secret env var file
make worker Run async cache celery worker
make database Updates the db template with any newly added migrations
make db_template Drop, then set up fresh db from template
make load_fixtures Load fixtures from fixtures/data.json

Setting up the local database

$ make database

make database drops then recreates the local database then loads db_template.sql so no migrations need to be run. Do this if you need a fresh database with no pre-existing pages or users.

$ make load_fixtures

To add some dummy content to your local database run make load_fixtures. This will overwrite your local database with data from db_fixtures.sql. This includes a dummy account with username "dev" and password "password".

To make sure setting up a fresh db is nice and speedy please make sure to run make db_template after adding any new migrations.

Image storage

Pages and images can be copied "upstream" from one environment to another. To facilitate this a single S3 bucket is used by all environments. A constraint of this approach is the bucket is immutable insofar as images can be uploaded but not deleted or changed.

The entries must be added on your conf/.env file:

AWS_STORAGE_BUCKET_NAME
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY

Speak to a team mate or consult dev vault to retrieve the AWS_STORAGE_BUCKET_NAME.

/etc/hosts file entry

UI clients on local expect the CMS to be reachable at the address http://cms.trade.great.

 Add 127.0.0.1 cms.trade.great

You can test this works by attempting to visit http://cms.trade.great:8010/admin in your browser.

Session

Signed cookies are used as the session backend to avoid using a database. We therefore must avoid storing non-trivial data in the session, because the browser will be exposed to the data.

Staff SSO

On local machine, SSO is turned off by default. If you need to enable, set the FEATURE_ENFORCE_STAFF_SSO_ENABLED to true. You also need to set:

STAFF_SSO_AUTHBROKER_URL
AUTHBROKER_CLIENT_ID
AUTHBROKER_CLIENT_SECRET

Speak to webops or a team mate for the above values.

Cache

A cached version of the page is created every time the page is saved. Additionally, all the cache entries are recreated by a scheduled task using django-celery-beat. Make sure to add the rebuild_all_cache task to the scheduler via the Django admin interface.

Helpful links

Related projects:

https://github.com/uktrade?q=directory

https://github.com/uktrade?q=great