You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

270 lines
10 KiB

9 years ago
9 years ago
  1. {% extends "base.html" %}
  2. {% load compress static hc_extras %}
  3. {% block title %}Account Settings - {{ site_name }}{% endblock %}
  4. {% block content %}
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <h1 class="settings-title">
  8. Settings
  9. <small>{{ request.user.email }}</small>
  10. </h1>
  11. </div>
  12. {% if messages %}
  13. <div class="col-sm-12">
  14. {% for message in messages %}
  15. <p class="alert alert-{{ message.tags }}">{{ message }}</p>
  16. {% endfor %}
  17. </div>
  18. {% endif %}
  19. </div>
  20. <div class="row">
  21. <div class="col-sm-3">
  22. <ul class="nav nav-pills nav-stacked">
  23. <li class="active"><a href="{% url 'hc-profile' %}">Account</a></li>
  24. <li><a href="{% url 'hc-appearance' %}">Appearance</a></li>
  25. {% if show_pricing %}
  26. <li><a href="{% url 'hc-billing' %}">Billing</a></li>
  27. {% endif %}
  28. <li><a href="{% url 'hc-notifications' %}">Email Reports</a></li>
  29. </ul>
  30. </div>
  31. <div class="col-sm-9 col-md-6">
  32. <div class="panel panel-{{ email_password_status|default:'default' }}">
  33. <div class="panel-body settings-block">
  34. <form method="post">
  35. {% csrf_token %}
  36. <h2>Email and Password</h2>
  37. <p class="settings-bar">
  38. Your account's email address is
  39. <code>{{ request.user.email }}</code>
  40. <a
  41. href="{% url 'hc-change-email' %}"
  42. class="btn btn-default pull-right">Change Email</a>
  43. </p>
  44. <p class="clearfix"></p>
  45. {% if request.user.has_usable_password %}
  46. <p class="settings-bar">
  47. Password authentication is enabled.
  48. <a
  49. href="{% url 'hc-set-password' %}"
  50. class="btn btn-default pull-right">Change Password</a>
  51. </p>
  52. {% else %}
  53. <p class="settings-bar">
  54. Attach a password to your {{ site_name }} account.
  55. <a
  56. href="{% url 'hc-set-password' %}"
  57. class="btn btn-default pull-right">Set Password</a>
  58. </p>
  59. {% endif %}
  60. </form>
  61. </div>
  62. {% if changed_password %}
  63. <div class="panel-footer">
  64. Your new password has been set!
  65. </div>
  66. {% endif %}
  67. </div>
  68. {% if use_2fa %}
  69. <div class="panel panel-{{ 2fa_status }}">
  70. <div class="panel-body settings-block">
  71. <form method="post">
  72. {% csrf_token %}
  73. <h2>Two-factor Authentication</h2>
  74. {% if credentials %}
  75. <table id="my-keys" class="table">
  76. <tr>
  77. <th>Security keys</th>
  78. </tr>
  79. {% for credential in credentials %}
  80. <tr>
  81. <td>
  82. <strong>{{ credential.name|default:"unnamed" }}</strong>
  83. – registered on {{ credential.created|date:"M j, Y" }}
  84. </td>
  85. <td class="text-right">
  86. <a href="{% url 'hc-remove-credential' credential.code %}">Remove</a>
  87. </td>
  88. </tr>
  89. {% endfor %}
  90. </table>
  91. {% if credentials|length == 1 %}
  92. <p class="alert alert-info">
  93. <strong>Tip: add a second key!</strong>
  94. It is a good practice to register at least two security keys
  95. and store them separately.
  96. </p>
  97. {% endif %}
  98. {% else %}
  99. <p>
  100. Two-factor authentication is not enabled yet.<br />
  101. Your account has no registered security keys.
  102. </p>
  103. {% endif %}
  104. <a
  105. href="{% url 'hc-add-credential' %}"
  106. class="btn btn-default pull-right">
  107. Register New Security Key
  108. </a>
  109. </form>
  110. </div>
  111. {% if added_credential_name %}
  112. <div class="panel-footer">
  113. Added security key <strong>{{ added_credential_name }}</strong>.
  114. </div>
  115. {% endif %}
  116. {% if removed_credential_name %}
  117. <div class="panel-footer">
  118. Removed security key <strong>{{ removed_credential_name }}</strong>.
  119. </div>
  120. {% endif %}
  121. </div>
  122. {% endif %}
  123. <div class="panel panel-{{ my_projects_status }}">
  124. <div class="panel-body settings-block">
  125. {% csrf_token %}
  126. <h2>My Projects</h2>
  127. {% if profile.projects.exists %}
  128. <table id="my-projects" class="table">
  129. <tr>
  130. <th>Project</th>
  131. <th>My role</th>
  132. <th></th>
  133. </tr>
  134. {% for project in request.user.project_set.all %}
  135. <tr>
  136. <td>
  137. <div class="name">
  138. <a href="{% url 'hc-checks' project.code %}">
  139. {{ project }}
  140. </a>
  141. </div>
  142. </td>
  143. <td>Owner</td>
  144. <td>
  145. <a
  146. href="{% url 'hc-project-settings' project.code %}"
  147. class="pull-right">Settings</a>
  148. </td>
  149. </tr>
  150. {% endfor %}
  151. {% for m in request.user.memberships.all %}
  152. <tr>
  153. <td>
  154. <div class="name">
  155. <a href="{% url 'hc-checks' m.project.code %}">
  156. {{ m.project }}
  157. </a>
  158. </div>
  159. </td>
  160. <td>
  161. {% if m.rw %}
  162. Member
  163. {% else %}
  164. Read-only
  165. {% endif %}
  166. </td>
  167. <td>
  168. <a
  169. href="#"
  170. data-name="{{ m.project }}"
  171. data-code="{{ m.project.code }}"
  172. class="pull-right leave-project">Leave</a>
  173. </td>
  174. </tr>
  175. {% endfor %}
  176. </table>
  177. {% else %}
  178. <p>You do not have any projects. Create one!</p>
  179. {% endif %}
  180. <a
  181. id="create-project"
  182. href="#"
  183. class="btn btn-default pull-right"
  184. data-toggle="modal"
  185. data-target="#add-project-modal">Create a New Project</a>
  186. </div>
  187. {% if left_project %}
  188. <div class="panel-footer">
  189. Left project <strong>{{ left_project }}</strong>.
  190. </div>
  191. {% endif %}
  192. </div>
  193. <div class="panel panel-default">
  194. <div class="panel-body settings-block">
  195. {% csrf_token %}
  196. <h2>Close Account</h2>
  197. <p>This will permanently remove your {{ site_name }} account.</p>
  198. <div class="text-right">
  199. <a
  200. id="close-account"
  201. href="{% url 'hc-close' %}"
  202. class="btn btn-default">Close Account</a>
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. <div id="leave-project-modal" class="modal">
  209. <div class="modal-dialog">
  210. <form id="leave-project-form" method="post">
  211. {% csrf_token %}
  212. <div class="modal-content">
  213. <div class="modal-header">
  214. <button type="button" class="close" data-dismiss="modal">&times;</button>
  215. <h4>Leave This Project?</h4>
  216. </div>
  217. <div class="modal-body">
  218. <p>
  219. You are about to leave the project <strong id="leave-project-name"></strong>.
  220. You will lose access to its checks and integrations.
  221. </p>
  222. <p>Are you sure?</p>
  223. <input
  224. type="hidden"
  225. name="code"
  226. id="leave-project-code" />
  227. </div>
  228. <div class="modal-footer">
  229. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  230. <button
  231. type="submit"
  232. name="leave_project"
  233. class="btn btn-danger">Leave Project</button>
  234. </div>
  235. </div>
  236. </form>
  237. </div>
  238. </div>
  239. {% include "accounts/add_project_modal.html" %}
  240. {% endblock %}
  241. {% block scripts %}
  242. {% compress js %}
  243. <script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
  244. <script src="{% static 'js/bootstrap.min.js' %}"></script>
  245. <script src="{% static 'js/add_project_modal.js' %}"></script>
  246. <script src="{% static 'js/profile.js' %}"></script>
  247. {% endcompress %}
  248. {% endblock %}