diff options
| author | Paulo Alvarado <commonzenpython@gmail.com> | 2018-05-18 19:50:58 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-05-18 19:50:58 -0400 |
| commit | ffb72a95bcd6fc5cce7915f3b3732a05837f29a2 (patch) | |
| tree | 861b9ee2aaaf19339afe93ff8c9488de11cd405f /tests/admin_inlines/admin.py | |
| parent | a7bc1aea03508f544c9dfac0f34b01996653cef4 (diff) | |
Fixed #29414 -- Restored form inputs on admin inlines when the user doesn't have the change permission.
Regression in 825f0beda804e48e9197fcf3b0d909f9f548aa47.
Diffstat (limited to 'tests/admin_inlines/admin.py')
| -rw-r--r-- | tests/admin_inlines/admin.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/admin_inlines/admin.py b/tests/admin_inlines/admin.py index a56704865d..7ac13ed3a4 100644 --- a/tests/admin_inlines/admin.py +++ b/tests/admin_inlines/admin.py @@ -7,9 +7,9 @@ from .models import ( Consigliere, EditablePKBook, ExtraTerrestrial, Fashionista, Holder, Holder2, Holder3, Holder4, Inner, Inner2, Inner3, Inner4Stacked, Inner4Tabular, NonAutoPKBook, NonAutoPKBookChild, Novel, - ParentModelWithCustomPk, Poll, Profile, ProfileCollection, Question, - ReadOnlyInline, ShoppingWeakness, Sighting, SomeChildModel, - SomeParentModel, SottoCapo, Title, TitleCollection, + NovelReadonlyChapter, ParentModelWithCustomPk, Poll, Profile, + ProfileCollection, Question, ReadOnlyInline, ShoppingWeakness, Sighting, + SomeChildModel, SomeParentModel, SottoCapo, Title, TitleCollection, ) site = admin.AdminSite(name="admin") @@ -153,6 +153,17 @@ class NovelAdmin(admin.ModelAdmin): inlines = [ChapterInline] +class ReadOnlyChapterInline(admin.TabularInline): + model = Chapter + + def has_change_permission(self, request, obj=None): + return False + + +class NovelReadonlyChapterAdmin(admin.ModelAdmin): + inlines = [ReadOnlyChapterInline] + + class ConsigliereInline(admin.TabularInline): model = Consigliere @@ -231,6 +242,7 @@ site.register(Holder3, inlines=[InnerInline3]) site.register(Poll, PollAdmin) site.register(Novel, NovelAdmin) +site.register(NovelReadonlyChapter, NovelReadonlyChapterAdmin) site.register(Fashionista, inlines=[InlineWeakness]) site.register(Holder4, Holder4Admin) site.register(Author, AuthorAdmin) |
