equal
deleted
inserted
replaced
670 self.role, select_target_entity=True) |
670 self.role, select_target_entity=True) |
671 else: |
671 else: |
672 insert_attr_select_relation( |
672 insert_attr_select_relation( |
673 select, self.filtered_variable, self.rtype, self.role, |
673 select, self.filtered_variable, self.rtype, self.role, |
674 self.target_attr, select_target_entity=False) |
674 self.target_attr, select_target_entity=False) |
675 values = [unicode(x) for x, in self.rqlexec(select.as_string())] |
675 values = [text_type(x) for x, in self.rqlexec(select.as_string())] |
676 except Exception: |
676 except Exception: |
677 self.exception('while computing values for %s', self) |
677 self.exception('while computing values for %s', self) |
678 return [] |
678 return [] |
679 finally: |
679 finally: |
680 select.recover() |
680 select.recover() |
1124 select.save_state() |
1124 select.save_state() |
1125 try: |
1125 try: |
1126 cleanup_select(select, self.filtered_variable) |
1126 cleanup_select(select, self.filtered_variable) |
1127 varmap, restrvar = self.add_path_to_select(skiplabel=True) |
1127 varmap, restrvar = self.add_path_to_select(skiplabel=True) |
1128 select.append_selected(nodes.VariableRef(restrvar)) |
1128 select.append_selected(nodes.VariableRef(restrvar)) |
1129 values = [unicode(x) for x, in self.rqlexec(select.as_string())] |
1129 values = [text_type(x) for x, in self.rqlexec(select.as_string())] |
1130 except Exception: |
1130 except Exception: |
1131 self.exception('while computing values for %s', self) |
1131 self.exception('while computing values for %s', self) |
1132 return [] |
1132 return [] |
1133 finally: |
1133 finally: |
1134 select.recover() |
1134 select.recover() |
1251 """return vocabulary for this facet, eg a list of 2-uple (label, value) |
1251 """return vocabulary for this facet, eg a list of 2-uple (label, value) |
1252 """ |
1252 """ |
1253 rset = self._range_rset() |
1253 rset = self._range_rset() |
1254 if rset: |
1254 if rset: |
1255 minv, maxv = rset[0] |
1255 minv, maxv = rset[0] |
1256 return [(unicode(minv), minv), (unicode(maxv), maxv)] |
1256 return [(text_type(minv), minv), (text_type(maxv), maxv)] |
1257 return [] |
1257 return [] |
1258 |
1258 |
1259 def possible_values(self): |
1259 def possible_values(self): |
1260 """Return a list of possible values (as string since it's used to |
1260 """Return a list of possible values (as string since it's used to |
1261 compare to a form value in javascript) for this facet. |
1261 compare to a form value in javascript) for this facet. |
1270 return None |
1270 return None |
1271 return self.wdgclass(self, min(values), max(values)) |
1271 return self.wdgclass(self, min(values), max(values)) |
1272 |
1272 |
1273 def formatvalue(self, value): |
1273 def formatvalue(self, value): |
1274 """format `value` before in order to insert it in the RQL query""" |
1274 """format `value` before in order to insert it in the RQL query""" |
1275 return unicode(value) |
1275 return text_type(value) |
1276 |
1276 |
1277 def infvalue(self, min=False): |
1277 def infvalue(self, min=False): |
1278 if min: |
1278 if min: |
1279 return self._cw.form.get('min_%s_inf' % self.__regid__) |
1279 return self._cw.form.get('min_%s_inf' % self.__regid__) |
1280 return self._cw.form.get('%s_inf' % self.__regid__) |
1280 return self._cw.form.get('%s_inf' % self.__regid__) |
1371 select.recover() |
1371 select.recover() |
1372 # don't call rset_vocabulary on empty result set, it may be an empty |
1372 # don't call rset_vocabulary on empty result set, it may be an empty |
1373 # *list* (see rqlexec implementation) |
1373 # *list* (see rqlexec implementation) |
1374 if rset: |
1374 if rset: |
1375 minv, maxv = rset[0] |
1375 minv, maxv = rset[0] |
1376 return [(unicode(minv), minv), (unicode(maxv), maxv)] |
1376 return [(text_type(minv), minv), (text_type(maxv), maxv)] |
1377 return [] |
1377 return [] |
1378 |
1378 |
1379 |
1379 |
1380 def possible_values(self): |
1380 def possible_values(self): |
1381 """return a list of possible values (as string since it's used to |
1381 """return a list of possible values (as string since it's used to |
1514 mask = reduce(lambda x, y: x | (y[0] or 0), rset, 0) |
1514 mask = reduce(lambda x, y: x | (y[0] or 0), rset, 0) |
1515 return sorted([(self._cw._(label), val) for label, val in self.choices |
1515 return sorted([(self._cw._(label), val) for label, val in self.choices |
1516 if not val or val & mask]) |
1516 if not val or val & mask]) |
1517 |
1517 |
1518 def possible_values(self): |
1518 def possible_values(self): |
1519 return [unicode(val) for label, val in self.vocabulary()] |
1519 return [text_type(val) for label, val in self.vocabulary()] |
1520 |
1520 |
1521 |
1521 |
1522 ## html widets ################################################################ |
1522 ## html widets ################################################################ |
1523 _DEFAULT_VOCAB_WIDGET_HEIGHT = 12 |
1523 _DEFAULT_VOCAB_WIDGET_HEIGHT = 12 |
1524 _DEFAULT_FACET_GROUP_HEIGHT = 15 |
1524 _DEFAULT_FACET_GROUP_HEIGHT = 15 |
1593 def _render_value(self, w, value, label, selected, overflow): |
1593 def _render_value(self, w, value, label, selected, overflow): |
1594 cssclass = 'facetValue facetCheckBox' |
1594 cssclass = 'facetValue facetCheckBox' |
1595 if selected: |
1595 if selected: |
1596 cssclass += ' facetValueSelected' |
1596 cssclass += ' facetValueSelected' |
1597 w(u'<div class="%s" cubicweb:value="%s">\n' |
1597 w(u'<div class="%s" cubicweb:value="%s">\n' |
1598 % (cssclass, xml_escape(unicode(value)))) |
1598 % (cssclass, xml_escape(text_type(value)))) |
1599 # If it is overflowed one must add padding to compensate for the vertical |
1599 # If it is overflowed one must add padding to compensate for the vertical |
1600 # scrollbar; given current css values, 4 blanks work perfectly ... |
1600 # scrollbar; given current css values, 4 blanks work perfectly ... |
1601 padding = u' ' * self.scrollbar_padding_factor if overflow else u'' |
1601 padding = u' ' * self.scrollbar_padding_factor if overflow else u'' |
1602 w('<span>%s</span>' % xml_escape(label)) |
1602 w('<span>%s</span>' % xml_escape(label)) |
1603 w(padding) |
1603 w(padding) |
1752 imgalt = self._cw._('selected') |
1752 imgalt = self._cw._('selected') |
1753 else: |
1753 else: |
1754 imgsrc = self._cw.data_url(self.unselected_img) |
1754 imgsrc = self._cw.data_url(self.unselected_img) |
1755 imgalt = self._cw._('not selected') |
1755 imgalt = self._cw._('not selected') |
1756 w(u'<div class="%s" cubicweb:value="%s">\n' |
1756 w(u'<div class="%s" cubicweb:value="%s">\n' |
1757 % (cssclass, xml_escape(unicode(self.value)))) |
1757 % (cssclass, xml_escape(text_type(self.value)))) |
1758 w(u'<div>') |
1758 w(u'<div>') |
1759 w(u'<img src="%s" alt="%s" cubicweb:unselimg="true" /> ' % (imgsrc, imgalt)) |
1759 w(u'<img src="%s" alt="%s" cubicweb:unselimg="true" /> ' % (imgsrc, imgalt)) |
1760 w(u'<label class="facetTitle" cubicweb:facetName="%s">%s</label>' |
1760 w(u'<label class="facetTitle" cubicweb:facetName="%s">%s</label>' |
1761 % (xml_escape(self.facet.__regid__), title)) |
1761 % (xml_escape(self.facet.__regid__), title)) |
1762 w(u'</div>\n') |
1762 w(u'</div>\n') |