Updates required to handle search folders
authorThierry Florac <tflorac@ulthar.net>
Wed, 07 Nov 2018 17:29:16 +0100
changeset 1060 29b1aaf9e080
parent 1059 34e6d07ea2e9
child 1061 d1db251eeea3
Updates required to handle search folders
src/pyams_content/shared/common/__init__.py
src/pyams_content/shared/common/zmi/dashboard.py
src/pyams_content/shared/common/zmi/rename.py
src/pyams_content/shared/common/zmi/summary.py
src/pyams_content/shared/site/interfaces.py
src/pyams_content/shared/site/zmi/container.py
src/pyams_content/shared/view/interfaces.py
--- a/src/pyams_content/shared/common/__init__.py	Tue Nov 06 14:40:22 2018 +0100
+++ b/src/pyams_content/shared/common/__init__.py	Wed Nov 07 17:29:16 2018 +0100
@@ -142,8 +142,9 @@
 
     @property
     def first_owner(self):
-        versions = IWorkflowVersions(self)
-        return versions.get_version(1).creator
+        versions = IWorkflowVersions(self, None)
+        if versions is not None:
+            return versions.get_version(1).creator
 
     @property
     def creation_label(self):
--- a/src/pyams_content/shared/common/zmi/dashboard.py	Tue Nov 06 14:40:22 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/dashboard.py	Wed Nov 07 17:29:16 2018 +0100
@@ -22,7 +22,6 @@
 from zope.intid.interfaces import IIntIds
 
 from pyams_catalog.query import CatalogResultSet
-from pyams_content import _
 from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION, PUBLISH_CONTENT_PERMISSION
 from pyams_content.profile.interfaces import IAdminProfile
 from pyams_content.shared.common import CONTENT_TYPES
@@ -59,6 +58,8 @@
 from pyams_zmi.layer import IAdminLayer
 from pyams_zmi.view import InnerAdminView
 
+from pyams_content import _
+
 
 #
 # Shared tools common adapters
@@ -233,8 +234,11 @@
         except AttributeError:
             return '--'
         else:
-            manager = get_utility(ISecurityManager)
-            return manager.get_principal(next(iter(owner))).title
+            if owner:
+                manager = get_utility(ISecurityManager)
+                return manager.get_principal(next(iter(owner))).title
+            else:
+                return '--'
 
 
 @adapter_config(name='modified', context=(Interface, IPyAMSLayer, IDashboardTable), provides=IColumn)
--- a/src/pyams_content/shared/common/zmi/rename.py	Tue Nov 06 14:40:22 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/rename.py	Wed Nov 07 17:29:16 2018 +0100
@@ -21,7 +21,7 @@
 
 from pyams_content.interfaces import MANAGE_SITE_PERMISSION
 from pyams_content.shared.common.interfaces import ISharedSite
-from pyams_content.shared.site.interfaces import ISiteFolder
+from pyams_content.shared.site.interfaces import ISiteFolder, IBaseSiteItem
 from pyams_content.skin.zmi.interfaces import ISiteTreeTable
 from pyams_form.form import ajax_config
 from pyams_pagelet.pagelet import pagelet_config
@@ -46,10 +46,10 @@
 @viewlet_config(name='rename-item.menu', context=ISharedSite, layer=IPyAMSLayer,
                 view=Interface, manager=IContextActions,
                 permission=MANAGE_SITE_PERMISSION, weight=900)
