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

{% load i18n bulma_tags %}

{% block title %}{% trans "Account" %}{% endblock %}
{% block content_title %}<h1 class="title">{% trans "E-mail Addresses" %}</h1>{% endblock %}

{% block content %}

  {% if user.emailaddress_set.all %}
    <p class="content">{% trans 'The following e-mail addresses are associated with your account:' %}</p>

    <form action="{% url 'account_email' %}" class="email_list" method="post">
      {% csrf_token %}
      <div class="content">
        {% for emailaddress in user.emailaddress_set.all %}
          <div class="field">
            <label for="email_radio_{{ forloop.counter }}"
                   class="radio {% if emailaddress.primary %}primary_email{% endif %}">
              <input id="email_radio_{{ forloop.counter }}" type="radio" name="email"
                     {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{% endif %}
                     value="{{ emailaddress.email }}"/>
              {{ emailaddress.email }}
              {% if emailaddress.verified %}
                <span class="verified">{% trans "Verified" %}</span>
              {% else %}
                <span class="unverified">{% trans "Unverified" %}</span>
              {% endif %}
              {% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %}
            </label>
          </div>
        {% endfor %}

        <div class="">
          <button class="button is-primary is-small" type="submit"
                  name="action_primary">{% trans 'Make Primary' %}</button>
          <button class="button is-small" type="submit" name="action_send">{% trans 'Re-send Verification' %}</button>
          <button class="button is-danger is-small" type="submit" name="action_remove">{% trans 'Remove' %}</button>
        </div>

      </div>
    </form>
  {% else %}
    <p>
      <strong>{% trans 'Warning:' %}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}
    </p>
  {% endif %}

  <br/><strong>{% trans "Add E-mail Address" %}</strong>
  <form method="post" action="{% url 'account_email' %}" class="add_email">
    {% csrf_token %}
    {{ form|bulma }}
    <button class="button is-warning" name="action_add" type="submit">{% trans "Add E-mail" %}</button>
  </form>
{% endblock %}