api_tokens.html 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. {% if perms.users.change_token %}
  12. <a href="{% url 'user:token_edit' pk=token.pk %}" class="btn btn-xs btn-warning">Edit</a>
  13. {% endif %}
  14. {% if perms.users.delete_token %}
  15. <a href="{% url 'user:token_delete' pk=token.pk %}" class="btn btn-xs btn-danger">Delete</a>
  16. {% endif %}
  17. </div>
  18. <i class="fa fa-key"></i> {{ token.key }}
  19. {% if token.is_expired %}
  20. <span class="label label-danger">Expired</span>
  21. {% endif %}
  22. </div>
  23. <div class="panel-body">
  24. <div class="row">
  25. <div class="col-md-4">
  26. <span title="{{ token.created }}">{{ token.created|date }}</span><br />
  27. <small class="text-muted">Created</small>
  28. </div>
  29. <div class="col-md-4">
  30. {% if token.expires %}
  31. <span title="{{ token.expires }}">{{ token.expires|date }}</span><br />
  32. {% else %}
  33. <span>Never</span><br />
  34. {% endif %}
  35. <small class="text-muted">Expires</small>
  36. </div>
  37. <div class="col-md-4">
  38. {% if token.write_enabled %}
  39. <span class="label label-success">Enabled</span>
  40. {% else %}
  41. <span class="label label-danger">Disabled</span>
  42. {% endif %}<br />
  43. <small class="text-muted">Create/edit/delete operations</small>
  44. </div>
  45. </div>
  46. {% if token.description %}
  47. <br /><span>{{ token.description }}</span>
  48. {% endif %}
  49. </div>
  50. </div>
  51. {% empty %}
  52. <p>You do not have any API tokens.</p>
  53. {% endfor %}
  54. {% if perms.users.add_token %}
  55. <a href="{% url 'user:token_add' %}" class="btn btn-primary">
  56. <span class="fa fa-plus" aria-hidden="true"></span>
  57. Add a token
  58. </a>
  59. {% else %}
  60. <div class="alert alert-info text-center" role="alert">
  61. 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.
  62. </div>
  63. {% endif %}
  64. </div>
  65. </div>
  66. {% endblock %}