1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #16117 -- Added decorators for admin action and display functions.

Refs #25134, #32099.
This commit is contained in:
Nick Pope
2021-01-13 16:19:22 +00:00
committed by GitHub
parent 83fcfc9ec8
commit 9204485396
18 changed files with 422 additions and 148 deletions

View File

@@ -692,6 +692,7 @@ class SystemChecksTestCase(SimpleTestCase):
self.assertEqual(errors, [])
def test_readonly_on_method(self):
@admin.display
def my_function(obj):
pass
@@ -705,6 +706,7 @@ class SystemChecksTestCase(SimpleTestCase):
class SongAdmin(admin.ModelAdmin):
readonly_fields = ("readonly_method_on_modeladmin",)
@admin.display
def readonly_method_on_modeladmin(self, obj):
pass
@@ -717,6 +719,7 @@ class SystemChecksTestCase(SimpleTestCase):
def __getattr__(self, item):
if item == "dynamic_method":
@admin.display
def method(obj):
pass
return method
@@ -777,6 +780,7 @@ class SystemChecksTestCase(SimpleTestCase):
def test_extra(self):
class SongAdmin(admin.ModelAdmin):
@admin.display
def awesome_song(self, instance):
if instance.title == "Born to Run":
return "Best Ever!"