File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,19 @@ def inner(
3737 # Permissions methods have following syntax: has_<some>_permission(self, request, obj=None):
3838 # But obj is not examined by default in django admin and it would also require additional
3939 # fetch from database, therefore it is not supported yet
40- has_object_argument = (
41- func .__name__ in model_admin .actions_detail
42- or func .__name__ in model_admin .actions_submit_line
40+ has_detail_action = func .__name__ in model_admin ._extract_action_names (
41+ model_admin .actions_detail
4342 )
43+ has_submit_line_action = (
44+ func .__name__
45+ in model_admin ._extract_action_names (
46+ model_admin .actions_submit_line
47+ )
48+ )
49+
4450 if not all (
4551 has_permission (request , kwargs .get ("object_id" ))
46- if has_object_argument
52+ if has_detail_action or has_submit_line_action
4753 else has_permission (request )
4854 for has_permission in permission_checks
4955 ):
Original file line number Diff line number Diff line change @@ -213,13 +213,19 @@ def has_changelist_row_action_false_permission(self, request):
213213 ######################################################################
214214 # Changeform actions
215215 ######################################################################
216- @action (description = "Changeform action dropdown" )
216+ @action (
217+ description = "Changeform action dropdown" ,
218+ permissions = ["changeform_action_dropdown" ],
219+ )
217220 def changeform_action_dropdown (self , request , object_id ):
218221 messages .success (
219222 request , "Changeform action dropdown successfully executed"
220223 )
221224 return redirect (reverse_lazy ("admin:example_user_changelist" ))
222225
226+ def has_changeform_action_dropdown_permission (self , request , object_id ):
227+ return True
228+
223229 @action (description = "Changeform action" )
224230 def changeform_action (self , request , object_id ):
225231 messages .success (request , "Changeform action successfully executed" )
You can’t perform that action at this time.
0 commit comments