Commit e0a865ae authored by njoyard's avatar njoyard Committed by GitHub

Merge pull request #97 from political-memory/dossier-search

Add search to dossiers
parents c712d0ec 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))
......@@ -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>
......
<!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>
{
"status_code": 200
}
\ No newline at end of file
<!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>