move BlogCategoryMenu to a separate menu.py
This commit is contained in:
parent
2288d81659
commit
53a6beed00
2 changed files with 29 additions and 25 deletions
|
@ -1,34 +1,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from cms.app_base import CMSApp
|
from cms.app_base import CMSApp
|
||||||
from cms.apphook_pool import apphook_pool
|
from cms.apphook_pool import apphook_pool
|
||||||
from cms.menu_bases import CMSAttachMenu
|
|
||||||
from menus.base import NavigationNode
|
|
||||||
from menus.menu_pool import menu_pool
|
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _, get_language
|
from django.utils.translation import ugettext_lazy as _, get_language
|
||||||
from .models import BlogCategory
|
from .menu import BlogCategoryMenu
|
||||||
|
|
||||||
|
|
||||||
class BlogCategoryMenu(CMSAttachMenu):
|
|
||||||
name = _('Blog Category menu')
|
|
||||||
|
|
||||||
def get_nodes(self, request):
|
|
||||||
nodes = []
|
|
||||||
qs = BlogCategory.objects.translated(get_language())
|
|
||||||
qs = qs.order_by('parent_id', 'translations__name')
|
|
||||||
for category in qs:
|
|
||||||
kwargs = { 'category': category.slug }
|
|
||||||
node = NavigationNode(
|
|
||||||
category.name,
|
|
||||||
category.get_absolute_url(),
|
|
||||||
category.pk,
|
|
||||||
category.parent_id
|
|
||||||
)
|
|
||||||
nodes.append(node)
|
|
||||||
return nodes
|
|
||||||
|
|
||||||
menu_pool.register_menu(BlogCategoryMenu)
|
|
||||||
|
|
||||||
class BlogApp(CMSApp):
|
class BlogApp(CMSApp):
|
||||||
name = _('Blog')
|
name = _('Blog')
|
||||||
urls = ['djangocms_blog.urls']
|
urls = ['djangocms_blog.urls']
|
||||||
|
|
28
djangocms_blog/menu.py
Normal file
28
djangocms_blog/menu.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from cms.menu_bases import CMSAttachMenu
|
||||||
|
from menus.base import NavigationNode
|
||||||
|
from menus.menu_pool import menu_pool
|
||||||
|
from django.utils.translation import ugettext_lazy as _, get_language
|
||||||
|
from .models import BlogCategory
|
||||||
|
|
||||||
|
|
||||||
|
class BlogCategoryMenu(CMSAttachMenu):
|
||||||
|
name = _('Blog Category menu')
|
||||||
|
|
||||||
|
def get_nodes(self, request):
|
||||||
|
nodes = []
|
||||||
|
qs = BlogCategory.objects.translated(get_language())
|
||||||
|
qs = qs.order_by('parent_id', 'translations__name')
|
||||||
|
for category in qs:
|
||||||
|
kwargs = { 'category': category.slug }
|
||||||
|
node = NavigationNode(
|
||||||
|
category.name,
|
||||||
|
category.get_absolute_url(),
|
||||||
|
category.pk,
|
||||||
|
category.parent_id
|
||||||
|
)
|
||||||
|
nodes.append(node)
|
||||||
|
return nodes
|
||||||
|
|
||||||
|
menu_pool.register_menu(BlogCategoryMenu)
|
||||||
|
|
Loading…
Reference in a new issue