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
Anthony
memopol
Commits
0ef69d56
Commit
0ef69d56
authored
Jun 09, 2016
by
njoyard
Browse files
Merge pull request #85 from political-memory/representative-views
Integrate views removed from d-r[-v]
parents
31deff01
41454979
Changes
40
Expand all
Hide whitespace changes
Inline
Side-by-side
memopol/api.py
View file @
0ef69d56
...
...
@@ -23,14 +23,16 @@ from representatives_recommendations.api import (
router
=
routers
.
DefaultRouter
()
router
.
register
(
r
'constituencies'
,
ConstituencyViewSet
)
router
.
register
(
r
'dossiers'
,
DossierViewSet
)
router
.
register
(
r
'dossier_scores'
,
DossierScoreViewSet
)
router
.
register
(
r
'groups'
,
GroupViewSet
)
router
.
register
(
r
'mandates'
,
MandateViewSet
)
router
.
register
(
r
'proposals'
,
ProposalViewSet
)
router
.
register
(
r
'recommendations'
,
RecommendationViewSet
)
router
.
register
(
r
'representatives'
,
RepresentativeViewSet
)
router
.
register
(
r
'scores'
,
RepresentativeScoreViewSet
)
router
.
register
(
r
'vote_scores'
,
VoteScoreViewSet
)
router
.
register
(
r
'votes'
,
VoteViewSet
)
router
.
register
(
r
'constituencies'
,
ConstituencyViewSet
,
'api-constituency'
)
router
.
register
(
r
'dossiers'
,
DossierViewSet
,
'api-dossier'
)
router
.
register
(
r
'dossier_scores'
,
DossierScoreViewSet
,
'api-dossierscore'
)
router
.
register
(
r
'groups'
,
GroupViewSet
,
'api-group'
)
router
.
register
(
r
'mandates'
,
MandateViewSet
,
'api-mandate'
)
router
.
register
(
r
'proposals'
,
ProposalViewSet
,
'api-proposal'
)
router
.
register
(
r
'recommendations'
,
RecommendationViewSet
,
'api-recommendation'
)
router
.
register
(
r
'representatives'
,
RepresentativeViewSet
,
'api-representative'
)
router
.
register
(
r
'scores'
,
RepresentativeScoreViewSet
,
'api-score'
)
router
.
register
(
r
'vote_scores'
,
VoteScoreViewSet
,
'api-votescore'
)
router
.
register
(
r
'votes'
,
VoteViewSet
,
'api-vote'
)
memopol/templatetags/memopol_tags.py
View file @
0ef69d56
# coding: utf-8
import
re
from
django
import
template
from
django.core.urlresolvers
import
reverse
from
django.utils.safestring
import
mark_safe
import
r
e
from
django.utils.html
import
escap
e
register
=
template
.
Library
()
link
=
'<a class="{network}-link" href="{url}" target="_blank">{label}</a>'
...
...
@@ -30,3 +34,34 @@ def website_link(url):
def
email_link
(
address
):
return
mark_safe
(
link
.
format
(
network
=
'email'
,
url
=
'mailto:%s'
%
address
,
label
=
address
))
@
register
.
simple_tag
def
group_url
(
group
):
if
group
.
kind
==
'chamber'
or
group
.
chamber
is
None
:
return
escape
(
reverse
(
'representative-list'
,
kwargs
=
{
'group_kind'
:
group
.
kind
,
'group'
:
group
.
name
}))
else
:
return
escape
(
reverse
(
'representative-list'
,
kwargs
=
{
'group_kind'
:
group
.
kind
,
'chamber'
:
group
.
chamber
.
name
,
'group'
:
group
.
name
}))
@
register
.
simple_tag
def
chamber_url
(
chamber
):
return
escape
(
reverse
(
'representative-list'
,
kwargs
=
{
'group_kind'
:
'chamber'
,
'group'
:
chamber
.
name
}))
@
register
.
simple_tag
def
country_url
(
country
):
return
escape
(
reverse
(
'representative-list'
,
kwargs
=
{
'group_kind'
:
'country'
,
'group'
:
country
.
name
}))
memopol/tests/base.py
View file @
0ef69d56
...
...
@@ -3,6 +3,8 @@ import os.path
from
django.test
import
Client
from
responsediff.response
import
Response
class
UrlGetTestMixin
(
object
):
url
=
None
...
...
@@ -35,3 +37,16 @@ class UrlGetTestMixin(object):
with
open
(
expected
,
'r'
)
as
f
:
self
.
assertHtmlInResult
(
f
.
read
())
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
)
expected
=
Response
.
for_test
(
self
)
expected
.
assertNoDiff
(
response
)
memopol/tests/response_fixtures/DossiersTest.test_dossier_detail/content
0 → 100644
View file @
0ef69d56
<!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.3c5ffeab3cbf.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"
>
<h1>
Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)
</h1>
<p>
<strong>
2010/2935(RSP)
</strong>
</p>
<h2>
Recommendations
</h2>
<table
class=
'table'
>
<tr>
<th>
Proposal
</th>
<th>
Title
</th>
<th>
Recommendation
</th>
<th>
Status
</th>
<th><i
aria-label=
"for"
class=
"fa fa-thumbs-up vote_positive"
title=
"for"
></i></th>
<th><i
aria-label=
"against"
class=
"fa fa-thumbs-down vote_negative"
title=
"against"
></i></th>
<th><i
aria-label=
"abstain"
class=
"fa fa-circle-o vote_abstain"
title=
"abstain"
></i></th>
</tr>
<tr>
<td>
RC-B7-0617/2010 - Accord commercial anti-contrefaçon (ACAC) - Considérant X
<br
/>
<small>
B7-0617/2010
Considérant X
</small>
</td>
<td>
Stop acta !
</td>
<td><i
aria-label=
"for"
class=
"fa fa-thumbs-up vote_positive"
title=
"for"
></i></td>
<td>
adopted
</td>
<td>
329
</td>
<td>
249
</td>
<td>
75
</td>
</tr>
<tr>
<td>
RC-B7-0617/2010 - Accord commercial anti-contrefaçon (ACAC) - Considérant CC
<br
/>
<small>
B7-0617/2010
Considérant CC
</small>
</td>
<td>
Stop acta !
</td>
<td><i
aria-label=
"for"
class=
"fa fa-thumbs-up vote_positive"
title=
"for"
></i></td>
<td>
adopted
</td>
<td>
315
</td>
<td>
312
</td>
<td>
14
</td>
</tr>
<tr>
<td>
RC-B7-0617/2010 - Accord commercial anti-contrefaçon (ACAC) - Résolution
<br
/>
<small>
B7-0617/2010
Résolution
</small>
</td>
<td>
Stop acta !
</td>
<td><i
aria-label=
"for"
class=
"fa fa-thumbs-up vote_positive"
title=
"for"
></i></td>
<td>
rejected
</td>
<td>
306
</td>
<td>
322
</td>
<td>
26
</td>
</tr>
</table>
</div>
<div
id=
'footer'
class=
'container-fluid'
>
Memopol is free software
<a
href=
"https://github.com/political-memory/political_memory"
>
released
</a>
under the terms of the
<a
href=
"http://www.gnu.org/licenses/agpl.html"
>
GNU aGPLV3+
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues'
>
Bug tracking system
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues/new'
>
Report a bug
</a>
<br
/>
Provided by
<a
href=
"http://www.laquadrature.net/"
>
La Quadrature du Net
</a>
</div>
</body>
</html>
memopol/tests/response_fixtures/DossiersTest.test_dossier_list/content
0 → 100644
View file @
0ef69d56
<!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.3c5ffeab3cbf.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"
>
<h1>
Dossiers
</h1>
<table
class=
'table'
>
<tr>
<th>
Title
</th>
<th>
Recommendations
</th>
<th>
Reference
</th>
</tr>
<tr>
<td>
<a
href=
'/votes/dossier/28147/'
>
Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)
</a>
</td>
<td>
3
</td>
<td>
2010/2935(RSP)
</td>
</tr>
</table>
<div
class=
'pagination-block'
>
<nav>
<ul
class=
'pagination pagination-sm'
>
</ul>
</nav>
<div
class=
'count'
>
Number of results : 1
<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>
</div>
<div
id=
'footer'
class=
'container-fluid'
>
Memopol is free software
<a
href=
"https://github.com/political-memory/political_memory"
>
released
</a>
under the terms of the
<a
href=
"http://www.gnu.org/licenses/agpl.html"
>
GNU aGPLV3+
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues'
>
Bug tracking system
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues/new'
>
Report a bug
</a>
<br
/>
Provided by
<a
href=
"http://www.laquadrature.net/"
>
La Quadrature du Net
</a>
</div>
</body>
</html>
memopol/tests/response_fixtures/GroupListTest.test_chambers/content
0 → 100644
View file @
0ef69d56
<!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.3c5ffeab3cbf.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"
>
<table
class=
'table'
>
<tr>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
EP
</a>
</td>
<td>
<a
href=
'/legislature/representative/chamber/European%20Parliament/'
>
<span
class=
"chamber-icon chamber-icon-ep"
></span>
European Parliament
</a>
</td>
</tr>
</table>
</div>
<div
id=
'footer'
class=
'container-fluid'
>
Memopol is free software
<a
href=
"https://github.com/political-memory/political_memory"
>
released
</a>
under the terms of the
<a
href=
"http://www.gnu.org/licenses/agpl.html"
>
GNU aGPLV3+
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues'
>
Bug tracking system
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues/new'
>
Report a bug
</a>
<br
/>
Provided by
<a
href=
"http://www.laquadrature.net/"
>
La Quadrature du Net
</a>
</div>