[primary] backport _rel_label method from the default branch stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 10 Aug 2010 18:26:43 +0200
branchstable
changeset 6090 887c069d88df
parent 6088 28f49a4fe702
child 6091 560df423149a
[primary] backport _rel_label method from the default branch
web/views/primary.py
--- a/web/views/primary.py	Tue Aug 10 14:56:31 2010 +0200
+++ b/web/views/primary.py	Tue Aug 10 18:26:43 2010 +0200
@@ -271,6 +271,19 @@
             label = display_name(self._cw, rschema.type, role)
         self.field(label, value, show_label=showlabel, tr=False, table=table)
 
+    def _rel_label(self, entity, rschema, role, dispctrl):
+        if rschema.final:
+            showlabel = dispctrl.get('showlabel', self.show_attr_label)
+        else:
+            showlabel = dispctrl.get('showlabel', self.show_rel_label)
+        if showlabel:
+            if dispctrl.get('label'):
+                label = self._cw._(dispctrl['label'])
+            else:
+                label = display_name(self._cw, rschema.type, role,
+                                     context=entity.__regid__)
+            return label
+        return u''
 
 class RelatedView(EntityView):
     __regid__ = 'autolimited'