summaryrefslogtreecommitdiff
path: root/tests/admin_views/admin.py
diff options
context:
space:
mode:
authorPaulo <commonzenpython@gmail.com>2017-08-22 19:48:55 -0400
committerTim Graham <timograham@gmail.com>2018-01-04 19:07:46 -0500
commitd1286a8a689e31435c07534fee7b61f41cea37f8 (patch)
tree1b74eafe481b46ee763c05957d51cef0d43671a6 /tests/admin_views/admin.py
parent5d5a2bd299c97f8e03d79380345ec8713d612f58 (diff)
Fixed #28517 -- Fixed admin delete confirmation view crash when related models don't have a delete permission.
Diffstat (limited to 'tests/admin_views/admin.py')
-rw-r--r--tests/admin_views/admin.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
index 1e4124fca5..12087865b4 100644
--- a/tests/admin_views/admin.py
+++ b/tests/admin_views/admin.py
@@ -36,11 +36,11 @@ from .models import (
Person, Persona, Picture, Pizza, Plot, PlotDetails, PlotProxy,
PluggableSearchPerson, Podcast, Post, PrePopulatedPost,
PrePopulatedPostLargeSlug, PrePopulatedSubPost, Promo, Question,
- ReadablePizza, Recipe, Recommendation, Recommender, ReferencedByGenRel,
- ReferencedByInline, ReferencedByParent, RelatedPrepopulated,
- RelatedWithUUIDPKModel, Report, Reservation, Restaurant,
- RowLevelChangePermissionModel, Section, ShortMessage, Simple, Sketch,
- State, Story, StumpJoke, Subscriber, SuperVillain, Telegram, Thing,
+ ReadablePizza, ReadOnlyPizza, Recipe, Recommendation, Recommender,
+ ReferencedByGenRel, ReferencedByInline, ReferencedByParent,
+ RelatedPrepopulated, RelatedWithUUIDPKModel, Report, Reservation,
+ Restaurant, RowLevelChangePermissionModel, Section, ShortMessage, Simple,
+ Sketch, State, Story, StumpJoke, Subscriber, SuperVillain, Telegram, Thing,
Topping, UnchangeableObject, UndeletableObject, UnorderedObject,
UserMessenger, Villain, Vodcast, Whatsit, Widget, Worker, WorkHour,
)
@@ -502,6 +502,19 @@ class StudentAdmin(admin.ModelAdmin):
search_fields = ('name',)
+class ReadOnlyPizzaAdmin(admin.ModelAdmin):
+ readonly_fields = ('name', 'toppings')
+
+ def has_add_permission(self, request):
+ return False
+
+ def has_change_permission(self, request, obj=None):
+ return True
+
+ def has_delete_permission(self, request, obj=None):
+ return True
+
+
class WorkHourAdmin(admin.ModelAdmin):
list_display = ('datum', 'employee')
list_filter = ('employee',)
@@ -1001,6 +1014,7 @@ site.register(Book, inlines=[ChapterInline])
site.register(Promo)
site.register(ChapterXtra1, ChapterXtra1Admin)
site.register(Pizza, PizzaAdmin)
+site.register(ReadOnlyPizza, ReadOnlyPizzaAdmin)
site.register(ReadablePizza)
site.register(Topping, ToppingAdmin)
site.register(Album, AlbumAdmin)