Skip to content

openknowledgeireland/mpcv

 
 

Repository files navigation

Build Status

Introduction

This is the source code to http://cv.democracyclub.org.uk/, which gathers the Curriculum Vitae of candidates for Member of Parliament of the UK.

Environment

You'll need to set these config variables in the environment:

# used for signing tokens in emails and sessions
MPCV_SECRET_KEY=somethingfairlyrandom

# set to an email address to send all emails to
MPCV_DEBUG_EMAIL=

# any setting from http://pythonhosted.org//Flask-Mail/
MPCV_MAIL_SERVER=localhost
MPCV_MAIL_USE_TLS=True/False
MPCV_MAIL_USERNAME=
MPCV_MAIL_PASSWORD=

# S3 bucket for storing CVs in
MPCV_S3_BUCKET_NAME=xxxx
MPCV_S3_ACCESS_KEY_ID=
MPCV_S3_SECRET_ACCESS_KEY=

# Admin functions accessible with this
MPCV_ADMIN_KEY=xxxx

# Disable asset bundling (for debugging)
MPCV_ASSETS_DEBUG=true

Development

To test in development do:

./main.py

ZZ9 9ZZ is a test constituency postcode, which uses fake data without even calling MaPit.

Testing

Python unit tests

These aim to test all the Python code.

./main_tests.py

You need the S3 bucket environment variables set, even when testing. And no other environment variables (main_tests.py sets some itself).

MPCV_S3_BUCKET_NAME=xxxx
MPCV_S3_ACCESS_KEY_ID=
MPCV_S3_SECRET_ACCESS_KEY=

You can find a line coverage report in covhtml/index.html.

Selenium integration tests

These test the main use paths, and any serious browser-side Javascript.

./selenium_tests.py http://localhost:5000/

The first parameter is the URL the site to test is running on.

It makes some assumptions about the ZZ9 9ZZ postcode - in particular it will upload a CV to one of the test users in that postcode.

Production

In production, Heroku uses the config in Procfile.

We use a custom Heroku buildpack to install phantom.js and python stuff. To set this up, run:

heroku buildpack:set https://github.com/ddollar/heroku-buildpack-multi.git

We use the scheduler add-on to build thumbnails. Install and configure that with:

heroku addons:add scheduler
heroku addons:open scheduler

Then add the following to your cron task:

python cron.py

About

Gather Curriculum Vitae of candidates for Member of Parliament of the UK.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 56.2%
  • HTML 25.6%
  • JavaScript 12.3%
  • CSS 5.9%