[simplified ui] Custom itree behaviour for simplified profile
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 21 Jul 2016 15:12:31 +0200
changeset 1491 0de8c6c807a7
parent 1490 e59235e603cf
child 1492 00a4b2034080
[simplified ui] Custom itree behaviour for simplified profile Display data objects as children of archive units, not as children of the transfer. Related to #14066262
entities/itree.py
--- a/entities/itree.py	Thu Jul 21 15:10:36 2016 +0200
+++ b/entities/itree.py	Thu Jul 21 15:12:31 2016 +0200
@@ -89,6 +89,13 @@
         for rel, role in [('seda_content', 'object'), ('seda_archive_unit', 'object')]:
             for child in seq.related(rel, role, entities=True):
                 yield child
+        if self.entity.container[0].simplified_profile:
+            for do in self._cw.execute(
+                    'Any DO, DOID ORDERBY DOID WHERE DO id DOID, '
+                    'REF seda_data_object_reference_id DO, '
+                    'REF seda_data_object_reference SEQ, SEQ eid %(x)s',
+                    {'x': seq.eid}).entities():
+                yield do
 
 
 class ITreeBaseContentAdapter(IContainedToITreeBase):
@@ -108,9 +115,14 @@
     """Adapt ArchiveTransfer entities to ITreeBase."""
     __select__ = is_instance('SEDAArchiveTransfer')
 
-    _children_relations = [('seda_binary_data_object', 'object'),
-                           ('seda_physical_data_object', 'object'),
-                           ('seda_archive_unit', 'object')]
+    @property
+    def _children_relations(self):
+        if self.entity.simplified_profile:
+            return [('seda_archive_unit', 'object')]
+        else:
+            return [('seda_binary_data_object', 'object'),
+                    ('seda_physical_data_object', 'object'),
+                    ('seda_archive_unit', 'object')]
 
     def parent(self):
         return None