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
e972a7d0
Kaydet (Commit)
e972a7d0
authored
Şub 04, 2016
tarafından
Federico Capoano
Kaydeden (comit)
Tim Graham
Şub 04, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #13875 -- Made admin's submit_row template tag pass whole context.
üst
dcee1dfc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
admin_modify.py
django/contrib/admin/templatetags/admin_modify.py
+4
-8
test_templatetags.py
tests/admin_views/test_templatetags.py
+26
-0
No files found.
django/contrib/admin/templatetags/admin_modify.py
Dosyayı görüntüle @
e972a7d0
import
json
from
django
import
template
from
django.template.context
import
Context
register
=
template
.
Library
()
...
...
@@ -43,14 +44,13 @@ def submit_row(context):
"""
Displays the row of buttons for delete and save.
"""
opts
=
context
[
'opts'
]
change
=
context
[
'change'
]
is_popup
=
context
[
'is_popup'
]
save_as
=
context
[
'save_as'
]
show_save
=
context
.
get
(
'show_save'
,
True
)
show_save_and_continue
=
context
.
get
(
'show_save_and_continue'
,
True
)
ctx
=
{
'opts'
:
opts
,
ctx
=
Context
(
context
)
ctx
.
update
({
'show_delete_link'
:
(
not
is_popup
and
context
[
'has_delete_permission'
]
and
change
and
context
.
get
(
'show_delete'
,
True
)
...
...
@@ -61,12 +61,8 @@ def submit_row(context):
(
not
save_as
or
context
[
'add'
])
),
'show_save_and_continue'
:
not
is_popup
and
context
[
'has_change_permission'
]
and
show_save_and_continue
,
'is_popup'
:
is_popup
,
'show_save'
:
show_save
,
'preserved_filters'
:
context
.
get
(
'preserved_filters'
),
}
if
context
.
get
(
'original'
)
is
not
None
:
ctx
[
'original'
]
=
context
[
'original'
]
})
return
ctx
...
...
tests/admin_views/test_templatetags.py
0 → 100644
Dosyayı görüntüle @
e972a7d0
from
__future__
import
unicode_literals
from
django.contrib.admin.templatetags.admin_modify
import
submit_row
from
django.contrib.auth.admin
import
UserAdmin
from
django.contrib.auth.models
import
User
from
django.test
import
RequestFactory
from
django.urls
import
reverse
from
.admin
import
site
from
.tests
import
AdminViewBasicTestCase
class
AdminTemplateTagsTest
(
AdminViewBasicTestCase
):
def
test_submit_row
(
self
):
"""
submit_row template tag should pass whole context.
"""
factory
=
RequestFactory
()
request
=
factory
.
get
(
reverse
(
'admin:auth_user_change'
,
args
=
[
self
.
superuser
.
pk
]))
request
.
user
=
self
.
superuser
admin
=
UserAdmin
(
User
,
site
)
extra_context
=
{
'extra'
:
True
}
response
=
admin
.
change_view
(
request
,
str
(
self
.
superuser
.
pk
),
extra_context
=
extra_context
)
template_context
=
submit_row
(
response
.
context_data
)
self
.
assertEqual
(
template_context
[
'extra'
],
True
)
self
.
assertEqual
(
template_context
[
'show_save'
],
True
)
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