Use different base name for wizard

Thanks to Sylvain Fankhauser for analysis
This commit is contained in:
Iacopo Spalletti 2016-04-29 09:21:35 +02:00
parent 88b8e0c738
commit 3ae4bc0ce7

View file

@ -1,6 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals from __future__ import absolute_import, print_function, unicode_literals
import warnings
from cms.utils.permissions import get_current_user from cms.utils.permissions import get_current_user
from django import forms from django import forms
from django.conf import settings from django.conf import settings
@ -46,8 +48,9 @@ try:
pass pass
for config in BlogConfig.objects.all().order_by('namespace'): for config in BlogConfig.objects.all().order_by('namespace'):
new_wizard = type(str(slugify(config.app_title)), (PostWizard,), {}) seed = slugify('{0}.{1}'.format(config.app_title, config.namespace))
new_form = type(str('{0}Form').format(slugify(config.app_title)), (PostWizardForm,), { new_wizard = type(str(seed), (PostWizard,), {})
new_form = type(str('{0}Form').format(seed), (PostWizardForm,), {
'default_appconfig': config.pk 'default_appconfig': config.pk
}) })
post_wizard = new_wizard( post_wizard = new_wizard(
@ -62,6 +65,10 @@ try:
except AlreadyRegisteredException: # pragma: no cover except AlreadyRegisteredException: # pragma: no cover
if settings.DEBUG: if settings.DEBUG:
raise 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: except ImportError:
# For django CMS version not supporting wizards just ignore this file # For django CMS version not supporting wizards just ignore this file
pass pass