web/views/autoform.py
changeset 4083 3b285889b8e9
parent 4082 c7117119e215
child 4105 de31c3afe975
equal deleted inserted replaced
4082:c7117119e215 4083:3b285889b8e9
   272                              'dunno what to do', rschema)
   272                              'dunno what to do', rschema)
   273                 continue
   273                 continue
   274             ttype = ttypes[0].type
   274             ttype = ttypes[0].type
   275             if self.should_inline_relation_form(rschema, ttype, role):
   275             if self.should_inline_relation_form(rschema, ttype, role):
   276                 formviews = list(self.inline_edition_form_view(rschema, ttype, role))
   276                 formviews = list(self.inline_edition_form_view(rschema, ttype, role))
   277                 if role == 'subject':
   277                 card = rschema.rdef(entity.e_schema, ttype).role_cardinality(role)
   278                     card = rschema.rproperty(entity.e_schema, ttype, 'cardinality')[0]
       
   279                 else:
       
   280                     card = rschema.rproperty(ttype, entity.e_schema, 'cardinality')[1]
       
   281                 # there is no related entity and we need at least one: we need to
   278                 # there is no related entity and we need at least one: we need to
   282                 # display one explicit inline-creation view
   279                 # display one explicit inline-creation view
   283                 if self.should_display_inline_creation_form(rschema, formviews, card):
   280                 if self.should_display_inline_creation_form(rschema, formviews, card):
   284                     formviews += self.inline_creation_form_view(rschema, ttype, role)
   281                     formviews += self.inline_creation_form_view(rschema, ttype, role)
   285                 # we can create more than one related entity, we thus display a link
   282                 # we can create more than one related entity, we thus display a link
   286                 # to add new related entities
   283                 # to add new related entities
   287                 if self.should_display_add_new_relation_link(rschema, formviews, card):
   284                 if self.should_display_add_new_relation_link(rschema, formviews, card):
   288                     addnewlink = self.vreg['views'].select(
   285                     addnewlink = self._cw.vreg['views'].select(
   289                         'inline-addnew-link', self._cw,
   286                         'inline-addnew-link', self._cw,
   290                         etype=ttype, rtype=rschema, role=role,
   287                         etype=ttype, rtype=rschema, role=role,
   291                         peid=self.edited_entity.eid, pform=self, card=card)
   288                         peid=self.edited_entity.eid, pform=self, card=card)
   292                     formviews.append(addnewlink)
   289                     formviews.append(addnewlink)
   293                 allformviews += formviews
   290                 allformviews += formviews