Skip to content

Optimize the declaration of view actions #13550

Closed
@jeremystretch

Description

@jeremystretch

Proposed Changes

ActionsMixin defines two attributes on a view:

  • actions - A tuple of support action names
  • action_perms - A dictionary mapping of action names to a set of required permissions for each

The following actions are defined by default:

    actions = ('add', 'import', 'export', 'bulk_edit', 'bulk_delete')
    action_perms = defaultdict(set, **{
        'add': {'add'},
        'import': {'add'},
        'bulk_edit': {'change'},
        'bulk_delete': {'delete'},
    })

These can be combined into a single mapping:

    actions = {
        'add': {'add'},
        'import': {'add'},
        'export': set(),
        'bulk_edit': {'change'},
        'bulk_delete': {'delete'},
    }

Justification

This change will simplify the list of support actions for a view and reduce duplicate code.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: housekeepingChanges to the application which do not directly impact the end user

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions