Override content tab for archive unit of simplified profiles
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 25 Aug 2016 16:18:39 +0200
changeset 1570 19310a537d42
parent 1569 3894ee20b976
child 1571 21a6626578ee
Override content tab for archive unit of simplified profiles Instead of displaying content subobjects, display directly the properties we're interested in. An archive unit may only have one content entity in the case of simplified profiles.
views/archiveunit.py
--- a/views/archiveunit.py	Thu Aug 25 16:13:25 2016 +0200
+++ b/views/archiveunit.py	Thu Aug 25 16:18:39 2016 +0200
@@ -248,6 +248,39 @@
                       subvid=self.subvid, tabid=self.__regid__, delete=len(rset) > 1)
 
 
+class SimplifiedArchiveUnitContentTab(tabs.TabsMixin, EntityView):
+    """Display content information about an archive unit of a simplified profile: direct link to
+    some content's attributes.
+    """
+
+    __regid__ = 'seda_au_content_tab'
+    __select__ = ArchiveUnitContentTab.__select__ & simplified_profile()
+
+    def entity_call(self, entity):
+        seq = entity.first_level_choice.content_sequence
+        content = seq.related('seda_content', 'object').one()
+        content.view('seda.simplified_au_content', w=self.w)
+
+
+class SimplifiedArchiveUnitContentView(tabs.PrimaryTab):
+    """SEDAContent view for underlying SimplifiedArchiveUnitContentTab."""
+
+    __regid__ = 'seda.simplified_au_content'
+    __select__ = is_instance('SEDAContent')
+
+    rtype_role_targets = [
+        ('seda_description_level', 'subject', None),
+        ('seda_title', 'object', None),
+        ('seda_start_date', 'object', None),
+        ('seda_end_date', 'object', None),
+        ('seda_description', 'object', None),
+        ('seda_originating_agency_from', 'object', None),
+        ('seda_transferring_agency_archive_unit_identifier', 'object', None),
+        ('seda_language_from', 'object', None),
+    ]
+    rsection, display_ctrl = rtags_from_rtype_role_targets('SEDAContent', rtype_role_targets)
+
+
 class SimplifiedArchiveUnitHistoryTab(tabs.TabsMixin, EntityView):
     """Display content's custodial history about an archive unit of a simplified profile.
     """