# HG changeset patch # User Adrien Di Mascio # Date 1286260390 -7200 # Node ID eb9a5bd778bc6449295404b382267e0a3217122f # Parent e330ead0804b06147f4569720cf5e6299b1a405c [forms] remove dead code and simplify inlineviews creation remove AutomaticEntityForm.should_inline_relation_form which is not used anywhere and comes from a time where uicfg did not exist. remove test for "force__display" presence in req.form to determine whether or not the inline creation form should be displayed. diff -r e330ead0804b -r eb9a5bd778bc web/views/autoform.py --- a/web/views/autoform.py Mon Oct 04 18:59:32 2010 +0200 +++ b/web/views/autoform.py Tue Oct 05 08:33:10 2010 +0200 @@ -826,40 +826,30 @@ 'dunno what to do', rschema) continue ttype = ttypes[0].type - if self.should_inline_relation_form(rschema, ttype, role): - formviews = list(self.inline_edition_form_view(rschema, ttype, role)) - card = rschema.role_rdef(entity.e_schema, ttype, role).role_cardinality(role) - # there is no related entity and we need at least one: we need to - # display one explicit inline-creation view - if self.should_display_inline_creation_form(rschema, formviews, card): - formviews += self.inline_creation_form_view(rschema, ttype, role) - # we can create more than one related entity, we thus display a link - # to add new related entities - if self.should_display_add_new_relation_link(rschema, formviews, card): - addnewlink = self._cw.vreg['views'].select( - 'inline-addnew-link', self._cw, - etype=ttype, rtype=rschema, role=role, card=card, - peid=self.edited_entity.eid, - petype=self.edited_entity.e_schema, pform=self) - formviews.append(addnewlink) - allformviews += formviews + formviews = list(self.inline_edition_form_view(rschema, ttype, role)) + card = rschema.role_rdef(entity.e_schema, ttype, role).role_cardinality(role) + # there is no related entity and we need at least one: we need to + # display one explicit inline-creation view + if self.should_display_inline_creation_form(rschema, formviews, card): + formviews += self.inline_creation_form_view(rschema, ttype, role) + # we can create more than one related entity, we thus display a link + # to add new related entities + if self.should_display_add_new_relation_link(rschema, formviews, card): + addnewlink = self._cw.vreg['views'].select( + 'inline-addnew-link', self._cw, + etype=ttype, rtype=rschema, role=role, card=card, + peid=self.edited_entity.eid, + petype=self.edited_entity.e_schema, pform=self) + formviews.append(addnewlink) + allformviews += formviews return allformviews - def should_inline_relation_form(self, rschema, targettype, role): - """return true if the given relation with entity has role and a - targettype target should be inlined - - At this point we now relation has inlined_attributes tag (eg is returned - by `inlined_relations()`. Overrides this for more finer control. - """ - return True - def should_display_inline_creation_form(self, rschema, existant, card): """return true if a creation form should be inlined by default true if there is no related entity and we need at least one """ - return not existant and card in '1+' or self._cw.form.has_key('force_%s_display' % rschema) + return not existant and card in '1+' def should_display_add_new_relation_link(self, rschema, existant, card): """return true if we should add a link to add a new creation form