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
a44531ae
Kaydet (Commit)
a44531ae
authored
Şub 24, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #18862 -- Honored script prefix in FlatPage.get_absolute_url.
üst
4b01ee7a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
models.py
django/contrib/flatpages/models.py
+3
-1
models.py
django/contrib/flatpages/tests/models.py
+8
-1
urlresolvers.py
django/core/urlresolvers.py
+9
-0
No files found.
django/contrib/flatpages/models.py
Dosyayı görüntüle @
a44531ae
...
...
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
from
django.db
import
models
from
django.contrib.sites.models
import
Site
from
django.core.urlresolvers
import
get_script_prefix
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.encoding
import
iri_to_uri
,
python_2_unicode_compatible
...
...
@@ -26,4 +27,5 @@ class FlatPage(models.Model):
return
"
%
s --
%
s"
%
(
self
.
url
,
self
.
title
)
def
get_absolute_url
(
self
):
return
iri_to_uri
(
self
.
url
)
# Handle script prefix manually because we bypass reverse()
return
iri_to_uri
(
get_script_prefix
()
.
rstrip
(
'/'
)
+
self
.
url
)
django/contrib/flatpages/tests/models.py
Dosyayı görüntüle @
a44531ae
...
...
@@ -2,6 +2,7 @@
from
__future__
import
unicode_literals
from
django.core.urlresolvers
import
set_script_prefix
,
clear_script_prefix
from
django.contrib.flatpages.models
import
FlatPage
from
django.test
import
TestCase
...
...
@@ -12,4 +13,10 @@ class FlatpageModelTests(TestCase):
pf
=
FlatPage
(
title
=
"Café!"
,
url
=
'/café/'
)
self
.
assertEqual
(
pf
.
get_absolute_url
(),
'/caf
%
C3
%
A9/'
)
def
test_get_absolute_url_honors_script_prefix
(
self
):
pf
=
FlatPage
(
title
=
"Tea!"
,
url
=
'/tea/'
)
set_script_prefix
(
'/beverages/'
)
try
:
self
.
assertEqual
(
pf
.
get_absolute_url
(),
'/beverages/tea/'
)
finally
:
clear_script_prefix
()
django/core/urlresolvers.py
Dosyayı görüntüle @
a44531ae
...
...
@@ -521,6 +521,15 @@ def get_script_prefix():
"""
return
getattr
(
_prefixes
,
"value"
,
'/'
)
def
clear_script_prefix
():
"""
Unsets the script prefix for the current thread.
"""
try
:
del
_prefixes
.
value
except
AttributeError
:
pass
def
set_urlconf
(
urlconf_name
):
"""
Sets the URLconf for the current thread (overriding the default one in
...
...
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