[formrenderers] Factor-out render_title to ease customisation in derived classes stable
authorAnthony Truchet <anthony.truchet@logilab.fr>
Tue, 22 May 2012 18:51:09 +0200
branchstable
changeset 8413 9ac36a6ec07e
parent 8407 6874eb7a08e8
child 8414 e7243ed7bb0a
[formrenderers] Factor-out render_title to ease customisation in derived classes
web/views/formrenderers.py
--- a/web/views/formrenderers.py	Mon May 14 15:25:41 2012 +0200
+++ b/web/views/formrenderers.py	Tue May 22 18:51:09 2012 +0200
@@ -492,6 +492,14 @@
     """
     __regid__ = 'inline'
 
+    def render_title(self, w, form, values):
+        w(u'<span>%(title)s</span> '
+          '#<span class="icounter">%(counter)s</span> ' % values)
+        if values['removejs']:
+            values['removemsg'] = self._cw._('remove-inlined-entity-form')
+            w(u'[<a href="javascript: %(removejs)s;$.noop();">%(removemsg)s</a>]'
+              % values)
+
     def render(self, w, form, values):
         form.add_media()
         try:
@@ -503,16 +511,9 @@
                 values['divid'], self._cw._('click on the box to cancel the deletion')))
         w(u'<div class="iformBody">')
         eschema = form.edited_entity.e_schema
-        if values['removejs']:
-            values['removemsg'] = self._cw._('remove-inlined-entity-form')
-            w(u'<div class="iformTitle"><span>%(title)s</span> '
-              '#<span class="icounter">%(counter)s</span> '
-              '[<a href="javascript: %(removejs)s;$.noop();">%(removemsg)s</a>]</div>'
-              % values)
-        else:
-            w(u'<div class="iformTitle"><span>%(title)s</span> '
-              '#<span class="icounter">%(counter)s</span></div>'
-              % values)
+        w(u'<div class="iformTitle">')
+        self.render_title(w, form, values)
+        w(u'</div>')
         # XXX that stinks
         # cleanup values
         for key in ('title', 'removejs', 'removemsg'):