[relations in ui] provide context information when computing label for a relation stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 27 Jul 2010 09:40:09 +0200
branchstable
changeset 6017 5f6a60ea8544
parent 6016 0eabedcfb0a9
child 6019 373a313ee9ec
[relations in ui] provide context information when computing label for a relation
schema.py
web/box.py
web/views/autoform.py
--- a/schema.py	Tue Jul 27 09:14:00 2010 +0200
+++ b/schema.py	Tue Jul 27 09:40:09 2010 +0200
@@ -15,9 +15,8 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""classes to define schemas for CubicWeb
+"""classes to define schemas for CubicWeb"""
 
-"""
 __docformat__ = "restructuredtext en"
 _ = unicode
 
--- a/web/box.py	Tue Jul 27 09:14:00 2010 +0200
+++ b/web/box.py	Tue Jul 27 09:40:09 2010 +0200
@@ -165,7 +165,8 @@
         role = get_role(self)
         self.w(u'<div class="sideBox">')
         self.wview('sidebox', entity.related(self.rtype, role, limit=limit),
-                   title=display_name(self._cw, self.rtype, role))
+                   title=display_name(self._cw, self.rtype, role,
+                                      context=entity.__regid__))
         self.w(u'</div>')
 
 
@@ -180,7 +181,8 @@
     def cell_call(self, row, col, view=None, **kwargs):
         self._cw.add_js('cubicweb.ajax.js')
         entity = self.cw_rset.get_entity(row, col)
-        box = SideBoxWidget(display_name(self._cw, self.rtype), self.__regid__)
+        title = display_name(self._cw, self.rtype, get_role(self), context=entity.__regid__)
+        box = SideBoxWidget(title, self.__regid__)
         related = self.related_boxitems(entity)
         unrelated = self.unrelated_boxitems(entity)
         box.extend(related)
@@ -292,7 +294,7 @@
         divid = domid(self.__regid__) + unicode(entity.eid)
         w(u'<div class="sideBox" id="%s%s">' % (domid(self.__regid__), entity.eid))
         w(u'<div class="sideBoxTitle"><span>%s</span></div>' %
-               rdef.rtype.display_name(req, self.role))
+               rdef.rtype.display_name(req, self.role, context=entity.__regid__))
         w(u'<div class="sideBox"><div class="sideBoxBody">')
         if related:
             w(u'<table>')
--- a/web/views/autoform.py	Tue Jul 27 09:14:00 2010 +0200
+++ b/web/views/autoform.py	Tue Jul 27 09:40:09 2010 +0200
@@ -443,7 +443,8 @@
         for rschema, role, related in field.relations_table(form):
             # already linked entities
             if related:
-                w(u'<tr><th class="labelCol">%s</th>' % rschema.display_name(req, role))
+                label = rschema.display_name(req, role, context=form.edited_entity.__regid__)
+                w(u'<tr><th class="labelCol">%s</th>' % label)
                 w(u'<td>')
                 w(u'<ul>')
                 for viewparams in related: