Commit 129ffd04 authored by Nicolas Joyard's avatar Nicolas Joyard

Add score filters

parent 949b7d0a
......@@ -15,6 +15,8 @@ from memopol_themes.models import Theme
class RepresentativeFilter(FilterSet):
search = MethodFilter(action='search_filter')
scoremin = MethodFilter(action='score_min_filter')
scoremax = MethodFilter(action='score_max_filter')
chamber = MethodFilter(action='chamber_filter')
country = MethodFilter(action='group_filter')
party = MethodFilter(action='group_filter')
......@@ -54,6 +56,24 @@ class RepresentativeFilter(FilterSet):
mandates__group=value
)
def score_min_filter(self, qs, value):
if len(value) == 0:
return qs
try:
return qs.filter(score__score__gte=int(value))
except ValueError:
return qs
def score_max_filter(self, qs, value):
if len(value) == 0:
return qs
try:
return qs.filter(score__score__lte=int(value))
except ValueError:
return qs
class DossierFilter(FilterSet):
......
<h4 class="text-center">Elmar BROK</h4>
---
<h4 class="text-center">David CASA</h4>
---
<h4 class="text-center">Jean-Marie CAVADA</h4>
---
<h4 class="text-center">Michel DANTIN</h4>
---
<h4 class="text-center">Tamás DEUTSCH</h4>
---
<h4 class="text-center">José Manuel FERNANDES</h4>
---
<h4 class="text-center">Ashley FOX</h4>
---
<h4 class="text-center">Kinga GÁL</h4>
---
<h4 class="text-center">Ildikó GÁLL-PELCZ</h4>
---
<h4 class="text-center">Mary HONEYBALL</h4>
---
<h4 class="text-center">Jarosław KALINOWSKI</h4>
---
<h4 class="text-center">Andrey KOVATCHEV</h4>
\ No newline at end of file
<h4 class="text-center">Zigmantas BALČYTIS</h4>
---
<h4 class="text-center">Vilija BLINKEVIČIŪTĖ</h4>
---
<h4 class="text-center">Cristian-Silviu BUŞOI</h4>
---
<h4 class="text-center">Nikolaos CHOUNTIS</h4>
---
<h4 class="text-center">Michael CRAMER</h4>
---
<h4 class="text-center">Viorica DĂNCILĂ</h4>
---
<h4 class="text-center">Bas EICKHOUT</h4>
---
<h4 class="text-center">Ismail ERTUG</h4>
---
<h4 class="text-center">Monika FLAŠÍKOVÁ BEŇOVÁ</h4>
---
<h4 class="text-center">Eider GARDIAZABAL RUBIAL</h4>
---
<h4 class="text-center">Marian HARKIN</h4>
---
<h4 class="text-center">Iliana IOTOVA</h4>
\ No newline at end of file
......@@ -48,3 +48,11 @@ class RepresentativeListTest(BaseTest):
def test_search_by_delegation(self):
self.selector_test('.representative-card h4',
'%s?delegation=95' % self.url)
def test_search_by_min_score(self):
self.selector_test('.representative-card h4',
'%s?scoremin=10' % self.url)
def test_search_by_max_score(self):
self.selector_test('.representative-card h4',
'%s?scoremax=0' % self.url)
......@@ -31,6 +31,17 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3" for="score-min">{% trans "Score between" %}</label>
<div class="col-sm-4">
<input type="number" class="form-control" name="scoremin" id="score-min" value="{{ filter.data.scoremin }}">
</div>
<label class="col-sm-1" for="score-max">{% trans "and" %}</label>
<div class="col-sm-4">
<input type="number" class="form-control" name="scoremax" id="score-max" value="{{ filter.data.scoremax }}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3" for="chamber-rep">{% trans "Chamber" %}</label>
<div class="col-sm-9">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment