4751 add plugin buttons to list templates

This commit is contained in:
Arthur 2022-11-11 11:30:41 -08:00
parent 6eba5d4d96
commit e7b01dc95b
4 changed files with 21 additions and 0 deletions

View File

@ -63,3 +63,11 @@ class PluginTemplateExtension:
automatically handled.
"""
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

View File

@ -73,3 +73,11 @@ def plugin_full_width_page(context, obj):
Render all full width page content registered by plugins
"""
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)

View File

@ -16,5 +16,8 @@ class SiteContent(PluginTemplateExtension):
def buttons(self):
return "SITE CONTENT - BUTTONS"
def list_buttons(self):
return "SITE CONTENT - LIST BUTTONS"
template_extensions = [SiteContent]

View File

@ -24,6 +24,8 @@ Context:
{% block controls %}
<div class="controls">
<div class="control-group">
{% plugin_list_buttons object %}
{% block extra_controls %}{% endblock %}
{% if 'add' in actions %}
{% add_button model %}