mirror of
https://github.com/django/django.git
synced 2025-09-27 04:29:17 +00:00
Fixed #28517 -- Fixed admin delete confirmation view crash when related models don't have a delete permission.
This commit is contained in:
parent
5d5a2bd299
commit
d1286a8a68
4 changed files with 51 additions and 12 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue