mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
import django_tables2 as tables
|
|
|
|
from utilities.tables import BaseTable, ButtonsColumn, LinkedCountColumn, TagColumn, ToggleColumn
|
|
from .models import SecretRole, Secret
|
|
|
|
|
|
#
|
|
# Secret roles
|
|
#
|
|
|
|
class SecretRoleTable(BaseTable):
|
|
pk = ToggleColumn()
|
|
name = tables.Column(
|
|
linkify=True
|
|
)
|
|
secret_count = LinkedCountColumn(
|
|
viewname='secrets:secret_list',
|
|
url_params={'role_id': 'pk'},
|
|
verbose_name='Secrets'
|
|
)
|
|
actions = ButtonsColumn(SecretRole)
|
|
|
|
class Meta(BaseTable.Meta):
|
|
model = SecretRole
|
|
fields = ('pk', 'name', 'secret_count', 'description', 'slug', 'actions')
|
|
default_columns = ('pk', 'name', 'secret_count', 'description', 'actions')
|
|
|
|
|
|
#
|
|
# Secrets
|
|
#
|
|
|
|
class SecretTable(BaseTable):
|
|
pk = ToggleColumn()
|
|
id = tables.Column( # Provides a link to the secret
|
|
linkify=True
|
|
)
|
|
assigned_object = tables.Column(
|
|
linkify=True,
|
|
orderable=False,
|
|
verbose_name='Assigned object'
|
|
)
|
|
role = tables.Column(
|
|
linkify=True
|
|
)
|
|
tags = TagColumn(
|
|
url_name='secrets:secret_list'
|
|
)
|
|
|
|
class Meta(BaseTable.Meta):
|
|
model = Secret
|
|
fields = ('pk', 'id', 'assigned_object', 'role', 'name', 'last_updated', 'hash', 'tags')
|
|
default_columns = ('pk', 'id', 'assigned_object', 'role', 'name', 'last_updated')
|