merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Sep 2009 19:49:47 +0200
branchstable
changeset 3357 5aed5d6cd5d0
parent 3356 9ca73fbd3a58 (diff)
parent 3352 83aabc5e3de3 (current diff)
child 3358 0cddc4d8cad8
merge
--- a/entities/schemaobjs.py	Mon Sep 21 19:16:10 2009 +0200
+++ b/entities/schemaobjs.py	Mon Sep 21 19:49:47 2009 +0200
@@ -63,14 +63,18 @@
         * raise ValidationError if inlining is'nt possible
         * eventually return True
         """
-        rtype = self.name
-        rschema = self.schema.rschema(rtype)
+        rschema = self.schema.rschema(self.name)
         if inlined == rschema.inlined:
             return False
         if inlined:
-            for (stype, otype) in rschema.iter_rdefs():
-                card = rschema.rproperty(stype, otype, 'cardinality')[0]
+            # don't use the persistent schema, we may miss cardinality changes
+            # in the same transaction
+            for rdef in self.reverse_relation_type:
+                card = rdef.cardinality[0]
                 if not card in '?1':
+                    rtype = self.name
+                    stype = rdef.stype
+                    otype = rdef.otype
                     msg = self.req._("can't set inlined=%(inlined)s, "
                                      "%(stype)s %(rtype)s %(otype)s "
                                      "has cardinality=%(card)s")
--- a/web/views/autoform.py	Mon Sep 21 19:16:10 2009 +0200
+++ b/web/views/autoform.py	Mon Sep 21 19:49:47 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/editforms.py	Mon Sep 21 19:16:10 2009 +0200
+++ b/web/views/editforms.py	Mon Sep 21 19:49:47 2009 +0200
@@ -526,4 +526,4 @@
         self.initialize_varmaker()
         entity = cls(self.req)
         entity.eid = self.varmaker.next()
-        self.render_form(entity, peid, rtype, role, i18nctx)
+        self.render_form(entity, peid, rtype, role, i18nctx, **kwargs)
--- a/web/views/formrenderers.py	Mon Sep 21 19:16:10 2009 +0200
+++ b/web/views/formrenderers.py	Mon Sep 21 19:49:47 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])
--- a/web/views/forms.py	Mon Sep 21 19:16:10 2009 +0200
+++ b/web/views/forms.py	Mon Sep 21 19:49:47 2009 +0200
@@ -531,7 +531,8 @@
                 break
         return result
 
-    def srelations_by_category(self, categories=None, permission=None):
+    def srelations_by_category(self, categories=None, permission=None,
+                               strict=False):
         return ()
 
     def should_display_add_new_relation_link(self, rschema, existant, card):