mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
fix custom link rendering
This commit is contained in:
parent
be484d20a2
commit
5e4878843e
@ -10,14 +10,24 @@ from utilities.utils import render_jinja2
|
|||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
LINK_BUTTON = '<a href="{}"{} class="btn btn-sm btn-{}">{}</a>\n'
|
LINK_BUTTON = '<a href="{}"{} class="btn btn-sm btn-{} m-1">{}</a>\n'
|
||||||
GROUP_BUTTON = '<div class="btn-group">\n' \
|
|
||||||
'<button type="button" class="btn btn-sm btn-{} dropdown-toggle" data-toggle="dropdown">\n' \
|
GROUP_BUTTON = """
|
||||||
'{} <span class="caret"></span>\n' \
|
<div class="dropdown m-1">
|
||||||
'</button>\n' \
|
<button
|
||||||
'<ul class="dropdown-menu pull-right">\n' \
|
class="btn btn-sm btn-{} dropdown-toggle"
|
||||||
'{}</ul></div>\n'
|
type="button"
|
||||||
GROUP_LINK = '<li><a href="{}"{}>{}</a></li>\n'
|
data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false">
|
||||||
|
{}
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
|
{}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
|
|
||||||
|
GROUP_LINK = '<li><a class="dropdown-item" href="{}"{}>{}</a></li>\n'
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
@ -60,7 +70,7 @@ def custom_links(context, obj):
|
|||||||
link_rendered, link_target, cl.button_class, text_rendered
|
link_rendered, link_target, cl.button_class, text_rendered
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
template_code += '<a class="btn btn-sm btn-default" disabled="disabled" title="{}">' \
|
template_code += '<a class="btn btn-sm btn-outline-dark" disabled="disabled" title="{}">' \
|
||||||
'<i class="mdi mdi-alert"></i> {}</a>\n'.format(e, cl.name)
|
'<i class="mdi mdi-alert"></i> {}</a>\n'.format(e, cl.name)
|
||||||
|
|
||||||
# Add grouped links to template
|
# Add grouped links to template
|
||||||
@ -79,7 +89,7 @@ def custom_links(context, obj):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
links_rendered.append(
|
links_rendered.append(
|
||||||
'<li><a disabled="disabled" title="{}"><span class="text-muted">'
|
'<li><a class="dropdown-item" disabled="disabled" title="{}"><span class="text-muted">'
|
||||||
'<i class="mdi mdi-alert"></i> {}</span></a></li>'.format(e, cl.name)
|
'<i class="mdi mdi-alert"></i> {}</span></a></li>'.format(e, cl.name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load perms %}
|
{% load perms %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
|
||||||
{% block title %}{{ object.device }} / {{ object }}{% endblock %}
|
{% block title %}{{ object.device }} / {{ object }}{% endblock %}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block controls %}
|
{% block controls %}
|
||||||
{% plugin_buttons object %}
|
|
||||||
<div class="controls mb-2 mx-0">
|
<div class="controls mb-2 mx-0">
|
||||||
<div class="d-flex flex-wrap justify-content-end">
|
<div class="d-flex flex-wrap justify-content-end">
|
||||||
|
{% custom_links object %}
|
||||||
|
{% plugin_buttons object %}
|
||||||
{% block extra_controls %}{% endblock %}
|
{% block extra_controls %}{% endblock %}
|
||||||
{% if request.user|can_add:object %}
|
{% if request.user|can_add:object %}
|
||||||
{% clone_button object %}
|
{% clone_button object %}
|
||||||
@ -71,6 +72,5 @@
|
|||||||
</small>
|
</small>
|
||||||
<span class="badge bg-primary">{{ object|meta:"app_label" }}.{{ object|meta:"model_name" }}:{{ object.pk }}</span>
|
<span class="badge bg-primary">{{ object|meta:"app_label" }}.{{ object|meta:"model_name" }}:{{ object.pk }}</span>
|
||||||
</p>
|
</p>
|
||||||
{% block tab_buttons %}{% custom_links object %}{% endblock %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block components %}{% endblock %}
|
{% block components %}{% endblock %}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load custom_links %}
|
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
<li class="breadcrumb-item">
|
<li class="breadcrumb-item">
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{% extends 'virtualization/virtualmachine/base.html' %}
|
{% extends 'virtualization/virtualmachine/base.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load custom_links %}
|
|
||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
Loading…
Reference in New Issue
Block a user