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
5b17dcd8
Kaydet (Commit)
5b17dcd8
authored
Kas 21, 2014
tarafından
Tim Heap
Kaydeden (comit)
Claude Paroz
Kas 21, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23883 -- Stopped flatatt modifying its argument
üst
d8f00e19
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
utils.py
django/forms/utils.py
+8
-7
test_util.py
tests/forms_tests/tests/test_util.py
+17
-0
No files found.
django/forms/utils.py
Dosyayı görüntüle @
5b17dcd8
...
@@ -29,16 +29,17 @@ def flatatt(attrs):
...
@@ -29,16 +29,17 @@ def flatatt(attrs):
The result is passed through 'mark_safe'.
The result is passed through 'mark_safe'.
"""
"""
key_value_attrs
=
[]
boolean_attrs
=
[]
boolean_attrs
=
[]
for
attr
,
value
in
list
(
attrs
.
items
()
):
for
attr
,
value
in
attrs
.
items
(
):
if
value
is
True
:
if
isinstance
(
value
,
bool
)
:
boolean_attrs
.
append
((
attr
,))
if
value
:
del
attrs
[
attr
]
boolean_attrs
.
append
((
attr
,))
el
if
value
is
Fal
se
:
else
:
del
attrs
[
attr
]
key_value_attrs
.
append
((
attr
,
value
))
return
(
return
(
format_html_join
(
''
,
' {0}="{1}"'
,
sorted
(
attrs
.
items
()
))
+
format_html_join
(
''
,
' {0}="{1}"'
,
sorted
(
key_value_attrs
))
+
format_html_join
(
''
,
' {0}'
,
sorted
(
boolean_attrs
))
format_html_join
(
''
,
' {0}'
,
sorted
(
boolean_attrs
))
)
)
...
...
tests/forms_tests/tests/test_util.py
Dosyayı görüntüle @
5b17dcd8
...
@@ -27,6 +27,23 @@ class FormsUtilTestCase(TestCase):
...
@@ -27,6 +27,23 @@ class FormsUtilTestCase(TestCase):
self
.
assertEqual
(
flatatt
({
'class'
:
"news"
,
'title'
:
"Read this"
,
'required'
:
False
}),
' class="news" title="Read this"'
)
self
.
assertEqual
(
flatatt
({
'class'
:
"news"
,
'title'
:
"Read this"
,
'required'
:
False
}),
' class="news" title="Read this"'
)
self
.
assertEqual
(
flatatt
({}),
''
)
self
.
assertEqual
(
flatatt
({}),
''
)
def
test_flatatt_no_side_effects
(
self
):
"""
Fixes #23883 -- Check that flatatt does not modify the dict passed in
"""
attrs
=
{
'foo'
:
'bar'
,
'true'
:
True
,
'false'
:
False
}
attrs_copy
=
copy
.
copy
(
attrs
)
self
.
assertEqual
(
attrs
,
attrs_copy
)
first_run
=
flatatt
(
attrs
)
self
.
assertEqual
(
attrs
,
attrs_copy
)
self
.
assertEqual
(
first_run
,
' foo="bar" true'
)
second_run
=
flatatt
(
attrs
)
self
.
assertEqual
(
attrs
,
attrs_copy
)
self
.
assertEqual
(
first_run
,
second_run
)
def
test_validation_error
(
self
):
def
test_validation_error
(
self
):
###################
###################
# ValidationError #
# ValidationError #
...
...
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