Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
9a3dfa2a
Kaydet (Commit)
9a3dfa2a
authored
Agu 17, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #23261 -- Removed old style list syntax for unordered_list filter
Per deprecation timeline.
üst
27b23217
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
101 deletions
+1
-101
defaultfilters.py
django/template/defaultfilters.py
+0
-39
builtins.txt
docs/ref/templates/builtins.txt
+0
-6
test_unordered_list.py
tests/template_tests/filter_tests/test_unordered_list.py
+1
-56
No files found.
django/template/defaultfilters.py
Dosyayı görüntüle @
9a3dfa2a
...
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
...
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
import
random
as
random_module
import
random
as
random_module
import
re
import
re
import
warnings
from
decimal
import
ROUND_HALF_UP
,
Context
,
Decimal
,
InvalidOperation
from
decimal
import
ROUND_HALF_UP
,
Context
,
Decimal
,
InvalidOperation
from
functools
import
wraps
from
functools
import
wraps
from
pprint
import
pformat
from
pprint
import
pformat
...
@@ -11,7 +10,6 @@ from pprint import pformat
...
@@ -11,7 +10,6 @@ from pprint import pformat
from
django.conf
import
settings
from
django.conf
import
settings
from
django.utils
import
formats
,
six
from
django.utils
import
formats
,
six
from
django.utils.dateformat
import
format
,
time_format
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.encoding
import
force_text
,
iri_to_uri
from
django.utils.html
import
(
from
django.utils.html
import
(
avoid_wrapping
,
conditional_escape
,
escape
,
escapejs
,
linebreaks
,
avoid_wrapping
,
conditional_escape
,
escape
,
escapejs
,
linebreaks
,
...
@@ -650,37 +648,6 @@ def unordered_list(value, autoescape=True):
...
@@ -650,37 +648,6 @@ def unordered_list(value, autoescape=True):
else
:
else
:
escaper
=
lambda
x
:
x
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
):
def
walk_items
(
item_list
):
item_iterator
=
iter
(
item_list
)
item_iterator
=
iter
(
item_list
)
try
:
try
:
...
@@ -717,12 +684,6 @@ def unordered_list(value, autoescape=True):
...
@@ -717,12 +684,6 @@ def unordered_list(value, autoescape=True):
indent
,
escaper
(
force_text
(
item
)),
sublist
))
indent
,
escaper
(
force_text
(
item
)),
sublist
))
return
'
\n
'
.
join
(
output
)
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
))
return
mark_safe
(
list_formatter
(
value
))
...
...
docs/ref/templates/builtins.txt
Dosyayı görüntüle @
9a3dfa2a
...
@@ -2231,12 +2231,6 @@ contains ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``, then
...
@@ -2231,12 +2231,6 @@ contains ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``, then
</ul>
</ul>
</li>
</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
.. templatefilter:: upper
upper
upper
...
...
tests/template_tests/filter_tests/test_unordered_list.py
Dosyayı görüntüle @
9a3dfa2a
from
django.template.defaultfilters
import
unordered_list
from
django.template.defaultfilters
import
unordered_list
from
django.test
import
SimpleTestCase
,
ignore_warnings
from
django.test
import
SimpleTestCase
from
django.utils.deprecation
import
RemovedInDjango110Warning
from
django.utils.encoding
import
python_2_unicode_compatible
from
django.utils.encoding
import
python_2_unicode_compatible
from
django.utils.safestring
import
mark_safe
from
django.utils.safestring
import
mark_safe
...
@@ -14,7 +13,6 @@ class UnorderedListTests(SimpleTestCase):
...
@@ -14,7 +13,6 @@ class UnorderedListTests(SimpleTestCase):
output
=
self
.
engine
.
render_to_string
(
'unordered_list01'
,
{
'a'
:
[
'x>'
,
[
'<y'
]]})
output
=
self
.
engine
.
render_to_string
(
'unordered_list01'
,
{
'a'
:
[
'x>'
,
[
'<y'
]]})
self
.
assertEqual
(
output
,
'
\t
<li>x>
\n\t
<ul>
\n\t\t
<li><y</li>
\n\t
</ul>
\n\t
</li>'
)
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
)
@setup
({
'unordered_list02'
:
'{
%
autoescape off
%
}{{ a|unordered_list }}{
%
endautoescape
%
}'
})
@setup
({
'unordered_list02'
:
'{
%
autoescape off
%
}{{ a|unordered_list }}{
%
endautoescape
%
}'
})
def
test_unordered_list02
(
self
):
def
test_unordered_list02
(
self
):
output
=
self
.
engine
.
render_to_string
(
'unordered_list02'
,
{
'a'
:
[
'x>'
,
[
'<y'
]]})
output
=
self
.
engine
.
render_to_string
(
'unordered_list02'
,
{
'a'
:
[
'x>'
,
[
'<y'
]]})
...
@@ -36,35 +34,6 @@ class UnorderedListTests(SimpleTestCase):
...
@@ -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>'
)
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>
\n\t
<ul>
\n\t\t
<li><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>
\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
):
class
FunctionTests
(
SimpleTestCase
):
def
test_list
(
self
):
def
test_list
(
self
):
...
@@ -171,27 +140,3 @@ class FunctionTests(SimpleTestCase):
...
@@ -171,27 +140,3 @@ class FunctionTests(SimpleTestCase):
unordered_list
(
item_generator
(),
autoescape
=
False
),
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>'
,
'
\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>'
,
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment