{% extends "sentry/bases/account.html" %}

{% load crispy_forms_tags %}
{% load i18n %}
{% load sentry_helpers %}
{% load sentry_features %}
{% block wrapperclass %}narrow account-settings{% endblock %}

{% block title %}{% trans "Account Settings" %} | {{ block.super }}{% endblock %}

{% block main %}
    <form action="" method="post">
        {% csrf_token %}
        {{ form|as_crispy_errors }}

        {% if request.user.has_unverified_emails %}
          <div class="alert alert-warning alert-block">
            {% trans "Your email address has not been verified. " %}
            <a href="{% url 'sentry-account-confirm-email-send' %}">{% trans "Resend Verification Email" %}</a>.
          </div>
        {% endif %}

        <legend style="margin-top: 0;">Your details</legend>

        <div class="account-settings-overview">
          <div class="avatar-preview">
            <label class="control-label">Avatar</label>
            <div>
              <a class="avatar-edit-link" href="{% url 'sentry-account-settings-avatar' %}">
                <span class="avatar">
                {% letter_avatar_svg request.user.get_display_name request.user.get_label size 118 %}
                {% if request.user.get_avatar_type == 'upload' %}
                    <img src="{% profile_photo_url request.user.id size 118 %}">
                {% elif request.user.get_avatar_type == 'gravatar' %}
                    <img src="{% gravatar_url user.email size 118 default 'blank' %}">
                {% endif %}
                </span>
                <span class="icon-settings"></span>
              </a>
            </div>
          </div>
          <div class="account-settings-body">
            {% with form.name as field %}
              {{ field|as_crispy_field }}
            {% endwith %}
            {% if form.username %}
              {% with form.username as field %}
                {{ field|as_crispy_field }}
              {% endwith %}
            {% endif %}
            {% with form.email as field %}
              {{ field|as_crispy_field }}
            {% endwith %}
            {% if form.new_password %}
              <p class="help-block pull-right" style="margin-top: 0">({% trans "Optional" %})</p>
              {% with form.new_password as field %}
                {{ field|as_crispy_field }}
              {% endwith %}
            {% endif %}
          </div>
        </div>

        {% if form.password %}
          <legend>{% trans "Verification"  %}</legend>
          {% with form.password as field %}
              {{ field|as_crispy_field }}
          {% endwith %}
        {% endif %}

        {% if not form.is_readonly %}
          <fieldset class="form-actions">
              <button type="submit" class="btn btn-primary">{% trans "Save Changes" %}</button>
          </fieldset>
        {% endif %}
    </form>
{% endblock %}
