1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Introduce table_config_form template tag to simplify form generation

This commit is contained in:
Jeremy Stretch
2020-10-23 16:47:53 -04:00
parent ff3d0b72b9
commit ce2210b7bc
4 changed files with 66 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from markdown import markdown
from utilities.forms import TableConfigForm
from utilities.utils import foreground_color
register = template.Library()
@@ -261,3 +262,11 @@ def badge(value, show_empty=False):
'value': value,
'show_empty': show_empty,
}
@register.inclusion_tag('utilities/templatetags/table_config_form.html')
def table_config_form(table, table_name=None):
return {
'table_name': table_name or table.__class__.__name__,
'table_config_form': TableConfigForm(table=table),
}