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

Update UserKey views to use "object" context var

This commit is contained in:
Jeremy Stretch
2020-11-19 13:43:17 -05:00
parent 2f1ca902f7
commit e5caea04c1
3 changed files with 10 additions and 10 deletions

View File

@ -3,7 +3,7 @@
{% block title %}User Key{% endblock %} {% block title %}User Key{% endblock %}
{% block usercontent %} {% block usercontent %}
{% if userkey %} {% if object %}
<div class="pull-right noprint"> <div class="pull-right noprint">
<a href="{% url 'user:userkey_edit' %}" class="btn btn-warning"> <a href="{% url 'user:userkey_edit' %}" class="btn btn-warning">
<span class="mdi mdi-pencil" aria-hidden="true"></span> <span class="mdi mdi-pencil" aria-hidden="true"></span>
@ -12,22 +12,22 @@
</div> </div>
<h4> <h4>
Your user key is: Your user key is:
{% if userkey.is_active %} {% if object.is_active %}
<span class="label label-success">Active</span> <span class="label label-success">Active</span>
{% else %} {% else %}
<span class="label label-danger">Inactive</span> <span class="label label-danger">Inactive</span>
{% endif %} {% endif %}
</h4> </h4>
{% include 'inc/created_updated.html' with obj=userkey %} {% include 'inc/created_updated.html' %}
{% if not userkey.is_active %} {% if not object.is_active %}
<div class="alert alert-warning" role="alert"> <div class="alert alert-warning" role="alert">
<i class="mdi mdi-alert"></i> <i class="mdi mdi-alert"></i>
Your user key is inactive. Ask an administrator to enable it for you. Your user key is inactive. Ask an administrator to enable it for you.
</div> </div>
{% endif %} {% endif %}
<pre>{{ userkey.public_key }}</pre> <pre>{{ object.public_key }}</pre>
<hr /> <hr />
{% if userkey.session_key %} {% if object.session_key %}
<div class="pull-right noprint"> <div class="pull-right noprint">
<a href="{% url 'user:sessionkey_delete' %}" class="btn btn-danger"> <a href="{% url 'user:sessionkey_delete' %}" class="btn btn-danger">
<span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span>
@ -35,7 +35,7 @@
</a> </a>
</div> </div>
<h4>Session key: <span class="label label-success">Active</span></h4> <h4>Session key: <span class="label label-success">Active</span></h4>
<small class="text-muted">Created {{ userkey.session_key.created }}</small> <small class="text-muted">Created {{ object.session_key.created }}</small>
{% else %} {% else %}
<h4>No active session key</h4> <h4>No active session key</h4>
{% endif %} {% endif %}

View File

@ -5,7 +5,7 @@
{% block title %}User Key{% endblock %} {% block title %}User Key{% endblock %}
{% block usercontent %} {% block usercontent %}
{% if userkey.is_active %} {% if object.is_active %}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
<strong>Warning:</strong> Changing your public key will require your user key to be re-activated by another <strong>Warning:</strong> Changing your public key will require your user key to be re-activated by another
user. You will be unable to retrieve any secrets until your key has been reactivated. user. You will be unable to retrieve any secrets until your key has been reactivated.

View File

@ -185,7 +185,7 @@ class UserKeyView(LoginRequiredMixin, View):
userkey = None userkey = None
return render(request, self.template_name, { return render(request, self.template_name, {
'userkey': userkey, 'object': userkey,
'active_tab': 'userkey', 'active_tab': 'userkey',
}) })
@ -205,7 +205,7 @@ class UserKeyEditView(LoginRequiredMixin, View):
form = UserKeyForm(instance=self.userkey) form = UserKeyForm(instance=self.userkey)
return render(request, self.template_name, { return render(request, self.template_name, {
'userkey': self.userkey, 'object': self.userkey,
'form': form, 'form': form,
'active_tab': 'userkey', 'active_tab': 'userkey',
}) })