equal
deleted
inserted
replaced
55 from functools import reduce |
55 from functools import reduce |
56 from warnings import warn |
56 from warnings import warn |
57 from copy import deepcopy |
57 from copy import deepcopy |
58 from datetime import datetime, timedelta |
58 from datetime import datetime, timedelta |
59 |
59 |
60 from six import string_types |
60 from six import text_type, string_types |
61 |
61 |
62 from logilab.mtconverter import xml_escape |
62 from logilab.mtconverter import xml_escape |
63 from logilab.common.graph import has_path |
63 from logilab.common.graph import has_path |
64 from logilab.common.decorators import cached, cachedproperty |
64 from logilab.common.decorators import cached, cachedproperty |
65 from logilab.common.date import datetime2ticks, ustrftime, ticks2datetime |
65 from logilab.common.date import datetime2ticks, ustrftime, ticks2datetime |
719 return self.sortfunc is not None or (self.label_vid is None |
719 return self.sortfunc is not None or (self.label_vid is None |
720 and not self.i18nable) |
720 and not self.i18nable) |
721 |
721 |
722 def rset_vocabulary(self, rset): |
722 def rset_vocabulary(self, rset): |
723 if self.i18nable: |
723 if self.i18nable: |
724 _ = self._cw._ |
724 tr = self._cw._ |
725 else: |
725 else: |
726 _ = unicode |
726 tr = text_type |
727 if self.rql_sort: |
727 if self.rql_sort: |
728 values = [(_(label), eid) for eid, label in rset] |
728 values = [(tr(label), eid) for eid, label in rset] |
729 else: |
729 else: |
730 if self.label_vid is None: |
730 if self.label_vid is None: |
731 values = [(_(label), eid) for eid, label in rset] |
731 values = [(tr(label), eid) for eid, label in rset] |
732 else: |
732 else: |
733 values = [(entity.view(self.label_vid), entity.eid) |
733 values = [(entity.view(self.label_vid), entity.eid) |
734 for entity in rset.entities()] |
734 for entity in rset.entities()] |
735 values = sorted(values) |
735 values = sorted(values) |
736 if not self.sortasc: |
736 if not self.sortasc: |
916 def restr_attr_type(self): |
916 def restr_attr_type(self): |
917 return self.target_attr_type |
917 return self.target_attr_type |
918 |
918 |
919 def rset_vocabulary(self, rset): |
919 def rset_vocabulary(self, rset): |
920 if self.i18nable: |
920 if self.i18nable: |
921 _ = self._cw._ |
921 tr = self._cw._ |
922 else: |
922 else: |
923 _ = unicode |
923 tr = text_type |
924 if self.rql_sort: |
924 if self.rql_sort: |
925 return [(_(value), value) for value, in rset] |
925 return [(tr(value), value) for value, in rset] |
926 values = [(_(value), value) for value, in rset] |
926 values = [(tr(value), value) for value, in rset] |
927 return sorted(values, reverse=not self.sortasc) |
927 return sorted(values, reverse=not self.sortasc) |
928 |
928 |
929 |
929 |
930 class AttributeFacet(RelationAttributeFacet): |
930 class AttributeFacet(RelationAttributeFacet): |
931 """Base facet to filter some entities according one of their attribute. |
931 """Base facet to filter some entities according one of their attribute. |