Greg
Greg (Guest REGistration) provides a core API for keeping track of guests at an institution.
It is built on Django and REST framework.
Installation
Poetry is used for dependency management.
# Make sure poetry is installed, see docs
poetry shell # Start a shell, creating a virtual environment.
poetry install # Install dependencies from lock file
Configuration
Local configuration is read from gregsite/settings/local.py
. Put secrets and local modifications here.
# Make sure a local settings file exists
$ touch gregsite/settings/local.py
gregsite/settings/base.py
contains common configuration for all environments. Put defaults here.
gregsite/settings/dev.py
contains development configuration. It's used when running a development server using python manage.py runserver
.
gregsite/settings/prod.py
contains production configuration. It's used when the application is initialized by an application server via gregsite.wsgi
or gregsite.asgi
.
Any settings in local.py
override definitions in base.py
, dev.py
and prod.py
.
Development
python manage.py migrate
# python manage.py loaddata testdata
# python manage.py createsuperuser
python manage.py runserver
API documentation
An OpenAPI schema is available at /api/schema/
. Point your browser to /api/schema/swagger-ui/
for an interactive Swagger UI.
Refer to drf-spectacular for details about the schema generation.
Sending notifications
python manage.py notification_publisher
Testing
Use pytest with the pytest-django library to run unit tests.
pytest
There are two scripts for adding data to the database:
- greg/tests/populate_fixtures.py
- greg/tests/populate_database.py
where the former uses randomized data, and the latter uses specific data useful in combination with the frontend. See the respective files for how to use them.
Themes
The application has three different themes: uio, uib and default. The default uses the palette found in Material UI, while uio and uib sets a color scheme that matches the institution.
To set the theme used update REACT_APP_THEME in frontend/.env.
Static type analysis
Use mypy to run static type checks using type hints.
mypy .
Container images
A Containerfile
is provided for application deployment purposes. It is not designed to be used for development.
update-harbor-image.sh
is a utility script for building and uploading a Docker image to our private image repository harbor.uio.no
.
It expects you to be logged in:
docker login harbor.uio.no
Deployment
TODO: Make a Helm chart.