[simplified ui] Add custom afs rtag for edition of data object in a simplified profile
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 21 Jul 2016 14:51:55 +0200
changeset 1488 88e99aa4886a
parent 1487 16f2f6e7cfc9
child 1489 c6a82e112fdf
[simplified ui] Add custom afs rtag for edition of data object in a simplified profile So that a reference is created transparently at the same time. This is because in simplified mode, we want to see data objects as children of archive units, not as first class object which are later referenced by archive units. Two distincts rules are added for SEDADataObjectReference and SEDACustodialHistoryFile else it won't work because of the ambiguity. Everything is then hidden in the SEDADataObjectReference form. In this mode, we should eventually ignore its cardinality and only consider the one of the data object. Related to #14066262
views/archiveunit.py
--- a/views/archiveunit.py	Thu Jul 21 15:13:05 2016 +0200
+++ b/views/archiveunit.py	Thu Jul 21 14:51:55 2016 +0200
@@ -24,6 +24,7 @@
 
 from cubes.compound import views as compound
 
+from cubes.seda.entities import simplified_profile
 from cubes.seda.entities.itree import parent_archive_unit
 from cubes.seda.views import (add_subobject_link, dropdown_button, rtags_from_rtype_role_targets,
                               copy_rtag)
@@ -320,3 +321,23 @@
                      | (is_instance('SEDAArchiveUnitRefId')
                         & is_archive_unit_ref())))
 
+
+bdo_afs = copy_rtag(afs, __name__,
+                    is_instance('SEDABinaryDataObject', 'SEDAPhysicalDataObject')
+                    & simplified_profile())
+bdo_afs.tag_object_of(
+    ('SEDADataObjectReference', 'seda_data_object_reference_id', '*'),
+    'main', 'inlined')
+bdo_afs.tag_object_of(
+    ('SEDACustodialHistoryFile', 'seda_data_object_reference_id', '*'),
+    'main', 'hidden')
+
+do_ref_afs = copy_rtag(afs, __name__,
+                       # Add yes to overtake afs for DataObjectReference defined in content
+                       is_instance('SEDADataObjectReference') & simplified_profile() & yes())
+do_ref_afs.tag_subject_of(
+    ('SEDADataObjectReference', 'seda_data_object_reference_id', '*'),
+    'inlined', 'hidden')
+do_ref_afs.tag_attribute(
+    ('SEDADataObjectReference', 'user_cardinality'),
+    'inlined', 'hidden')