web/views/facets.py
changeset 7402 826e5663a686
parent 7300 4058ed1e3bc2
child 7600 75d208ab8444
equal deleted inserted replaced
7400:2391a6f526bf 7402:826e5663a686
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
   201     __select__ = relation_possible('has_text', 'subject') & match_context_prop()
   201     __select__ = relation_possible('has_text', 'subject') & match_context_prop()
   202     __regid__ = 'has_text-facet'
   202     __regid__ = 'has_text-facet'
   203     rtype = 'has_text'
   203     rtype = 'has_text'
   204     role = 'subject'
   204     role = 'subject'
   205     order = 0
   205     order = 0
       
   206 
       
   207     @property
       
   208     def wdgclass(self):
       
   209         return facet.FacetStringWidget
       
   210 
   206     @property
   211     @property
   207     def title(self):
   212     def title(self):
   208         return self._cw._('has_text')
   213         return self._cw._('has_text')
   209 
   214 
   210     def get_widget(self):
   215     def get_widget(self):
   211         """return the widget instance to use to display this facet
   216         """return the widget instance to use to display this facet
   212 
   217 
   213         default implentation expects a .vocabulary method on the facet and
   218         default implentation expects a .vocabulary method on the facet and
   214         return a combobox displaying this vocabulary
   219         return a combobox displaying this vocabulary
   215         """
   220         """
   216         return facet.FacetStringWidget(self)
   221         return self.wdgclass(self)
   217 
   222 
   218     def add_rql_restrictions(self):
   223     def add_rql_restrictions(self):
   219         """add restriction for this facet into the rql syntax tree"""
   224         """add restriction for this facet into the rql syntax tree"""
   220         value = self._cw.form.get(self.__regid__)
   225         value = self._cw.form.get(self.__regid__)
   221         if not value:
   226         if not value: