web/views/autoform.py
branchstable
changeset 3593 987232bd79cd
parent 3586 52b00c5e441a
child 3594 c5b40ab4ea43
equal deleted inserted replaced
3592:4c08780e54ed 3593:987232bd79cd
   344 
   344 
   345     @cached
   345     @cached
   346     def inlined_form_views(self):
   346     def inlined_form_views(self):
   347         """compute and return list of inlined form views (hosting the inlined form object)
   347         """compute and return list of inlined form views (hosting the inlined form object)
   348         """
   348         """
   349         formviews = []
   349         allformviews = []
   350         entity = self.edited_entity
   350         entity = self.edited_entity
   351         for rschema, ttypes, role in self.inlined_relations():
   351         for rschema, ttypes, role in self.inlined_relations():
   352             # show inline forms only if there's one possible target type
   352             # show inline forms only if there's one possible target type
   353             # for rschema
   353             # for rschema
   354             if len(ttypes) != 1:
   354             if len(ttypes) != 1:
   356                              'inlined form but there is multiple target types, '
   356                              'inlined form but there is multiple target types, '
   357                              'dunno what to do', rschema)
   357                              'dunno what to do', rschema)
   358                 continue
   358                 continue
   359             ttype = ttypes[0].type
   359             ttype = ttypes[0].type
   360             if self.should_inline_relation_form(rschema, ttype, role):
   360             if self.should_inline_relation_form(rschema, ttype, role):
   361                 formviews += self.inline_edition_form_view(rschema, ttype, role)
   361                 formviews = list(self.inline_edition_form_view(rschema, ttype, role))
   362                 if role == 'subject':
   362                 if role == 'subject':
   363                     card = rschema.rproperty(entity.e_schema, ttype, 'cardinality')[0]
   363                     card = rschema.rproperty(entity.e_schema, ttype, 'cardinality')[0]
   364                 else:
   364                 else:
   365                     card = rschema.rproperty(ttype, entity.e_schema, 'cardinality')[1]
   365                     card = rschema.rproperty(ttype, entity.e_schema, 'cardinality')[1]
   366                 # there is no related entity and we need at least one: we need to
   366                 # there is no related entity and we need at least one: we need to
   373                     addnewlink = self.vreg['views'].select(
   373                     addnewlink = self.vreg['views'].select(
   374                         'inline-addnew-link', self.req,
   374                         'inline-addnew-link', self.req,
   375                         etype=ttype, rtype=rschema, role=role,
   375                         etype=ttype, rtype=rschema, role=role,
   376                         peid=self.edited_entity.eid, pform=self, card=card)
   376                         peid=self.edited_entity.eid, pform=self, card=card)
   377                     formviews.append(addnewlink)
   377                     formviews.append(addnewlink)
   378         return formviews
   378                 allformviews += formviews
       
   379         return allformviews
   379 
   380 
   380     def inlined_forms(self):
   381     def inlined_forms(self):
   381         for formview in self.inlined_form_views():
   382         for formview in self.inlined_form_views():
   382             if formview.form: # may be None for the addnew_link artefact form
   383             if formview.form: # may be None for the addnew_link artefact form
   383                 yield formview.form
   384                 yield formview.form