Skip to content

Commit

Permalink
Hide plugin buttons when changing the parent object isn't allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed May 2, 2024
1 parent 69b59da commit 2272ff0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions content_editor/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ class ContentEditor(ModelAdmin):

def _content_editor_context(self, request, context):
instance = context.get("original")
if not instance:
show_plugins = True
if instance is None:
instance = self.model()
else:
show_plugins = self.has_change_permission(request, instance)

plugins = []
adding_not_allowed = ["_adding_not_allowed"]
Expand All @@ -139,7 +142,7 @@ def _content_editor_context(self, request, context):
if callable(iaf.opts.regions)
else iaf.opts.regions
)
if iaf.opts.has_add_permission(request, instance)
if show_plugins and iaf.opts.has_add_permission(request, instance)
else adding_not_allowed
)
plugins.append(
Expand Down

0 comments on commit 2272ff0

Please sign in to comment.