Override archive unit tab for archive unit of simplified profiles
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 25 Aug 2016 16:20:33 +0200
changeset 1571 21a6626578ee
parent 1570 19310a537d42
child 1572 7c37ce56f26d
Override archive unit tab for archive unit of simplified profiles We don't have to handle the case of "reference" archive unit. Refactor a bit the original tab class to ease this overriding, by introducing a 'sub_unit_types' class property.
views/archiveunit.py
--- a/views/archiveunit.py	Thu Aug 25 16:18:39 2016 +0200
+++ b/views/archiveunit.py	Thu Aug 25 16:20:33 2016 +0200
@@ -324,16 +324,18 @@
     _('creating SEDAArchiveUnit (SEDAArchiveUnit seda_archive_unit '
       'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement %(linkto)s)')
 
+    sub_unit_types = [('unit_content', _('archive unit (content)')),
+                      ('unit_ref', _('archive unit (reference)'))]
+
     def entity_call(self, entity):
         seq = entity.first_level_choice.content_sequence
         urlparams = {'__redirectparams': 'tab=' + self.__regid__,
                      '__redirectpath': entity.rest_path()}
         links = []
-        for unit_type, label in (('unit_content', self._cw._('archive unit (content)')),
-                                 ('unit_ref', self._cw._('archive unit (reference)'))):
+        for unit_type, label in self.sub_unit_types:
             urlparams['unit_type'] = unit_type
             link = add_subobject_link(seq, self.rtype, self.role, urlparams,
-                                      msg=label, klass='')
+                                      msg=self._cw._(label), klass='')
             if link:
                 links.append(link)
         if links:
@@ -347,6 +349,13 @@
                           tabid=self.__regid__)
 
 
+class SimplifiedArchiveUnitArchiveUnitsTab(ArchiveUnitArchiveUnitsTab):
+
+    __select__ = ArchiveUnitArchiveUnitsTab.__select__ & simplified_profile()
+
+    sub_unit_types = [('unit_content', _('seda_archive_unit_object'))]
+
+
 class ArchiveUnitDataObjectReferencesTab(ArchiveUnitSubObjectsTab):
     """Tab for data object references of an archive unit"""