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
b7219c7b
Kaydet (Commit)
b7219c7b
authored
Ara 14, 2014
tarafından
Mosson, Andrew
Kaydeden (comit)
Tim Graham
Ara 17, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23497 -- Made admin system checks run for custom AdminSites.
üst
c7786550
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
11 deletions
+30
-11
checks.py
django/contrib/admin/checks.py
+2
-5
sites.py
django/contrib/admin/sites.py
+3
-1
1.7.2.txt
docs/releases/1.7.2.txt
+2
-0
tests.py
tests/admin_checks/tests.py
+23
-5
No files found.
django/contrib/admin/checks.py
Dosyayı görüntüle @
b7219c7b
...
...
@@ -11,12 +11,9 @@ from django.forms.models import BaseModelForm, _get_foreign_key, BaseModelFormSe
def
check_admin_app
(
**
kwargs
):
from
django.contrib.admin.sites
import
s
ite
from
django.contrib.admin.sites
import
s
ystem_check_errors
return
list
(
chain
.
from_iterable
(
model_admin
.
check
(
model
,
**
kwargs
)
for
model
,
model_admin
in
site
.
_registry
.
items
()
))
return
system_check_errors
class
BaseModelAdminChecks
(
object
):
...
...
django/contrib/admin/sites.py
Dosyayı görüntüle @
b7219c7b
...
...
@@ -15,6 +15,8 @@ from django.utils.translation import ugettext_lazy, ugettext as _
from
django.views.decorators.cache
import
never_cache
from
django.conf
import
settings
system_check_errors
=
[]
class
AlreadyRegistered
(
Exception
):
pass
...
...
@@ -99,7 +101,7 @@ class AdminSite(object):
admin_class
=
type
(
"
%
sAdmin"
%
model
.
__name__
,
(
admin_class
,),
options
)
if
admin_class
is
not
ModelAdmin
and
settings
.
DEBUG
:
admin_class
.
check
(
model
)
system_check_errors
.
extend
(
admin_class
.
check
(
model
)
)
# Instantiate the admin class to save in the registry
self
.
_registry
[
model
]
=
admin_class
(
model
,
self
)
...
...
docs/releases/1.7.2.txt
Dosyayı görüntüle @
b7219c7b
...
...
@@ -149,3 +149,5 @@ Bugfixes
* Restored the ``pre_migrate`` signal if all apps have migrations
(:ticket:`23975`).
* Made admin system checks run for custom ``AdminSite``\s (:ticket:`23497`).
tests/admin_checks/tests.py
Dosyayı görüntüle @
b7219c7b
...
...
@@ -35,18 +35,20 @@ class ValidFormFieldsets(admin.ModelAdmin):
)
class
MyAdmin
(
admin
.
ModelAdmin
):
@classmethod
def
check
(
cls
,
model
,
**
kwargs
):
return
[
'error!'
]
@override_settings
(
SILENCED_SYSTEM_CHECKS
=
[
'fields.W342'
],
# ForeignKey(unique=True)
INSTALLED_APPS
=
[
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'admin_checks'
]
)
class
SystemChecksTestCase
(
TestCase
):
@override_settings
(
DEBUG
=
True
)
def
test_checks_are_performed
(
self
):
class
MyAdmin
(
admin
.
ModelAdmin
):
@classmethod
def
check
(
self
,
model
,
**
kwargs
):
return
[
'error!'
]
admin
.
site
.
register
(
Song
,
MyAdmin
)
try
:
errors
=
checks
.
run_checks
()
...
...
@@ -54,6 +56,22 @@ class SystemChecksTestCase(TestCase):
self
.
assertEqual
(
errors
,
expected
)
finally
:
admin
.
site
.
unregister
(
Song
)
admin
.
sites
.
system_check_errors
=
[]
@override_settings
(
DEBUG
=
True
)
def
test_custom_adminsite
(
self
):
class
CustomAdminSite
(
admin
.
AdminSite
):
pass
custom_site
=
CustomAdminSite
()
custom_site
.
register
(
Song
,
MyAdmin
)
try
:
errors
=
checks
.
run_checks
()
expected
=
[
'error!'
]
self
.
assertEqual
(
errors
,
expected
)
finally
:
custom_site
.
unregister
(
Song
)
admin
.
sites
.
system_check_errors
=
[]
def
test_readonly_and_editable
(
self
):
class
SongAdmin
(
admin
.
ModelAdmin
):
...
...
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