Bases: horizon.tables.actions.BaseAction
Represents an action which can be taken on this table’s data.
Required. The short name or “slug” representing this action. This name should not be changed at runtime.
A descriptive name used for display purposes. Defaults to the value of name with the first letter of each word capitalized.
Used like verbose_name in cases where handles_multiple is True. Defaults to verbose_name with the letter “s” appended.
The HTTP method for this action. Defaults to POST. Other methods may or may not succeed currently.
Boolean value indicating whether or not this action can be taken without any additional input (e.g. an object id). Defaults to True.
Boolean value indicating whether this action should be evaluated in the period after the table is instantiated but before the data has been loaded.
This can allow actions which don’t need access to the full table data to bypass any API calls and processing which would otherwise be required to load the table.
A list that contains the allowed data types of the action. If the datum’s type is in this list, the action will be shown on the row for the datum.
Default to be an empty list ([]). When set to empty, the action will accept any kind of data.
list of scope and rule tuples to do policy checks on, the composition of which is (scope, rule)
scope: service type managing the policy for action rule: string representing the action to be checked
- for a policy that requires a single rule check:
- policy_rules should look like
- “((“compute”, “compute:create_instance”),)”
- for a policy that requires multiple rule checks:
- rules should look like
- “((“identity”, “identity:list_users”),
- (“identity”, “identity:list_roles”))”
At least one of the following methods must be defined:
Handler for a single-object action.
Handler for multi-object actions.
If a single function can work for both single-object and multi-object cases then simply providing a handle function will internally route both single and multiple requests to handle with the calls from single being transformed into a list containing only the single object id.
Returns the full POST parameter name for this action.
Defaults to {{ table.name }}__{{ action.name }}.
Bases: horizon.utils.html.HTMLElement
Common base class for all Action classes.
Determine whether this action is allowed for the current request.
This method is meant to be overridden with more specific checks.
Method to see if the action is allowed for a certain type of data. Only affects mixed data type tables.
Returns a list of the default HTML attributes for the action. Defaults to returning an id attribute with the value {{ table.name }}__action_{{ action.name }}__{{ creation counter }}.
Returns a list of the default classes for the action. Defaults to ["btn", "btn-default", "btn-sm"].
Provide the target for a policy request.
This method is meant to be overridden to return target details when one of the policy checks requires them. E.g., {“user_id”: datum.id}
Allows per-action customization based on current conditions.
This is particularly useful when you wish to create a “toggle” action that will be rendered differently based on the value of an attribute on the current row’s data.
By default this method is a no-op.
Bases: type
Metaclass for adding all actions options from inheritance tree to action. This way actions can inherit from each other but still use the class attributes DSL. Meaning, all attributes of Actions are defined as class attributes, but in the background, it will be used as parameters for the initializer of the object. The object is then initialized clean way. Similar principle is used in DataTableMetaclass.
Bases: horizon.tables.actions.Action
A table action which takes batch action on one or more objects. This action should not require user input on a per-object basis.
An internal name for this action.
Method accepting an integer/long parameter and returning the display forms of the name properly pluralised (depending on the integer) and translated in a string or tuple/list.
String or tuple/list. The display forms of the name. Should be a transitive verb, capitalized and translated. (“Delete”, “Rotate”, etc.) If tuple or list - then setting self.current_present_action = n will set the current active item from the list(action_present[n])
You can pass a complete action name including ‘data_type’ by specifying ‘%(data_type)s’ substitution in action_present (“Delete %(data_type)s”). Otherwise a complete action name is a format of “<action> <data_type>”. <data_type> is determined based on the number of items. By passing a complete action name you allow translators to control the order of words as they want.
NOTE: action_present attribute is bad for translations and should be avoided. Please use the action_present method instead. This form is kept for legacy.
Method accepting an integer/long parameter and returning the display forms of the name properly pluralised (depending on the integer) and translated in a string or tuple/list.
String or tuple/list. The past tense of action_present. (“Deleted”, “Rotated”, etc.) If tuple or list - then setting self.current_past_action = n will set the current active item from the list(action_past[n])
NOTE: action_past attribute is bad for translations and should be avoided. Please use the action_past method instead. This form is kept for legacy.
Optional display name (if the data_type method is not defined) for the type of data that receives the action. (“Key Pair”, “Floating IP”, etc.)
Optional plural word (if the data_type method is not defined) for the type of data being acted on. Defaults to appending ‘s’. Relying on the default is bad for translations and should not be done, so it’s absence will raise a DeprecationWarning. It is currently kept as optional for legacy code.
NOTE: data_type_singular and data_type_plural attributes are bad for translations and should not be used. Please use the action_present and action_past methods. This form is kept temporarily for legacy code but will be removed.
Optional location to redirect after completion of the delete action. Defaults to the current page.
Optional message for providing an appropriate help text for the horizon user.
Required. Accepts a single object id and performs the specific action.
Return values are discarded, errors raised are caught and logged.
Returns a list of the default HTML attributes for the action.
Returns the URL to redirect to after a successful action.
Switches the action verbose name, if needed.
Bases: horizon.tables.actions.BatchAction
A table action used to perform delete operations on table data.
A short name or “slug” representing this action. Defaults to ‘delete’
Method accepting an integer/long parameter and returning the display forms of the name properly pluralised (depending on the integer) and translated in a string or tuple/list.
A string containing the transitive verb describing the delete action. Defaults to ‘Delete’
NOTE: action_present attribute is bad for translations and should be avoided. Please use the action_present method instead. This form is kept for legacy.
Method accepting an integer/long parameter and returning the display forms of the name properly pluralised (depending on the integer) and translated in a string or tuple/list.
A string set to the past tense of action_present. Defaults to ‘Deleted’
NOTE: action_past attribute is bad for translations and should be avoided. Please use the action_past method instead. This form is kept for legacy.
A string used to name the data to be deleted.
Optional. Plural of data_type_singular. Defaults to data_type_singular appended with an ‘s’. Relying on the default is bad for translations and should not be done, so it’s absence will raise a DeprecationWarning. It is currently kept as optional for legacy code.
NOTE: data_type_singular and data_type_plural attributes are bad for translations and should not be used. Please use the action_present and action_past methods. This form is kept temporarily for legacy code but will be removed.
Action entry point. Overrides base class’ action method.
Accepts a single object id passing it over to the delete method responsible for the object’s destruction.
Required. Deletes an object referenced by obj_id.
Override to provide delete functionality specific to your data.
Bases: type
Bases: horizon.tables.actions.BaseAction
A base class representing a filter action for a table.
The short name or “slug” representing this action. Defaults to "filter".
A descriptive name used for display purposes. Defaults to the value of name with the first letter of each word capitalized.
A string representing the name of the request parameter used for the search term. Default: "q".
A string representing the type of this filter. If this is set to "server" then filter_choices must also be provided. Default: "query".
Required for server type filters. A tuple of tuples representing the filter options. Tuple composition should evaluate to (string, string, boolean), representing the filter parameter, display value, and whether or not it should be applied to the API request as an API query attribute. API type filters do not need to be accounted for in the filter method since the API will do the filtering. However, server type filters in general will need to be performed in the filter method. By default this attribute is not provided.
If True, the filter function will be called for the initial GET request with an empty filter_string, regardless of the value of method.
Provides the actual filtering logic.
This method must be overridden by subclasses and return the filtered data.
Returns the full query parameter name for this action.
Defaults to {{ table.name }}__{{ action.name }}__{{ action.param_name }}.
Provide the value, string, and help_text (if applicable) for the template to render.
Determine if the given filter field should be used as an API filter.
Bases: horizon.tables.actions.FilterAction
A filter action with fixed buttons.
Override to separate rows into categories.
To have filtering working properly on the client, each row will need CSS class(es) beginning with ‘category-‘, followed by the value of the fixed button.
Return a dict with a key for the value of each fixed button, and a value that is a list of rows in that category.
Returns a list of dictionaries describing the fixed buttons to use for filtering.
Each list item should be a dict with the following keys:
Bases: horizon.tables.actions.BaseAction
A table action which is simply a link rather than a form POST.
Required. The short name or “slug” representing this action. This name should not be changed at runtime.
A string which will be rendered as the link text. (Required)
A string or a callable which resolves to a url to be used as the link target. You must either define the url attribute or override the get_link_url method on the class.
A list that contains the allowed data types of the action. If the datum’s type is in this list, the action will be shown on the row for the datum.
Defaults to be an empty list ([]). When set to empty, the action will accept any kind of data.
Returns the final URL based on the value of url.
If url is callable it will call the function. If not, it will then try to call reverse on url. Failing that, it will simply return the value of url as-is.
When called for a row action, the current row data object will be passed as the first parameter.
Bases: horizon.tables.actions.FilterAction
A filter action for name property.
Naive case-insensitive search.
Bases: object
A table action for cell updates by inline editing.
Determine whether updating is allowed for the current request.
This method is meant to be overridden with more specific checks. Data of the row and of the cell are passed to the method.
Method for saving data of the cell.
This method must implements saving logic of the inline edited table cell.