mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Introduce ButtonsColumn to reduce boilerplate and standardize organizational object links
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from utilities.tables import BaseTable, TagColumn, ToggleColumn
|
||||
from utilities.tables import BaseTable, ButtonsColumn, TagColumn, ToggleColumn
|
||||
from .models import Tenant, TenantGroup
|
||||
|
||||
MPTT_LINK = """
|
||||
@ -13,15 +13,6 @@ MPTT_LINK = """
|
||||
</span>
|
||||
"""
|
||||
|
||||
TENANTGROUP_ACTIONS = """
|
||||
<a href="{% url 'tenancy:tenantgroup_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Change log">
|
||||
<i class="fa fa-history"></i>
|
||||
</a>
|
||||
{% if perms.tenancy.change_tenantgroup %}
|
||||
<a href="{% url 'tenancy:tenantgroup_edit' slug=record.slug %}?return_url={{ request.path }}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
||||
{% endif %}
|
||||
"""
|
||||
|
||||
COL_TENANT = """
|
||||
{% if record.tenant %}
|
||||
<a href="{% url 'tenancy:tenant' slug=record.tenant.slug %}" title="{{ record.tenant.description }}">{{ record.tenant }}</a>
|
||||
@ -44,11 +35,7 @@ class TenantGroupTable(BaseTable):
|
||||
tenant_count = tables.Column(
|
||||
verbose_name='Tenants'
|
||||
)
|
||||
actions = tables.TemplateColumn(
|
||||
template_code=TENANTGROUP_ACTIONS,
|
||||
attrs={'td': {'class': 'text-right noprint'}},
|
||||
verbose_name=''
|
||||
)
|
||||
actions = ButtonsColumn(TenantGroup, pk_field='slug')
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = TenantGroup
|
||||
|
Reference in New Issue
Block a user