Updated dashboards columns
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Sep 2017 14:48:25 +0200
changeset 133 08237dfa6357
parent 132 ae2a738e3d23
child 134 2ee56ec464d5
Updated dashboards columns
src/pyams_content/shared/common/zmi/dashboard.py
--- a/src/pyams_content/shared/common/zmi/dashboard.py	Mon Sep 11 14:47:59 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/dashboard.py	Mon Sep 11 14:48:25 2017 +0200
@@ -29,7 +29,7 @@
 from pyams_skin.interfaces.container import ITableElementName
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_workflow.interfaces import IWorkflowState, IWorkflow, IWorkflowVersions
+from pyams_workflow.interfaces import IWorkflowState, IWorkflow, IWorkflowVersions, IWorkflowPublicationInfo
 from pyams_zmi.interfaces.menu import IContentManagementMenu
 from pyams_zmi.layer import IAdminLayer
 from z3c.table.interfaces import IValues, IColumn
@@ -129,23 +129,12 @@
     """Shared tool dashboard sequence ID column"""
 
     _header = _("Unique ID")
-    weight = 14
+    weight = 15
 
     def getValue(self, obj):
         target = get_parent(obj, ISequentialIdTarget)
         sequence = get_utility(ISequentialIntIds, name=target.sequence_name)
-        return sequence.get_short_oid(ISequentialIdInfo(obj).oid, target.sequence_prefix)
-
-
-@adapter_config(name='version', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn)
-class SharedToolDashboardVersionColumn(I18nColumn, GetAttrColumn):
-    """Shared tool dashboard version column"""
-
-    _header = _("Version")
-    weight = 15
-
-    def getValue(self, obj):
-        return str(IWorkflowState(obj).version_id)
+        return sequence.get_base_oid(ISequentialIdInfo(obj).oid, target.sequence_prefix)
 
 
 @adapter_config(name='status', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn)
@@ -161,6 +150,13 @@
         result = self.request.localizer.translate(workflow.get_state_label(state.state))
         if state.state_urgency:
             result += ' <i class="fa fa-fw fa-exclamation-triangle txt-color-red"></i>'
+        elif state.state in workflow.published_states:
+            pub_info = IWorkflowPublicationInfo(obj, None)
+            if (pub_info is not None) and not pub_info.is_published():
+                translate = self.request.localizer.translate
+                result += ' <i class="fa fa-fw fa-hourglass-half font-xs opacity-75 hint align-base" ' \
+                          'data-ams-hint-offset="5" title="{0}"></i>'.format(
+                    translate(_("Content publication start date is not passed yet")))
         return result
 
 
@@ -176,12 +172,23 @@
         return format_datetime(state.state_date, SH_DATETIME_FORMAT, request=self.request)
 
 
+@adapter_config(name='version', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn)
+class SharedToolDashboardVersionColumn(I18nColumn, GetAttrColumn):
+    """Shared tool dashboard version column"""
+
+    _header = _("Version")
+    weight = 25
+
+    def getValue(self, obj):
+        return str(IWorkflowState(obj).version_id)
+
+
 @adapter_config(name='status_principal', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn)
 class SharedToolDashboardStatusPrincipalColumn(I18nColumn, GetAttrColumn):
     """Shared tool dashboard status principal column"""
 
     _header = _("Status principal")
-    weight = 22
+    weight = 30
 
     def getValue(self, obj):
         state = IWorkflowState(obj)
@@ -194,7 +201,7 @@
     """Shared tool dashboard owner column"""
 
     _header = _("Owner")
-    weight = 30
+    weight = 35
 
     def getValue(self, obj):
         manager = get_utility(ISecurityManager)
@@ -270,8 +277,6 @@
     _single_title = _("MANAGER - {0} content waiting for your action")
     _plural_title = _("MANAGER - {0} contents waiting for your action")
 
-    dt_sort_order = 'asc'
-
 
 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolDashboardManagerWaitingTable), provides=IValues)
 class SharedToolDashboardManagerWaitingValues(ContextRequestViewAdapter):
@@ -939,3 +944,17 @@
         return II18n(self.context).query_attribute('title', request=self.request)
 
     subtitle = _("Last updated contents")
+
+
+#
+# Advanced search access menu
+#
+
+@viewlet_config(name='advanced-search.menu', context=ISharedTool, layer=IAdminLayer,
+                manager=IAllContentsMenu, permission=VIEW_SYSTEM_PERMISSION, weight=90)
+class SharedToolAdvancedSearchMenu(MenuItem):
+    """Shared tool advanced search menu"""
+
+    label = _("Advanced search")
+    icon_class = None
+    url = '#advanced-search.html'