summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-08-17 10:03:22 -0400
committerTim Graham <timograham@gmail.com>2015-09-23 19:31:09 -0400
commit9a3dfa2a524aedb8580b7311585f9d52f252f4e7 (patch)
tree5eb1f2b5879df2728bd626582d5803d86cd70d58
parent27b2321793c62fb2cbb00fd2830c9387a187a84f (diff)
Refs #23261 -- Removed old style list syntax for unordered_list filter
Per deprecation timeline.
-rw-r--r--django/template/defaultfilters.py39
-rw-r--r--docs/ref/templates/builtins.txt6
-rw-r--r--tests/template_tests/filter_tests/test_unordered_list.py57
3 files changed, 1 insertions, 101 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 5f5003b176..d2c77508fe 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
import random as random_module
import re
-import warnings
from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation
from functools import wraps
from pprint import pformat
@@ -11,7 +10,6 @@ from pprint import pformat
from django.conf import settings
from django.utils import formats, six
from django.utils.dateformat import format, time_format
-from django.utils.deprecation import RemovedInDjango110Warning
from django.utils.encoding import force_text, iri_to_uri
from django.utils.html import (
avoid_wrapping, conditional_escape, escape, escapejs, linebreaks,
@@ -650,37 +648,6 @@ def unordered_list(value, autoescape=True):
else:
escaper = lambda x: x
- def convert_old_style_list(list_):
- """
- Converts old style lists to the new easier to understand format.
-
- The old list format looked like:
- ['Item 1', [['Item 1.1', []], ['Item 1.2', []]]
-
- And it is converted to:
- ['Item 1', ['Item 1.1', 'Item 1.2]]
- """
- if not isinstance(list_, (tuple, list)) or len(list_) != 2:
- return list_, False
- first_item, second_item = list_
- if second_item == []:
- return [first_item], True
- try:
- # see if second item is iterable
- iter(second_item)
- except TypeError:
- return list_, False
- old_style_list = True
- new_second_item = []
- for sublist in second_item:
- item, old_style_list = convert_old_style_list(sublist)
- if not old_style_list:
- break
- new_second_item.extend(item)
- if old_style_list:
- second_item = new_second_item
- return [first_item, second_item], old_style_list
-
def walk_items(item_list):
item_iterator = iter(item_list)
try:
@@ -717,12 +684,6 @@ def unordered_list(value, autoescape=True):
indent, escaper(force_text(item)), sublist))
return '\n'.join(output)
- value, converted = convert_old_style_list(value)
- if converted:
- warnings.warn(
- "The old style syntax in `unordered_list` is deprecated and will "
- "be removed in Django 1.10. Use the the new format instead.",
- RemovedInDjango110Warning)
return mark_safe(list_formatter(value))
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index abc14f0cd8..a21dd75caf 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -2231,12 +2231,6 @@ contains ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``, then
</ul>
</li>
-.. deprecated:: 1.8
-
- An older, more restrictive and verbose input format is also supported:
- ``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``.
- Support for this syntax will be removed in Django 1.10.
-
.. templatefilter:: upper
upper
diff --git a/tests/template_tests/filter_tests/test_unordered_list.py b/tests/template_tests/filter_tests/test_unordered_list.py
index 4fbc22a657..eab9442780 100644
--- a/tests/template_tests/filter_tests/test_unordered_list.py
+++ b/tests/template_tests/filter_tests/test_unordered_list.py
@@ -1,6 +1,5 @@
from django.template.defaultfilters import unordered_list
-from django.test import SimpleTestCase, ignore_warnings
-from django.utils.deprecation import RemovedInDjango110Warning
+from django.test import SimpleTestCase
from django.utils.encoding import python_2_unicode_compatible
from django.utils.safestring import mark_safe
@@ -14,7 +13,6 @@ class UnorderedListTests(SimpleTestCase):
output = self.engine.render_to_string('unordered_list01', {'a': ['x>', ['<y']]})
self.assertEqual(output, '\t<li>x&gt;\n\t<ul>\n\t\t<li>&lt;y</li>\n\t</ul>\n\t</li>')
- @ignore_warnings(category=RemovedInDjango110Warning)
@setup({'unordered_list02': '{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}'})
def test_unordered_list02(self):
output = self.engine.render_to_string('unordered_list02', {'a': ['x>', ['<y']]})
@@ -36,35 +34,6 @@ class UnorderedListTests(SimpleTestCase):
self.assertEqual(output, '\t<li>x>\n\t<ul>\n\t\t<li><y</li>\n\t</ul>\n\t</li>')
-@ignore_warnings(category=RemovedInDjango110Warning)
-class DeprecatedUnorderedListSyntaxTests(SimpleTestCase):
-
- @setup({'unordered_list01': '{{ a|unordered_list }}'})
- def test_unordered_list01(self):
- output = self.engine.render_to_string('unordered_list01', {'a': ['x>', [['<y', []]]]})
- self.assertEqual(output, '\t<li>x&gt;\n\t<ul>\n\t\t<li>&lt;y</li>\n\t</ul>\n\t</li>')
-
- @setup({'unordered_list02': '{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}'})
- def test_unordered_list02(self):
- output = self.engine.render_to_string('unordered_list02', {'a': ['x>', [['<y', []]]]})
- self.assertEqual(output, '\t<li>x>\n\t<ul>\n\t\t<li><y</li>\n\t</ul>\n\t</li>')
-
- @setup({'unordered_list03': '{{ a|unordered_list }}'})
- def test_unordered_list03(self):
- output = self.engine.render_to_string('unordered_list03', {'a': ['x>', [[mark_safe('<y'), []]]]})
- self.assertEqual(output, '\t<li>x&gt;\n\t<ul>\n\t\t<li><y</li>\n\t</ul>\n\t</li>')
-
- @setup({'unordered_list04': '{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}'})
- def test_unordered_list04(self):
- output = self.engine.render_to_string('unordered_list04', {'a': ['x>', [[mark_safe('<y'), []]]]})
- self.assertEqual(output, '\t<li>x>\n\t<ul>\n\t\t<li><y</li>\n\t</ul>\n\t</li>')
-
- @setup({'unordered_list05': '{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}'})
- def test_unordered_list05(self):
- output = self.engine.render_to_string('unordered_list05', {'a': ['x>', [['<y', []]]]})
- self.assertEqual(output, '\t<li>x>\n\t<ul>\n\t\t<li><y</li>\n\t</ul>\n\t</li>')
-
-
class FunctionTests(SimpleTestCase):
def test_list(self):
@@ -171,27 +140,3 @@ class FunctionTests(SimpleTestCase):
unordered_list(item_generator(), autoescape=False),
'\t<li>ulitem-a</li>\n\t<li>ulitem-b</li>\n\t<li>ulitem-<a>c</a></li>',
)
-
- @ignore_warnings(category=RemovedInDjango110Warning)
- def test_legacy(self):
- """
- Old format for unordered lists should still work
- """
- self.assertEqual(unordered_list(['item 1', []]), '\t<li>item 1</li>')
-
- self.assertEqual(
- unordered_list(['item 1', [['item 1.1', []]]]),
- '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t</ul>\n\t</li>',
- )
-
- self.assertEqual(
- unordered_list(['item 1', [['item 1.1', []],
- ['item 1.2', []]]]), '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1'
- '</li>\n\t\t<li>item 1.2</li>\n\t</ul>\n\t</li>',
- )
-
- self.assertEqual(
- unordered_list(['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]),
- '\t<li>States\n\t<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>Lawrence</li>'
- '\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>\n\t\t<li>Illinois</li>\n\t</ul>\n\t</li>',
- )