Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the declaration of view actions #13550

Closed
jeremystretch opened this issue Aug 24, 2023 · 0 comments
Closed

Optimize the declaration of view actions #13550

jeremystretch opened this issue Aug 24, 2023 · 0 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Milestone

Comments

@jeremystretch
Copy link
Member

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.

@jeremystretch jeremystretch added type: housekeeping Changes to the application which do not directly impact the end user needs milestone Awaiting prioritization for inclusion with a future NetBox release labels Aug 24, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed needs milestone Awaiting prioritization for inclusion with a future NetBox release labels Oct 13, 2023
@jeremystretch jeremystretch added this to the v3.7 milestone Oct 13, 2023
@jeremystretch jeremystretch self-assigned this Oct 13, 2023
jeremystretch added a commit that referenced this issue Oct 20, 2023
* Merge actions and action_perms into a single mapping

* Update obsolete permission maps

* Update obsolete action lists

* Normalize empty permission mappings

* Cleanup

* Add deprecation warnings

* Introduce DEFAULT_ACTION_PERMISSIONS constant
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Projects
None yet
Development

No branches or pull requests

1 participant