refactor to ease overriding stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Sep 2009 19:49:21 +0200
branchstable
changeset 3356 9ca73fbd3a58
parent 3355 39ea15e4589a
child 3357 5aed5d6cd5d0
refactor to ease overriding
web/views/autoform.py
web/views/formrenderers.py
--- a/web/views/autoform.py	Mon Sep 21 19:49:02 2009 +0200
+++ b/web/views/autoform.py	Mon Sep 21 19:49:21 2009 +0200
@@ -302,6 +302,13 @@
         """
         return not existant and card in '1+' or self.req.form.has_key('force_%s_display' % rschema)
 
+    def display_inline_creation_form(self, w, rschema, targettype, role,
+                                     i18nctx):
+        entity = self.edited_entity
+        w(self.view('inline-creation', None, etype=targettype,
+                    peid=entity.eid, ptype=entity.e_schema,
+                    rtype=rschema, role=role, i18nctx=i18nctx))
+
     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
         (through ajax call)
--- a/web/views/formrenderers.py	Mon Sep 21 19:49:02 2009 +0200
+++ b/web/views/formrenderers.py	Mon Sep 21 19:49:21 2009 +0200
@@ -508,9 +508,8 @@
         # there is no related entity and we need at least one: we need to
         # display one explicit inline-creation view
         if form.should_display_inline_creation_form(rschema, existant, card):
-            w(form.view('inline-creation', None, etype=targettype,
-                        peid=entity.eid, ptype=entity.e_schema,
-                        rtype=rschema, role=role, i18nctx=i18nctx))
+            form.display_inline_creation_form(w, rschema, targettype,
+                                              role, i18nctx)
             existant = True
         # we can create more than one related entity, we thus display a link
         # to add new related entities
@@ -529,7 +528,6 @@
         w(u'</div>')
 
 
-
 class EntityInlinedFormRenderer(EntityFormRenderer):
     """specific renderer for entity inlined edition form
     (inline-[creation|edition])