okfn/rtei

Name: rtei

Owner: Open Knowledge International

Description: Right to Education Index website

Created: 2016-02-01 12:29:39.0

Updated: 2018-05-10 09:19:04.0

Pushed: 2018-05-10 09:19:03.0

Homepage: https://www.rtei.org

Size: 6203

Language: CSS

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Right to Education Index (RTEI) website

Build Status

This site can be found at https://www.rtei.org and it is powered by Wagtail

Setup

Custom Settings

RTEI requires the following values to be set as env vars:

ET_KEY='xxx'

ail to receive contact requests from the form on /about/contact-us/
_CONTACT_FORM_EMAIL = 'contact_form@example.com'
L_HOST = 'xxx'
L_HOST_PASSWORD = 'xxx'
L_HOST_USER = 'xxx'

 Storage for docs and resources
ACCESS_KEY_ID = 'xxx'
SECRET_ACCESS_KEY = 'xxx'
STORAGE_BUCKET_NAME = 'xxx'

stgres DB to use (dev defaults to postgres://rtei:rtei@localhost/rtei)
BASE_URL='postgres:...'

asticSearch endpoint use for search (dev defaults to http://localhost:9200)
TICSEARCH_URL = 'http://example.com/es'

ogle Analytics site code for production
LE_ANALYTICS_CODE = 'xxx'

Notes for development

Tests

Install the tests requirements:

pip install -r test-requirements.txt

Run:

./manage.py test
Generate data

The JSON data needed to power the visualizations on the site is built using the build_data.py script, which parses the original Excel (xlsx) file located at data.

Before running the script you must install its requirements:

cd rtei
pip install -r data-requirements.txt

Run ./build_data.py -h to see all the options available.

Most of the times you will want to:

  1. Update /rtei/static/data/rtei_data_{year}.xlsx if necessary
  2. Run ./build_data.py all

The JSON data files are generated in rtei/static/data/{year} by default. These files are:

Map data

The map visualizations are powered by a TopoJSON file. This is built using two input files, data/countries.geojson, which is constant and does not need to be updated, and data/scores_per_country.csv, which needs to be updated:

./build_data.py -o data scores-per-country-csv

Install the topojson command (use a version lower than 2.0):

npm install topojson@1.6.27

This is the full command that needs to be done (note that the output file goes to the rtei/static/data):

topojson -p -o rtei/static/data/countries.topojson --stitch-poles false --id-property iso2 -e data/scores_per_country.csv data/countries.geojson
Dump Site data

Dump a new set of site data (this is the internal data for managing the site, like pages etc, not the data powering the visualizations):

cd rtei
python manage.py dumpdata --natural-foreign --indent=4 -e contenttypes -e auth.Permission -e sessions -e wagtailcore.pagerevision -e auth.user > rtei/fixtures/data.json
Deployment

The site is hosted on Heroku:

Migrate data on Heroku

Database migrates can be run on heroku against the production settings with:

heroku run python ./manage.py migrate --settings=rtei.settings.production
Translations

Translations are managed on Transifex. You will need to install the Transifex command line client:

pip install transifex-client

If you haven't already done it, you need to create a ~/.transifexrc file with the following contents:

[https://www.transifex.com]
hostname = https://www.transifex.com
username = YOUR_USERNAME
password = YOUR_PASSWORD
token =

To test that it's properly configured, run the following on the repo directory:

tx status

You should see something along these lines:

rtei -> rtei (1 of 1)
Translation Files:
 - en: locale/django.pot (source)
 - ar: locale/ar/LC_MESSAGES/django.po
 - es: locale/es/LC_MESSAGES/django.po
 - fr: locale/fr/LC_MESSAGES/django.po
Uploading translations to Transifex

New strings added to the source code that need to be translated must be regularly extracted and uploaded to Transifex.

Note: This also includes strings in the original data! (eg Indicator titles or responses)

To do so run the following:

# Extract translatable strings from data
./build_data.py translation-strings

# Extract strings from source code into po files (also keep the master pot file)
./manage.py makemessages --keep-pot

# Upload to Transifex
tx push -s -t --skip

#Commit new po files
git commit -am "Update translation files with new strings"

At this point the strings are available for translation on Transifex.

Updating translations from Transifex

Once the translators have finished workin on Transifex, update the source code translations with the following commands:

# Pull strings from Transifex
tx pull

# Compile strings catalogue, ie the locale/*.mo files (You need to restart the server after this)
./manage compilemessages

# Commit the changes
git commit -am "Updated strings from Transifex"
Rebuilding CSS

The project uses SASS. To install it run:

sudo gem install sass

To rebuild the CSS, watching for changes in the scss files, run:

sass rtei/static/scss/rtei.scss:rtei/static/css/rtei.css --watch

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.