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
2ab244ff
Kaydet (Commit)
2ab244ff
authored
Kas 22, 2015
tarafından
Johannes Ammon
Kaydeden (comit)
Tim Graham
Kas 23, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Made ListFilter.choices() argument name more explicit.
üst
e07def14
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
24 deletions
+22
-24
filters.py
django/contrib/admin/filters.py
+22
-24
No files found.
django/contrib/admin/filters.py
Dosyayı görüntüle @
2ab244ff
...
...
@@ -37,9 +37,11 @@ class ListFilter(object):
"""
raise
NotImplementedError
(
'subclasses of ListFilter must provide a has_output() method'
)
def
choices
(
self
,
c
l
):
def
choices
(
self
,
c
hangelist
):
"""
Returns choices ready to be output in the template.
`changelist` is the ChangeList to be displayed.
"""
raise
NotImplementedError
(
'subclasses of ListFilter must provide a choices() method'
)
...
...
@@ -98,18 +100,16 @@ class SimpleListFilter(ListFilter):
def
expected_parameters
(
self
):
return
[
self
.
parameter_name
]
def
choices
(
self
,
c
l
):
def
choices
(
self
,
c
hangelist
):
yield
{
'selected'
:
self
.
value
()
is
None
,
'query_string'
:
c
l
.
get_query_string
({},
[
self
.
parameter_name
]),
'query_string'
:
c
hangelist
.
get_query_string
({},
[
self
.
parameter_name
]),
'display'
:
_
(
'All'
),
}
for
lookup
,
title
in
self
.
lookup_choices
:
yield
{
'selected'
:
self
.
value
()
==
force_text
(
lookup
),
'query_string'
:
cl
.
get_query_string
({
self
.
parameter_name
:
lookup
,
},
[]),
'query_string'
:
changelist
.
get_query_string
({
self
.
parameter_name
:
lookup
},
[]),
'display'
:
title
,
}
...
...
@@ -197,17 +197,17 @@ class RelatedFieldListFilter(FieldListFilter):
def
field_choices
(
self
,
field
,
request
,
model_admin
):
return
field
.
get_choices
(
include_blank
=
False
)
def
choices
(
self
,
c
l
):
def
choices
(
self
,
c
hangelist
):
yield
{
'selected'
:
self
.
lookup_val
is
None
and
not
self
.
lookup_val_isnull
,
'query_string'
:
c
l
.
get_query_string
({},
'query_string'
:
c
hangelist
.
get_query_string
({},
[
self
.
lookup_kwarg
,
self
.
lookup_kwarg_isnull
]),
'display'
:
_
(
'All'
),
}
for
pk_val
,
val
in
self
.
lookup_choices
:
yield
{
'selected'
:
self
.
lookup_val
==
smart_text
(
pk_val
),
'query_string'
:
c
l
.
get_query_string
({
'query_string'
:
c
hangelist
.
get_query_string
({
self
.
lookup_kwarg
:
pk_val
,
},
[
self
.
lookup_kwarg_isnull
]),
'display'
:
val
,
...
...
@@ -215,7 +215,7 @@ class RelatedFieldListFilter(FieldListFilter):
if
self
.
include_empty_choice
:
yield
{
'selected'
:
bool
(
self
.
lookup_val_isnull
),
'query_string'
:
c
l
.
get_query_string
({
'query_string'
:
c
hangelist
.
get_query_string
({
self
.
lookup_kwarg_isnull
:
'True'
,
},
[
self
.
lookup_kwarg
]),
'display'
:
self
.
empty_value_display
,
...
...
@@ -236,14 +236,14 @@ class BooleanFieldListFilter(FieldListFilter):
def
expected_parameters
(
self
):
return
[
self
.
lookup_kwarg
,
self
.
lookup_kwarg2
]
def
choices
(
self
,
c
l
):
def
choices
(
self
,
c
hangelist
):
for
lookup
,
title
in
(
(
None
,
_
(
'All'
)),
(
'1'
,
_
(
'Yes'
)),
(
'0'
,
_
(
'No'
))):
yield
{
'selected'
:
self
.
lookup_val
==
lookup
and
not
self
.
lookup_val2
,
'query_string'
:
c
l
.
get_query_string
({
'query_string'
:
c
hangelist
.
get_query_string
({
self
.
lookup_kwarg
:
lookup
,
},
[
self
.
lookup_kwarg2
]),
'display'
:
title
,
...
...
@@ -251,7 +251,7 @@ class BooleanFieldListFilter(FieldListFilter):
if
isinstance
(
self
.
field
,
models
.
NullBooleanField
):
yield
{
'selected'
:
self
.
lookup_val2
==
'True'
,
'query_string'
:
c
l
.
get_query_string
({
'query_string'
:
c
hangelist
.
get_query_string
({
self
.
lookup_kwarg2
:
'True'
,
},
[
self
.
lookup_kwarg
]),
'display'
:
_
(
'Unknown'
),
...
...
@@ -271,17 +271,16 @@ class ChoicesFieldListFilter(FieldListFilter):
def
expected_parameters
(
self
):
return
[
self
.
lookup_kwarg
]
def
choices
(
self
,
c
l
):
def
choices
(
self
,
c
hangelist
):
yield
{
'selected'
:
self
.
lookup_val
is
None
,
'query_string'
:
c
l
.
get_query_string
({},
[
self
.
lookup_kwarg
]),
'query_string'
:
c
hangelist
.
get_query_string
({},
[
self
.
lookup_kwarg
]),
'display'
:
_
(
'All'
)
}
for
lookup
,
title
in
self
.
field
.
flatchoices
:
yield
{
'selected'
:
smart_text
(
lookup
)
==
self
.
lookup_val
,
'query_string'
:
cl
.
get_query_string
({
self
.
lookup_kwarg
:
lookup
}),
'query_string'
:
changelist
.
get_query_string
({
self
.
lookup_kwarg
:
lookup
}),
'display'
:
title
,
}
...
...
@@ -338,12 +337,11 @@ class DateFieldListFilter(FieldListFilter):
def
expected_parameters
(
self
):
return
[
self
.
lookup_kwarg_since
,
self
.
lookup_kwarg_until
]
def
choices
(
self
,
c
l
):
def
choices
(
self
,
c
hangelist
):
for
title
,
param_dict
in
self
.
links
:
yield
{
'selected'
:
self
.
date_params
==
param_dict
,
'query_string'
:
cl
.
get_query_string
(
param_dict
,
[
self
.
field_generic
]),
'query_string'
:
changelist
.
get_query_string
(
param_dict
,
[
self
.
field_generic
]),
'display'
:
title
,
}
...
...
@@ -377,11 +375,11 @@ class AllValuesFieldListFilter(FieldListFilter):
def
expected_parameters
(
self
):
return
[
self
.
lookup_kwarg
,
self
.
lookup_kwarg_isnull
]
def
choices
(
self
,
c
l
):
def
choices
(
self
,
c
hangelist
):
yield
{
'selected'
:
(
self
.
lookup_val
is
None
and
self
.
lookup_val_isnull
is
None
),
'query_string'
:
c
l
.
get_query_string
({},
'query_string'
:
c
hangelist
.
get_query_string
({},
[
self
.
lookup_kwarg
,
self
.
lookup_kwarg_isnull
]),
'display'
:
_
(
'All'
),
}
...
...
@@ -393,7 +391,7 @@ class AllValuesFieldListFilter(FieldListFilter):
val
=
smart_text
(
val
)
yield
{
'selected'
:
self
.
lookup_val
==
val
,
'query_string'
:
c
l
.
get_query_string
({
'query_string'
:
c
hangelist
.
get_query_string
({
self
.
lookup_kwarg
:
val
,
},
[
self
.
lookup_kwarg_isnull
]),
'display'
:
val
,
...
...
@@ -401,7 +399,7 @@ class AllValuesFieldListFilter(FieldListFilter):
if
include_none
:
yield
{
'selected'
:
bool
(
self
.
lookup_val_isnull
),
'query_string'
:
c
l
.
get_query_string
({
'query_string'
:
c
hangelist
.
get_query_string
({
self
.
lookup_kwarg_isnull
:
'True'
,
},
[
self
.
lookup_kwarg
]),
'display'
:
self
.
empty_value_display
,
...
...
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