web/views/autoform.py
changeset 8900 010a59e12d89
parent 8748 f5027f8d2478
child 9179 570208f74a84
equal deleted inserted replaced
8899:c7a95ebcc093 8900:010a59e12d89
   270         self.form.render(w=self.w, divid=divid, title=title, removejs=removejs,
   270         self.form.render(w=self.w, divid=divid, title=title, removejs=removejs,
   271                          i18nctx=i18nctx, counter=self._cw.data[countkey] ,
   271                          i18nctx=i18nctx, counter=self._cw.data[countkey] ,
   272                          **kwargs)
   272                          **kwargs)
   273 
   273 
   274     def form_title(self, entity, i18nctx):
   274     def form_title(self, entity, i18nctx):
   275         return self._cw.pgettext(i18nctx, entity.__regid__)
   275         return self._cw.pgettext(i18nctx, entity.cw_etype)
   276 
   276 
   277     def add_hiddens(self, form, entity):
   277     def add_hiddens(self, form, entity):
   278         """to ease overriding (see cubes.vcsfile.views.forms for instance)"""
   278         """to ease overriding (see cubes.vcsfile.views.forms for instance)"""
   279         iid = 'rel-%s-%s-%s' % (self.peid, self.rtype, entity.eid)
   279         iid = 'rel-%s-%s-%s' % (self.peid, self.rtype, entity.eid)
   280         #  * str(self.rtype) in case it's a schema object
   280         #  * str(self.rtype) in case it's a schema object
   496         eid = form.edited_entity.eid
   496         eid = form.edited_entity.eid
   497         w(u'<table id="relatedEntities">')
   497         w(u'<table id="relatedEntities">')
   498         for rschema, role, related in field.relations_table(form):
   498         for rschema, role, related in field.relations_table(form):
   499             # already linked entities
   499             # already linked entities
   500             if related:
   500             if related:
   501                 label = rschema.display_name(req, role, context=form.edited_entity.__regid__)
   501                 label = rschema.display_name(req, role, context=form.edited_entity.cw_etype)
   502                 w(u'<tr><th class="labelCol">%s</th>' % label)
   502                 w(u'<tr><th class="labelCol">%s</th>' % label)
   503                 w(u'<td>')
   503                 w(u'<td>')
   504                 w(u'<ul>')
   504                 w(u'<ul>')
   505                 for viewparams in related:
   505                 for viewparams in related:
   506                     w(u'<li class="invisible">%s<div id="span%s" class="%s">%s</div></li>'
   506                     w(u'<li class="invisible">%s<div id="span%s" class="%s">%s</div></li>'
   606         for pendingid in pending_inserts:
   606         for pendingid in pending_inserts:
   607             eidfrom, rtype, eidto = pendingid.split(':')
   607             eidfrom, rtype, eidto = pendingid.split(':')
   608             pendingid = 'id' + pendingid
   608             pendingid = 'id' + pendingid
   609             if int(eidfrom) == entity.eid: # subject
   609             if int(eidfrom) == entity.eid: # subject
   610                 label = display_name(form._cw, rtype, 'subject',
   610                 label = display_name(form._cw, rtype, 'subject',
   611                                      entity.__regid__)
   611                                      entity.cw_etype)
   612                 reid = eidto
   612                 reid = eidto
   613             else:
   613             else:
   614                 label = display_name(form._cw, rtype, 'object',
   614                 label = display_name(form._cw, rtype, 'object',
   615                                      entity.__regid__)
   615                                      entity.cw_etype)
   616                 reid = eidfrom
   616                 reid = eidfrom
   617             jscall = "javascript: cancelPendingInsert('%s', 'tr', null, %s);" \
   617             jscall = "javascript: cancelPendingInsert('%s', 'tr', null, %s);" \
   618                      % (pendingid, entity.eid)
   618                      % (pendingid, entity.eid)
   619             rset = form._cw.eid_rset(reid)
   619             rset = form._cw.eid_rset(reid)
   620             eview = form._cw.view('text', rset, row=0)
   620             eview = form._cw.view('text', rset, row=0)
   850         """
   850         """
   851         result = []
   851         result = []
   852         for rschema, _, role in self._relations_by_section('relations',
   852         for rschema, _, role in self._relations_by_section('relations',
   853                                                            strict=True):
   853                                                            strict=True):
   854             result.append( (rschema.display_name(self.edited_entity._cw, role,
   854             result.append( (rschema.display_name(self.edited_entity._cw, role,
   855                                                  self.edited_entity.__regid__),
   855                                                  self.edited_entity.cw_etype),
   856                             rschema, role) )
   856                             rschema, role) )
   857         return sorted(result)
   857         return sorted(result)
   858 
   858 
   859     def inlined_relations(self):
   859     def inlined_relations(self):
   860         """return a list of (relation schema, target schemas, role) matching
   860         """return a list of (relation schema, target schemas, role) matching