[range facet] refactor to ease overriding, possible_values raise DontUpdateFacet (not handled by js actually)
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 01 Jul 2011 15:26:45 +0200
changeset 7607 d332ecfc224a
parent 7606 01b49ec8fe80
child 7608 47311917a548
[range facet] refactor to ease overriding, possible_values raise DontUpdateFacet (not handled by js actually)
web/facet.py
--- a/web/facet.py	Fri Jul 01 15:26:44 2011 +0200
+++ b/web/facet.py	Fri Jul 01 15:26:45 2011 +0200
@@ -1018,15 +1018,19 @@
         # when a value is equal to one of the limit, don't add the restriction,
         # else we filter out NULL values implicitly
         if infvalue != self.infvalue(min=True):
-            self.rqlst.add_constant_restriction(self.filtered_variable,
-                                                self.rtype,
-                                                self.formatvalue(infvalue),
-                                                self.attrtype, '>=')
+            self._add_restriction(infvalue, '>=')
         if supvalue != self.supvalue(max=True):
-            self.rqlst.add_constant_restriction(self.filtered_variable,
-                                                self.rtype,
-                                                self.formatvalue(supvalue),
-                                                self.attrtype, '<=')
+            self._add_restriction(supvalue, '<=')
+
+    def _add_restriction(self, operator, value):
+        self.select.add_constant_restriction(self.filtered_variable,
+                                             self.rtype,
+                                             self.formatvalue(value),
+                                             self.attrtype, operator)
+
+    def possible_values(self):
+        # javascript don't know how to update the widget anyway
+        raise facet.DontUpdateFacet()
 
 
 class DateRangeFacet(RangeFacet):