{% extends "layouts/auth.html" %}
{% block title %}{{_("Profiles")}} | {{_('Setup')}}{% endblock %}
{% block content %}

<div class="setup-box setup-box-medium add-top animated bounceInUp">
  <h2 class="text-center"><span class="icon-profiles"></span> Profiles</h2>

  {% if error %}
  <h3>Oh shits {{ error }}</h3>
  {% endif %}
  <hr>
  
  {% if result.profiles %}
  <h3>Configured profiles</h3>
  <ul>
    {% for rid in result.profiles|sort %}
      {% set profile = result.profiles[rid] %}
      <li><form method="POST" action='/profiles/remove/{{ rid }}/'
                target=_blank>
         {{ profile.name }}
         &lt;{{ profile.email }}&gt;
         {% if profile.note %}({{ profile.note }}){% endif %}
         [auto_configurable={{ profile.auto_configurable }}]
         {% if profile.email != result.default_email %}
           &nbsp; &nbsp; <input type='submit' value='Remove'>
         {% endif %}
      </form></li>
    {% endfor %}
  </ul>
  {% endif %}

  {% if result.new_emails %}
    <h3>Discovered e-mail addresses</h3>
    <ul>
      {% for email in result.new_emails|sort %}<li>
        {% set info = result.new_emails[email] %}
        <form method="POST">
          {% if info.name %}{{ info.name }}{% endif %}
          &lt;{{ email }}&gt;
          {% if info.pgp_keys %}(on keys: {{ info.pgp_keys|join(", ") }}){% endif %}
          <input type="hidden" name="email" value="{{ email }}">
          <input type="hidden" name="name" value="{{ info.name }}">
          <input type="submit" value="Add to profiles">
          Account password: <input type="password" name="pass" value="">
        </form>
      </li>{% endfor %}
    </ul>
  {% endif %}
  
  <hr><form method="POST">
    <h3>Add another e-mail address</h3>
    E-mail: <input type="text" name="email" value=""><br>
    Name: <input type="text" name="name" value=""><br>
    Note: <input type="text" name="note" value=""><br>
    <input type="submit" value="Add to profiles">
  </form>
  
  {% if result.profiles %}
  <hr>
  <form method="POST">
    <input type="hidden" name="advance" value="Yes">
    <input type="submit" value="Continue...">   
  </form>
  {% endif %}

</div>

{% endblock %}
