from .models import Token
from netbox.tables import NetBoxTable, columns
__all__ = (
'TokenTable',
)
TOKEN = """{{ record }}"""
ALLOWED_IPS = """{{ value|join:", " }}"""
COPY_BUTTON = """
{% if settings.ALLOW_TOKEN_RETRIEVAL %}
{% endif %}
"""
class TokenTable(NetBoxTable):
key = columns.TemplateColumn(
template_code=TOKEN
)
write_enabled = columns.BooleanColumn(
verbose_name='Write'
)
created = columns.DateColumn()
expired = columns.DateColumn()
last_used = columns.DateTimeColumn()
allowed_ips = columns.TemplateColumn(
template_code=ALLOWED_IPS
)
actions = columns.ActionsColumn(
actions=('edit', 'delete'),
extra_buttons=COPY_BUTTON
)
class Meta(NetBoxTable.Meta):
model = Token
fields = (
'pk', 'description', 'key', 'write_enabled', 'created', 'expires', 'last_used', 'allowed_ips',
)