Skip to content
Snippets Groups Projects
Benjamin Bertrand's avatar
Benjamin Bertrand authored
The database constraints will catch the same error
(and raise an IntegrityError).

Having some validation at the model level allows to display nicer error
messages.
We use CSEntryError exception and not ValidationError so that it can be
used both by the API and views.
782709a3
History

CSEntry

Control System Entry web server.

Development

You can use docker for development:

  1. Clone the repository

  2. Create the database. Data will be stored under "./data" by default. You can export the PGDATA_VOLUME variable to use another directory:

    # Start only postgres so it has time to initialize
    $ docker-compose up -d postgres
    or
    $ make db
    # Initialize the database
    $ docker-compose run --rm web flask initdb
    or
    $ make initdb
  3. Start the application:

    $ docker-compose up
  4. Open your browser and go to http://localhost:8000.

  5. To run the tests:

    $ make test

Once the database has been created, you only need to run docker-compose up to start the app.

Testing

By default docker-compose reads both docker-compose.yml and docker-compose.override.yml. In docker-compose.override.yml, the current directory is mounted as a volume. This is great for development.

To test the built image, we should only use the docker-compose.yml (and ignore docker-compose.override.yml).

  1. Create the database:

    # Start only postgres so it has time to initialize
    $ docker-compose -f docker-compose.yml up -d postgres
    or
    $ make db_image
  2. Run the tests:

    $ docker-compose -f docker-compose.yml run --rm web
    or
    $ make test_image

Backup & restore

To dump the database:

$ docker run --rm --link csentry_postgres:postgres --net csentry_default -e PGPASSWORD="<csentry_password>"
  postgres:9.6 pg_dump -h postgres -U csentry csentry_db | gzip > csentry_db.dump.gz

To restore the database:

$ gunzip -c csentry_db.dump.g | docker run --rm --link csentry_postgres:postgres --net csentry_default
  -e PGPASSWORD="<csentry_password>" -i postgres:9.6 psql -h postgres -U csentry csentry_db