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

View File

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

View File

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

View File

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

View File

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