Skip to content
Browse files

Fixed #965 (toolbar shown too foten)

cms_toolbar tag should now fail silently if for some reason there is no toolbar on the request
  • Loading branch information...
1 parent 0e7448d commit a5207e2990954cf5addcaefbd52f473ce492de11 Jonas Obrist committed Aug 28, 2011
Showing with 6 additions and 1 deletion.
  1. +1 −1 cms/cms_toolbar.py
  2. +5 −0 cms/templatetags/cms_tags.py
View
2 cms/cms_toolbar.py
@@ -67,7 +67,7 @@ def init(self):
self.edit_mode_switcher = Switcher(LEFT, 'editmode', 'edit', 'edit-off',
_('Edit mode'))
self.edit_mode = self.is_staff and self.edit_mode_switcher.get_state(self.request)
-
+ self.show_toolbar = self.is_staff or self.edit_mode_switcher.get_state(self.request)
def get_items(self, context, **kwargs):
"""
View
5 cms/templatetags/cms_tags.py
@@ -405,6 +405,11 @@ def render(self, context):
request = context.get('request', None)
if not request:
return ''
+ toolbar = getattr(request, 'toolbar', None)
+ if not toolbar:
+ return ''
+ if not toolbar.show_toolbar:
+ return ''
return super(CMSToolbar, self).render(context)
def get_context(self, context):

0 comments on commit a5207e2

Please sign in to comment.
Something went wrong with that request. Please try again.