Misc cleanup

This commit is contained in:
Jeremy Stretch 2023-07-25 12:27:56 -04:00
parent 2e61f9443c
commit dda6d8ff4e
5 changed files with 48 additions and 30 deletions

View File

@ -24,24 +24,26 @@
<h5 class="card-header">{% trans "Token" %}</h5> <h5 class="card-header">{% trans "Token" %}</h5>
<div class="card-body"> <div class="card-body">
<table class="table table-hover attr-table"> <table class="table table-hover attr-table">
{% if key %}
<tr> <tr>
<th scope="row">{% trans "Key" %}</th> <th scope="row">{% trans "Key" %}</th>
<td> <td>
{% if key %}
<div class="float-end"> <div class="float-end">
{% copy_content "token_id" %} {% copy_content "token_id" %}
</div> </div>
<div id="token_id">{{ key }}</div> <div id="token_id">{{ key }}</div>
{% else %}
{{ object.partial }}
{% endif %}
</td> </td>
</tr> </tr>
{% endif %}
<tr> <tr>
<th scope="row">{% trans "Description" %}</th> <th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td> <td>{{ object.description|placeholder }}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">{% trans "User" %}</th> <th scope="row">{% trans "Write enabled" %}</th>
<td>{{ object.user }}</td> <td>{% checkmark object.write_enabled %}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">{% trans "Created" %}</th> <th scope="row">{% trans "Created" %}</th>
@ -49,13 +51,15 @@
</tr> </tr>
<tr> <tr>
<th scope="row">{% trans "Expires" %}</th> <th scope="row">{% trans "Expires" %}</th>
<td> <td>{{ object.expires|placeholder }}</td>
{% if object.expires %} </tr>
{{ object.expires|annotated_date }} <tr>
{% else %} <th scope="row">{% trans "Last used" %}</th>
<span>{% trans "Never" %}</span> <td>{{ object.last_used|placeholder }}</td>
{% endif %} </tr>
</td> <tr>
<th scope="row">{% trans "Allowed IPs" %}</th>
<td>{{ object.allowed_ips|join:", "|placeholder }}</td>
</tr> </tr>
</table> </table>
</div> </div>

View File

@ -11,34 +11,46 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-md-6"> <div class="col-md-6">
<div class="card"> <div class="card">
<h5 class="card-header">{% trans "User" %}</h5> <h5 class="card-header">{% trans "Token" %}</h5>
<div class="card-body"> <div class="card-body">
<table class="table table-hover attr-table"> <table class="table table-hover attr-table">
<tr> <tr>
<th scope="row">{% trans "Key" %}</th> <th scope="row">{% trans "Key" %}</th>
<td>{{ object }}</td> <td>{% if settings.ALLOW_TOKEN_RETRIEVAL %}{{ object.key }}{% else %}{{ object.partial }}{% endif %}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">{% trans "User" %}</th> <th scope="row">{% trans "User" %}</th>
<td>{{ object.user }}</td> <td>
</tr> <a href="{% url 'users:netboxuser' pk=object.user.pk %}">{{ object.user }}</a>
<tr> </td>
<th scope="row">{% trans "Expires" %}</th>
<td>{{ object.expires|placeholder }}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">{% trans "Description" %}</th> <th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td> <td>{{ object.description|placeholder }}</td>
</tr> </tr>
<tr>
<th scope="row">{% trans "Write enabled" %}</th>
<td>{% checkmark object.write_enabled %}</td>
</tr>
<tr>
<th scope="row">{% trans "Created" %}</th>
<td>{{ object.created|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "Expires" %}</th>
<td>{{ object.expires|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Last used" %}</th>
<td>{{ object.last_used|placeholder }}</td>
</tr>
<tr> <tr>
<th scope="row">{% trans "Allowed IPs" %}</th> <th scope="row">{% trans "Allowed IPs" %}</th>
<td>{{ object.allowed_ips }}</td> <td>{{ object.allowed_ips|join:", "|placeholder }}</td>
</tr> </tr>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6">
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -18,6 +18,7 @@ class Migration(migrations.Migration):
'proxy': True, 'proxy': True,
'indexes': [], 'indexes': [],
'constraints': [], 'constraints': [],
'verbose_name': 'token',
}, },
bases=('users.token',), bases=('users.token',),
), ),

View File

@ -328,6 +328,7 @@ class UserToken(Token):
""" """
class Meta: class Meta:
proxy = True proxy = True
verbose_name = 'token'
def get_absolute_url(self): def get_absolute_url(self):
return reverse('users:usertoken', args=[self.pk]) return reverse('users:usertoken', args=[self.pk])

View File

@ -62,9 +62,9 @@ class UserTokenTable(NetBoxTable):
class Meta(NetBoxTable.Meta): class Meta(NetBoxTable.Meta):
model = UserToken model = UserToken
fields = [ fields = (
'pk', 'id', 'key', 'description', 'write_enabled', 'created', 'expires', 'last_used', 'allowed_ips', 'pk', 'id', 'key', 'description', 'write_enabled', 'created', 'expires', 'last_used', 'allowed_ips',
] )
class TokenTable(UserTokenTable): class TokenTable(UserTokenTable):
@ -78,9 +78,9 @@ class TokenTable(UserTokenTable):
class Meta(NetBoxTable.Meta): class Meta(NetBoxTable.Meta):
model = Token model = Token
fields = [ fields = (
'pk', 'id', 'key', 'user', 'description', 'write_enabled', 'created', 'expires', 'last_used', 'allowed_ips', 'pk', 'id', 'key', 'user', 'description', 'write_enabled', 'created', 'expires', 'last_used', 'allowed_ips',
] )
class UserTable(NetBoxTable): class UserTable(NetBoxTable):