# HG changeset patch # User Sylvain Thénault # Date 1253603803 -7200 # Node ID 0cddc4d8cad8ec387f44a70c79d0a922ed5791c6 # Parent 5aed5d6cd5d0a52f081813cf4ab65a84b659f84f [forms] do similar refactoring for inline edition than for inline creation diff -r 5aed5d6cd5d0 -r 0cddc4d8cad8 web/views/autoform.py --- a/web/views/autoform.py Mon Sep 21 19:49:47 2009 +0200 +++ b/web/views/autoform.py Tue Sep 22 09:16:43 2009 +0200 @@ -293,7 +293,27 @@ """return true if the given relation with entity has role and a targettype target should be inlined """ - return self.rinlined.etype_get(self.edited_entity.id, rschema, role, targettype) + return self.rinlined.etype_get(self.edited_entity.id, rschema, role, + targettype) + + def display_inline_edition_form(self, w, rschema, targettype, role, + i18nctx): + """display inline forms for already related entities. + + Return True if some inlined form are actually displayed + """ + existant = False + entity = self.edited_entity + related = entity.has_eid() and entity.related(rschema, role) + if related: + # display inline-edition view for all existing related entities + for i, relentity in enumerate(related.entities()): + if relentity.has_perm('update'): + w(self.view('inline-edition', related, row=i, col=0, + rtype=rschema, role=role, ptype=entity.e_schema, + peid=entity.eid, i18nctx=i18nctx)) + existant = True + return existant def should_display_inline_creation_form(self, rschema, existant, card): """return true if a creation form should be inlined diff -r 5aed5d6cd5d0 -r 0cddc4d8cad8 web/views/formrenderers.py --- a/web/views/formrenderers.py Mon Sep 21 19:49:47 2009 +0200 +++ b/web/views/formrenderers.py Tue Sep 22 09:16:43 2009 +0200 @@ -491,16 +491,8 @@ __ = self.req.pgettext i18nctx = 'inlined:%s.%s.%s' % (entity.e_schema, rschema, role) w(u'
' % rschema) - existant = False - related = entity.has_eid() and entity.related(rschema, role) - if related: - # display inline-edition view for all existing related entities - for i, relentity in enumerate(related.entities()): - if relentity.has_perm('update'): - w(form.view('inline-edition', related, row=i, col=0, - rtype=rschema, role=role, ptype=entity.e_schema, - peid=entity.eid, i18nctx=i18nctx)) - existant = True + existant = form.display_inline_edition_form(w, rschema, targettype, + role, i18nctx) if role == 'subject': card = rschema.rproperty(entity.e_schema, targettype, 'cardinality')[0] else: