diff --git a/examples/cone.example/example.ini b/examples/cone.example/example.ini index e8a71e33..9823d342 100644 --- a/examples/cone.example/example.ini +++ b/examples/cone.example/example.ini @@ -46,10 +46,10 @@ cone.root.title = cone.example #cone.root.mainmenu_empty_title = false ugm.backend = file -ugm.users_file = var/ugm/users -ugm.groups_file = var/ugm/groups -ugm.roles_file = var/ugm/roles -ugm.datadir = var/ugm/data +ugm.users_file = examples/cone.example/var/ugm/users +ugm.groups_file = examples/cone.example/var/ugm/groups +ugm.roles_file = examples/cone.example/var/ugm/roles +ugm.datadir = examples/cone.example/var/ugm/data [pipeline:main] pipeline = diff --git a/src/cone/app/browser/actions.py b/src/cone/app/browser/actions.py index 3a89b95d..b605e5c1 100644 --- a/src/cone/app/browser/actions.py +++ b/src/cone/app/browser/actions.py @@ -79,6 +79,14 @@ def __call__(self, model, request): return u'
%s
' % rendered_actions return u'
%s
' % (self.css, rendered_actions) + def __repr__(self): + return ( + f'<{self.__class__.__module__}.{self.__class__.__name__} ' + f'({self.keys()}) at {id(self)}>' + ) + + __str__ = __repr__ + class Action(object): """Abstract Action. diff --git a/src/cone/app/browser/contextmenu.py b/src/cone/app/browser/contextmenu.py index e847a37f..8b2b16dd 100644 --- a/src/cone/app/browser/contextmenu.py +++ b/src/cone/app/browser/contextmenu.py @@ -69,6 +69,8 @@ def display(self): def __call__(self, model, request): self.model = model self.request = request + if not self.display: + return u'' return render_template( self.template, request=request, @@ -162,5 +164,11 @@ class ContextActionsToolbar(ContextMenuToolbar): class ContextMenu(Tile): @property - def toolbars(self): - return context_menu.values() + def rendered_toolbars(self): + rendered_toolbars = [] + for toolbar in context_menu.values(): + rendered_toolbar = toolbar(self.model, self.request) + if not rendered_toolbar: + continue + rendered_toolbars.append(rendered_toolbar) + return rendered_toolbars diff --git a/src/cone/app/browser/templates/contextmenu.pt b/src/cone/app/browser/templates/contextmenu.pt index 1460e0bf..49091ab8 100644 --- a/src/cone/app/browser/templates/contextmenu.pt +++ b/src/cone/app/browser/templates/contextmenu.pt @@ -6,11 +6,13 @@ role="contextmenu" ajax:bind="contextactionschanged" ajax:action="contextmenu:#contextmenu:replace" - class="navbar mt-2 p-0 contextsensitiv navbar-expand rounded shadow-sm card"> + class="navbar mt-2 p-0 contextsensitiv navbar-expand rounded shadow-sm card" + tal:define="rendered_toolbars context.rendered_toolbars" + tal:condition="rendered_toolbars">
diff --git a/src/cone/app/browser/templates/contextmenu_dropdown.pt b/src/cone/app/browser/templates/contextmenu_dropdown.pt index 109a95db..91d34a44 100644 --- a/src/cone/app/browser/templates/contextmenu_dropdown.pt +++ b/src/cone/app/browser/templates/contextmenu_dropdown.pt @@ -1,7 +1,7 @@ -