Merge pull request #56 from nephila/feature/toolbar
Dynamically remove page-meta / page-tags toolbars from post detail view
This commit is contained in:
commit
797a71981c
2 changed files with 24 additions and 1 deletions
|
@ -12,7 +12,10 @@ History
|
|||
* Fix multilanguage issues
|
||||
* Fix SEO fields length
|
||||
* Post absolute url is generated from the title in any language if current is
|
||||
not available..
|
||||
not available
|
||||
* If djangocms-page-meta and djangocms-page-tags are installed, the relevant
|
||||
toolbar items are removed from the toolbar in the post detail view to avoid
|
||||
confusings page meta / tags with post ones
|
||||
|
||||
0.2.0 (2014-09-24)
|
||||
++++++++++++++++++
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue