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
e6836136
Kaydet (Commit)
e6836136
authored
Nis 27, 2019
tarafından
Tobias Kunze
Kaydeden (comit)
Mariusz Felisiak
May 03, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #20122 -- Made pluralize template filter return '' on invalid input.
üst
e3968df5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
defaultfilters.py
django/template/defaultfilters.py
+3
-5
test_pluralize.py
tests/template_tests/filter_tests/test_pluralize.py
+3
-2
No files found.
django/template/defaultfilters.py
Dosyayı görüntüle @
e6836136
...
...
@@ -879,17 +879,15 @@ def pluralize(value, arg='s'):
singular_suffix
,
plural_suffix
=
bits
[:
2
]
try
:
if
float
(
value
)
!=
1
:
return
plural_suffix
return
singular_suffix
if
float
(
value
)
==
1
else
plural_suffix
except
ValueError
:
# Invalid string that's not a number.
pass
except
TypeError
:
# Value isn't a string or a number; maybe it's a list?
try
:
if
len
(
value
)
!=
1
:
return
plural_suffix
return
singular_suffix
if
len
(
value
)
==
1
else
plural_suffix
except
TypeError
:
# len() of unsized object.
pass
return
singular_suffix
return
''
@register.filter
(
"phone2numeric"
,
is_safe
=
True
)
...
...
tests/template_tests/filter_tests/test_pluralize.py
Dosyayı görüntüle @
e6836136
...
...
@@ -58,8 +58,9 @@ class FunctionTests(SimpleTestCase):
self
.
assertEqual
(
pluralize
(
0
,
'y,ies,error'
),
''
)
def
test_no_len_type
(
self
):
self
.
assertEqual
(
pluralize
(
object
(),
'y,es'
),
'
y
'
)
self
.
assertEqual
(
pluralize
(
object
(),
'y,es'
),
''
)
self
.
assertEqual
(
pluralize
(
object
(),
'es'
),
''
)
def
test_value_error
(
self
):
self
.
assertEqual
(
pluralize
(
''
,
'y,es'
),
'y'
)
self
.
assertEqual
(
pluralize
(
''
,
'y,es'
),
''
)
self
.
assertEqual
(
pluralize
(
''
,
'es'
),
''
)
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