2016-03-01 11:23:03 -05:00
|
|
|
import django_tables2 as tables
|
|
|
|
|
2020-05-06 14:42:51 -04:00
|
|
|
from utilities.tables import BaseTable, TagColumn, ToggleColumn
|
2016-05-16 12:07:12 -04:00
|
|
|
from .models import SecretRole, Secret
|
|
|
|
|
2016-07-28 15:04:27 -04:00
|
|
|
SECRETROLE_ACTIONS = """
|
2020-02-19 12:45:52 -05:00
|
|
|
<a href="{% url 'secrets:secretrole_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Change log">
|
2018-06-20 14:54:04 -04:00
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
2016-05-18 16:35:35 -04:00
|
|
|
{% if perms.secrets.change_secretrole %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<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>
|
2016-05-18 16:35:35 -04:00
|
|
|
{% endif %}
|
2016-05-16 12:07:12 -04:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Secret roles
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class SecretRoleTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2019-12-10 13:03:09 -05:00
|
|
|
name = tables.LinkColumn()
|
2020-04-29 11:32:53 -04:00
|
|
|
secret_count = tables.Column(
|
|
|
|
verbose_name='Secrets'
|
|
|
|
)
|
2017-05-24 11:33:11 -04:00
|
|
|
actions = tables.TemplateColumn(
|
2020-04-29 11:32:53 -04:00
|
|
|
template_code=SECRETROLE_ACTIONS,
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
2017-05-24 11:33:11 -04:00
|
|
|
)
|
2016-05-16 12:07:12 -04:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-05-16 12:07:12 -04:00
|
|
|
model = SecretRole
|
2020-04-29 11:32:53 -04:00
|
|
|
fields = ('pk', 'name', 'secret_count', 'description', 'slug', 'users', 'groups', 'actions')
|
|
|
|
default_columns = ('pk', 'name', 'secret_count', 'description', 'actions')
|
2016-03-01 11:23:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Secrets
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class SecretTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2017-03-29 16:05:23 -04:00
|
|
|
device = tables.LinkColumn()
|
2020-05-06 14:42:51 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='secrets:secret_list'
|
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-01 11:23:03 -05:00
|
|
|
model = Secret
|
2020-05-06 14:42:51 -04:00
|
|
|
fields = ('pk', 'device', 'role', 'name', 'last_updated', 'hash', 'tags')
|
2020-04-29 11:32:53 -04:00
|
|
|
default_columns = ('pk', 'device', 'role', 'name', 'last_updated')
|