A platform for profiling public figures in Brazilian politics
cuducos Merge pull request #104 from okfn-brasil/pyup-scheduled-update-2018-1…
…2-10

Scheduled weekly dependency update for week 49
Latest commit 20edf4b Dec 11, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
jupyter Update nltk from 3.3 to 3.4 Dec 3, 2018
perfil Add Rosie's suspicions to the candidate detail view Oct 2, 2018
.codeclimate.yml Avoid the dependency of related models on import Sep 10, 2018
.coveragerc
.env.sample Avoid the dependency of related models on import Sep 10, 2018
.gitignore New website (soon) Sep 11, 2018
.pyup.yml
.travis.yml Avoid the dependency of related models on import Sep 10, 2018
Dockerfile Update to Python 3.7.1 Nov 13, 2018
LICENSE Add license Jun 22, 2018
Procfile Adapt Django for Heroku deploy Aug 27, 2018
README.md Import bill data Sep 18, 2018
codecov.yml Setup coverage CI Aug 1, 2018
docker-compose.prod.yml Change port on production Sep 18, 2018
docker-compose.yml Avoid the dependency of related models on import Sep 10, 2018
manage.py Change Django app architecture Jul 25, 2018
pytest.ini Avoid the dependency of related models on import Sep 10, 2018
requirements.txt Update requests from 2.20.1 to 2.21.0 Dec 10, 2018
setup.cfg Use pep8 and pycodestyle Sep 18, 2018

README.md

Travis CI Codecov Code Climate Apoia.se

Perfil Político

A platform for profiling candidates in Brazilian 2018 General Election, based entirely on open data.

Install

This project requires Docker and Docker Compose.

Settings

To run the API, you must copy the .env.sample to a .env file and edit it accordingly.

Running

Starting the application:

$ docker-compose up

The website and API will be available at localhost:8000 and the Jupyter at localhost:8888.

Database

Initial setup

You should create your database by applying migrations:

$ docker-compose run django ./manage.py migrate

Bringing data in

Your local data/ directory is mapped, inside the container, to /mnt/data. Each command uses a CSV (compressed as .xz or not) from a public and available source. Use --help for more info. Yet some extra data can be generated with some Django custom commands.

Once you have download the datasets to data/, the roadmap is:

$ docker-compose run django python manage.py load_affiliations /mnt/data/filiacao.csv
$ docker-compose run django python manage.py load_candidates /mnt/data/candidatura.csv
$ docker-compose run django python manage.py link_affiliations_and_candidates
$ docker-compose run django python manage.py link_politicians_and_election_results
$ docker-compose run django python manage.py load_assets /mnt/data/bemdeclarado.csv
$ docker-compose run django python manage.py load_bills /mnt/data/senado.csv
$ docker-compose run django python manage.py load_bills /mnt/data/camara.csv

API

GET /api/candidate/<year>/<state>/<post>/

List all candidates from a certain state to a given post. For example:

/api/candidate/2018/df/deputado-distrital/

Post options for 2018 are:

  • 1o-suplente
  • 2o-suplente
  • deputado-distrital
  • deputado-estadual
  • deputado-federal
  • governador
  • presidente
  • senador
  • vice-governador
  • vice-presidente

State options are the abbreviation of the 27 Brazilian states, plus br for national election posts.

GET /api/candidate/<pk>/

Returns the details of a given candidate.

GET /api/stats/<year>/<post>/<characteristic>/

Get national statistics for a given characteristic in a elected post.

Post options are:

  • deputado-distrital
  • deputado-estadual
  • deputado-federal
  • governador
  • prefeito
  • senador
  • vereador

Characteristic options are:

  • age
  • education
  • ethnicity
  • gender
  • marital_status
  • occupation
  • party

GET /api/stats/<state>/<year>/<post>/<characteristic>/

Same as above but aggregated by state.

Tests

$ docker-compose run django py.test
$ docker-compose run django black . --check