Remove djangocms-page-meta and djangocms-page-tags from Page menu in blog detail view to avoid confusion

This commit is contained in:
Iacopo Spalletti 2014-11-15 10:34:20 +01:00
parent d76eb6f2b7
commit 663a4789b1

View file

@ -26,3 +26,23 @@ class BlogToolbar(CMSToolbar):
admin_menu.add_modal_item(_('Edit Post'), reverse(
'admin:djangocms_blog_post_change', args=(current_post.pk,)),
active=True)
def post_template_populate(self):
current_post = getattr(self.request, BLOG_CURRENT_POST_IDENTIFIER, None)
if current_post and self.request.user.has_perm('djangocms_blog.change_post'): # pragma: no cover
# removing page meta menu, if present, to avoid confusion
try: # pragma: no cover
import djangocms_page_meta
menu = self.request.toolbar.get_or_create_menu('page')
pagemeta = menu.get_or_create_menu('pagemeta', 'meta')
menu.remove_item(pagemeta)
except ImportError:
pass
# removing page tags menu, if present, to avoid confusion
try: # pragma: no cover
import djangocms_page_meta
menu = self.request.toolbar.get_or_create_menu('page')
pagetags = menu.get_or_create_menu('pagetags', 'tags')
menu.remove_item(pagetags)
except ImportError:
pass