Commit a8094501 authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Finish navigation pane implementation

parent dee7cc3c
from representatives.models import Group
from representatives.models import Chamber, Group
def search_form_options(request):
......@@ -6,6 +6,7 @@ def search_form_options(request):
# Note: Those queries needs to be eval in the template so that we can cache
# it efficiently
d['chambers'] = Chamber.objects.all()
d['countries'] = Group.objects.filter(kind='country')
d['parties'] = Group.objects.filter(kind='group')
d['delegations'] = Group.objects.filter(kind='delegation')
......
# coding: utf-8
from dal.autocomplete import ModelSelect2
import datetime
from django.db.models import Q
from django.utils.text import slugify
from django_filters import FilterSet, MethodFilter, ModelChoiceFilter
from django_filters import FilterSet, MethodFilter
from representatives.models import Chamber, Group, Representative
from representatives.models import Representative
from representatives_votes.models import Dossier
from memopol_themes.models import Theme
def rep_chamber_filter(qs, value):
today = datetime.date.today()
return qs.filter(
Q(mandates__end_date__gte=today) | Q(mandates__end_date__isnull=True),
mandates__group__chamber=value
)
def dossier_chamber_filter(qs, value):
return qs.filter(documents__chamber=value)
def group_filter(qs, value):
today = datetime.date.today()
return qs.filter(
Q(mandates__end_date__gte=today) | Q(mandates__end_date__isnull=True),
mandates__group=value
)
class RepresentativeFilter(FilterSet):
search = MethodFilter(action='search_filter')
chamber = ModelChoiceFilter(queryset=Chamber.objects.all(),
action=rep_chamber_filter)
country = ModelChoiceFilter(queryset=Group.objects.filter(kind='country'),
action=group_filter)
party = ModelChoiceFilter(queryset=Group.objects.filter(kind='party'),
action=group_filter)
delegation = ModelChoiceFilter(
queryset=Group.objects.filter(kind='delegation'),
action=group_filter)
committee = ModelChoiceFilter(
queryset=Group.objects.filter(kind='committee'),
action=group_filter)
group = ModelChoiceFilter(queryset=Group.objects.exclude(
kind__in=['chamber', 'country']),
action=group_filter,
widget=ModelSelect2(url='group-autocomplete'),
label='Party, committee or delegation')
chamber = MethodFilter(action='chamber_filter')
country = MethodFilter(action='group_filter')
party = MethodFilter(action='group_filter')
delegation = MethodFilter(action='group_filter')
committee = MethodFilter(action='group_filter')
class Meta:
model = Representative
......@@ -72,13 +32,33 @@ class RepresentativeFilter(FilterSet):
return qs.filter(slug__icontains=slugify(value))
def chamber_filter(self, qs, value):
if len(value) == 0:
return qs
today = datetime.date.today()
return qs.filter(
Q(mandates__end_date__gte=today) |
Q(mandates__end_date__isnull=True),
mandates__group__chamber=value
)
def group_filter(self, qs, value):
if len(value) == 0:
return qs
today = datetime.date.today()
return qs.filter(
Q(mandates__end_date__gte=today) |
Q(mandates__end_date__isnull=True),
mandates__group=value
)
class DossierFilter(FilterSet):
search = MethodFilter(action='search_filter')
chamber = ModelChoiceFilter(queryset=Chamber.objects.all(),
action=dossier_chamber_filter)
chamber = MethodFilter(action='chamber_filter')
class Meta:
model = Dossier
......@@ -91,6 +71,12 @@ class DossierFilter(FilterSet):
return qs.filter(Q(title__icontains=value) |
Q(reference__icontains=value))
def chamber_filter(self, qs, value):
if len(value) == 0:
return qs
return qs.filter(documents__chamber=value)
class ThemeFilter(FilterSet):
......
<option value="">All</option>
---
<option value="1">
European Parliament
</option>
\ No newline at end of file
<div id="intro">
<h1 class="text-center"><span class="glyphicon glyphicon-eye-open"></span><br/>Political memory</h1>
<p class="lead text-center hidden-xs">What is Memopol ?</p>
<p class="text-justify hidden-xs">Political Memory is a tool designed by La Quadrature du Net to help citizens reach their representative and track their voting records on issues related to fundamental freedoms online.</p>
<div class="container-fluid hidden-xs">
<div class="row">
<div class="pull-right">
<a class="btn btn-default">More on our blog</a>
</div>
</div>
</div>
</div>
\ No newline at end of file
<option value="">All</option>
---
<option value="1">
European Parliament
</option>
\ No newline at end of file
<option value="">All</option>
---
<option data-url="/legislature/representative/?committee=47" value="47">
AGRI –
Committee on Agriculture and Rural Development
</option>
---
<option data-url="/legislature/representative/?committee=89" value="89">
CONT –
Committee on Budgetary Control
</option>
---
<option data-url="/legislature/representative/?committee=34" value="34">
BUDG –
Committee on Budgets
</option>
---
<option data-url="/legislature/representative/?committee=7" value="7">
LIBE –
Committee on Civil Liberties, Justice and Home Affairs
</option>
---
<option data-url="/legislature/representative/?committee=37" value="37">
AFCO –
Committee on Constitutional Affairs
</option>
---
<option data-url="/legislature/representative/?committee=20" value="20">
CULT –
Committee on Culture and Education
</option>
---
<option data-url="/legislature/representative/?committee=8" value="8">
DEVE –
Committee on Development
</option>
---
<option data-url="/legislature/representative/?committee=30" value="30">
ECON –
Committee on Economic and Monetary Affairs
</option>
---
<option data-url="/legislature/representative/?committee=3" value="3">
EMPL –
Committee on Employment and Social Affairs
</option>
---
<option data-url="/legislature/representative/?committee=55" value="55">
PECH –
Committee on Fisheries
</option>
---
<option data-url="/legislature/representative/?committee=5" value="5">
AFET –
Committee on Foreign Affairs
</option>
---
<option data-url="/legislature/representative/?committee=23" value="23">
ITRE –
Committee on Industry, Research and Energy
</option>
---
<option data-url="/legislature/representative/?committee=49" value="49">
INTA –
Committee on International Trade
</option>
---
<option data-url="/legislature/representative/?committee=9" value="9">
JURI –
Committee on Legal Affairs
</option>
---
<option data-url="/legislature/representative/?committee=6" value="6">
PETI –
Committee on Petitions
</option>
---
<option data-url="/legislature/representative/?committee=24" value="24">
REGI –
Committee on Regional Development
</option>
---
<option data-url="/legislature/representative/?committee=48" value="48">
ENVI –
Committee on the Environment, Public Health and Food Safety
</option>
---
<option data-url="/legislature/representative/?committee=58" value="58">
IMCO –
Committee on the Internal Market and Consumer Protection
</option>
---
<option data-url="/legislature/representative/?committee=68" value="68">
TRAN –
Committee on Transport and Tourism
</option>
---
<option data-url="/legislature/representative/?committee=77" value="77">
FEMM –
Committee on Women's Rights and Gender Equality
</option>
---
<option data-url="/legislature/representative/?committee=61" value="61">
CRIS –
Special Committee on the Financial, Economic and Social Crisis
</option>
---
<option data-url="/legislature/representative/?committee=50" value="50">
SURE –
Special committee on the policy challenges and budgetary resources for a sustainable European Union after 2013
</option>
---
<option data-url="/legislature/representative/?committee=4" value="4">
DROI –
Subcommittee on Human Rights
</option>
\ No newline at end of file
<option value="">All</option>
---
<option value="106">
AT –
Austria
</option>
---
<option value="98">
BE –
Belgium
</option>
---
<option value="117">
BG –
Bulgaria
</option>
---
<option value="184">
CY –
Cyprus
</option>
---
<option value="88">
CZ –
Czech Republic
</option>
---
<option value="113">
DK –
Denmark
</option>
---
<option value="126">
EE –
Estonia
</option>
---
<option value="115">
FI –
Finland
</option>
---
<option value="110">
FR –
France
</option>
---
<option value="22">
DE –
Germany
</option>
---
<option value="134">
GR –
Greece
</option>
---
<option value="85">
HU –
Hungary
</option>
---
<option value="182">
IE –
Ireland
</option>
---
<option value="100">
IT –
Italy
</option>
---
<option value="93">
LV –
Latvia
</option>
---
<option value="145">
LT –
Lithuania
</option>
---
<option value="112">
LU –
Luxembourg
</option>
---
<option value="186">
MT –
Malta
</option>
---
<option value="57">
NL –
Netherlands
</option>
---
<option value="2">
PL –
Poland
</option>
---
<option value="109">
PT –
Portugal
</option>
---
<option value="19">
RO –
Romania
</option>
---
<option value="169">
SK –
Slovakia
</option>
---
<option value="120">
SI –
Slovenia
</option>
---
<option value="91">
ES –
Spain
</option>
---
<option value="140">
SE –
Sweden
</option>
---
<option value="33">
GB –
United Kingdom
</option>
\ No newline at end of file
<option value="">All</option>
---
<option data-url="/legislature/representative/?delegation=95" value="95">
Delegation for relations with Afghanistan
</option>
---
<option data-url="/legislature/representative/?delegation=82" value="82">
Delegation for relations with Albania, Bosnia and Herzegovina, Serbia, Montenegro and Kosovo
</option>
---
<option data-url="/legislature/representative/?delegation=151" value="151">
Delegation for relations with Albania, Bulgaria and Romania
</option>
---
<option data-url="/legislature/representative/?delegation=35" value="35">
Delegation for relations with Australia and New Zealand
</option>
---
<option data-url="/legislature/representative/?delegation=29" value="29">
Delegation for relations with Belarus
</option>
---
<option data-url="/legislature/representative/?delegation=81" value="81">
Delegation for relations with Bosnia and Herzegovina, and Kosovo
</option>
---
<option data-url="/legislature/representative/?delegation=175" value="175">
Delegation for relations with Bulgaria and Romania
</option>
---
<option data-url="/legislature/representative/?delegation=86" value="86">
Delegation for relations with Canada
</option>
---
<option data-url="/legislature/representative/?delegation=165" value="165">
Delegation for relations with Czechoslovakia
</option>
---
<option data-url="/legislature/representative/?delegation=190" value="190">
Delegation for relations with Estonia
</option>
---
<option data-url="/legislature/representative/?delegation=191" value="191">
Delegation for relations with Estonia, Lithuania and Latvia
</option>
---
<option data-url="/legislature/representative/?delegation=73" value="73">
Delegation for relations with India
</option>
---
<option data-url="/legislature/representative/?delegation=99" value="99">
Delegation for relations with Iran
</option>
---
<option data-url="/legislature/representative/?delegation=94" value="94">
Delegation for relations with Iraq
</option>
---
<option data-url="/legislature/representative/?delegation=12" value="12">
Delegation for relations with Israel
</option>
---
<option data-url="/legislature/representative/?delegation=38" value="38">
Delegation for relations with Japan
</option>
---
<option data-url="/legislature/representative/?delegation=180" value="180">
Delegation for relations with Lithuania
</option>
---
<option data-url="/legislature/representative/?delegation=53" value="53">
Delegation for relations with Mercosur
</option>
---
<option data-url="/legislature/representative/?delegation=121" value="121">
Delegation for relations with Palestine
</option>
---
<option data-url="/legislature/representative/?delegation=132" value="132">
Delegation for relations with Russia
</option>
---
<option data-url="/legislature/representative/?delegation=64" value="64">
Delegation for relations with South Africa
</option>
---
<option data-url="/legislature/representative/?delegation=194" value="194">
Delegation for relations with Sweden
</option>
---
<option data-url="/legislature/representative/?delegation=195" value="195">
Delegation for relations with Sweden, Finland, Iceland and the Nordic Council
</option>
---
<option data-url="/legislature/representative/?delegation=59" value="59">
Delegation for relations with Switzerland and Norway and to the EU-Iceland Joint Parliamentary Committee and the European Economic Area (EEA) Joint Parliamentary Committee
</option>
---
<option data-url="/legislature/representative/?delegation=178" value="178">
Delegation for relations with Switzerland, Iceland and Norway
</option>
---
<option data-url="/legislature/representative/?delegation=166" value="166">
Delegation for relations with Switzerland, Iceland and Norway and to the European Economic Area (EEA) Joint Parliamentary Committee
</option>
---
<option data-url="/legislature/representative/?delegation=78" value="78">
Delegation for relations with the Arab Peninsula
</option>
---
<option data-url="/legislature/representative/?delegation=65" value="65">
Delegation for relations with the countries of Central America
</option>
---
<option data-url="/legislature/representative/?delegation=137" value="137">
Delegation for relations with the countries of Central America and Mexico
</option>
---
<option data-url="/legislature/representative/?delegation=185" value="185">
Delegation for relations with the countries of South America
</option>
---
<option data-url="/legislature/representative/?delegation=102" value="102">
Delegation for relations with the countries of South America and MERCOSUR
</option>
---
<option data-url="/legislature/representative/?delegation=51" value="51">
Delegation for relations with the countries of South Asia
</option>
---
<option data-url="/legislature/representative/?delegation=74" value="74">
Delegation for relations with the countries of South Asia and the South Asia Association for Regional Cooperation (SAARC)
</option>
---
<option data-url="/legislature/representative/?delegation=163" value="163">
Delegation for relations with the countries of South Asia and the South Asian Association for Regional Cooperation (SAARC)
</option>
---
<option data-url="/legislature/representative/?delegation=72" value="72">
Delegation for relations with the countries of Southeast Asia and the Association of Southeast Asian Nations (ASEAN)
</option>
---
<option data-url="/legislature/representative/?delegation=83" value="83">
Delegation for relations with the countries of south-east Europe
</option>
---
<option data-url="/legislature/representative/?delegation=14" value="14">
Delegation for relations with the countries of the Andean Community
</option>
---
<option data-url="/legislature/representative/?delegation=164" value="164">
Delegation for relations with the Czech Republic and the Slovak Republic
</option>
---
<option data-url="/legislature/representative/?delegation=62" value="62">
Delegation for relations with the Federative Republic of Brazil
</option>
---
<option data-url="/legislature/representative/?delegation=52" value="52">
Delegation for relations with the Gulf States, including Yemen
</option>
---
<option data-url="/legislature/representative/?delegation=40" value="40">
Delegation for relations with the Korean Peninsula
</option>
---
<option data-url="/legislature/representative/?delegation=63" value="63">
Delegation for relations with the Maghreb countries and the Arab Maghreb Union
</option>
---