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
33a0b7ac
Kaydet (Commit)
33a0b7ac
authored
Nis 08, 2018
tarafından
Paul Donohue
Kaydeden (comit)
Tim Graham
Nis 12, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29296 -- Fixed crashes in admindocs when a view is a callable object.
üst
ee17bb8a
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
37 additions
and
7 deletions
+37
-7
AUTHORS
AUTHORS
+1
-0
middleware.py
django/contrib/admindocs/middleware.py
+3
-1
utils.py
django/contrib/admindocs/utils.py
+6
-0
views.py
django/contrib/admindocs/views.py
+3
-6
1.11.13.txt
docs/releases/1.11.13.txt
+3
-0
2.0.5.txt
docs/releases/2.0.5.txt
+3
-0
test_middleware.py
tests/admin_docs/test_middleware.py
+5
-0
test_views.py
tests/admin_docs/test_views.py
+6
-0
urls.py
tests/admin_docs/urls.py
+2
-0
views.py
tests/admin_docs/views.py
+5
-0
No files found.
AUTHORS
Dosyayı görüntüle @
33a0b7ac
...
@@ -637,6 +637,7 @@ answer newbie questions, and generally made Django that much better:
...
@@ -637,6 +637,7 @@ answer newbie questions, and generally made Django that much better:
Paul Bissex <http://e-scribe.com/>
Paul Bissex <http://e-scribe.com/>
Paul Collier <paul@paul-collier.com>
Paul Collier <paul@paul-collier.com>
Paul Collins <paul.collins.iii@gmail.com>
Paul Collins <paul.collins.iii@gmail.com>
Paul Donohue <django@PaulSD.com>
Paul Lanier <planier@google.com>
Paul Lanier <planier@google.com>
Paul McLanahan <paul@mclanahan.net>
Paul McLanahan <paul@mclanahan.net>
Paul McMillan <Paul@McMillan.ws>
Paul McMillan <Paul@McMillan.ws>
...
...
django/contrib/admindocs/middleware.py
Dosyayı görüntüle @
33a0b7ac
...
@@ -2,6 +2,8 @@ from django.conf import settings
...
@@ -2,6 +2,8 @@ from django.conf import settings
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.utils.deprecation
import
MiddlewareMixin
from
django.utils.deprecation
import
MiddlewareMixin
from
.utils
import
get_view_name
class
XViewMiddleware
(
MiddlewareMixin
):
class
XViewMiddleware
(
MiddlewareMixin
):
"""
"""
...
@@ -24,5 +26,5 @@ class XViewMiddleware(MiddlewareMixin):
...
@@ -24,5 +26,5 @@ class XViewMiddleware(MiddlewareMixin):
if
request
.
method
==
'HEAD'
and
(
request
.
META
.
get
(
'REMOTE_ADDR'
)
in
settings
.
INTERNAL_IPS
or
if
request
.
method
==
'HEAD'
and
(
request
.
META
.
get
(
'REMOTE_ADDR'
)
in
settings
.
INTERNAL_IPS
or
(
request
.
user
.
is_active
and
request
.
user
.
is_staff
)):
(
request
.
user
.
is_active
and
request
.
user
.
is_staff
)):
response
=
HttpResponse
()
response
=
HttpResponse
()
response
[
'X-View'
]
=
"
%
s.
%
s"
%
(
view_func
.
__module__
,
view_func
.
__name__
)
response
[
'X-View'
]
=
get_view_name
(
view_func
)
return
response
return
response
django/contrib/admindocs/utils.py
Dosyayı görüntüle @
33a0b7ac
...
@@ -18,6 +18,12 @@ else:
...
@@ -18,6 +18,12 @@ else:
docutils_is_available
=
True
docutils_is_available
=
True
def
get_view_name
(
view_func
):
mod_name
=
view_func
.
__module__
view_name
=
getattr
(
view_func
,
'__qualname__'
,
view_func
.
__class__
.
__name__
)
return
mod_name
+
'.'
+
view_name
def
trim_docstring
(
docstring
):
def
trim_docstring
(
docstring
):
"""
"""
Uniformly trim leading/trailing whitespace from docstrings.
Uniformly trim leading/trailing whitespace from docstrings.
...
...
django/contrib/admindocs/views.py
Dosyayı görüntüle @
33a0b7ac
...
@@ -23,6 +23,8 @@ from django.utils.inspect import (
...
@@ -23,6 +23,8 @@ from django.utils.inspect import (
from
django.utils.translation
import
gettext
as
_
from
django.utils.translation
import
gettext
as
_
from
django.views.generic
import
TemplateView
from
django.views.generic
import
TemplateView
from
.utils
import
get_view_name
# Exclude methods starting with these strings from documentation
# Exclude methods starting with these strings from documentation
MODEL_METHODS_EXCLUDE
=
(
'_'
,
'add_'
,
'delete'
,
'save'
,
'set_'
)
MODEL_METHODS_EXCLUDE
=
(
'_'
,
'add_'
,
'delete'
,
'save'
,
'set_'
)
...
@@ -124,18 +126,13 @@ class TemplateFilterIndexView(BaseAdminDocsView):
...
@@ -124,18 +126,13 @@ class TemplateFilterIndexView(BaseAdminDocsView):
class
ViewIndexView
(
BaseAdminDocsView
):
class
ViewIndexView
(
BaseAdminDocsView
):
template_name
=
'admin_doc/view_index.html'
template_name
=
'admin_doc/view_index.html'
@staticmethod
def
_get_full_name
(
func
):
mod_name
=
func
.
__module__
return
'
%
s.
%
s'
%
(
mod_name
,
func
.
__qualname__
)
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
views
=
[]
views
=
[]
urlconf
=
import_module
(
settings
.
ROOT_URLCONF
)
urlconf
=
import_module
(
settings
.
ROOT_URLCONF
)
view_functions
=
extract_views_from_urlpatterns
(
urlconf
.
urlpatterns
)
view_functions
=
extract_views_from_urlpatterns
(
urlconf
.
urlpatterns
)
for
(
func
,
regex
,
namespace
,
name
)
in
view_functions
:
for
(
func
,
regex
,
namespace
,
name
)
in
view_functions
:
views
.
append
({
views
.
append
({
'full_name'
:
self
.
_get_full
_name
(
func
),
'full_name'
:
get_view
_name
(
func
),
'url'
:
simplify_regex
(
regex
),
'url'
:
simplify_regex
(
regex
),
'url_name'
:
':'
.
join
((
namespace
or
[])
+
(
name
and
[
name
]
or
[])),
'url_name'
:
':'
.
join
((
namespace
or
[])
+
(
name
and
[
name
]
or
[])),
'namespace'
:
':'
.
join
((
namespace
or
[])),
'namespace'
:
':'
.
join
((
namespace
or
[])),
...
...
docs/releases/1.11.13.txt
Dosyayı görüntüle @
33a0b7ac
...
@@ -12,3 +12,6 @@ Bugfixes
...
@@ -12,3 +12,6 @@ Bugfixes
* Fixed a regression in Django 1.11.8 where altering a field with a unique
* Fixed a regression in Django 1.11.8 where altering a field with a unique
constraint may drop and rebuild more foreign keys than necessary
constraint may drop and rebuild more foreign keys than necessary
(:ticket:`29193`).
(:ticket:`29193`).
* Fixed crashes in ``django.contrib.admindocs`` when a view is a callable
object, such as ``django.contrib.syndication.views.Feed`` (:ticket:`29296`).
docs/releases/2.0.5.txt
Dosyayı görüntüle @
33a0b7ac
...
@@ -15,3 +15,6 @@ Bugfixes
...
@@ -15,3 +15,6 @@ Bugfixes
* Fixed a regression in Django 1.11.8 where altering a field with a unique
* Fixed a regression in Django 1.11.8 where altering a field with a unique
constraint may drop and rebuild more foreign keys than necessary
constraint may drop and rebuild more foreign keys than necessary
(:ticket:`29193`).
(:ticket:`29193`).
* Fixed crashes in ``django.contrib.admindocs`` when a view is a callable
object, such as ``django.contrib.syndication.views.Feed`` (:ticket:`29296`).
tests/admin_docs/test_middleware.py
Dosyayı görüntüle @
33a0b7ac
...
@@ -40,3 +40,8 @@ class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase):
...
@@ -40,3 +40,8 @@ class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase):
user
.
save
()
user
.
save
()
response
=
self
.
client
.
head
(
'/xview/class/'
)
response
=
self
.
client
.
head
(
'/xview/class/'
)
self
.
assertNotIn
(
'X-View'
,
response
)
self
.
assertNotIn
(
'X-View'
,
response
)
def
test_callable_object_view
(
self
):
self
.
client
.
force_login
(
self
.
superuser
)
response
=
self
.
client
.
head
(
'/xview/callable_object/'
)
self
.
assertEqual
(
response
[
'X-View'
],
'admin_docs.views.XViewCallableObject'
)
tests/admin_docs/test_views.py
Dosyayı görüntüle @
33a0b7ac
...
@@ -51,6 +51,12 @@ class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
...
@@ -51,6 +51,12 @@ class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
)
)
self
.
assertContains
(
response
,
'Views by namespace test'
)
self
.
assertContains
(
response
,
'Views by namespace test'
)
self
.
assertContains
(
response
,
'Name: <code>test:func</code>.'
)
self
.
assertContains
(
response
,
'Name: <code>test:func</code>.'
)
self
.
assertContains
(
response
,
'<h3><a href="/admindocs/views/admin_docs.views.XViewCallableObject/">'
'/xview/callable_object_without_xview/</a></h3>'
,
html
=
True
,
)
def
test_view_index_with_method
(
self
):
def
test_view_index_with_method
(
self
):
"""
"""
...
...
tests/admin_docs/urls.py
Dosyayı görüntüle @
33a0b7ac
...
@@ -13,4 +13,6 @@ urlpatterns = [
...
@@ -13,4 +13,6 @@ urlpatterns = [
url
(
r'^'
,
include
(
ns_patterns
,
namespace
=
'test'
)),
url
(
r'^'
,
include
(
ns_patterns
,
namespace
=
'test'
)),
url
(
r'^xview/func/$'
,
views
.
xview_dec
(
views
.
xview
)),
url
(
r'^xview/func/$'
,
views
.
xview_dec
(
views
.
xview
)),
url
(
r'^xview/class/$'
,
views
.
xview_dec
(
views
.
XViewClass
.
as_view
())),
url
(
r'^xview/class/$'
,
views
.
xview_dec
(
views
.
XViewClass
.
as_view
())),
url
(
r'^xview/callable_object/$'
,
views
.
xview_dec
(
views
.
XViewCallableObject
())),
url
(
r'^xview/callable_object_without_xview/$'
,
views
.
XViewCallableObject
()),
]
]
tests/admin_docs/views.py
Dosyayı görüntüle @
33a0b7ac
...
@@ -13,3 +13,8 @@ def xview(request):
...
@@ -13,3 +13,8 @@ def xview(request):
class
XViewClass
(
View
):
class
XViewClass
(
View
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
return
HttpResponse
()
return
HttpResponse
()
class
XViewCallableObject
(
View
):
def
__call__
(
self
,
request
):
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