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
75d2da79
Kaydet (Commit)
75d2da79
authored
May 16, 2014
tarafından
Stas Rudakou
Kaydeden (comit)
Russell Keith-Magee
May 16, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Fixed #22266 - quote PK before redirecting away from add_view (django.contrib.admin)
Backport of
ebd70d4d
from master.
üst
bd45139d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
options.py
django/contrib/admin/options.py
+2
-2
tests.py
tests/admin_views/tests.py
+24
-0
No files found.
django/contrib/admin/options.py
Dosyayı görüntüle @
75d2da79
...
...
@@ -11,7 +11,7 @@ from django.contrib.admin import widgets, helpers
from
django.contrib.admin
import
validation
from
django.contrib.admin.checks
import
(
BaseModelAdminChecks
,
ModelAdminChecks
,
InlineModelAdminChecks
)
from
django.contrib.admin.utils
import
(
unquote
,
flatten_fieldsets
,
from
django.contrib.admin.utils
import
(
quote
,
unquote
,
flatten_fieldsets
,
get_deleted_objects
,
model_format_dict
,
NestedObjects
,
lookup_needs_distinct
)
from
django.contrib.admin.templatetags.admin_static
import
static
...
...
@@ -1100,7 +1100,7 @@ class ModelAdmin(BaseModelAdmin):
if
post_url_continue
is
None
:
post_url_continue
=
reverse
(
'admin:
%
s_
%
s_change'
%
(
opts
.
app_label
,
opts
.
model_name
),
args
=
(
pk_value
,),
args
=
(
quote
(
pk_value
)
,),
current_app
=
self
.
admin_site
.
name
)
post_url_continue
=
add_preserved_filters
({
'preserved_filters'
:
preserved_filters
,
'opts'
:
opts
},
post_url_continue
)
return
HttpResponseRedirect
(
post_url_continue
)
...
...
tests/admin_views/tests.py
Dosyayı görüntüle @
75d2da79
...
...
@@ -1779,6 +1779,30 @@ class AdminViewStringPrimaryKeyTest(TestCase):
args
=
(
quote
(
self
.
pk
),))
self
.
assertContains
(
response
,
'<a href="
%
s" class="historylink"'
%
expected_link
)
def
test_redirect_on_add_view_continue_button
(
self
):
"""As soon as an object is added using "Save and continue editing"
button, the user should be redirected to the object's change_view.
In case primary key is a string containing some special characters
like slash or underscore, these characters must be escaped (see #22266)
"""
response
=
self
.
client
.
post
(
'/test_admin/admin/admin_views/modelwithstringprimarykey/add/'
,
{
'string_pk'
:
'123/history'
,
"_continue"
:
"1"
,
# Save and continue editing
}
)
self
.
assertEqual
(
response
.
status_code
,
302
)
# temporary redirect
self
.
assertEqual
(
response
[
'location'
],
(
'http://testserver/test_admin/admin/admin_views/'
'modelwithstringprimarykey/123_2Fhistory/'
# PK is quoted
)
)
@override_settings
(
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,))
class
SecureViewTests
(
TestCase
):
...
...
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