Giter Site home page Giter Site logo

public-people / public-people-data Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 4.0 1.1 MB

Making news more useful for democracy in South Africa

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

License: MIT License

Shell 1.38% Python 57.17% CSS 7.97% HTML 33.48%
democracy news popolo django

public-people-data's Introduction

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

Configuration for running the server and database in docker-compose has been provided. The simplest way to get up and running is using docker-compose but nothing strictly depends on it, so feel free to set up another way, bearing in mind that less support would be available.

The following only has to be run the first time you set up your development environment, or when you've deleted the database volume and want to set it up again.

  1. Clone this git repository and change into the repository directory.

  2. Start and create the database - this will keep the docker-compose log running in this shell

docker-compose up db
  1. Then in another shell prompt, initialise the database and superuser:
docker-compose run --rm web python manage.py migrate
docker-compose run --rm web python manage.py createsuperuser
  1. Start the sample data server
docker-compose -f docker-compose.yml -f docker-compose.dev-data.yml up -d dev-data
  1. Load some example popolo data:
docker-compose run --rm web python manage.py popolo_sources_update --create http://dev-data:8001/pombola.json

Then you can run the server

docker-compose up -d web

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/

Search for one of the names in the example popolo data to see the site working.

Subsequently, you only need to start the database and server with

docker-compose up

Resetting the development database to revert changes

There are two ways to reset the development database back to the way it's just been set up:

The popolo data can be loaded again, which will "update" it back to its current state, but not delete anything you've added manually:

docker-compose run --rm web python manage.py popolo_sources_update http://dev-data:8001/pombola.json

Or you can delete the database server and its data and set up your development environment from scratch:

docker-compose rm -sfv
docker volume ls; docker volume rm public-people-data_db-data

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 \

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

public-people-data's People

Contributors

chrisjanwust avatar dependabot[bot] avatar jbothma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.