# HG changeset patch # User Sylvain Thénault # Date 1253296194 -7200 # Node ID 76888cd23d83522c72d7109a6f80ea090da3d3ad # Parent 44efba78afac088e07e8c4050fb5628af2f8ba09 facets enhancement: can now set label_vid to use a view instead of a simple attribute as label diff -r 44efba78afac -r 76888cd23d83 web/facet.py --- a/web/facet.py Fri Sep 18 19:48:58 2009 +0200 +++ b/web/facet.py Fri Sep 18 19:49:54 2009 +0200 @@ -346,6 +346,8 @@ sortfunc = None # ascendant/descendant sorting sortasc = True + # if you want to call a view on the entity instead of using `target_attr` + label_vid = None @property def title(self): @@ -384,8 +386,14 @@ rqlst.recover() def rset_vocabulary(self, rset): - _ = self.req._ - return [(_(label), eid) for eid, label in rset] + if self.label_vid is None: + _ = self.req._ + return [(_(label), eid) for eid, label in rset] + if self.sortfunc is None: + return sorted((entity.view(self.label_vid), entity.eid) + for entity in rset.entities()) + return [(entity.view(self.label_vid), entity.eid) + for entity in rset.entities()] @cached def support_and(self):