nickyspag / public-people-data

Making news more useful for democracy in South Africa

Home Page:https://publicpeople.org.za

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Public People

This django app provides a basic user interface showing news and public post/membership history about public people. It also provides an API for retrieving the identity and post data about persons, and an interface for administrators to manage the person data.

Person data is in the Popolo standard. We get our baseline data from Peoples' Assembly, but we can correct it directly in this database.

How this project is organised

On the server:

  • uses dj-database-url for database URL injection
  • uses django-pipeline for asset compilation and fingerprinting
  • uses pyscss for compiling SCSS to CSS
  • Bower to install assets
  • better debugging with python manage.py runserver_plus from django-extensions
  • cookies for session storage

On the client:

  • JQuery
  • Google Analytics
  • Bootstrap
  • FontAwesome

Setting up your dev environment

Clone this git repository

Create a project python 2 virtual environment in the repository directory and activate it

Install python dependencies using pip install -r requirements.txt

Create a database

Then, the first time you run the server, run migrations and create a superuser

python manage.py migrate
python manage.py createsuperuser

Update popolo data:

The first time, create the source

python manage.py popolo_sources_update --create https://www.pa.org.za/media_root/popolo_json/pombola.json

Subsequently, just update (without --create)

python manage.py popolo_sources_update https://www.pa.org.za/media_root/popolo_json/pombola.json

Then you can run the server

python manage.py runserver

You can log in as your new superuser and explore the data using the admin interface at http://localhost:8000/admin and the public interface at http://localhost:8000/

Development

  • Put javascript into code4sa/static/javascript/app.js
  • Put SCSS stylesheets into code4sa/static/stylesheets/app.scss
  • Install new asset packs with Bower: bower install -Sp package-to-install
  • Get better debugging with python manage.py runserver_plus

Production deployment

Production deployment is based on running the app on dokku

Intitial deployment

dokku apps:create publicpeople
dokku config:set DATABASE_URL=postgresql://.../publicpeople \
                 DJANGO_DEBUG=false \
                 DISABLE_COLLECTSTATIC=1 \
                 DJANGO_SECRET_KEY=some-secret-key \
                 NEW_RELIC_APP_NAME=cool app name \
                 NEW_RELIC_LICENSE_KEY=new relic license key

After pushing to the dokku git remote:

dokku run publicpeople python manage.py migrate
dokku run publicpeople python manage.py createsuperuser

Regular change deployment

git push dokku master

Updating popolo data

The first time, create the source

dokku run publicpeople python app/manage.py popolo_sources_update --create https://www.pa.org.za/media_root/popolo_json/pombola.json

Subsequently, just update (without --create)

dokku run publicpeople python app/manage.py popolo_sources_update https://www.pa.org.za/media_root/popolo_json/pombola.json

Accessing the data

People API

The People API can be explored interactively at https://publicpeople.org.za/api/

News API

An example query to the News API

News API documentation

License

MIT License

Attribution

About

Making news more useful for democracy in South Africa

https://publicpeople.org.za

License:MIT License


Languages

Language:Python 66.1%Language:HTML 31.6%Language:Shell 1.5%Language:CSS 0.7%