[web/views] display unique composite entities in deleteconf 3.25
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Thu, 23 Mar 2017 12:09:59 +0100
branch3.25
changeset 12090 245a4f81053b
parent 12089 54b518367617
child 12091 3c9e296f0a6a
[web/views] display unique composite entities in deleteconf When the entity has two relations to the same composite, display it only once.
cubicweb/web/views/editforms.py
--- a/cubicweb/web/views/editforms.py	Thu Mar 23 11:47:59 2017 +0100
+++ b/cubicweb/web/views/editforms.py	Thu Mar 23 12:09:59 2017 +0100
@@ -76,13 +76,16 @@
     show_composite_skip_rtypes = set('wf_info_for',)
 
     def _iter_composite_entities(self, entity, limit=None):
+        eids = set()
         for rdef, role in entity.e_schema.composite_rdef_roles:
             if rdef.rtype in self.show_composite_skip_rtypes:
                 continue
             for centity in entity.related(
                 rdef.rtype, role, limit=limit
             ).entities():
-                yield centity
+                if centity.eid not in eids:
+                    eids.add(centity.eid)
+                    yield centity
 
     def call(self, onsubmit=None):
         """ask for confirmation before real deletion"""