web/views/formrenderers.py
branch3.5
changeset 3275 5247789df541
parent 3264 5d1f3f6c042d
child 3293 69c0ba095536
child 3327 44efba78afac
equal deleted inserted replaced
3274:7d53d8491932 3275:5247789df541
    85         return '\n'.join(data)
    85         return '\n'.join(data)
    86 
    86 
    87     def render_label(self, form, field):
    87     def render_label(self, form, field):
    88         if field.label is None:
    88         if field.label is None:
    89             return u''
    89             return u''
    90         label = self.req._(field.label)
    90         if isinstance(field.label, tuple): # i.e. needs contextual translation
       
    91             label = self.req.pgettext(*field.label)
       
    92         else:
       
    93             label = self.req._(field.label)
    91         attrs = {'for': form.context[field]['id']}
    94         attrs = {'for': form.context[field]['id']}
    92         if field.required:
    95         if field.required:
    93             attrs['class'] = 'required'
    96             attrs['class'] = 'required'
    94         return tags.label(label, **attrs)
    97         return tags.label(label, **attrs)
    95 
    98 
   483             if form.should_inline_relation_form(rschema, targettype, role):
   486             if form.should_inline_relation_form(rschema, targettype, role):
   484                 self.inline_relation_form(w, form, rschema, targettype, role)
   487                 self.inline_relation_form(w, form, rschema, targettype, role)
   485 
   488 
   486     def inline_relation_form(self, w, form, rschema, targettype, role):
   489     def inline_relation_form(self, w, form, rschema, targettype, role):
   487         entity = form.edited_entity
   490         entity = form.edited_entity
   488         __ = self.req.__
   491         __ = self.req.pgettext
   489         w(u'<div id="inline%sslot">' % rschema)
   492         w(u'<div id="inline%sslot">' % rschema)
   490         existant = entity.has_eid() and entity.related(rschema)
   493         existant = entity.has_eid() and entity.related(rschema)
   491         if existant:
   494         if existant:
   492             # display inline-edition view for all existing related entities
   495             # display inline-edition view for all existing related entities
   493             w(form.view('inline-edition', existant, rtype=rschema, role=role,
   496             w(form.view('inline-edition', existant, rtype=rschema, role=role,
   511               % divid)
   514               % divid)
   512             js = "addInlineCreationForm('%s', '%s', '%s', '%s')" % (
   515             js = "addInlineCreationForm('%s', '%s', '%s', '%s')" % (
   513                 entity.eid, targettype, rschema, role)
   516                 entity.eid, targettype, rschema, role)
   514             if card in '1?':
   517             if card in '1?':
   515                 js = "toggleVisibility('%s'); %s" % (divid, js)
   518                 js = "toggleVisibility('%s'); %s" % (divid, js)
       
   519             ctx = 'inlined:%s.%s.%s' % (entity.e_schema, rschema, role)
   516             w(u'<a class="addEntity" id="add%s:%slink" href="javascript: %s" >+ %s.</a>'
   520             w(u'<a class="addEntity" id="add%s:%slink" href="javascript: %s" >+ %s.</a>'
   517               % (rschema, entity.eid, js, __('add a %s' % targettype)))
   521               % (rschema, entity.eid, js, __(ctx, 'add a %s' % targettype)))
   518             w(u'</div>')
   522             w(u'</div>')
   519             w(u'<div class="trame_grise">&#160;</div>')
   523             w(u'<div class="trame_grise">&#160;</div>')
   520         w(u'</div>')
   524         w(u'</div>')
   521 
   525 
   522 
   526