web/views/formrenderers.py
branchstable
changeset 2996 866a2c135c33
parent 2656 a93ae0f6c0ad
child 3023 7864fee8b4ec
child 3211 7918d4a5cdbf
child 3244 1fc804b2c5ba
equal deleted inserted replaced
2995:4ef565c1d183 2996:866a2c135c33
   102             help.append('<div class="helper">%s</div>' % self.req._(descr))
   102             help.append('<div class="helper">%s</div>' % self.req._(descr))
   103         example = field.example_format(self.req)
   103         example = field.example_format(self.req)
   104         if example:
   104         if example:
   105             help.append('<div class="helper">(%s: %s)</div>'
   105             help.append('<div class="helper">(%s: %s)</div>'
   106                         % (self.req._('sample format'), example))
   106                         % (self.req._('sample format'), example))
   107         return u'&nbsp;'.join(help)
   107         return u'&#160;'.join(help)
   108 
   108 
   109     # specific methods (mostly to ease overriding) #############################
   109     # specific methods (mostly to ease overriding) #############################
   110 
   110 
   111     def error_message(self, form):
   111     def error_message(self, form):
   112         """return formatted error message
   112         """return formatted error message
   123                             if not field in displayed)
   123                             if not field in displayed)
   124             if errors:
   124             if errors:
   125                 if len(errors) > 1:
   125                 if len(errors) > 1:
   126                     templstr = '<li>%s</li>\n'
   126                     templstr = '<li>%s</li>\n'
   127                 else:
   127                 else:
   128                     templstr = '&nbsp;%s\n'
   128                     templstr = '&#160;%s\n'
   129                 for field, err in errors:
   129                 for field, err in errors:
   130                     if field is None:
   130                     if field is None:
   131                         errormsg += templstr % err
   131                         errormsg += templstr % err
   132                     else:
   132                     else:
   133                         errormsg += templstr % '%s: %s' % (req._(field), err)
   133                         errormsg += templstr % '%s: %s' % (req._(field), err)
   277             if self.display_label:
   277             if self.display_label:
   278                 w(u'<th class="labelCol">%s</th>' % self.render_label(form, field))
   278                 w(u'<th class="labelCol">%s</th>' % self.render_label(form, field))
   279             if self.display_help:
   279             if self.display_help:
   280                 w(self.render_help(form, field))
   280                 w(self.render_help(form, field))
   281         # empty slot for buttons
   281         # empty slot for buttons
   282         w(u'<th class="labelCol">&nbsp;</th>')
   282         w(u'<th class="labelCol">&#160;</th>')
   283         w(u'</tr>')
   283         w(u'</tr>')
   284         w(u'<tr>')
   284         w(u'<tr>')
   285         for field in fields:
   285         for field in fields:
   286             error = form.form_field_error(field)
   286             error = form.form_field_error(field)
   287             if error:
   287             if error:
   434                 w(u'</ul>')
   434                 w(u'</ul>')
   435                 w(u'</td>')
   435                 w(u'</td>')
   436                 w(u'</tr>')
   436                 w(u'</tr>')
   437         pendings = list(form.restore_pending_inserts())
   437         pendings = list(form.restore_pending_inserts())
   438         if not pendings:
   438         if not pendings:
   439             w(u'<tr><th>&nbsp;</th><td>&nbsp;</td></tr>')
   439             w(u'<tr><th>&#160;</th><td>&#160;</td></tr>')
   440         else:
   440         else:
   441             for row in pendings:
   441             for row in pendings:
   442                 # soon to be linked to entities
   442                 # soon to be linked to entities
   443                 w(u'<tr id="tr%s">' % row[1])
   443                 w(u'<tr id="tr%s">' % row[1])
   444                 w(u'<th>%s</th>' % row[3])
   444                 w(u'<th>%s</th>' % row[3])
   512             if card in '1?':
   512             if card in '1?':
   513                 js = "toggleVisibility('%s'); %s" % (divid, js)
   513                 js = "toggleVisibility('%s'); %s" % (divid, js)
   514             w(u'<a class="addEntity" id="add%s:%slink" href="javascript: %s" >+ %s.</a>'
   514             w(u'<a class="addEntity" id="add%s:%slink" href="javascript: %s" >+ %s.</a>'
   515               % (rschema, entity.eid, js, __('add a %s' % targettype)))
   515               % (rschema, entity.eid, js, __('add a %s' % targettype)))
   516             w(u'</div>')
   516             w(u'</div>')
   517             w(u'<div class="trame_grise">&nbsp;</div>')
   517             w(u'<div class="trame_grise">&#160;</div>')
   518         w(u'</div>')
   518         w(u'</div>')
   519 
   519 
   520 
   520 
   521 class EntityInlinedFormRenderer(EntityFormRenderer):
   521 class EntityInlinedFormRenderer(EntityFormRenderer):
   522     """specific renderer for entity inlined edition form
   522     """specific renderer for entity inlined edition form