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
087679f3
Commit
087679f3
authored
Jul 04, 2016
by
Nicolas Joyard
Browse files
Add search to dossiers
parent
c712d0ec
Changes
24
Hide whitespace changes
Inline
Side-by-side
memopol/filters.py
View file @
087679f3
...
...
@@ -10,6 +10,7 @@ from django.utils.text import slugify
from
django_filters
import
FilterSet
,
MethodFilter
,
ModelChoiceFilter
from
representatives.models
import
Chamber
,
Group
,
Representative
from
representatives_votes.models
import
Dossier
def
chamber_filter
(
qs
,
value
):
...
...
@@ -53,3 +54,19 @@ class RepresentativeFilter(FilterSet):
return
qs
return
qs
.
filter
(
slug__icontains
=
slugify
(
value
))
class
DossierFilter
(
FilterSet
):
search
=
MethodFilter
(
action
=
'search_filter'
)
class
Meta
:
model
=
Dossier
fields
=
[
'search'
]
def
search_filter
(
self
,
qs
,
value
):
if
len
(
value
)
==
0
:
return
qs
return
qs
.
filter
(
Q
(
title__icontains
=
value
)
|
Q
(
reference__icontains
=
value
))
memopol/tests/response_fixtures/DossiersTest.test_dossier_list.content
View file @
087679f3
...
...
@@ -14,6 +14,10 @@
<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 -->
...
...
@@ -78,37 +82,113 @@
<div
class=
"container-fluid main-container"
>
<h1>
Dossiers
</h1>
<table
class=
'table'
>
<tr>
<th>
Title
</th>
<th>
Recommendations
</th>
<th>
Reference
</th>
</tr>
<form
class=
'filter-form'
action=
'/votes/dossier/'
method=
'get'
>
<div
class=
"form-group has-success"
><label
class=
"control-label"
for=
"id_search"
>
Search
</label><input
class=
"form-control"
id=
"id_search"
name=
"search"
placeholder=
"Search"
title=
"Filter"
type=
"text"
/><span
class=
"help-block"
>
Filter
</span></div>
<div
class=
"form-group"
>
<button
class=
'btn btn-primary'
type=
'submit'
>
<span
class=
"glyphicon glyphicon-filter"
></span>
Filter
</button>
</div>
</form>
<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>
<h1>
Dossiers
</h1>
<table
class=
'table'
>
<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>
<th>
Title
</th>
<th>
Recommendations
</th>
<th>
Reference
</th>
</tr>
</table>
<div
class=
'pagination-block'
>
<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'
>
...
...
@@ -158,6 +238,8 @@
</div>
</div>
...
...
memopol/tests/response_fixtures/DossiersTest.test_dossier_search.content
0 → 100644
View file @
087679f3
<!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.540ce621a9a1.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"
>
<form
class=
'filter-form'
action=
'/votes/dossier/'
method=
'get'
>
<div
class=
"form-group has-success"
><label
class=
"control-label"
for=
"id_search"
>
Search
</label><input
class=
"form-control"
id=
"id_search"
name=
"search"
placeholder=
"Search"
title=
"Filter"
type=
"text"
value=
"acta"
/><span
class=
"help-block"
>
Filter
</span></div>
<div
class=
"form-group"
>
<button
class=
'btn btn-primary'
type=
'submit'
>
<span
class=
"glyphicon glyphicon-filter"
></span>
Filter
</button>
</div>
</form>
<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=
'?search=acta&paginate_by=12'
>
12
</a>
/
<a
href=
'?search=acta&paginate_by=24'
>
24
</a>
/
<a
href=
'?search=acta&paginate_by=48'
>
48
</a>
/
<a
href=
'?search=acta&paginate_by=96'
>
96
</a>
)
</div>
</div>
<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=
'?search=acta&paginate_by=12'
>
12
</a>
/
<a
href=
'?search=acta&paginate_by=24'
>
24
</a>
/
<a
href=
'?search=acta&paginate_by=48'
>
48
</a>
/
<a
href=
'?search=acta&paginate_by=96'
>
96
</a>
)
</div>
</div>
</div>
<div
id=
'footer'
class=
'container-fluid'
>
<div
class=
'license-links'
>
Memopol is
<a
href=
'https://github.com/political-memory/political_memory'
>
free software
</a>
released under the terms of the
<a
href=
'http://www.gnu.org/licenses/agpl.html'
>
GNU aGPLV3+
</a>
</div>
<div
class=
'footer-link'
>
<a
href=
'https://github.com/political-memory/political_memory/issues/new'
>
Report a bug
</a>
</div>
<div
class=
'footer-link'
>
<a
href=
'http://www.memopol.org/'
>
Blog
</a>
</div>
<div
class=
'footer-link'
>
<a
href=
'http://memopol.readthedocs.io/en/master/'
>
Documentation
</a>
</div>
<div
class=
'footer-separator'
></div>
<div
class=
'footer-link'
>
Developed by
<a
href=
'http://www.laquadrature.net/'
>
La Quadrature du Net
</a>
</div>
<div
class=
'footer-link'
>
EP data provided by
<a
href=
'http://parltrack.euwiki.org/'
>
Parltrack
</a>
</div>
</div>
</body>
</html>
memopol/tests/response_fixtures/DossiersTest.test_dossier_search.metadata
0 → 100644
View file @
087679f3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/response_fixtures/DossiersTest.test_dossier_search_noresults.content
0 → 100644
View file @
087679f3
<!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.540ce621a9a1.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"
>
<form
class=
'filter-form'
action=
'/votes/dossier/'
method=
'get'
>
<div
class=
"form-group has-success"
><label
class=
"control-label"
for=
"id_search"
>
Search
</label><input
class=
"form-control"
id=
"id_search"
name=
"search"
placeholder=
"Search"
title=
"Filter"
type=
"text"
value=
"no-dossier-will-have-that-title-ever"
/><span
class=
"help-block"
>
Filter
</span></div>
<div
class=
"form-group"
>
<button
class=
'btn btn-primary'
type=
'submit'
>
<span
class=
"glyphicon glyphicon-filter"
></span>
Filter
</button>
</div>
</form>
<div
class=
'no-results'
>
No matching dossiers found :(
</div>
</div>
<div
id=
'footer'
class=
'container-fluid'
>
<div
class=
'license-links'
>
Memopol is
<a
href=
'https://github.com/political-memory/political_memory'
>
free software
</a>
released under the terms of the
<a
href=
'http://www.gnu.org/licenses/agpl.html'
>
GNU aGPLV3+
</a>
</div>
<div
class=
'footer-link'
>
<a
href=
'https://github.com/political-memory/political_memory/issues/new'
>
Report a bug
</a>
</div>
<div
class=
'footer-link'
>