Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2731 from daegun/fixInheritance

Fix inheritance
  • Loading branch information...
commit 57bdab768d8e7a2d7efe8998180d75988970932a 2 parents 5b5c36d + 406229d
@digi604 digi604 authored
View
3  cms/models/pagemodel.py
@@ -38,6 +38,7 @@ class Page(with_metaclass(PageMetaClass, MPTTModel)):
(1, _('for logged in users only')),
(2, _('for anonymous users only')),
)
+ TEMPLATE_DEFAULT = TEMPLATE_INHERITANCE_MAGIC if get_cms_setting('TEMPLATE_INHERITANCE') else get_cms_setting('TEMPLATES')[0][0]
X_FRAME_OPTIONS_INHERIT = 0
X_FRAME_OPTIONS_DENY = 1
@@ -69,7 +70,7 @@ class Page(with_metaclass(PageMetaClass, MPTTModel)):
navigation_extenders = models.CharField(_("attached menu"), max_length=80, db_index=True, blank=True, null=True)
template = models.CharField(_("template"), max_length=100, choices=template_choices,
help_text=_('The template used to render the content.'),
- default=TEMPLATE_INHERITANCE_MAGIC)
+ default=TEMPLATE_DEFAULT)
site = models.ForeignKey(Site, help_text=_('The site the page is accessible at.'), verbose_name=_("site"),
related_name='djangocms_pages')
View
20 cms/tests/settings.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
+from cms import constants
from cms.test_utils.testcases import CMSTestCase
from cms.test_utils.util.context_managers import SettingsOverride
from cms.utils import get_cms_setting
@@ -27,3 +28,22 @@ def test_invalid_language_code(self):
ImproperlyConfigured,
get_cms_setting, 'LANGUAGES'
)
+
+ def test_create_page_with_inheritance_override(self):
+ with SettingsOverride(CMS_TEMPLATE_INHERITANCE=True):
+ for template in get_cms_setting('TEMPLATES'):
+ if (template[0] == constants.TEMPLATE_INHERITANCE_MAGIC):
+ return
+ self.assertRaises(
+ ImproperlyConfigured,
+ get_cms_setting, 'TEMPLATES'
+ )
+
+ def test_create_page_without_inheritance_override(self):
+ with SettingsOverride(CMS_TEMPLATE_INHERITANCE=False):
+ for template in get_cms_setting('TEMPLATES'):
+ if (template[0] == constants.TEMPLATE_INHERITANCE_MAGIC):
+ self.assertRaises(
+ ImproperlyConfigured,
+ get_cms_setting, 'TEMPLATES'
+ )
View
3  cms/utils/conf.py
@@ -78,7 +78,8 @@ def get_media_url():
def get_templates():
templates = list(getattr(settings, 'CMS_TEMPLATES', []))
- templates.append((constants.TEMPLATE_INHERITANCE_MAGIC, _('Inherit the template of the nearest ancestor')))
+ if get_cms_setting('TEMPLATE_INHERITANCE'):
+ templates.append((constants.TEMPLATE_INHERITANCE_MAGIC, _('Inherit the template of the nearest ancestor')))
return templates

0 comments on commit 57bdab7

Please sign in to comment.
Something went wrong with that request. Please try again.