1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #21870 -- Admin check for list_editable_item

During the admin check for list_editable _check_list_editable_item
should return an empty list if all checks pass. Additionally the
Testcase test_readonly_and_editable was changed to test what the
name implies instead of duplicating the logic of test_readonly.
This commit is contained in:
Arne Brodowski 2014-01-24 14:35:17 +01:00 committed by Baptiste Mispelon
parent e1d18b9d2e
commit 38be3cf5e4
2 changed files with 26 additions and 0 deletions

View File

@ -791,6 +791,8 @@ class ModelAdminChecks(BaseModelAdminChecks):
id='admin.E126',
)
]
else:
return []
def _check_search_fields(self, cls, model):
""" Check search_fields is a sequence. """

View File

@ -52,6 +52,30 @@ class SystemChecksTestCase(TestCase):
def test_readonly_and_editable(self):
class SongAdmin(admin.ModelAdmin):
readonly_fields = ["original_release"]
list_display = ["pk", "original_release"]
list_editable = ["original_release"]
fieldsets = [
(None, {
"fields": ["title", "original_release"],
}),
]
errors = SongAdmin.check(model=Song)
expected = [
checks.Error(
('"list_editable[0]" refers to field "original_release", '
'whih is not editable through the admin.'),
hint=None,
obj=SongAdmin,
id='admin.E126',
)
]
self.assertEqual(errors, expected)
def test_editable(self):
class SongAdmin(admin.ModelAdmin):
list_display = ["pk", "title"]
list_editable = ["title"]
fieldsets = [
(None, {
"fields": ["title", "original_release"],