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

Enable a PluginTemplateExtension subclass to register for multiple models #16726

Closed
jeremystretch opened this issue Jun 25, 2024 · 0 comments
Closed
Assignees
Labels
status: accepted This issue has been accepted for implementation topic: plugins Relates to the plugins framework type: feature Introduction of new functionality to the application
Milestone

Comments

@jeremystretch
Copy link
Member

jeremystretch commented Jun 25, 2024

NetBox version

v4.0.6

Feature type

New functionality

Proposed functionality

A subclass of PluginTemplateExtension must currently register against a single model. For example:

from netbox.plugins import PluginTemplateExtension

class SiteCustomContent(PluginTemplateExtension):
    model = 'dcim.site'

This issue proposes adding an alternative models attribute to specify an iterable of models. For example:

from netbox.plugins import PluginTemplateExtension

class SiteCustomContent(PluginTemplateExtension):
    models = ['dcim.region', 'dcim.site', 'dcim.location']

The content introduced by this class will then be embedded on the relevant view for each of the listed models.

If models is defined, it will take precedence over model.

Use case

This obviates the need to create a redundant PluginTemplateExtension subclass for each core model.

Database changes

None

External dependencies

None

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application topic: plugins Relates to the plugins framework labels Jun 25, 2024
@jeremystretch jeremystretch self-assigned this Jun 28, 2024
@jeremystretch jeremystretch added this to the v4.1 milestone Jul 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 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 topic: plugins Relates to the plugins framework type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

1 participant