More cleanups

This commit is contained in:
Iacopo Spalletti 2015-07-21 06:59:23 +02:00
parent f8179aa026
commit a67fdc6c6b
4 changed files with 15 additions and 6 deletions

View file

@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
from django.utils.translation import ugettext_lazy as _, get_language
from django.utils.translation import ugettext_lazy as _
from .menu import BlogCategoryMenu

View file

@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
from cms.menu_bases import CMSAttachMenu
from django.db.models.signals import post_delete, post_save
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import get_language
from menus.base import Modifier, NavigationNode
from menus.menu_pool import menu_pool
from django.db.models.signals import post_save, post_delete
from django.utils.translation import ugettext_lazy as _, get_language
from .models import BlogCategory
@ -34,7 +36,8 @@ class BlogNavModifier(Modifier):
a corresponding category is selected in menu
"""
def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
if post_cut: return nodes
if post_cut:
return nodes
if not hasattr(request, 'toolbar'):
return nodes
models = ('djangocms_blog.post', 'djangocms_blog.blogcategory')
@ -45,7 +48,8 @@ class BlogNavModifier(Modifier):
cat = request.toolbar.obj
else:
cat = request.toolbar.obj.categories.first()
if not cat: return nodes
if not cat:
return nodes
for node in nodes:
if (node.namespace.startswith(BlogCategoryMenu.__name__) and
@ -57,6 +61,7 @@ class BlogNavModifier(Modifier):
menu_pool.register_modifier(BlogNavModifier)
def clear_menu_cache(**kwargs):
menu_pool.clear(all=True)

View file

@ -22,6 +22,7 @@ from djangocms_blog.models import BlogCategory, Post
User = get_user_model()
def _get_cat_pk(lang, name):
return lambda: BlogCategory.objects.translated(lang, name=name).get().pk

View file

@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
import copy
from django.utils.translation import activate
from djangocms_blog.views import CategoryEntriesView, PostDetailView
from menus.menu_pool import menu_pool
from parler.utils.context import switch_language
from djangocms_blog.views import PostDetailView, CategoryEntriesView
from . import BaseTest