Home

Awesome

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:


SECRET_KEY='xxx'

# Email to receive contact requests from the form on /about/contact-us/
RTEI_CONTACT_FORM_EMAIL='contact_form@example.com'
EMAIL_HOST='xxx'
EMAIL_HOST_PASSWORD='xxx'
EMAIL_HOST_USER='xxx'

# S3 Storage for docs and resources
AWS_ACCESS_KEY_ID='xxx'
AWS_SECRET_ACCESS_KEY='xxx'
AWS_STORAGE_BUCKET_NAME='xxx'

# Postgres DB to use (dev defaults to postgres://rtei:pass@localhost/rtei)
DATABASE_URL='postgres:...'

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

# Google Analytics site code for production
GOOGLE_ANALYTICS_CODE='xxx'

Notes for development

Tests

Install the tests requirements:

pip install -r test-requirements.txt

Run:

./manage.py test

Contents for development

Use the staging database's dump to populate contents for development. Copy images from the staging site to mimic the blog appearance.

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/2021/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