api_tokens.html 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. {% extends 'users/_user.html' %}
  2. {% load helpers %}
  3. {% block title %}API Tokens{% endblock %}
  4. {% block usercontent %}
  5. <div class="row">
  6. <div class="col-md-12">
  7. {% for token in tokens %}
  8. <div class="panel panel-{% if token.is_expired %}danger{% else %}default{% endif %}">
  9. <div class="panel-heading">
  10. <div class="pull-right noprint">
  11. <a class="btn btn-xs btn-success copy-token" data-clipboard-target="#token_{{ token.pk }}">Copy</a>
  12. {% if perms.users.change_token %}
  13. <a href="{% url 'user:token_edit' pk=token.pk %}" class="btn btn-xs btn-warning">Edit</a>
  14. {% endif %}
  15. {% if perms.users.delete_token %}
  16. <a href="{% url 'user:token_delete' pk=token.pk %}" class="btn btn-xs btn-danger">Delete</a>
  17. {% endif %}
  18. </div>
  19. <i class="fa fa-key"></i>
  20. <span id="token_{{ token.pk }}">{{ token.key }}</span>
  21. {% if token.is_expired %}
  22. <span class="label label-danger">Expired</span>
  23. {% endif %}
  24. </div>
  25. <div class="panel-body">
  26. <div class="row">
  27. <div class="col-md-4">
  28. <span title="{{ token.created }}">{{ token.created|date }}</span><br />
  29. <small class="text-muted">Created</small>
  30. </div>
  31. <div class="col-md-4">
  32. {% if token.expires %}
  33. <span title="{{ token.expires }}">{{ token.expires|date }}</span><br />
  34. {% else %}
  35. <span>Never</span><br />
  36. {% endif %}
  37. <small class="text-muted">Expires</small>
  38. </div>
  39. <div class="col-md-4">
  40. {% if token.write_enabled %}
  41. <span class="label label-success">Enabled</span>
  42. {% else %}
  43. <span class="label label-danger">Disabled</span>
  44. {% endif %}<br />
  45. <small class="text-muted">Create/edit/delete operations</small>
  46. </div>
  47. </div>
  48. {% if token.description %}
  49. <br /><span>{{ token.description }}</span>
  50. {% endif %}
  51. </div>
  52. </div>
  53. {% empty %}
  54. <p>You do not have any API tokens.</p>
  55. {% endfor %}
  56. {% if perms.users.add_token %}
  57. <a href="{% url 'user:token_add' %}" class="btn btn-primary">
  58. <span class="fa fa-plus" aria-hidden="true"></span>
  59. Add a token
  60. </a>
  61. {% else %}
  62. <div class="alert alert-info text-center" role="alert">
  63. You do not have permission to create new API tokens. If needed, ask an administrator to enable token creation for your account or an assigned group.
  64. </div>
  65. {% endif %}
  66. </div>
  67. </div>
  68. {% endblock %}
  69. {% block javascript %}
  70. <script type="text/javascript">
  71. new ClipboardJS('.copy-token');
  72. </script>
  73. {% endblock %}