This project is the Department of Biodiversity, Conservation and Attractions Sea Turtles Database corporate application.
wastd
: the core Django project directory, containing common settings, configuration and templates.observations
: the primary data model for the project, defining theEncounter
andObservation
models and subclasses.users
: an extension of the Djangocontrib.auth.models.User
class, customised for this project.wamtram2
: auto-generated model classes to provide readonly ORM utility for the legacy WAMTRAM database.
The intent is for this project to replace the WAMTRAM legacy project and to act as the repository for
turtle tagging data. The wamtram
application was created to ease access to the legacy database, and
the tagging
application was created as an interim step to refactoring the legacy data into the
Encounter/Observation model defined in the observations
application. It is expected that wamtram
will
be removed after data migration, and that tagging
will be removed after the data is refactored.
The recommended way to set up this project for development is using Poetry to install and manage a virtual Python environment. With Poetry installed, change into the project directory and run:
poetry install
To run Python commands in the virtualenv, thereafter run them like so:
poetry run python manage.py
Manage new or updating project dependencies with Poetry also, like so:
poetry add newpackage==1.0
This project uses python-dotenv to set environment variables (in a .env
file).
The following variables are required for the project to run:
DATABASE_URL="postgis://USER:PASSWORD@HOST:5432/DATABASE_NAME"
Variables below may also need to be defined (context-dependent):
SECRET_KEY=ThisIsASecretKey
DEBUG=True
GEOSERVER_URL=https://geoserver.url/service
Use runserver
to run a local copy of the application:
poetry run python manage.py runserver 0:8080
Run console commands manually:
poetry run python manage.py shell_plus
The production system stores media uploads in Azure blob storage. Credentials for doing so should be defined in the following environment variables:
AZURE_ACCOUNT_NAME=name
AZURE_ACCOUNT_KEY=key
AZURE_CONTAINER=container_name
To bypass this and use local media storage (for development, etc.) simply set
the LOCAL_MEDIA_STORAGE=True
environment variable and create a writable
media
directory in the project directory.
To build a new Docker image from the Dockerfile
:
docker image build -t ghcr.io/dbca-wa/wastd .
Use sphinx-build
build docs locally:
poetry run sphinx-build -b html docs _build
Use http.server
serve them:
poetry run python -m http.server --directory _build 8080
This project includes the following pre-commit hooks:
- TruffleHog (credential scanning): https://github.com/marketplace/actions/trufflehog-oss
Pre-commit hooks may have additional system dependencies to run. Optionally install pre-commit hooks locally like so:
poetry run pre-commit install
Reference: https://pre-commit.com/