[views] Simplify afs rtags management a bit
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 21 Apr 2017 16:03:45 +0200
changeset 2625 5bfec4248b69
parent 2624 6caf89c3e630
child 2626 9705a695191b
[views] Simplify afs rtags management a bit by avoiding `au_content_afs` copy of `afs`, which may be unwillingly selected while for instance `simplified_afs` is expected. Since this is tricky to handle, simplify things a bit by adding rules formerly in `au_content_afs` as default rules and only create on custom `afs` copy for 'reference' archive unit. Related to extranet #18337031
cubicweb_seda/views/archiveunit.py
--- a/cubicweb_seda/views/archiveunit.py	Tue Apr 18 11:03:03 2017 +0200
+++ b/cubicweb_seda/views/archiveunit.py	Fri Apr 21 16:03:45 2017 +0200
@@ -1060,7 +1060,16 @@
 afs.tag_object_of(('*', 'seda_data_object_reference', CONTENT_ETYPE),
                   'main', 'hidden')
 
+# add rtags for content archive unit in default afs
+afs.tag_object_of(
+    ('*', 'seda_archive_unit_ref_id_from', 'SEDAAltArchiveUnitArchiveUnitRefId'),
+    'inlined', 'hidden')
+afs.tag_subject_of(
+    ('SEDAAltArchiveUnitArchiveUnitRefId',
+     'seda_seq_alt_archive_unit_archive_unit_ref_id_management', '*'),
+    'inlined', 'inlined')
 
+# and create a custom one for reference archive unit
 au_ref_afs = copy_rtag(afs, __name__,
                        is_instance('SEDAAltArchiveUnitArchiveUnitRefId')
                        & is_archive_unit_ref())
@@ -1072,17 +1081,6 @@
      'seda_seq_alt_archive_unit_archive_unit_ref_id_management', '*'),
     'inlined', 'hidden')
 
-au_content_afs = copy_rtag(afs, __name__,
-                           is_instance('SEDAAltArchiveUnitArchiveUnitRefId')
-                           & ~is_archive_unit_ref())
-au_content_afs.tag_object_of(
-    ('*', 'seda_archive_unit_ref_id_from', 'SEDAAltArchiveUnitArchiveUnitRefId'),
-    'inlined', 'hidden')
-au_content_afs.tag_subject_of(
-    ('SEDAAltArchiveUnitArchiveUnitRefId',
-     'seda_seq_alt_archive_unit_archive_unit_ref_id_management', '*'),
-    'inlined', 'inlined')
-
 
 class AltArchiveUnitRefIdSimplifiedAutomaticEntityForm(widgets.SimplifiedAutomaticEntityForm):
     """Force display of AltArchiveUnitArchiveUnitRefId's sub-ArchiveUnitRefId or