Add a tab with content's custodial history on archive unit of simplified profiles
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 25 Aug 2016 16:13:25 +0200
changeset 1569 3894ee20b976
parent 1568 2121a3e866ef
child 1570 19310a537d42
Add a tab with content's custodial history on archive unit of simplified profiles
i18n/en.po
i18n/fr.po
views/archiveunit.py
--- a/i18n/en.po	Thu Aug 25 16:08:07 2016 +0200
+++ b/i18n/en.po	Thu Aug 25 16:13:25 2016 +0200
@@ -4972,6 +4972,9 @@
 msgid "seda_au_data_objects_refs_tab"
 msgstr ""
 
+msgid "seda_au_history_tab"
+msgstr ""
+
 msgid "seda_au_management_tab"
 msgstr ""
 
--- a/i18n/fr.po	Thu Aug 25 16:08:07 2016 +0200
+++ b/i18n/fr.po	Thu Aug 25 16:13:25 2016 +0200
@@ -4980,6 +4980,9 @@
 msgid "seda_au_data_objects_refs_tab"
 msgstr "objets-données"
 
+msgid "seda_au_history_tab"
+msgstr "historique de conservation"
+
 msgid "seda_au_management_tab"
 msgstr "gestion"
 
--- a/views/archiveunit.py	Thu Aug 25 16:08:07 2016 +0200
+++ b/views/archiveunit.py	Thu Aug 25 16:13:25 2016 +0200
@@ -28,7 +28,7 @@
 from cubes.seda.entities.itree import parent_archive_unit
 from cubes.seda.views import (add_subobject_link, add_subobjects_button, dropdown_button,
                               rtags_from_rtype_role_targets, copy_rtag)
-from cubes.seda.views import viewlib, widgets, archivetransfer
+from cubes.seda.views import viewlib, widgets, archivetransfer, content
 from cubes.seda.views import uicfg as sedauicfg  # noqa - ensure those rules are defined first
 
 
@@ -138,6 +138,7 @@
         'main_tab',
         _('seda_au_management_tab'),
         _('seda_au_content_tab'),
+        _('seda_au_history_tab'),
         _('seda_au_archive_units_tab'),
         _('seda_au_data_objects_refs_tab'),
     ]
@@ -247,6 +248,37 @@
                       subvid=self.subvid, tabid=self.__regid__, delete=len(rset) > 1)
 
 
+class SimplifiedArchiveUnitHistoryTab(tabs.TabsMixin, EntityView):
+    """Display content's custodial history about an archive unit of a simplified profile.
+    """
+
+    __regid__ = 'seda_au_history_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_content_history_tab', w=self.w)
+
+
+class SimplifiedArchiveUnitContentHistoryView(content.ContentHistoryTab):
+
+    __select__ = content.ContentHistoryTab.__select__ & simplified_profile()
+
+    tabid = 'seda_au_history_tab'
+
+    def url_params(self, entity):
+        params = super(SimplifiedArchiveUnitContentHistoryView, self).url_params(entity)
+        params['__redirectpath'] = self.parent(entity).rest_path()
+        return params
+
+    def parent(self, entity):
+        # return parent archive unit for the SEDAContent entity
+        return (entity.seda_content[0]
+                .reverse_seda_seq_alt_archive_unit_archive_unit_ref_id_management[0]
+                .reverse_seda_alt_archive_unit_archive_unit_ref_id[0])
+
+
 class ArchiveUnitArchiveUnitsTab(tabs.TabsMixin, EntityView):
     """Tab for sub-archive units of an archive unit"""