{% extends 'yaccounts/base.html' %}

{% load i18n %}

{% load staticfiles %}

{% block body %}

<div class="container">
  <div class="row">
    <div class="col-sm-6 col-md-4 col-md-offset-4">
      <h1 class="text-center login-title">{% trans 'Create Account' %}</h1>
      
      <!-- Frame -->
      <div class="account-wall">

        <img class="profile-img" src="{{ avatar }}" alt="Avatar">
        <p style="text-align: center; font-weight: bold;">{{ username }}</p>
        
        <!-- Django Messages -->
        {% include 'yaccounts/django_messages.html' %}

        <!-- Email Login -->
        <form class="form-signup" method="POST" action="{{ post_url }}">
          {% csrf_token %}

          <p>
            {% trans 'In order to activate your account, please provide us your e-mail address.' %}
          </p>

          <!-- Email -->
          <input type="text" class="form-control" placeholder="{% trans 'Email' %}" name="email" value="{{ email }}" required>
          <br>
          
          <!-- Page to redirect after login -->
          {% if next %}
            <input type="hidden" name="next" value="{{ next }}">
          {% endif %}
          
          <!-- Submit -->
          <button class="btn btn-lg btn-default btn-primary btn-block" type="submit">{% trans 'Activate' %}</button>

          <span class="clearfix"></span>
        </form>
      
      </div>

      <a href="{% url 'yaccounts:login' %}" class="text-center new-account">{% trans 'Already have an account?' %}</a>

    </div>
  </div>
</div>

{% endblock %}

{% block javascript %}
  <script>
      $(document).ready(function() {
          $('form button[type="submit"]').on('click', function() { $('form button[type="submit"]').attr('disabled', true); $('form').submit(); } );
      });    
  </script>
{% endblock %}