From 5a8f9fdf03903db4d3e25de2a0aebed97fd51fb9 Mon Sep 17 00:00:00 2001 From: German Ilyin Date: Thu, 12 May 2016 19:56:18 +0600 Subject: [PATCH 1/2] Handle the case when there is no menu_structure in config --- djangocms_blog/cms_menus.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/djangocms_blog/cms_menus.py b/djangocms_blog/cms_menus.py index e28873e..af6f412 100644 --- a/djangocms_blog/cms_menus.py +++ b/djangocms_blog/cms_menus.py @@ -125,7 +125,11 @@ class BlogNavModifier(Modifier): if app and app.app_config: namespace = resolve(request.path).namespace config = app.get_config(namespace) - if config and config.menu_structure != MENU_TYPE_CATEGORIES: + try: + if config and config.menu_structure != MENU_TYPE_CATEGORIES: + return nodes + except AttributeError: + # in case `menu_structure` is not present in config return nodes if post_cut: return nodes From 429d6bd8f270fc9d13db48e6b659ba3a6b08ba69 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 13 May 2016 08:54:08 +0200 Subject: [PATCH 2/2] Minor addition --- djangocms_blog/cms_menus.py | 7 +++++-- tests/test_utils/admin.py | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/djangocms_blog/cms_menus.py b/djangocms_blog/cms_menus.py index af6f412..b105dfd 100644 --- a/djangocms_blog/cms_menus.py +++ b/djangocms_blog/cms_menus.py @@ -126,9 +126,12 @@ class BlogNavModifier(Modifier): namespace = resolve(request.path).namespace config = app.get_config(namespace) try: - if config and config.menu_structure != MENU_TYPE_CATEGORIES: + if config and ( + not isinstance(config, BlogConfig) or + config.menu_structure != MENU_TYPE_CATEGORIES + ): return nodes - except AttributeError: + except AttributeError: # pragma: no cover # in case `menu_structure` is not present in config return nodes if post_cut: diff --git a/tests/test_utils/admin.py b/tests/test_utils/admin.py index 3efd5fa..a48bd82 100644 --- a/tests/test_utils/admin.py +++ b/tests/test_utils/admin.py @@ -9,7 +9,6 @@ from .models import CustomUser class CustomUserAdmin(UserAdmin): model = CustomUser - fieldsets = ( (None, {'fields': ('username', 'password')}), (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),