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
4502489a
Kaydet (Commit)
4502489a
authored
Eyl 03, 2017
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #18974 -- Removed @models.permalink() decorator per deprecation timeline.
üst
5e31be1b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
3 additions
and
98 deletions
+3
-98
__init__.py
django/db/models/__init__.py
+1
-31
2.1.txt
docs/releases/2.1.txt
+2
-0
__init__.py
tests/model_permalink/__init__.py
+0
-0
models.py
tests/model_permalink/models.py
+0
-30
tests.py
tests/model_permalink/tests.py
+0
-25
urls.py
tests/model_permalink/urls.py
+0
-7
views.py
tests/model_permalink/views.py
+0
-5
No files found.
django/db/models/__init__.py
Dosyayı görüntüle @
4502489a
...
...
@@ -30,36 +30,6 @@ from django.db.models.fields.related import ( # isort:skip
)
def
permalink
(
func
):
"""
Decorator that calls urls.reverse() to return a URL using parameters
returned by the decorated function "func".
"func" should be a function that returns a tuple in one of the
following formats:
(viewname, viewargs)
(viewname, viewargs, viewkwargs)
"""
import
warnings
from
functools
import
wraps
from
django.urls
import
reverse
from
django.utils.deprecation
import
RemovedInDjango21Warning
warnings
.
warn
(
'permalink() is deprecated in favor of calling django.urls.reverse() '
'in the decorated method.'
,
RemovedInDjango21Warning
,
stacklevel
=
2
,
)
@wraps
(
func
)
def
inner
(
*
args
,
**
kwargs
):
bits
=
func
(
*
args
,
**
kwargs
)
return
reverse
(
bits
[
0
],
None
,
*
bits
[
1
:
3
])
return
inner
__all__
=
aggregates_all
+
fields_all
+
indexes_all
__all__
+=
[
'ObjectDoesNotExist'
,
'signals'
,
...
...
@@ -72,5 +42,5 @@ __all__ += [
'Prefetch'
,
'Q'
,
'QuerySet'
,
'prefetch_related_objects'
,
'DEFERRED'
,
'Model'
,
'FilteredRelation'
,
'ForeignKey'
,
'ForeignObject'
,
'OneToOneField'
,
'ManyToManyField'
,
'ManyToOneRel'
,
'ManyToManyRel'
,
'OneToOneRel'
,
'permalink'
,
'ManyToOneRel'
,
'ManyToManyRel'
,
'OneToOneRel'
,
]
docs/releases/2.1.txt
Dosyayı görüntüle @
4502489a
...
...
@@ -249,3 +249,5 @@ how to remove usage of these features.
* The ``authenticate()`` method of authentication backends requires ``request``
as the first positional argument.
* The ``django.db.models.permalink()`` decorator is removed.
tests/model_permalink/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
5e31be1b
tests/model_permalink/models.py
deleted
100644 → 0
Dosyayı görüntüle @
5e31be1b
import
warnings
from
django.db
import
models
from
django.utils.deprecation
import
RemovedInDjango21Warning
def
set_attr
(
name
,
value
):
def
wrapper
(
function
):
setattr
(
function
,
name
,
value
)
return
function
return
wrapper
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
category
=
RemovedInDjango21Warning
)
class
Guitarist
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
slug
=
models
.
CharField
(
max_length
=
50
)
@models.permalink
def
url
(
self
):
"Returns the URL for this guitarist."
return
(
'guitarist_detail'
,
[
self
.
slug
])
@models.permalink
@set_attr
(
'attribute'
,
'value'
)
def
url_with_attribute
(
self
):
"Returns the URL for this guitarist and holds an attribute"
return
(
'guitarist_detail'
,
[
self
.
slug
])
tests/model_permalink/tests.py
deleted
100644 → 0
Dosyayı görüntüle @
5e31be1b
from
django.test
import
SimpleTestCase
,
override_settings
from
.models
import
Guitarist
@override_settings
(
ROOT_URLCONF
=
'model_permalink.urls'
)
class
PermalinkTests
(
SimpleTestCase
):
def
test_permalink
(
self
):
g
=
Guitarist
(
name
=
'Adrien Moignard'
,
slug
=
'adrienmoignard'
)
self
.
assertEqual
(
g
.
url
(),
'/guitarists/adrienmoignard/'
)
def
test_wrapped_docstring
(
self
):
"Methods using the @permalink decorator retain their docstring."
g
=
Guitarist
(
name
=
'Adrien Moignard'
,
slug
=
'adrienmoignard'
)
self
.
assertEqual
(
g
.
url
.
__doc__
,
"Returns the URL for this guitarist."
)
def
test_wrapped_attribute
(
self
):
"""
Methods using the @permalink decorator can have attached attributes
from other decorators
"""
g
=
Guitarist
(
name
=
'Adrien Moignard'
,
slug
=
'adrienmoignard'
)
self
.
assertTrue
(
hasattr
(
g
.
url_with_attribute
,
'attribute'
))
self
.
assertEqual
(
g
.
url_with_attribute
.
attribute
,
'value'
)
tests/model_permalink/urls.py
deleted
100644 → 0
Dosyayı görüntüle @
5e31be1b
from
django.conf.urls
import
url
from
.
import
views
urlpatterns
=
[
url
(
r'^guitarists/(\w{1,50})/$'
,
views
.
empty_view
,
name
=
'guitarist_detail'
),
]
tests/model_permalink/views.py
deleted
100644 → 0
Dosyayı görüntüle @
5e31be1b
from
django.http
import
HttpResponse
def
empty_view
(
request
,
*
args
,
**
kwargs
):
return
HttpResponse
(
''
)
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