13044 add detail view template

This commit is contained in:
Arthur 2023-07-21 16:56:41 +07:00
parent d66318aa36
commit 36968024ee
2 changed files with 49 additions and 5 deletions

View File

@ -0,0 +1,44 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load render_table from django_tables2 %}
{% block title %}{% trans "User" %} {{ object.key }}{% endblock %}
{% block subtitle %}{% endblock %}
{% block content %}
<div class="row mb-3">
<div class="col-md-6">
<div class="card">
<h5 class="card-header">{% trans "User" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Key" %}</th>
<td>{{ object.key }}</td>
</tr>
<tr>
<th scope="row">{% trans "User" %}</th>
<td>{{ object.user }}</td>
</tr>
<tr>
<th scope="row">{% trans "Expires" %}</th>
<td>{{ object.expires|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Allowed IPs" %}</th>
<td>{{ object.allowed_ips }}</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-6">
</div>
</div>
{% endblock %}

View File

@ -1,8 +1,7 @@
import django_tables2 as tables import django_tables2 as tables
from netbox.tables import NetBoxTable, columns from netbox.tables import NetBoxTable, columns
from users.models import NetBoxGroup, NetBoxUser, ObjectPermission from users.models import NetBoxGroup, NetBoxUser, ObjectPermission, Token, UserToken
from .models import Token
__all__ = ( __all__ = (
'GroupTable', 'GroupTable',
@ -59,7 +58,8 @@ class TokenTable(NetBoxTable):
class UserTokenTable(NetBoxTable): class UserTokenTable(NetBoxTable):
key = columns.TemplateColumn( key = columns.TemplateColumn(
template_code=TOKEN template_code=TOKEN,
linkify=True,
) )
write_enabled = columns.BooleanColumn( write_enabled = columns.BooleanColumn(
verbose_name='Write' verbose_name='Write'
@ -76,9 +76,9 @@ class UserTokenTable(NetBoxTable):
) )
class Meta(NetBoxTable.Meta): class Meta(NetBoxTable.Meta):
model = Token model = UserToken
fields = ( fields = (
'pk', 'description', 'key', 'write_enabled', 'created', 'expires', 'last_used', 'allowed_ips', 'pk', 'key', 'user', 'description', 'write_enabled', 'created', 'expires', 'last_used', 'allowed_ips',
) )