Display archive unit as parent in breadcrumbs for data object in simplified profiles
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 26 Aug 2016 11:17:04 +0200
changeset 1565 9e26a3fac4e9
parent 1564 eea6033bc0cf
child 1566 5c2023bb6e0c
Display archive unit as parent in breadcrumbs for data object in simplified profiles
views/dataobject.py
--- a/views/dataobject.py	Fri Aug 26 11:11:18 2016 +0200
+++ b/views/dataobject.py	Fri Aug 26 11:17:04 2016 +0200
@@ -21,7 +21,7 @@
 
 from cubicweb import tags, view, _
 from cubicweb.predicates import match_form_params, is_instance
-from cubicweb.web.views import uicfg, tabs
+from cubicweb.web.views import uicfg, tabs, ibreadcrumbs
 
 from cubes.relationwidget import views as rwdg
 from cubes.skos.views import widgets as skos
@@ -315,3 +315,13 @@
         else:
             unit = self._cw._('<no unit specified>')
         self.w(u' (%s)' % xml_escape(unit))
+
+
+class IBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter):
+    """Override adapter from compound when BDO is within a simplified profile to display the archive
+    unit as parent.
+    """
+    __select__ = is_instance('SEDABinaryDataObject') & simplified_profile()
+
+    def parent_entity(self):
+        return self.entity.cw_adapt_to('ITreeBase').parent()