1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

51 lines
1.3 KiB
Python
Raw Normal View History

2016-03-01 11:23:03 -05:00
import django_tables2 as tables
from django_tables2.utils import Accessor
from utilities.tables import BaseTable, SearchTable, ToggleColumn
2016-05-16 12:07:12 -04:00
from .models import SecretRole, Secret
2016-07-28 15:04:27 -04:00
SECRETROLE_ACTIONS = """
2016-05-18 16:35:35 -04:00
{% if perms.secrets.change_secretrole %}
2016-07-28 15:04:27 -04:00
<a href="{% url 'secrets:secretrole_edit' slug=record.slug %}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
2016-05-18 16:35:35 -04:00
{% endif %}
2016-05-16 12:07:12 -04:00
"""
#
# Secret roles
#
class SecretRoleTable(BaseTable):
pk = ToggleColumn()
2016-05-16 12:07:12 -04:00
name = tables.LinkColumn(verbose_name='Name')
secret_count = tables.Column(verbose_name='Secrets')
slug = tables.Column(verbose_name='Slug')
2016-07-28 15:04:27 -04:00
actions = tables.TemplateColumn(template_code=SECRETROLE_ACTIONS, attrs={'td': {'class': 'text-right'}},
verbose_name='')
2016-05-16 12:07:12 -04:00
class Meta(BaseTable.Meta):
2016-05-16 12:07:12 -04:00
model = SecretRole
2016-07-28 15:04:27 -04:00
fields = ('pk', 'name', 'secret_count', 'slug', 'actions')
2016-03-01 11:23:03 -05:00
#
# Secrets
#
class SecretTable(BaseTable):
pk = ToggleColumn()
device = tables.LinkColumn()
2016-03-01 11:23:03 -05:00
class Meta(BaseTable.Meta):
2016-03-01 11:23:03 -05:00
model = Secret
fields = ('pk', 'device', 'role', 'name', 'last_updated')
class SecretSearchTable(SearchTable):
class Meta(SearchTable.Meta):
model = Secret
fields = ('device', 'role', 'name', 'last_updated')