-@viewlet_config(name='rename-item.menu', context=ISiteFolder, layer=IPyAMSLayer,
+@viewlet_config(name='rename-item.menu', context=IBaseSiteItem, layer=IPyAMSLayer,
                 view=ISiteTreeTable, manager=ITableItemColumnActionsMenu,
                 permission=MANAGE_SITE_PERMISSION, weight=900)
-@viewlet_config(name='rename-item.menu', context=ISiteFolder, layer=IPyAMSLayer,
+@viewlet_config(name='rename-item.menu', context=IBaseSiteItem, layer=IPyAMSLayer,
                 view=Interface, manager=IContextActions,
                 permission=MANAGE_SITE_PERMISSION, weight=900)
 class SiteContainerRenameMenu(ToolbarMenuItem):
@@ -64,9 +64,9 @@
 @pagelet_config(name='rename-item.html', context=ISharedSite, layer=IPyAMSLayer,
                 permission=MANAGE_SITE_PERMISSION)
 @ajax_config(name='rename-item.json', context=ISharedSite, layer=IPyAMSLayer)
-@pagelet_config(name='rename-item.html', context=ISiteFolder, layer=IPyAMSLayer,
+@pagelet_config(name='rename-item.html', context=IBaseSiteItem, layer=IPyAMSLayer,
                 permission=MANAGE_SITE_PERMISSION)
-@ajax_config(name='rename-item.json', context=ISiteFolder, layer=IPyAMSLayer)
+@ajax_config(name='rename-item.json', context=IBaseSiteItem, layer=IPyAMSLayer)
 class SiteContainerRenameForm(AdminDialogEditForm):
     """Site container rename form"""
 
--- a/src/pyams_content/shared/common/zmi/summary.py	Tue Nov 06 14:40:22 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/summary.py	Wed Nov 07 17:29:16 2018 +0100
@@ -12,20 +12,14 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
-
 from z3c.form import field
 from z3c.form.interfaces import DISPLAY_MODE, IDataConverter
-from zope.interface import implementer, Interface
+from zope.interface import Interface, implementer
 
-from pyams_content import _
-# import interfaces
-from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, IBaseSharedTool
+from pyams_content.shared.common.interfaces import IBaseSharedTool, IWfSharedContent, IWfSharedContentRoles
 from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
-# import packages
 from pyams_content.shared.common.zmi.header import SharedContentHeaderContentProvider
-from pyams_form.interfaces.form import IWidgetForm, IInnerTabForm, IInnerSubForm
+from pyams_form.interfaces.form import IInnerSubForm, IInnerTabForm, IWidgetForm
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_security.utility import get_principal
 from pyams_sequence.interfaces import ISequentialIdInfo
@@ -38,9 +32,11 @@
 from pyams_utils.traversing import get_parent
 from pyams_utils.url import absolute_url
 from pyams_viewlet.viewlet import contentprovider_config
-from pyams_workflow.interfaces import IWorkflowState, IWorkflow, IWorkflowPublicationInfo, IWorkflowStateHistoryItem, \
+from pyams_workflow.interfaces import IWorkflow, IWorkflowPublicationInfo, IWorkflowState, IWorkflowStateHistoryItem, \
     IWorkflowVersions
-from pyams_zmi.form import AdminDisplayForm, InnerAdminDisplayForm, InnerAdminAddForm
+from pyams_zmi.form import AdminDisplayForm, InnerAdminAddForm, InnerAdminDisplayForm
+
+from pyams_content import _
 
 
 @pagelet_config(name='summary.html', context=IWfSharedContent, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -97,13 +93,13 @@
 
     def __new__(cls, context, request, form):
         workflow = IWorkflow(context)
-        state = IWorkflowState(context)
-        if state.state not in workflow.waiting_states:
+        state = IWorkflowState(context, None)
+        if (state is None) or (state.state not in workflow.waiting_states):
             return None
         return InnerAdminDisplayForm.__new__(cls)
 
     fields = field.Fields(IWorkflowState).select('state', 'state_urgency') + \
-        field.Fields(IWorkflowStateHistoryItem).select('comment')
+             field.Fields(IWorkflowStateHistoryItem).select('comment')
 
     def updateWidgets(self, prefix=None):
         super(SharedContentWorkflowWaitingState, self).updateWidgets(prefix)
@@ -135,8 +131,8 @@
     weight = 20
 
     def __new__(cls, context, request, form):
-        info = IWorkflowPublicationInfo(context)
-        if not info.publication_effective_date:
+        info = IWorkflowPublicationInfo(context, None)
+        if (info is None) or not info.publication_effective_date:
             return None
         return InnerAdminDisplayForm.__new__(cls)
 
@@ -153,11 +149,17 @@
     legend = _("Current version")
     weight = 30
 
+    def __new__(cls, context, request, form):
+        state = IWorkflowState(context, None)
+        if state is None:
+            return None
+        return InnerAdminDisplayForm.__new__(cls)
+
     fields = field.Fields(IWorkflowState).select('version_id', 'state') + \
-        field.Fields(IWfSharedContent).select('creation_label') + \
-        field.Fields(IWfSharedContentRoles).select('owner') + \
-        field.Fields(IWfSharedContent).select('last_update_label') + \
-        field.Fields(IWfSharedContent).select('modifiers')
+             field.Fields(IWfSharedContent).select('creation_label') + \
+             field.Fields(IWfSharedContentRoles).select('owner') + \
+             field.Fields(IWfSharedContent).select('last_update_label') + \
+             field.Fields(IWfSharedContent).select('modifiers')
 
     def updateWidgets(self, prefix=None):
         super(SharedContentWorkflowVersionSummary, self).updateWidgets(prefix)
@@ -182,20 +184,31 @@
 
     legend = _("Content history")
 
+    def __new__(cls, context, request, form):
+        info = IWorkflowPublicationInfo(context, None)
+        if info is None:
+            return None
+        return InnerAdminDisplayForm.__new__(cls)
+
     fields = field.Fields(IWorkflowPublicationInfo).select('first_publication_date') + \
-        field.Fields(IWfSharedContent).select('first_owner')
+             field.Fields(IWfSharedContent).select('first_owner')
 
     weight = 40
 
     def updateWidgets(self, prefix=None):
         super(SharedContentWorkflowHistorySummary, self).updateWidgets(prefix)
-        workflow = IWorkflow(self.context)
-        versions = IWorkflowVersions(self.context)
-        value = ''
-        for version in versions.get_versions():
-            state = IWorkflowState(version)
-            pub_date = tztime(state.get_first_state_date(workflow.published_states))
-            if pub_date is not None:
-                value = format_datetime(pub_date)
-                break
-        self.widgets['first_publication_date'].value = value
+        if 'first_publication_date' in self.widgets:
+            versions = IWorkflowVersions(self.context, None)
+            if versions is not None:
+                workflow = IWorkflow(self.context)
+                value = ''
+                for version in versions.get_versions():
+                    state = IWorkflowState(version)
+                    pub_date = tztime(state.get_first_state_date(workflow.published_states))
+                    if pub_date is not None:
+                        value = format_datetime(pub_date)
+                        break
+            else:
+                info = IWorkflowPublicationInfo(self.context, None)
+                value = format_datetime(info.first_publication_date)
+            self.widgets['first_publication_date'].value = value
--- a/src/pyams_content/shared/site/interfaces.py	Tue Nov 06 14:40:22 2018 +0100
+++ b/src/pyams_content/shared/site/interfaces.py	Wed Nov 07 17:29:16 2018 +0100
@@ -56,7 +56,11 @@
     visible = Attribute("Visible element?")
 
 
-class ISiteContainer(IContainer, IContained, IWorkflowPublicationSupport):
+class IBaseSiteItem(IContained, IWorkflowPublicationSupport):
+    """Base site item class"""
+
+
+class ISiteContainer(IContainer, IBaseSiteItem):
     """Base site container interface"""
 
     contains(ISiteElement)
--- a/src/pyams_content/shared/site/zmi/container.py	Tue Nov 06 14:40:22 2018 +0100
+++ b/src/pyams_content/shared/site/zmi/container.py	Wed Nov 07 17:29:16 2018 +0100
@@ -12,8 +12,6 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
 import json
 from datetime import datetime
 
@@ -27,17 +25,14 @@
 from zope.intid.interfaces import IIntIds
 from zope.lifecycleevent import ObjectMovedEvent
 
-from pyams_content import _
-# import interfaces
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION, MANAGE_SITE_PERMISSION
 from pyams_content.shared.common.interfaces import ISharedContent
 from pyams_content.shared.common.interfaces.zmi import IDashboardTable
 from pyams_content.shared.common.zmi.dashboard import SharedToolDashboardOwnerColumn, SharedToolDashboardSequenceColumn, \
     SharedToolDashboardStatusColumn, SharedToolDashboardStatusDateColumn, SharedToolDashboardStatusPrincipalColumn, \
     SharedToolDashboardVersionColumn
-# import packages
 from pyams_content.shared.site import WfSiteTopic
-from pyams_content.shared.site.interfaces import IContentLink, ISiteContainer, ISiteManager
+from pyams_content.shared.site.interfaces import IBaseSiteItem, IContentLink, ISiteContainer, ISiteManager
 from pyams_content.skin import pyams_content
 from pyams_content.skin.zmi.interfaces import ISiteTreeMenu, ISiteTreeTable, IUserAddingsMenuLabel
 from pyams_form.form import ajax_config
@@ -71,8 +66,10 @@
 from pyams_zmi.layer import IAdminLayer
 from pyams_zmi.view import AdminView
 
+from pyams_content import _
 
-@adapter_config(context=(ISiteContainer, IAdminLayer), provides=IBreadcrumbItem)
+
+@adapter_config(context=(IBaseSiteItem, IAdminLayer), provides=IBreadcrumbItem)
 class SiteContainerBreadcrumbAdapter(BreadcrumbAdminLayerItem):
     """Site container breadcrumb adapter"""
 
@@ -96,7 +93,7 @@
 # Site container publication views
 #
 
-@viewlet_config(name='workflow-publication.menu', context=ISiteContainer, layer=IPyAMSLayer, view=ISiteTreeTable,
+@viewlet_config(name='workflow-publication.menu', context=IBaseSiteItem, layer=IPyAMSLayer, view=ISiteTreeTable,
                 manager=ITableItemColumnActionsMenu, permission=MANAGE_SITE_PERMISSION, weight=210)
 class SiteContainerTableItemWorkflowPublicationMenu(ToolbarMenuItem):
     """Site container tree item workflow publication menu"""
@@ -108,7 +105,7 @@
     stop_propagation = True
 
 
-@viewlet_config(name='workflow-publication.menu', context=ISiteContainer, layer=IAdminLayer, manager=IPropertiesMenu,
+@viewlet_config(name='workflow-publication.menu', context=IBaseSiteItem, layer=IAdminLayer, manager=IPropertiesMenu,
                 permission=MANAGE_SITE_PERMISSION, weight=210)
 class SiteContainerWorkflowPublicationMenu(MenuItem):
     """Site container workflow publication menu"""
@@ -119,9 +116,9 @@
     modal_target = True
 
 
-@pagelet_config(name='workflow-publication.html', context=ISiteContainer, layer=IPyAMSLayer,
+@pagelet_config(name='workflow-publication.html', context=IBaseSiteItem, layer=IPyAMSLayer,
                 permission=MANAGE_SITE_PERMISSION)
-@ajax_config(name='workflow-publication.json', context=ISiteContainer, layer=IPyAMSLayer)
+@ajax_config(name='workflow-publication.json', context=IBaseSiteItem, layer=IPyAMSLayer)
 class SiteContainerWorkflowPublicationEditForm(AdminDialogEditForm):
     """Site container workflow publication edit form"""
 
@@ -150,8 +147,8 @@
                     icon_class = 'fa-eye-slash text-danger opaque'
                 value = '<i class="fa fa-fw {icon_class} hint align-base" title="{title}" ' \
                         'data-ams-hint-gravity="e"></i>'.format(
-                            icon_class=icon_class,
-                            title=self.request.localizer.translate(_("Visible element?")))
+                    icon_class=icon_class,
+                    title=self.request.localizer.translate(_("Visible element?")))
                 intids = get_utility(IIntIds)
                 output.setdefault('events', []).append(
                     get_json_table_cell_refresh_event(self.context, self.request,
@@ -166,9 +163,9 @@
 # Site container tree view
 #
 
-@viewlet_config(name='site-tree.menu', layer=IAdminLayer, context=ISiteContainer, manager=ISiteManagementMenu,
+@viewlet_config(name='site-tree.menu', layer=IAdminLayer, context=IBaseSiteItem, manager=ISiteManagementMenu,
                 permission=VIEW_SYSTEM_PERMISSION, weight=10)
-@viewletmanager_config(name='site-tree.menu', layer=IAdminLayer, context=ISiteContainer, provides=ISiteTreeMenu)
+@viewletmanager_config(name='site-tree.menu', layer=IAdminLayer, context=IBaseSiteItem, provides=ISiteTreeMenu)
 @implementer(ISiteTreeMenu)
 class SiteContainerTreeMenu(MenuItem):
     """Site container tree menu"""
@@ -231,7 +228,7 @@
         return attributes
 
 
-@adapter_config(name='sorter', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+@adapter_config(name='sorter', context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
 class SiteContainerTreeSorterColumn(SorterColumn):
     """Site container tree sorter column"""
 
@@ -244,7 +241,7 @@
             return ''
 
 
-@view_config(name='set-site-order.json', context=ISiteContainer, request_type=IPyAMSLayer,
+@view_config(name='set-site-order.json', context=IBaseSiteItem, request_type=IPyAMSLayer,
              permission=MANAGE_SITE_PERMISSION, renderer='json', xhr=True)
 def set_site_order(request):
     """Set site elements order"""
@@ -297,7 +294,7 @@
     return result
 
 
-@adapter_config(name='visible', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+@adapter_config(name='visible', context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
 class SiteContainerTreeVisibleColumn(JsActionColumn):
     """Site container tree visible column"""
 
@@ -332,8 +329,8 @@
                     icon_class = 'fa-eye-slash text-danger opaque'
             return '<i class="fa fa-fw {icon_class} hint align-base" title="{title}" ' \
                    'data-ams-hint-gravity="e"></i>'.format(
-                    icon_class=icon_class,
-                    title=self.request.localizer.translate(self.get_icon_hint(item)))
+                icon_class=icon_class,
+                title=self.request.localizer.translate(self.get_icon_hint(item)))
 
     def get_icon_hint(self, item):
         translate = self.request.localizer.translate
@@ -349,7 +346,7 @@
             return self.get_icon(item)
 
 
-@view_config(name='switch-content-visibility.json', context=ISiteContainer, request_type=IPyAMSLayer,
+@view_config(name='switch-content-visibility.json', context=IBaseSiteItem, request_type=IPyAMSLayer,
              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
 def switch_content_visibility(request):
     """Switch content link visibility"""
@@ -364,7 +361,7 @@
     }
 
 
-@adapter_config(name='name', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+@adapter_config(name='name', context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
 class SiteContainerTreeNameColumn(NameColumn):
     """Site container tree name column"""
 
@@ -377,8 +374,8 @@
                '        <i class="fa fa-fw fa-plus-square-o switch"></i>' \
                '    </span>&nbsp;&nbsp;{title}' \
                '</span>'.format(
-                    hint=self.request.localizer.translate(_("Click to open/close all folders")),
-                    title=super(SiteContainerTreeNameColumn, self).renderHeadCell())
+            hint=self.request.localizer.translate(_("Click to open/close all folders")),
+            title=super(SiteContainerTreeNameColumn, self).renderHeadCell())
 
     def renderCell(self, item, name=None):
         depth = -3
@@ -392,15 +389,15 @@
                '        <i class="fa fa-fw {switch}"></i>' \
                '    </span>&nbsp;&nbsp;<span class="title">{title}</span>' \
                '</div>'.format(
-                padding='<span class="tree-node-padding"></span>' * depth,
-                hint=self.request.localizer.translate(_("Click to show/hide inner folders")),
-                switch='fa-{state}-square-o switch'.format(
-                    state=self.table.rows_state or ('minus' if item in lineage(self.context) else 'plus'))
-                if ISiteContainer.providedBy(item) else '',
-                title=name or super(SiteContainerTreeNameColumn, self).renderCell(item))
+            padding='<span class="tree-node-padding"></span>' * depth,
+            hint=self.request.localizer.translate(_("Click to show/hide inner folders")),
+            switch='fa-{state}-square-o switch'.format(
+                state=self.table.rows_state or ('minus' if item in lineage(self.context) else 'plus'))
+            if ISiteContainer.providedBy(item) else '',
+            title=name or super(SiteContainerTreeNameColumn, self).renderCell(item))
 
 
-@adapter_config(name='content-type', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+@adapter_config(name='content-type', context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
 class SiteContainerContentTypeColumn(I18nColumn, GetAttrColumn):
     """Site container content type column"""
 
@@ -412,7 +409,7 @@
         return self.request.localizer.translate(obj.content_name)
 
 
-@adapter_config(name='sequence', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+@adapter_config(name='sequence', context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
 class SiteContainerTreeSequenceColumn(SharedToolDashboardSequenceColumn):
     """Site container tree OID column"""
 
@@ -426,7 +423,7 @@
         return result
 
 
-@adapter_config(name='status', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+@adapter_config(name='status', context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
 class SiteContainerTreeStatusColumn(SharedToolDashboardStatusColumn):
     """Site container tree status column"""
 
@@ -440,7 +437,7 @@
         return result
 
 
-@adapter_config(name='status_date', context=(ISiteContainer, IPyAMSLayer, IDashboardTable), provides=IColumn)
+@adapter_config(name='status_date', context=(IBaseSiteItem, IPyAMSLayer, IDashboardTable), provides=IColumn)
 class SiteContainerTreeStatusDateColumn(SharedToolDashboardStatusDateColumn):
     """Site container tree status date column"""
 
@@ -454,7 +451,7 @@
         return result
 
 
-@adapter_config(name='version', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+@adapter_config(name='version', context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
 class SiteContainerTreeVersionColumn(SharedToolDashboardVersionColumn):
     """Site container tree version column"""
 
@@ -468,7 +465,7 @@
         return result
 
 
-@adapter_config(name='status_principal', context=(ISiteContainer, IPyAMSLayer, IDashboardTable), provides=IColumn)
+@adapter_config(name='status_principal', context=(IBaseSiteItem, IPyAMSLayer, IDashboardTable), provides=IColumn)
 class SiteContainerTreeStatusPrincipalColumn(SharedToolDashboardStatusPrincipalColumn):
     """Site container tree status principal column"""
 
@@ -482,7 +479,7 @@
         return result
 
 
-@adapter_config(name='owner', context=(ISiteContainer, IPyAMSLayer, IDashboardTable), provides=IColumn)
+@adapter_config(name='owner', context=(IBaseSiteItem, IPyAMSLayer, IDashboardTable), provides=IColumn)
 class SiteContainerTreeOwnerColumn(SharedToolDashboardOwnerColumn):
     """Site container tree owner column"""
 
@@ -496,7 +493,7 @@
         return result
 
 
-@adapter_config(name='trash', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+@adapter_config(name='trash', context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
 class SiteContainerTreeTrashColumn(TrashColumn):
     """Site container tree trash column"""
 
@@ -516,7 +513,7 @@
     return delete_container_element(request, ignore_permission=True)
 
 
-@adapter_config(context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IValues)
+@adapter_config(context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=IValues)
 class SiteContainerTreeValuesAdapter(ContextRequestViewAdapter):
     """Site container tree values adapter"""
 
@@ -540,7 +537,7 @@
         return values
 
 
-@pagelet_config(name='site-tree.html', context=ISiteContainer, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
+@pagelet_config(name='site-tree.html', context=IBaseSiteItem, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
 @implementer(IInnerPage)
 class SiteContainerTreeView(AdminView, ContainerView):
     """Site Container tree view"""
@@ -552,14 +549,14 @@
         self.table = SiteContainerTreeTable(context, request, can_sort=ISiteManager.providedBy(context))
 
 
-@adapter_config(context=(ISiteContainer, IAdminLayer, ISiteTreeTable), provides=IPageHeader)
+@adapter_config(context=(IBaseSiteItem, IAdminLayer, ISiteTreeTable), provides=IPageHeader)
 class SiteContainerViewHeaderAdapter(DefaultPageHeaderAdapter):
     """Site container tree view header adapter"""
 
     icon_class = 'fa fa-fw fa-sitemap'
 
 
-@view_config(name='get-tree.json', context=ISiteContainer, request_type=IPyAMSLayer,
+@view_config(name='get-tree.json', context=IBaseSiteItem, request_type=IPyAMSLayer,
              permission=VIEW_SYSTEM_PERMISSION, renderer='json', xhr=True)
 def get_tree(request):
     """Get whole tree"""
@@ -596,7 +593,7 @@
     return result
 
 
-@adapter_config(context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=ITableElementName)
+@adapter_config(context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=ITableElementName)
 class SiteContainerTableElementName(ContextRequestViewAdapter):
     """Site container tree table element name"""
 
@@ -605,7 +602,7 @@
         return II18n(self.context).query_attribute('title', request=self.request)
 
 
-@adapter_config(context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=ITableElementEditor)
+@adapter_config(context=(IBaseSiteItem, IPyAMSLayer, ISiteTreeTable), provides=ITableElementEditor)
 class SiteContainerTableElementEditor(DefaultElementEditorAdapter):
     """Site container tree table element editor"""
 
--- a/src/pyams_content/shared/view/interfaces.py	Tue Nov 06 14:40:22 2018 +0100
+++ b/src/pyams_content/shared/view/interfaces.py	Wed Nov 07 17:29:16 2018 +0100
@@ -12,20 +12,15 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
+from zope.interface import Attribute, Interface
+from zope.schema import Bool, Choice, Int, Set
+from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
 
-# import interfaces
-from pyams_content.shared.common.interfaces import ISharedContent, IWfSharedContent, ISharedTool, \
-    CONTENT_TYPES_VOCABULARY
+from pyams_content.shared.common.interfaces import CONTENT_TYPES_VOCABULARY, ISharedContent, ISharedTool, \
+    IWfSharedContent
 from pyams_content.shared.common.interfaces.types import ALL_DATA_TYPES_VOCABULARY
 from pyams_sequence.interfaces import IInternalReferencesList
-
-# import packages
 from pyams_thesaurus.schema import ThesaurusTermsListField
-from zope.interface import Interface, Attribute
-from zope.schema import Set, Choice, Bool, Int
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from pyams_content import _
 
@@ -33,7 +28,6 @@
 VIEW_CONTENT_TYPE = 'view'
 VIEW_CONTENT_NAME = _('View')
 
-
 CREATION_DATE_ORDER = 'created_date'
 UPDATE_DATE_ORDER = 'modified_date'
 PUBLICATION_DATE_ORDER = 'publication_date'
@@ -159,15 +153,15 @@
 
 VIEW_REFERENCES_SETTINGS_KEY = 'pyams_content.view.references'
 
-
 ALWAYS_REFERENCE_MODE = 'always'
 IFEMPTY_REFERENCE_MODE = 'if_empty'
 
-REFERENCES_MODES = {ALWAYS_REFERENCE_MODE: _("Always include selected internal references"),
-                    IFEMPTY_REFERENCE_MODE: _("Include selected internal references only if empty")}
+REFERENCES_MODES = {
+    ALWAYS_REFERENCE_MODE: _("Always include selected internal references"),
+    IFEMPTY_REFERENCE_MODE: _("Include selected internal references only if empty")
+}
 
-REFERENCES_MODES_VOCABULARY = SimpleVocabulary([SimpleTerm(v, title=t)
-                                                for v, t in REFERENCES_MODES.items()])
+REFERENCES_MODES_VOCABULARY = SimpleVocabulary([SimpleTerm(v, title=t) for v, t in REFERENCES_MODES.items()])
 
 
 class IViewInternalReferencesSettings(IViewSettings, IInternalReferencesList):