1
0
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:
Jeremy Stretch
2020-07-01 13:47:01 -04:00
parent 8959d2e0a7
commit c484fa99e2
8 changed files with 75 additions and 231 deletions

View File

@ -1,17 +1,8 @@
import django_tables2 as tables
from utilities.tables import BaseTable, TagColumn, ToggleColumn
from utilities.tables import BaseTable, ButtonsColumn, TagColumn, ToggleColumn
from .models import SecretRole, Secret
SECRETROLE_ACTIONS = """
<a href="{% url 'secrets:secretrole_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Change log">
<i class="fa fa-history"></i>
</a>
{% if perms.secrets.change_secretrole %}
<a href="{% url 'secrets:secretrole_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 %}
"""
#
# Secret roles
@ -23,11 +14,7 @@ class SecretRoleTable(BaseTable):
secret_count = tables.Column(
verbose_name='Secrets'
)
actions = tables.TemplateColumn(
template_code=SECRETROLE_ACTIONS,
attrs={'td': {'class': 'text-right noprint'}},
verbose_name=''
)
actions = ButtonsColumn(SecretRole, pk_field='slug')
class Meta(BaseTable.Meta):
model = SecretRole