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
53c57645
Kaydet (Commit)
53c57645
authored
Mar 02, 2014
tarafından
Thomas Sorrel
Kaydeden (comit)
Baptiste Mispelon
Mar 03, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #16727 -- Added protocol-relative URL support to contenttypes.views.shortcut.
üst
7bbb6958
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
2 deletions
+50
-2
views.py
django/contrib/contenttypes/views.py
+1
-1
1.7.txt
docs/releases/1.7.txt
+3
-0
testdata.json
tests/contenttypes_tests/fixtures/testdata.json
+21
-0
models.py
tests/contenttypes_tests/models.py
+11
-0
tests.py
tests/contenttypes_tests/tests.py
+14
-1
No files found.
django/contrib/contenttypes/views.py
Dosyayı görüntüle @
53c57645
...
...
@@ -34,7 +34,7 @@ def shortcut(request, content_type_id, object_id):
# if necessary.
# If the object actually defines a domain, we're done.
if
absurl
.
startswith
(
'http://'
)
or
absurl
.
startswith
(
'https://'
):
if
absurl
.
startswith
(
(
'http://'
,
'https://'
,
'//'
)
):
return
http
.
HttpResponseRedirect
(
absurl
)
# Otherwise, we need to introspect the object's relationships for a
...
...
docs/releases/1.7.txt
Dosyayı görüntüle @
53c57645
...
...
@@ -1147,6 +1147,9 @@ Miscellaneous
``django.utils.translation.trans_real.get_supported_language_variant()``
now no longer have a ``supported`` argument.
* The ``shortcut`` view in ``django.contrib.contenttypes.views`` now supports
protocol-relative URLs (e.g. ``//example.com``).
.. _deprecated-features-1.7:
Features deprecated in 1.7
...
...
tests/contenttypes_tests/fixtures/testdata.json
Dosyayı görüntüle @
53c57645
...
...
@@ -36,6 +36,27 @@
"date_created"
:
"3000-01-01 21:22:23"
}
},
{
"pk"
:
1
,
"model"
:
"contenttypes_tests.schemeincludedurl"
,
"fields"
:
{
"url"
:
"http://test_scheme_included_http/"
}
},
{
"pk"
:
2
,
"model"
:
"contenttypes_tests.schemeincludedurl"
,
"fields"
:
{
"url"
:
"https://test_scheme_included_https/"
}
},
{
"pk"
:
3
,
"model"
:
"contenttypes_tests.schemeincludedurl"
,
"fields"
:
{
"url"
:
"//test_default_scheme_kept/"
}
},
{
"pk"
:
1
,
"model"
:
"sites.site"
,
...
...
tests/contenttypes_tests/models.py
Dosyayı görüntüle @
53c57645
...
...
@@ -24,3 +24,14 @@ class Article(models.Model):
def
__str__
(
self
):
return
self
.
title
@python_2_unicode_compatible
class
SchemeIncludedURL
(
models
.
Model
):
url
=
models
.
URLField
(
max_length
=
100
)
def
__str__
(
self
):
return
self
.
url
def
get_absolute_url
(
self
):
return
self
.
url
tests/contenttypes_tests/tests.py
Dosyayı görüntüle @
53c57645
...
...
@@ -12,7 +12,7 @@ from django.test import TestCase
from
django.test.utils
import
override_settings
from
django.utils.encoding
import
force_str
from
.models
import
Author
,
Article
from
.models
import
Author
,
Article
,
SchemeIncludedURL
class
ContentTypesViewsTests
(
TestCase
):
...
...
@@ -27,6 +27,19 @@ class ContentTypesViewsTests(TestCase):
self
.
assertRedirects
(
response
,
'http://testserver
%
s'
%
obj
.
get_absolute_url
(),
status_code
=
302
,
target_status_code
=
404
)
def
test_shortcut_with_absolute_url_including_scheme
(
self
):
"""
Can view a shortcut when object's get_absolute_url returns a full URL
the tested URLs are in fixtures/testdata.json :
"http://...", "https://..." and "//..."
"""
for
obj
in
SchemeIncludedURL
.
objects
.
all
():
short_url
=
'/shortcut/
%
s/
%
s/'
%
(
ContentType
.
objects
.
get_for_model
(
SchemeIncludedURL
)
.
id
,
obj
.
pk
)
response
=
self
.
client
.
get
(
short_url
)
self
.
assertRedirects
(
response
,
obj
.
get_absolute_url
(),
status_code
=
302
,
fetch_redirect_response
=
False
)
def
test_shortcut_no_absolute_url
(
self
):
"Shortcuts for an object that has no get_absolute_url method raises 404"
for
obj
in
Article
.
objects
.
all
():
...
...
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