From 3ae4bc0ce7dda64278f88e44636ffff06a0c9a6c Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 29 Apr 2016 09:21:35 +0200 Subject: [PATCH] Use different base name for wizard Thanks to Sylvain Fankhauser for analysis --- djangocms_blog/cms_wizards.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/djangocms_blog/cms_wizards.py b/djangocms_blog/cms_wizards.py index 12b7bd23..6fb5718b 100644 --- a/djangocms_blog/cms_wizards.py +++ b/djangocms_blog/cms_wizards.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals +import warnings + from cms.utils.permissions import get_current_user from django import forms from django.conf import settings @@ -46,8 +48,9 @@ class PostWizard(Wizard): pass for config in BlogConfig.objects.all().order_by('namespace'): - new_wizard = type(str(slugify(config.app_title)), (PostWizard,), {}) - new_form = type(str('{0}Form').format(slugify(config.app_title)), (PostWizardForm,), { + seed = slugify('{0}.{1}'.format(config.app_title, config.namespace)) + new_wizard = type(str(seed), (PostWizard,), {}) + new_form = type(str('{0}Form').format(seed), (PostWizardForm,), { 'default_appconfig': config.pk }) post_wizard = new_wizard( @@ -62,6 +65,10 @@ class PostWizard(Wizard): except AlreadyRegisteredException: # pragma: no cover if settings.DEBUG: raise + else: + warnings.warn('Wizard {0} cannot be registered. Please make sure that ' + 'BlogConfig.namespace {1} and BlogConfig.app_title {2} are' + 'unique together'.format(seed, config.namespace, config.app_title)) except ImportError: # For django CMS version not supporting wizards just ignore this file pass