Merge pull request #220 from nephila/feature/catch_wizard_registration_errors

Catch wizard registration errors
This commit is contained in:
Iacopo Spalletti 2016-03-10 12:28:55 +01:00
commit 37e6c96d5e
2 changed files with 14 additions and 5 deletions

View file

@ -352,6 +352,10 @@ content types, such as blog posts.
For each configured Apphook, a content type is added to the wizard.
Some issues with multiple registrations raising django CMS ``AlreadyRegisteredException``
hae been reported; to handle these cases gracefully, the exception is swallowed
when Django ``DEBUG == True`` avoiding breaking production websites. In these cases they
wizard may not show up, but the rest will work as intended.
.. _settings:

View file

@ -2,13 +2,14 @@
from __future__ import absolute_import, print_function, unicode_literals
from cms.utils.permissions import get_current_user
from django import forms
from django.conf import settings
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
try:
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool
from django import forms
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
from cms.wizards.wizard_pool import wizard_pool, AlreadyRegisteredException
from parler.forms import TranslatableModelForm
from .cms_appconfig import BlogConfig
@ -56,7 +57,11 @@ try:
model=Post,
description=_('Create a new {0} in {1}').format(config.object_name, config.app_title),
)
wizard_pool.register(post_wizard)
try:
wizard_pool.register(post_wizard)
except AlreadyRegisteredException: # pragma: no cover
if settings.DEBUG:
raise
except ImportError:
# For django CMS version not supporting wizards just ignore this file
pass