Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Political Memory
memopol
Commits
a5656192
Commit
a5656192
authored
Jun 13, 2016
by
njoyard
Committed by
GitHub
Jun 13, 2016
Browse files
Merge pull request #88 from political-memory/allow-former-meps
Allow former meps
parents
2fa87a88
18a1355e
Changes
36
Expand all
Hide whitespace changes
Inline
Side-by-side
core/templates/core/blocks/active-filter.haml
0 → 100644
View file @
a5656192
Display :
-
if
active_only
current legislature only /
%a
{
'href'
:
'?active_only=0'
}
all data
-
else
%a
{
'href'
:
'?active_only=1'
}
current legislature only
=
"/ all data"
\ No newline at end of file
core/templates/core/blocks/pagination.haml
View file @
a5656192
...
...
@@ -37,6 +37,11 @@
%div
.count
Number of results : {{ paginator.count }}
-
if
active_only
!=
None
%br
-
include
'core/blocks/active-filter.html'
%br
Number of displayed results :
{{ paginator.per_page }}
...
...
core/views.py
View file @
a5656192
...
...
@@ -4,6 +4,46 @@ from django import http
import
unicodecsv
as
csv
class
ActiveLegislatureMixin
(
object
):
"""
Mixin for views that can switch between active legislature and all data
"""
default_active_only
=
True
def
get
(
self
,
*
args
,
**
kwargs
):
self
.
set_active_only
()
return
super
(
ActiveLegislatureMixin
,
self
).
get
(
*
args
,
**
kwargs
)
def
override_active_only
(
self
):
"""
Redefine this method to override active legislature selection
- return None to enable user choice
- return True or False to disable user choice and set active state
"""
return
None
def
set_active_only
(
self
):
if
'active_only'
in
self
.
request
.
GET
:
self
.
request
.
session
[
'active_only'
]
=
\
self
.
request
.
GET
[
'active_only'
]
==
'1'
elif
'active_only'
not
in
self
.
request
.
session
:
self
.
request
.
session
[
'active_only'
]
=
self
.
default_active_only
def
get_active_only
(
self
):
overriden
=
self
.
override_active_only
()
if
overriden
is
None
:
return
self
.
request
.
session
[
'active_only'
]
else
:
return
overriden
def
get_context_data
(
self
,
**
kwargs
):
c
=
super
(
ActiveLegislatureMixin
,
self
).
get_context_data
(
**
kwargs
)
if
self
.
override_active_only
()
is
None
:
c
[
'active_only'
]
=
self
.
get_active_only
()
return
c
class
PaginationMixin
(
object
):
pagination_limits
=
(
12
,
24
,
48
,
96
)
...
...
memopol/tests/base.py
View file @
a5656192
...
...
@@ -42,9 +42,6 @@ class UrlGetTestMixin(object):
class
ResponseDiffMixin
(
object
):
def
responsediff_test
(
self
,
url
,
numQueries
):
# Setup session variables
self
.
client
.
get
(
url
)
with
self
.
assertNumQueries
(
numQueries
):
response
=
self
.
client
.
get
(
url
)
...
...
memopol/tests/response_fixtures/DossiersTest.test_dossier_detail/content
View file @
a5656192
...
...
@@ -10,7 +10,7 @@
- The Political Memory of
</title>
<link
rel=
"stylesheet"
href=
"/static/collected/libs/bootstrap/dist/css/bootstrap.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/fontawesome/css/font-awesome.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/flag-icon-css/css/flag-icon.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/CACHE/css/base.
6cb1be2fbcdd
.css"
type=
"text/css"
/>
<link
rel=
"stylesheet"
href=
"/static/collected/libs/bootstrap/dist/css/bootstrap.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/fontawesome/css/font-awesome.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/flag-icon-css/css/flag-icon.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/CACHE/css/base.
c7d56d0a17c9
.css"
type=
"text/css"
/>
<script
type=
"text/javascript"
src=
"/static/collected/libs/jquery/dist/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"/static/collected/libs/bootstrap/dist/js/bootstrap.js"
></script>
...
...
memopol/tests/response_fixtures/DossiersTest.test_dossier_list/content
View file @
a5656192
...
...
@@ -10,7 +10,7 @@
- The Political Memory of
</title>
<link
rel=
"stylesheet"
href=
"/static/collected/libs/bootstrap/dist/css/bootstrap.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/fontawesome/css/font-awesome.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/flag-icon-css/css/flag-icon.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/CACHE/css/base.
6cb1be2fbcdd
.css"
type=
"text/css"
/>
<link
rel=
"stylesheet"
href=
"/static/collected/libs/bootstrap/dist/css/bootstrap.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/fontawesome/css/font-awesome.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/flag-icon-css/css/flag-icon.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/CACHE/css/base.
c7d56d0a17c9
.css"
type=
"text/css"
/>
<script
type=
"text/javascript"
src=
"/static/collected/libs/jquery/dist/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"/static/collected/libs/bootstrap/dist/js/bootstrap.js"
></script>
...
...
@@ -119,6 +119,8 @@
</nav>
<div
class=
'count'
>
Number of results : 1
<br
/>
Number of displayed results :
12
...
...
memopol/tests/response_fixtures/GroupListTest.test_active_committees/content
0 → 100644
View file @
a5656192
<!DOCTYPE html>
<html
class=
"no-js"
lang=
"en"
>
<!--<![endif]-->
<head>
<meta
charset=
"utf-8"
/>
<link
rel=
"icon"
type=
"image/png"
href=
"/static/collected/img/favicon.ico"
/>
<!-- Set the viewport width to device width for mobile -->
<meta
name=
"viewport"
content=
"width=device-width"
/>
<title>
Home
- The Political Memory of
</title>
<link
rel=
"stylesheet"
href=
"/static/collected/libs/bootstrap/dist/css/bootstrap.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/fontawesome/css/font-awesome.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/flag-icon-css/css/flag-icon.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/CACHE/css/base.c7d56d0a17c9.css"
type=
"text/css"
/>
<script
type=
"text/javascript"
src=
"/static/collected/libs/jquery/dist/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"/static/collected/libs/bootstrap/dist/js/bootstrap.js"
></script>
</head>
<body
>
<!-- -load memopol_tags cache -->
<div
id=
'header'
class=
'container-fluid'
>
<a
id=
'logo'
href=
'/'
>
<img
src=
'/static/collected/images/logo.png'
/>
</a>
<h1>
<a
id=
'header_banner'
href=
'/'
>
Political Memory
</a>
</h1>
<p
class=
'organization'
>
</p>
</div>
<div
id=
'nav'
class=
'container-fluid'
>
<ul
class=
'nav'
>
<li>
<a
href=
'/legislature/representative/'
>
Representatives
</a>
</li>
<li>
<a
href=
'/legislature/group/country/'
>
Countries
</a>
</li>
<li>
<a
href=
'/legislature/group/chamber/'
>
Chambers
</a>
</li>
<li>
<a
href=
'/legislature/group/group/'
>
Parties
</a>
</li>
<li>
<a
href=
'/legislature/group/delegation/'
>
Delegations
</a>
</li>
<li>
<a
href=
'/legislature/group/committee/'
>
Committees
</a>
</li>
<li>
<a
href=
'/votes/dossier/'
>
Dossiers
</a>
</li>
</ul>
</div>
<div
class=
"container-fluid main-container"
>
<div
class=
'pagination-block'
>
<nav>
<ul
class=
'pagination pagination-sm'
>
<li
class=
'active'
>
<a
href=
''
>
1
</a>
</li>
<li>
<a
href=
'?&page=2'
>
2
</a>
</li>
<li>
<a
aria-label=
'Next'
href=
'?&page=2'
>
<i
aria-hidden=
"true"
class=
"fa fa-chevron-right"
></i>
</a>
</li>
<li>
<a
aria-label=
'Last'
href=
'?&page=2'
>
<i
aria-hidden=
"true"
class=
"fa fa-chevron-circle-right"
></i>
</a>
</li>
</ul>
</nav>
<div
class=
'count'
>
Number of results : 20
<br
/>
Display :
current legislature only /
<a
href=
'?active_only=0'
>
all data
</a>
<br
/>
Number of displayed results :
12
(
<a
href=
'?paginate_by=12'
>
12
</a>
/
<a
href=
'?paginate_by=24'
>
24
</a>
/
<a
href=
'?paginate_by=48'
>
48
</a>
/
<a
href=
'?paginate_by=96'
>
96
</a>
)
</div>
</div>
<table
class=
'table'
>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Agriculture%20and%20Rural%20Development/'
>
AGRI
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Agriculture%20and%20Rural%20Development/'
>
Committee on Agriculture and Rural Development
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Budgetary%20Control/'
>
CONT
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Budgetary%20Control/'
>
Committee on Budgetary Control
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Budgets/'
>
BUDG
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Budgets/'
>
Committee on Budgets
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Civil%20Liberties,%20Justice%20and%20Home%20Affairs/'
>
LIBE
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Civil%20Liberties,%20Justice%20and%20Home%20Affairs/'
>
Committee on Civil Liberties, Justice and Home Affairs
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Constitutional%20Affairs/'
>
AFCO
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Constitutional%20Affairs/'
>
Committee on Constitutional Affairs
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Culture%20and%20Education/'
>
CULT
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Culture%20and%20Education/'
>
Committee on Culture and Education
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Economic%20and%20Monetary%20Affairs/'
>
ECON
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Economic%20and%20Monetary%20Affairs/'
>
Committee on Economic and Monetary Affairs
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Employment%20and%20Social%20Affairs/'
>
EMPL
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Employment%20and%20Social%20Affairs/'
>
Committee on Employment and Social Affairs
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Fisheries/'
>
PECH
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Fisheries/'
>
Committee on Fisheries
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Foreign%20Affairs/'
>
AFET
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Foreign%20Affairs/'
>
Committee on Foreign Affairs
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Industry,%20Research%20and%20Energy/'
>
ITRE
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Industry,%20Research%20and%20Energy/'
>
Committee on Industry, Research and Energy
</a>
</td>
</tr>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20International%20Trade/'
>
INTA
</a>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20International%20Trade/'
>
Committee on International Trade
</a>
<