Return the list of actions, prior to any request-based filtering.
(self, action_location=ActionLocation.CHANGE_LIST)
| 1077 | return capfirst(name.replace("_", " ")) |
| 1078 | |
| 1079 | def _get_base_actions(self, action_location=ActionLocation.CHANGE_LIST): |
| 1080 | """Return the list of actions, prior to any request-based filtering.""" |
| 1081 | actions = [] |
| 1082 | base_actions = ( |
| 1083 | self.get_action(action, action_location) for action in self.actions or [] |
| 1084 | ) |
| 1085 | # get_action might have returned None, so filter any of those out. |
| 1086 | base_actions = [action for action in base_actions if action] |
| 1087 | base_action_names = {action.name for action in base_actions} |
| 1088 | |
| 1089 | # Gather actions from the admin site first |
| 1090 | for name, func in self.admin_site.actions: |
| 1091 | if name in base_action_names: |
| 1092 | continue |
| 1093 | locations = getattr(func, "locations", [ActionLocation.CHANGE_LIST]) |
| 1094 | if action_location not in locations: |
| 1095 | continue |
| 1096 | description = self._get_action_description(func, name) |
| 1097 | action = Action( |
| 1098 | func=func, |
| 1099 | name=name, |
| 1100 | description=description, |
| 1101 | plural_description=getattr(func, "plural_description", description), |
| 1102 | locations=locations, |
| 1103 | ) |
| 1104 | actions.append(action) |
| 1105 | # Add actions from this ModelAdmin. |
| 1106 | actions.extend(base_actions) |
| 1107 | return actions |
| 1108 | |
| 1109 | def _filter_actions_by_permissions(self, request, actions): |
| 1110 | """Filter out any actions that the user doesn't have access to.""" |