Commit 9c884e2a authored by James Pic's avatar James Pic

Merge pull request #47 from political-memory/pr

Release
parents de0af789 832e7e33
{
"directory": "static/libs"
}
*.sqlite3
celerybeat-*
core/static/libs/*
deploy
# libs
static/libs
node_modules
# compiled css
static/stylesheets/*.min.css
# settings
memopol/config.json
......@@ -21,3 +15,6 @@ __pycache__/
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
.dpl
db.sqlite
log/
The OpenShift `python` cartridge documentation can be found at:
http://openshift.github.io/documentation/oo_cartridge_guide.html#python
For information about .openshift directory, consult the documentation:
http://openshift.github.io/documentation/oo_user_guide.html#the-openshift-directory
For information about action hooks, consult the documentation:
http://openshift.github.io/documentation/oo_user_guide.html#action-hooks
export OPENSHIFT_PYTHON_WSGI_APPLICATION=memopol/wsgi.py
#!/bin/bash
# This deploy hook gets executed after dependencies are resolved and the
# build hook has been run but before the application has been started back
# up again. This script gets executed directly, so it could be python, php,
# ruby, etc.
set -xe
source ${OPENSHIFT_HOMEDIR}app-root/runtime/dependencies/python/virtenv/bin/activate
pip install -U pip
pip install -Ue ${OPENSHIFT_REPO_DIR}
# We don't have sentry yet
# python ${OPENSHIFT_REPO_DIR}manage.py raven test
python ${OPENSHIFT_REPO_DIR}manage.py migrate --noinput
pushd ${OPENSHIFT_REPO_DIR}
if [ -f ${OPENSHIFT_DATA_DIR}sentry ]; then
pip install raven
./manage.py raven test
else
echo ${OPENSHIFT_DATA_DIR}sentry does not exist, not setting up raven.
fi
PATH="${OPENSHIFT_DATA_DIR}node/bin:$PATH"
HOME=$OPENSHIFT_DATA_DIR
CI=true
bin/install_client_deps.sh
mkdir -p wsgi
./manage.py collectstatic --noinput
./manage.py compress
popd
mkdir -p ${OPENSHIFT_DATA_DIR}media
mkdir -p ${OPENSHIFT_REPO_DIR}wsgi/static/media
ln -sf ${OPENSHIFT_DATA_DIR}media ${OPENSHIFT_REPO_DIR}wsgi/static/media
ln -sf ${OPENSHIFT_DATA_DIR}compress/CACHE ${OPENSHIFT_REPO_DIR}wsgi/static/collected/CACHE
Run scripts or jobs on a periodic basis
=======================================
Any scripts or jobs added to the minutely, hourly, daily, weekly or monthly
directories will be run on a scheduled basis (frequency is as indicated by the
name of the directory) using run-parts.
run-parts ignores any files that are hidden or dotfiles (.*) or backup
files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved}
The presence of two specially named files jobs.deny and jobs.allow controls
how run-parts executes your scripts/jobs.
jobs.deny ===> Prevents specific scripts or jobs from being executed.
jobs.allow ===> Only execute the named scripts or jobs (all other/non-named
scripts that exist in this directory are ignored).
The principles of jobs.deny and jobs.allow are the same as those of cron.deny
and cron.allow and are described in detail at:
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Automating_System_Tasks.html#s2-autotasks-cron-access
See: man crontab or above link for more details and see the the weekly/
directory for an example.
PLEASE NOTE: The Cron cartridge must be installed in order to run the configured jobs.
For more information about cron, consult the documentation:
http://openshift.github.io/documentation/oo_cartridge_guide.html#cron
http://openshift.github.io/documentation/oo_user_guide.html#cron
#!/bin/bash
set -x
cmd=$1
cd $OPENSHIFT_REPO_DIR
export CLEAN=1
nohup bin/update_all > $OPENSHIFT_LOG_DIR/update_all.log 2>&1 &
Run scripts or jobs on a weekly basis
=====================================
Any scripts or jobs added to this directory will be run on a scheduled basis
(weekly) using run-parts.
run-parts ignores any files that are hidden or dotfiles (.*) or backup
files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} and handles
the files named jobs.deny and jobs.allow specially.
In this specific example, the chronograph script is the only script or job file
executed on a weekly basis (due to white-listing it in jobs.allow). And the
README and chrono.dat file are ignored either as a result of being black-listed
in jobs.deny or because they are NOT white-listed in the jobs.allow file.
For more details, please see ../README.cron file.
Time And Relative D...n In Execution (Open)Shift!
#!/bin/bash
echo "`date`: `cat $(dirname \"$0\")/chrono.dat`"
#
# Script or job files listed in here (one entry per line) will be
# executed on a weekly-basis.
#
# Example: The chronograph script will be executed weekly but the README
# and chrono.dat files in this directory will be ignored.
#
# The README file is actually ignored due to the entry in the
# jobs.deny which is checked before jobs.allow (this file).
#
chronograph
#
# Any script or job files listed in here (one entry per line) will NOT be
# executed (read as ignored by run-parts).
#
README
For information about markers, consult the documentation:
http://openshift.github.io/documentation/oo_user_guide.html#markers
sudo: false
env:
- DJANGO_DEBUG=True DJANGO_SETTINGS_MODULE=memopol.settings
language: python
python:
- "2.7"
- '2.7'
before_install:
- pip install codecov
install:
- pip install django
- pip install -U pip
- pip install -r requirements.txt
- cp memopol/config.json.sample memopol/config.json
- pip install -e .[testing]
before_script:
- npm install -g bower
- bower install
- npm install
- bin/install_client_deps.sh
script:
- ./manage.py migrate
- node_modules/gulp/bin/gulp.js less
- bash -c '! lesscpy -N static/less/base.less 2>&1 | grep Error'
- flake8 . --exclude '*/migrations,docs,static' --ignore E128
- py.test memopol representatives_positions representatives_recommendations
- rm -rf db.sqlite
- django-admin migrate
- django-admin update_score
after_success:
- codecov
deploy:
- provider: openshift
user: jamespic@gmail.com
password:
secure: W7hQDKAtmpOfwLjBuss6NEKqPSrRhsbgH8a8eV+/Oo6HZxMi1mbNFSi+6WRNSs3Cil0ZZV+awoqC61jIzV4oTwEYcy5bv9NWNSY1QO34DECMS5sY00wA0zKhkdsdTr9Pc3TLRp1cw6x2KNCF356FKZojFTRbjtfJ79rqBc5k5ww=
app: master
domain: memopol
skip_cleanup: true
deployment_branch: master
on:
repo: political-memory/political_memory
branch: master
- provider: openshift
user: jamespic@gmail.com
password:
secure: W7hQDKAtmpOfwLjBuss6NEKqPSrRhsbgH8a8eV+/Oo6HZxMi1mbNFSi+6WRNSs3Cil0ZZV+awoqC61jIzV4oTwEYcy5bv9NWNSY1QO34DECMS5sY00wA0zKhkdsdTr9Pc3TLRp1cw6x2KNCF356FKZojFTRbjtfJ79rqBc5k5ww=
app: lqdn
domain: memopol
skip_cleanup: true
deployment_branch: lqdn
on:
repo: political-memory/political_memory
branch: lqdn
- provider: openshift
user: jamespic@gmail.com
password:
secure: W7hQDKAtmpOfwLjBuss6NEKqPSrRhsbgH8a8eV+/Oo6HZxMi1mbNFSi+6WRNSs3Cil0ZZV+awoqC61jIzV4oTwEYcy5bv9NWNSY1QO34DECMS5sY00wA0zKhkdsdTr9Pc3TLRp1cw6x2KNCF356FKZojFTRbjtfJ79rqBc5k5ww=
app: pr
domain: memopol
skip_cleanup: true
deployment_branch: pr
on:
repo: political-memory/political_memory
branch: pr
How to install memopol
1. Create a directory containing the whole project (say ~memopol)
2. Create a python virtualenv in ~memopol : ~memopol/ve
3. Clone memopol main repository (http://git.laquadrature.net/memopol/memopol_political_memory) in ~memopol/memopol_political_memory
4. Clone django-representative directory (http://git.laquadrature.net/memopol/compotista_django-representatives) in ~memopol/django-representatives
5. Clone the last version of django-chronograph (https://bitbucket.org/wnielson/django-chronograph) in ~memopol/django-chronograph
(It seems that the version in pip is not up to date…)
6. Symlink ~memopol/memopol_political_memory/representatives -> ~memopol/django-representatives/representatives
7. Symlink ~memopol/memopol_political_memory/chronograph -> ~memopol/django-chronograph/chronograph
8. Install requierements in the virtualenv with pip install -r ~memopol//memopol_political_memory/requierements
9. Config your database in ~memopol/memopol_political_memory/settings.py
10. Sync the database python manage.py syncdb
11. Import mep from a compotista instance : python manage.py update update_eu_mps
12. Run the server
[![Build Status](https://travis-ci.org/political-memory/political_memory.svg?branch=master)](https://travis-ci.org/political-memory/political_memory)
[![codecov.io](https://codecov.io/github/political-memory/political_memory/coverage.svg?branch=master)](https://codecov.io/github/political-memory/political_memory?branch=master)
git clone git@github.com:political-memory/political_memory.git
cd political_memory
cp memopol/config.json.sample memopol/config.json
# Create a throwable virtualenv
virtualenv ve
source ve/bin/activate
......@@ -16,14 +15,8 @@
# Create the local db
python manage.py migrate
# Some static files
bower install
# Install node modules
npm install
# Build static files
node_modules/gulp/bin/gulp.js less
# Install browser libs
bin/install_client_deps.sh
# In another terminal (don't forget to activate the venv)
./manage.py runserver
#!/bin/bash
#
# This script downloads browser client libraries.
# Currently all scripts are downloaded from GitHub.
#
# Versions used may be changed by altering the lines
# starting with 'downloadFromGithub' at the bottom.
# The last argument is expected to be a git ref (ie
# a branch name, tag or commit-ish).
#
set -e
DEST=$(dirname $(dirname $0))/static/libs
# Github download helper
# $1 destination directory name under static/libs
# $2 github repo name (user-or-org/repo)
# $3 ref to use (branch or tag or commit)
function downloadFromGithub()
{
local dest=$DEST/$1
local repo=$2
local ref=$3
echo "* Downloading $repo ($ref) from Github..."
wget -O temp.zip -q https://github.com/${repo}/archive/${ref}.zip
unzip -q temp.zip
mv $(basename ${repo})* ${dest}
rm temp.zip
}
set -e
[ -d ${DEST} ] && rm -r ${DEST}
mkdir -p ${DEST}
downloadFromGithub jquery jquery/jquery 2.1.4
downloadFromGithub fontawesome FortAwesome/Font-Awesome v4.3.0
downloadFromGithub flag-icon-css lipis/flag-icon-css 0.7.1
downloadFromGithub bootstrap twbs/bootstrap v3.3.5
echo "* Done."
if [ -n "$OPENSHIFT_HOMEDIR" ]; then
source ${OPENSHIFT_HOMEDIR}app-root/runtime/dependencies/python/virtenv/bin/activate
fi
function pipe_download_to_command() {
if [ -n "$OPENSHIFT_DATA_DIR" ]; then
cd $OPENSHIFT_DATA_DIR
fi
[ -n "$CLEAN" ] && rm -rf $1
[ -f "$1" ] || wget http://parltrack.euwiki.org/dumps/$1 || exit 1
if [ -n "$OPENSHIFT_REPO_DIR" ]; then
cd $OPENSHIFT_REPO_DIR
fi
export DJANGO_SETTINGS_MODULE=memopol.settings
unxz -c ${OPENSHIFT_DATA_DIR}$1 | $2
[ -n "$CLEAN" ] && rm -rf $1
}
#!/bin/bash
bin/update_representatives
# grace time for pg
sleep 120
bin/update_dossiers
sleep 120
bin/update_votes
sleep 120
bin/update_scores
#!/bin/bash
set -ex
source ${OPENSHIFT_REPO_DIR}bin/lib.sh
pipe_download_to_command ep_dossiers.json.xz parltrack_import_dossiers
#!/bin/bash
set -ex
source ${OPENSHIFT_REPO_DIR}bin/lib.sh
pipe_download_to_command ep_meps_current.json.xz parltrack_import_representatives
#!/bin/bash
set -ex
source ${OPENSHIFT_REPO_DIR}bin/lib.sh
[ -n "$OPENSHIFT_REPO_DIR" ] && cd $OPENSHIFT_REPO_DIR
./manage.py update_score
#!/bin/bash
set -ex
source ${OPENSHIFT_REPO_DIR}bin/lib.sh
pipe_download_to_command ep_votes.json.xz parltrack_import_votes
{
"name": "Memopol",
"version": "3.0.0",
"dependencies": {
"bootstrap": "~3.3.5",
"flag-icon-css": "~0.7.1"
},
"devDependencies": {
"fontawesome": "~4.3.0"
}
}
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.db import migrations, models
from django.conf import settings
def set_site_name(apps, schema_editor):
Site = apps.get_model('sites', 'Site')
Site.objects.filter(pk=settings.SITE_ID).update(
name=settings.SITE_NAME, domain=settings.SITE_DOMAIN)
class Migration(migrations.Migration):
dependencies = [
('votes', '0001_initial'),
('sites', '0001_initial'),
]
operations = [
migrations.DeleteModel(
name='MemopolVote',
),
migrations.RunPython(set_site_name),
]
{% extends "contrib/admin/templates/admin/index.html" %}
{% block branding %}
<h1 id="site-name">Administration for Memopol</h1>
{% endblock %}
{% block content %}
{{ block.super }}
{% endblock %}
/ -load memopol_tags cache
- load i18n
- load cache
- load staticfiles
#header.container-fluid
%a{href: "/", id: 'logo'}
%img{src: '{% static "images/logo.png" %}'}
%h1
%a#header_banner{href: "/"}
-trans "Political Memory"
%p.organization
=config.ORGANIZATION_NAME
#nav.container-fluid
-include "core/blocks/navigation.html"
%ul.nav
%li
%a{href: "{% url 'legislature:representative-index' %}"}
Representatives
%li
%a{href: "{% url 'legislature:group-index' kind='country' %}"}
Countries
%li
%a{href: "{% url 'legislature:group-index' kind='group' %}"}
Parties
%li
%a{href: "{% url 'legislature:group-index' kind='delegation' %}"}
Delegations
%li
%a{href: "{% url 'legislature:group-index' kind='committee' %}"}
Committees
%ul.nav
%li
%a{href: "{% url 'votes:dossier-index' %}"}
Votes
-# Pagination block display pagination for the `object_list`
`object_list` could be generated with core.view_utils.render_paginate_list
.pagination-block
%nav
%ul.pagination.pagination-sm
- if object_list.has_previous
- if page_obj.has_previous
%li
%a{'href': '?={queries.urlencode}&page=1',
'aria-label': 'First'}
<i aria-hidden="true" class="fa fa-chevron-circle-left"></i>
%li
%a{'href': '?={queries.urlencode}&page=={object_list.previous_page_number}',
%a{'href': '?={queries.urlencode}&page=={page_obj.previous_page_number}',
'aria-label': 'Previous'}
<i aria-hidden="true" class="fa fa-chevron-left"></i>
- for page_num in object_list.page_range
- if not page_num
%li.disabled
%a{'href': ''}
- elif page_num == object_list.number
%li.active
%a{'href': ''}
{{ page_num }}
- else
%li
%a{'href': '?={queries.urlencode}&page=={page_num}'}
{{ page_num }}
- for p in page_range
- if p
- if p == page_obj.number
%li.active
%a{'href': ''}
{{ p }}
- else
%li
%a{'href': '?={queries.urlencode}&page=={p}'}
{{ p }}
- if object_list.has_next
- if page_obj.has_next
%li
%a{'href': '?={queries.urlencode}&page=={object_list.next_page_number}',
%a{'href': '?={queries.urlencode}&page=={page_obj.next_page_number}',
'aria-label': 'Next'}
<i aria-hidden="true" class="fa fa-chevron-right"></i>
%li
%a{'href': '?={queries.urlencode}&page=={paginator.num_pages}',
'aria-label': 'Last'}
<i aria-hidden="true" class="fa fa-chevron-circle-right"></i>
%div.count
Number of results : {{ paginator.count }}
%br
......@@ -38,9 +42,10 @@
{{ paginator.per_page }}
(
- for limit in pagination_limits
%a{'href': '?limit={{ limit }}'}
%a{'href': '?paginate_by={{ limit }}'}
{{ limit }}
- if not forloop.last
\/
)
- include 'core/blocks/grid-list.html'
- if grid_list
- include 'core/blocks/grid-list.html'
- extends "base.html"
- block content
.row
.col-md-8
%p
Memopol is reachable only in <b>reduced functionality mode</b>.
By the way, you could access to
<a href="{% url 'legislature:representative-index' %}">the list of MEPs</a>.
%p
You can help on building the new Memopol by <a href="https://wiki.laquadrature.net/Projects/Memopol/Roadmap">coding, translating, de signing, funding, etc...</a>.
.col-md-4
.panel.panel-default
.panel-body
%p
<a href="http://memopol.org">Memopol Blog</a> is available as well as the new
<a href="http://git.laquadrature.net/memopol/memopol/issues">
bugtracking system</a>