mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 01:06:11 -06:00
4751 add plugin buttons to list templates
This commit is contained in:
parent
6eba5d4d96
commit
e7b01dc95b
@ -63,3 +63,11 @@ class PluginTemplateExtension:
|
|||||||
automatically handled.
|
automatically handled.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def list_buttons(self):
|
||||||
|
"""
|
||||||
|
Buttons that will be rendered and added to the existing list of buttons on the list view. Content
|
||||||
|
should be returned as an HTML string. Note that content does not need to be marked as safe because this is
|
||||||
|
automatically handled.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
@ -73,3 +73,11 @@ def plugin_full_width_page(context, obj):
|
|||||||
Render all full width page content registered by plugins
|
Render all full width page content registered by plugins
|
||||||
"""
|
"""
|
||||||
return _get_registered_content(obj, 'full_width_page', context)
|
return _get_registered_content(obj, 'full_width_page', context)
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag(takes_context=True)
|
||||||
|
def plugin_list_buttons(context, obj):
|
||||||
|
"""
|
||||||
|
Render all list buttons registered by plugins
|
||||||
|
"""
|
||||||
|
return _get_registered_content(obj, 'list_buttons', context)
|
||||||
|
@ -16,5 +16,8 @@ class SiteContent(PluginTemplateExtension):
|
|||||||
def buttons(self):
|
def buttons(self):
|
||||||
return "SITE CONTENT - BUTTONS"
|
return "SITE CONTENT - BUTTONS"
|
||||||
|
|
||||||
|
def list_buttons(self):
|
||||||
|
return "SITE CONTENT - LIST BUTTONS"
|
||||||
|
|
||||||
|
|
||||||
template_extensions = [SiteContent]
|
template_extensions = [SiteContent]
|
||||||
|
@ -24,6 +24,8 @@ Context:
|
|||||||
{% block controls %}
|
{% block controls %}
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
{% plugin_list_buttons object %}
|
||||||
|
|
||||||
{% block extra_controls %}{% endblock %}
|
{% block extra_controls %}{% endblock %}
|
||||||
{% if 'add' in actions %}
|
{% if 'add' in actions %}
|
||||||
{% add_button model %}
|
{% add_button model %}
|
||||||
|
Loading…
Reference in New Issue
Block a user