This is a port to Django of the PHP election leaflets application which can be found at https://code.google.com/archive/p/theelectionleafletproject/.
In order to speed up this port, we are running the first version using the original database structure. We'll tidy up areas of the database as necessary as new functionality is added. This shouldn't make a difference to new developers if you're starting from scratch.
You'll need some basic requirements installed on your machine, probably through your package manager:
- Python 3.12.x
- Node.js 18+
- PostgreSQL
- PostGIS
- Redis
- Yarn
This should do the trick on macOS or Linux with Homebrew:
brew install python node postgresql postgis redis yarn pipenv
- Launch a shell with pipenv
pipenv shell
- Settings and database
createdb electionleaflets
createuser electionleaflets
psql -c 'ALTER ROLE electionleaflets WITH SUPERUSER' # Needed to activate PostGIS
cp electionleaflets/settings/local.py.example electionleaflets/settings/local.py # Optional: add a TheyWorkForYou API key here
python manage.py migrate
python manage.py createcachetable
python manage.py constituencies_load_constituencies
mkdir -p electionleaflets/media/uploads/{thumbnail,small,medium,large}
python manage.py createsuperuser # Create a user to login to /admin with
- Install frontend dependencies
yarn install && bower install
- Run gulp in another tab for development. This will watch for changes and recompile assets automatically. You'll need gulp-cli
gulp
- Run django
python manage.py runserver
-
Visit the site at http://127.0.0.1:8000/
-
See our guidelines for contributing
The app is deployed to AWS using the Serverless Framework. This manages resources in AWS Lambda and AWS API Gateway.
The app is deployed through CircleCI. The staging deployment is triggered by temporarily adding the current branch to context in the sam-deploy job. The production deployment is triggered by merging to master.