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

Merge pull request #47 from political-memory/pr

Release
parents de0af789 832e7e33
[![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', '0002_delete_memopolvote'),
('sites', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='recommendation',
options={'ordering': ['proposal__datetime']},
),
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>
%h3
What is memopol?
%p
Political Memory is a tool designed by La Quadrature du Net to help
European citizens to reach members of European Parliament (MEPs) and
track their voting records on issues related to fundamental
freedoms online. <em><a href="">More...</a></em>
from django.test import TestCase
# Create your tests here.
# coding: utf-8
# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
from create_child_instance_from_parent import create_child_instance_from_parent
from render_paginate_list import render_paginate_list
# coding: utf-8
# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
from __future__ import absolute_import
def create_child_instance_from_parent(child_cls, parent_instance):
"""
Create a child model instance from a parent instance
"""
parent_cls = parent_instance.__class__
field = child_cls._meta.get_ancestor_link(parent_cls).column
child_instance = child_cls(**{
field: parent_instance.pk
})
child_instance.__dict__.update(parent_instance.__dict__)
child_instance.save()
return child_instance
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment