Contributing¶
Contents
Setup¶
Create a Python 3.11 virtual environment.
Set up the git pre-commit hook:
pip install pre-commit
pre-commit install
Backend¶
Install development dependencies:
pip install -r requirements_dev.txt
Run database migrations:
./manage.py migrate
If you don’t have an instance of Pelican backend, create its database and load fixtures:
createdb pelican_backend
gunzip -c tests/fixtures/pelican-backend.sql | psql pelican_backend
Frontend¶
Change to the frontend directory:
cd frontend
Install development dependencies:
npm install
Development¶
In one terminal, start the backend server:
./manage.py runserver
In another terminal, start the frontend server:
cd frontend
npx vue-cli-service serve
Backend¶
The Django project is made up of two apps:
api: Serves API requestsexporter: Generates the exports to Google Docs
API documentation¶
See also
If you edit views.py, regenerate the OpenAPI document by running the server and:
curl http://127.0.0.1:8000/api/schema/ -o docs/_static/openapi.yaml
Pelican backend integration¶
Pelican backend’s database is treated as a read-only legacy database, with managed = False in all model’s Meta class, and with a DATABASE_ROUTERS setting that routes queries to its database.
To update api/models.py following changes to Pelican backend’s database schema:
Run
python manage.py inspectdb > api/models.pyReplace comments at top of file
Replace
models.DO_NOTHINGwithon_delete=models.CASCADEDataset.meta: Addblank=True, default=dictDatasetFilter.dataset_id_original: Rename toparent, addrelated_name="children"DatasetFilter.dataset_id_filtered: Rename todataset, addrelated_name="filtered"ProgressMonitorDataset.dataset: Addrelated_name="progress"ProgressMonitorItem.item: Rename todata_itemReport.type: ChangeTextFieldtoCharField, addmax_length=255, and remove# This field type is a guess.
Learning¶
Testing¶
Backend¶
./manage.py test
Frontend¶
npm run test
Run linters:
npx vue-cli-service lint
Production¶
Prepare a production build:
npx vue-cli-service build
This sets the NODE_ENV environment variable to "production". To override this default, use:
npx vue-cli-service build --mode development