8000 Fixed #6289 -- Don't fail silently on templates with variable extends · django-cms/django-cms@7de9b97 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7de9b97

Browse files
committed
Fixed #6289 -- Don't fail silently on templates with variable extends
1 parent 569e5dc commit 7de9b97

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
before toolbar.
77
* Fixed a bug where CMS would incorrectly highlight plugin content when plugin
88
contains invisible elements
9+
* Fixed a regression where templates which inherit from a template using an ``{% extends %}``
10+
tag with a default would raise an exception.
911

1012

1113
=== 3.5.0 (2018-01-31) ===
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends "placeholder_tests/test_variable_extends.html" %}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% extends TEMPLATE|default:"placeholder_tests/base.html" %}
2+
{% load cms_tags %}
3+
{% block four %}{% placeholder "four" %}{% endblock %}

cms/tests/test_placeholder.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ def test_placeholder_scanning_extend(self):
6565
placeholders = _get_placeholder_slots('placeholder_tests/test_one.html')
6666
self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'three']))
6767

68+
def test_placeholder_scanning_variable_extend(self):
69+
placeholders = _get_placeholder_slots('placeholder_tests/test_variable_extends.html')
70+
self.assertEqual(placeholders, [u'one', u'two', u'three', u'four'])
71+
72+
def test_placeholder_scanning_inherit_from_variable_extend(self):
73+
placeholders = _get_placeholder_slots('placeholder_tests/test_inherit_from_variable_extends.html')
74+
self.assertEqual(placeholders, [u'one', u'two', u'three', u'four'])
75+
6876
def test_placeholder_scanning_sekizai_extend(self):
6977
placeholders = _get_placeholder_slots('placeholder_tests/test_one_sekizai.html')
7078
self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'three']))

cms/utils/placeholder.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from django.template.loader_tags import BlockNode, ExtendsNode, IncludeNode
1313
from django.utils import six
1414

15-
from sekizai.helpers import get_varname, is_variable_extend_node
15+
from sekizai.helpers import get_varname
1616

1717
from cms.exceptions import DuplicatePlaceholderWarning
1818
from cms.utils.conf import get_cms_setting
@@ -279,10 +279,6 @@ def get_static_placeholders(template, context):
279279

280280

281281
def _get_block_nodes(extend_node):
282-
# we don't support variable extensions
283-
if is_variable_extend_node(extend_node):
284-
return []
285-
286282
parent = extend_node.get_parent(get_context())
287283
parent_nodelist = _get_nodelist(parent)
288284
parent_nodes = parent_nodelist.get_nodes_by_type(BlockNode)
@@ -315,10 +311,6 @@ def _get_placeholder_nodes_from_extend(extend_node, node_class):
315311
Returns a list of placeholders found in the parent template(s) of this
316312
ExtendsNode
317313
"""
318-
# we don't support variable extensions
319-
if is_variable_extend_node(extend_node):
320-
return []
321-
322314
# This is a dictionary mapping all BlockNode instances found
323315
# in the template that contains the {% extends %} tag
324316
block_nodes = _get_block_nodes(extend_node)

0 commit comments

Comments
 (0)
0