{% extends "administration/base.html" %}

{% block page_title %}{{action}} User{% endblock %}

{% block content %}

<div class='user'>
    {% if edit_user %}
    <form action="{% url 'user_edit' edit_user.id %}" method="post">
    {% else %}
    <form action="{% url 'user_create' %}" method="post">
    {% endif %}
      {% csrf_token %}
      {{ user_form.as_p }}
      <input type="submit" name='user' value="{{action}} user" class='btn btn-primary' />
    </form>

    {% if edit_user %}
    <form action="{% url 'user_edit' edit_user.id %}" method="post">
      {% csrf_token %}
      {{ password_form.as_p }}
      <p>Note: if you change your password, your API key will also be changed to a new, randomly generated one.</p>
      <input type="submit" name='password' value="Change Password" class='btn btn-primary' />
    </form>
    {% endif %}

    {% if edit_user and edit_user.api_key %}
    <p>
      <label>API key:</label>
      <code>{{ edit_user.api_key.key }}</code>
    </p>
    {% endif %}
</div>
{% endblock %}
