8000 Fixed #6289 -- Don't fail silently on templates with variable extends by czpython · Pull Request #6291 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

Fixed #6289 -- Don't fail silently on templates with variable extends #6291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.txt
8000
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
before toolbar.
* Fixed a bug where CMS would incorrectly highlight plugin content when plugin
contains invisible elements
* Fixed a regression where templates which inherit from a template using an ``{% extends %}``
tag with a default would raise an exception.


=== 3.5.0 (2018-01-31) ===
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "placeholder_tests/test_variable_extends.html" %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% extends TEMPLATE|default:"placeholder_tests/base.html" %}
{% load cms_tags %}
{% block four %}{% placeholder "four" %}{% endblock %}
8 changes: 8 additions & 0 deletions cms/tests/test_placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ def test_placeholder_scanning_extend(self):
placeholders = _get_placeholder_slots('placeholder_tests/test_one.html')
self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'three']))

def test_placeholder_scanning_variable_extend(self):
placeholders = _get_placeholder_slots('placeholder_tests/test_variable_extends.html')
self.assertEqual(placeholders, [u'one', u'two', u'three', u'four'])

def test_placeholder_scanning_inherit_from_variable_extend(self):
placeholders = _get_placeholder_slots('placeholder_tests/test_inherit_from_variable_extends.html')
self.assertEqual(placeholders, [u'one', u'two', u'three', u'four'])

def test_placeholder_scanning_sekizai_extend(self):
placeholders = _get_placeholder_slots('placeholder_tests/test_one_sekizai.html')
self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'three']))
Expand Down
10 changes: 1 addition & 9 deletions cms/utils/placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.template.loader_tags import BlockNode, ExtendsNode, IncludeNode
from django.utils import six

from sekizai.helpers import get_varname, is_variable_extend_node
from sekizai.helpers import get_varname

from cms.exceptions import DuplicatePlaceholderWarning
from cms.utils.conf import get_cms_setting
Expand Down Expand Up @@ -279,10 +279,6 @@ def get_static_placeholders(template, context):


def _get_block_nodes(extend_node):
# we don't support variable extensions
if is_variable_extend_node(extend_node):
return []

parent = extend_node.get_parent(get_context())
parent_nodelist = _get_nodelist(parent)
parent_nodes = parent_nodelist.get_nodes_by_type(BlockNode)
Expand Down Expand Up @@ -315,10 +311,6 @@ def _get_placeholder_nodes_from_extend(extend_node, node_class):
Returns a list of placeholders found in the parent template(s) of this
ExtendsNode
"""
# we don't support variable extensions
if is_variable_extend_node(extend_node):
return []

# This is a dictionary mapping all BlockNode instances found
# in the template that contains the {% extends %} tag
block_nodes = _get_block_nodes(extend_node)
Expand Down
0