From 7952a95daf78de54a3284a791a0e1848d57d0fbd Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Tue, 11 Feb 2020 13:09:15 +0100 Subject: [PATCH 1/3] Moved contentmenu provider into core --- bika/lims/browser/configure.zcml | 1 + bika/lims/browser/contentmenu.py | 35 +++++++- bika/lims/browser/contentmenu.zcml | 16 ++++ .../plone.app.contentmenu.contentmenu.pt | 89 +++++++++++++++++++ 4 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 bika/lims/browser/contentmenu.zcml create mode 100644 bika/lims/browser/templates/plone.app.contentmenu.contentmenu.pt diff --git a/bika/lims/browser/configure.zcml b/bika/lims/browser/configure.zcml index 9f7104f540..44330ff0f5 100644 --- a/bika/lims/browser/configure.zcml +++ b/bika/lims/browser/configure.zcml @@ -19,6 +19,7 @@ + diff --git a/bika/lims/browser/contentmenu.py b/bika/lims/browser/contentmenu.py index 5c14982817..fa25d9defc 100644 --- a/bika/lims/browser/contentmenu.py +++ b/bika/lims/browser/contentmenu.py @@ -19,10 +19,37 @@ # Some rights reserved, see README and LICENSE. from plone.app.contentmenu.menu import WorkflowMenu as BaseClass +from plone.app.contentmenu.view import ContentMenuProvider +from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile +from zope.component import getUtility +from zope.browsermenu.interfaces import IBrowserMenu -class WorkflowMenu(BaseClass): +class SenaiteContentMenuProvider(ContentMenuProvider): + """Provides a proper styled content menu + """ + index = ViewPageTemplateFile( + "templates/plone.app.contentmenu.contentmenu.pt") + + def render(self): + return self.index() + + # From IContentMenuView + + def available(self): + return True + def menu(self): + menu = getUtility(IBrowserMenu, name='plone_contentmenu') + items = menu.getMenuItems(self.context, self.request) + # always filter out the selection of the default view + items = filter( + lambda a: not a["action"].endswith("/select_default_view"), items) + items.reverse() + return items + + +class WorkflowMenu(BaseClass): def getMenuItems(self, context, request): """Overrides the workflow actions menu displayed top right in the object's view. Displays the current state of the object, as well as a @@ -32,6 +59,6 @@ def getMenuItems(self, context, request): """ actions = super(WorkflowMenu, self).getMenuItems(context, request) # Remove status history menu item ('Advanced...') - actions = [action for action in actions - if not action['action'].endswith('/content_status_history')] - return actions + return filter( + lambda a: not a["action"].endswith("/content_status_history"), + actions) diff --git a/bika/lims/browser/contentmenu.zcml b/bika/lims/browser/contentmenu.zcml new file mode 100644 index 0000000000..98be900251 --- /dev/null +++ b/bika/lims/browser/contentmenu.zcml @@ -0,0 +1,16 @@ + + + + + + diff --git a/bika/lims/browser/templates/plone.app.contentmenu.contentmenu.pt b/bika/lims/browser/templates/plone.app.contentmenu.contentmenu.pt new file mode 100644 index 0000000000..98da7fe3d5 --- /dev/null +++ b/bika/lims/browser/templates/plone.app.contentmenu.contentmenu.pt @@ -0,0 +1,89 @@ +
+ + + + +
From c2ea5a6102f4f4008a20268ae1373c2e97191520 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Tue, 11 Feb 2020 13:13:09 +0100 Subject: [PATCH 2/3] Updated changelog --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 74e86cca32..4851a0d7ac 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,7 @@ Changelog **Added** +- #1529 Moved contentmenu provider into core - #1523 Moved Installation Screens into core - #1520 JavaScripts/CSS Integration and Cleanup - #1517 Integrate senaite.core.spotlight From 59dda1561c406f46aaa6c885256e4db695c5c976 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Tue, 11 Feb 2020 13:21:55 +0100 Subject: [PATCH 3/3] formatting only --- bika/lims/browser/contentmenu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bika/lims/browser/contentmenu.py b/bika/lims/browser/contentmenu.py index fa25d9defc..df4b2ad1df 100644 --- a/bika/lims/browser/contentmenu.py +++ b/bika/lims/browser/contentmenu.py @@ -40,7 +40,7 @@ def available(self): return True def menu(self): - menu = getUtility(IBrowserMenu, name='plone_contentmenu') + menu = getUtility(IBrowserMenu, name="plone_contentmenu") items = menu.getMenuItems(self.context, self.request) # always filter out the selection of the default view items = filter(