diff --git a/djangocms_blog/cms_app.py b/djangocms_blog/cms_app.py index cefe215..fd9a38d 100644 --- a/djangocms_blog/cms_app.py +++ b/djangocms_blog/cms_app.py @@ -1,34 +1,10 @@ # -*- coding: utf-8 -*- from cms.app_base import CMSApp 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 .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): name = _('Blog') urls = ['djangocms_blog.urls'] diff --git a/djangocms_blog/menu.py b/djangocms_blog/menu.py new file mode 100644 index 0000000..f1760c4 --- /dev/null +++ b/djangocms_blog/menu.py @@ -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) +