[views] fix boolean value

previously bool value was 0 or 1 it seems that elasticsearch 6 will not cast this value anymore

authorSamuel Trégouët <samuel.tregouet@logilab.fr>
changeset0d7d628fed76
branchdefault
phasepublic
hiddenno
parent revision#375b6fe412de [es6] fix tests of 0.7.XXX
child revision#905b137c2778 [pkg] prepare 0.7.4
files modified by this revision
cubicweb_elasticsearch/views.py
# HG changeset patch
# User Samuel Trégouët <samuel.tregouet@logilab.fr>
# Date 1545229421 -3600
# Wed Dec 19 15:23:41 2018 +0100
# Node ID 0d7d628fed76b6d84da5dbac0beee311caaa45cc
# Parent 375b6fe412de4564b418eca4dadf3ee5ffd9c6ba
[views] fix boolean value

previously bool value was 0 or 1 it seems that elasticsearch 6 will not cast
this value anymore

diff --git a/cubicweb_elasticsearch/views.py b/cubicweb_elasticsearch/views.py
@@ -99,13 +99,19 @@
1          start, stop = 0, 10
2          for key, value in self._cw.form.items():
3              if key.startswith('es_'):
4                  # FIXME TODO have better typing mechanisme (inspect facets?)
5                  try:
6 -                    facet_selections[key.replace('es_', '')] = int(value)
7 +                    if value.lower() == 'true':
8 +                        value = True
9 +                    elif value.lower() == 'false':
10 +                        value = False
11 +                    else:
12 +                        value = int(value)
13                  except ValueError:
14 -                    facet_selections[key.replace('es_', '')] = value
15 +                    pass
16 +                facet_selections[key.replace('es_', '')] = value
17              if key == 'page':
18                  try:
19                      start = (max(int(value) - 1, 0)) * 10
20                      stop = start + 10
21                  except ValueError: