Skip to content
This repository has been archived by the owner on Jul 28, 2019. It is now read-only.

Latest commit

 

History

History
94 lines (59 loc) · 3.28 KB

README.en.md

File metadata and controls

94 lines (59 loc) · 3.28 KB

Build Status

Other languages: Français

A tool for visualising contracts for the City of Montreal

Consolidates files contracts and grants from the City of Montreal hosted on the open data portal to produce:

  • A programmable interface (API) according to the Contracting Open Data Standard format and to sort the data according to different parameters
  • Data visualization for listing and exporting contracts and grants. The web interface obtains the data by connecting to the API.

Dependencies

The API requires the following:

  • Python 2.7 or greater
  • Postgresql 9.3 or greater

The code was developed using the [Flask] (http://flask.pocoo.org/) Python microframework. Flask and all other necessary libraries are contained in the file requirements.txt.

The project follows standards for hosting on Heroku. That said, it is possible to execute the code on any configuration meeting the above prerequisites; it will be necessary to add a WSGI as [uwsgi] (http://flask.pocoo.org/docs/0.10/deploying/uwsgi/) to link the python code to a web server such as Apache or Nginx.

Installation

You can clone the code using Git:

git clone https://github.com/opennorth/ovc-vdm.git
cd ovc-vdm

Or download a zip.

Installing Python dependencies

It is recommended that you setup a virtual environment for installing Python dependencies, so as to avoid effecting your wider system.

Once you've done that, install dependencies as follows.

pip install -r requirements.txt

Environment variables

You need to set the following environment variables prior to running the application:

export APP_SETTINGS="config.DevelopmentConfig"
export DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DBNAME"
export EMAIL_CREDENTIALS="user@password"
  • APP_SETTING sets the configuration mode for running the application. The different modes are configured in the config.py file.
  • DATABASE_URL tells SQLAlchemy how to connect to the database.
  • EMAIL_CREDENTIAL is used to generate alert emails via the platform SendGrid.

Initialize the database

Before running the application, you must setup the initial database schema as follows:

python manage.py db init
python manage.py db upgrade

Import data

There are two steps to importing the intial data into the database:

python manage.py update_sources   # Import data sources
python manage.py update_releases  # Impore contracts and releases - takes a very long time

Launch the application

python app.py  # Run the development server

To use the application in production mode, it is necessary to start using WSGI Python. To run on the Heroku platform, procfile file is already in place.

Run the tests

./run_test.sh

This uses the node testing library.

Further documentation