🌍 A website to help people find their UK polling station
Python HTML Other
Switch branches/tags
Nothing to show
Clone or download
Latest commit e06c76c Aug 2, 2018
Failed to load latest commit information.
.tx More i18n strings Mar 14, 2016
fixtures/vcr_cassettes update council importer test for newer json format Oct 31, 2017
locale Revert "add date of polling day for EU Ref" Jul 16, 2016
polling_stations Merge pull request #1407 from chris48s/preston_api Jul 27, 2018
requirements Update django from 1.11.14 to 1.11.15 Aug 1, 2018
.coveragerc don't include aloe/selenium code in coverage reports Dec 1, 2017
.gitignore pull in uglify-js from npm, gitignore node dependencies Sep 1, 2017
.pyup.yml disable daily mode for pyup Mar 1, 2018
.travis.yml Revert "alow greenkeeper bot to update lockfile" Jul 30, 2018
CODE_OF_CONDUCT.md link to code of conduct in sensible places Aug 8, 2017
CONTRIBUTING.md link to code of conduct in sensible places Aug 8, 2017
LICENSE.rst initial Feb 21, 2015
Procfile heroku update Feb 28, 2015
README.md remove greenkeeper badge Jul 30, 2018
manage.py Add pytest and tox Mar 12, 2017
package-lock.json Bump leaflet from 1.3.1 to 1.3.3 Jul 30, 2018
pytest.ini Add pytest and tox Mar 12, 2017
requirements.txt remove gunicorn from requirements Feb 28, 2015
tox.ini stop running tests on python 3.4 Feb 24, 2018


Stories in Ready

Build Status Coverage Status


This is a work in progress project that needs help in a number of ways:

  1. Importing the data we have collected from councils (See Below)
  2. If you are a developer (python, django, frontend, etc) or designer, we need help making the site itself.
  3. If you are interested in helping us gather this data, or if you know a lot about the strange world of the UK geographic system.

If you are interested in helping out in any way at all, please contact sym@democracyclub.org.uk

Getting Started


UK-Polling-Stations requires python 3.4 or 3.5

Install system dependencies

UK-Polling-Stations requires Python 3, Postgres, PostGIS, libgeos, GDAL, Node JS and NPM.

On Mac OSX, run:

brew install postgresql
brew install postgis
brew install geos
brew install gdal
brew install node

From a clean install of Ubuntu 14.04 (Trusty):

sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 python-psycopg2 python3-dev postgis postgresql-9.3-postgis-2.1 libxml2-dev libxslt-dev nodejs npm

sudo ln -s /usr/bin/nodejs /usr/bin/node

or on Ubuntu 16.04 (Xenial):

sudo apt-get install postgresql-9.5 postgresql-server-dev-9.5 python-psycopg2 python3-dev postgis postgresql-9.5-postgis-2.2 libxml2-dev libxslt1-dev nodejs-legacy npm

For other linux distributions, see here for details on installing geospatial libraries for use with Django.

The API docs rely on drafter for parsing API Blueprint. On OSX this can be installed using

brew install --HEAD https://raw.github.com/apiaryio/drafter/master/tools/homebrew/drafter.rb

On Ubuntu, this needs to be installed/compiled manually:

wget https://github.com/apiaryio/drafter/releases/download/v3.2.7/drafter-v3.2.7.tar.gz
tar xvzf drafter-v3.2.7.tar.gz
cd drafter-v3.2.7
./configure --shared
make libdrafter
sudo cp build/out/Release/lib.target/libdrafter.so /usr/lib/libdrafter.so
sudo cp src/drafter.h /usr/include/drafter/drafter.h

Install python dependencies

pip install -r requirements/base.txt

Install front-end dependencies

npm install

Install testing system dependencies

We have a suite of end-to-end integration tests. We use ChromeDriver to drive headless Chrome or Chromuim. This step isn't required to get a dev install running but will be required to run the full test suite.

On ubuntu, run

sudo apt-get install chromium-browser chromium-chromedriver

to install the dependencies. The chromedriver executable needs to be in PATH, so either add /usr/lib/chromium-browser/chromedriver to PATH or create a symlink e.g:

sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/local/bin/chromedriver

On Mac OSX, run:

brew tap homebrew/cask
brew cask install chromedriver

and if you don't already have Chrome installed:

brew cask install google-chrome

Install testing python dependencies

pip install -r requirements/testing.txt

Create local config

cp polling_stations/settings/local.example.py polling_stations/settings/local.py

Create database

sudo -u postgres createdb polling_stations
sudo -u postgres createuser dc -P -s
sudo -u postgres psql polling_stations
psql (9.3.6)
Type "help" for help.

polling_stations=# CREATE EXTENSION postgis;

Run migrations

python manage.py migrate

Import initial data

Import ONSPD

For development purposes, you can use the ONSPD for geocoding. Grab the latest release from http://geoportal.statistics.gov.uk/datasets?q=ONS%20Postcode%20Directory%20(ONSPD)&sort=-updatedAt unzip the data and import it using:

python manage.py import_onspd /path/to/data

Import Councils

python manage.py import_councils

Import some Polling District/Station data

For development purposes, you will need to seed your database with some data. Most of our import scripts reference data is hosted privately, but there are a number of councils who publish their data at a public location.

For example:

  • python manage.py import_camden
  • python manage.py import_doncaster
  • python manage.py import_lambeth
  • python manage.py import_salford
  • python manage.py import_southampton
  • python manage.py import_st_albans
  • python manage.py import_tunbridge_wells
  • python manage.py import_wolverhampton

all reference data which is publicly available.

Importing the data we have from councils

Each council that has unimported data has a Github Issue with the Data Import label.

You can see the current status in the Waffle Board.

We make a Django manage.py command in the data_collection app for each council which imports the raw data. If you are interested in helping the project by writing an import script, see the issues tagged recommended for beginners for more info.