Development¶
Prerequisites¶
You need the following libraries and/or programs:
Python 3.6 or higher
Python Virtualenv and Pip
PostgreSQL 9.5 or above
Getting started¶
Developers can follow the following steps to set up the project on their local development machine.
Obtain source¶
You can retrieve the source code using the following command:
$ git clone git@github.com:VNG-realisatie/besluiten-api.git brc
Note: You can also use the HTTPS syntax:
$ git clone https://github.com/VNG-realisatie/besluiten-api.git brc
Setting up virtualenv¶
Go to the project directory:
$ cd brc
Create the virtual environment:
$ virtualenv -p /usr/bin/python3.x ./env
Source the activate script in your virtual environment to enable it:
$ source env/bin/activate
Install all the required libraries:
(env) $ pip install -r requirements/dev.txt
Installing the database¶
The default settings for the database are:
name:
brc
user:
brc
password:
brc
You can customize these by setting (any of) the following environment variables:
DB_NAME
DB_USER
DB_PASSWORD
DB_HOST
DB_PORT
Launch the migration process
(env) $ python src/manage.py migrate
Note
You can put local, machine specific setting changes in
src/brc/conf/local.py
. These settings are NOT checked into version
control.
Running server¶
Create a superuser to access the management interface:
(env) $ python src/manage.py createsuperuser
You can now run your installation and point your browser to the address given by this command:
(env) $ python src/manage.py runserver
Generate the API schema¶
Install Javascript modules:
$ npm install
Launch the schema generation tool:
generate-schema
The resulting
openapi.yaml
andswagger2.0.json
files can be visualized with Swagger
Update installation¶
When updating an existing installation:
Activate the virtual environment:
$ cd brc $ source env/bin/activate
Update the code and libraries:
(env) $ git pull (env) $ pip install -r requirements/dev.txt (env) $ npm install
Update the database:
(env) $ python src/manage.py migrate