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

{% load i18n form_tags %}

{% block main_content %}
  <form method="post" style="margin-top: 20px">
    {% csrf_token %}
    <div class="col-sm-offset-4 col-sm-5">
      <div class="form-group{% if form.code.errors %} has-error{% endif %}">
        <label for="id_code">{{ form.code.label }} *</label>
        {{ form.code }}
        {% if form.code.errors %}
          <p class="help-block">
            {% for error in form.code.errors %}
              {{ error }}
            {% endfor %}
          </p>
        {% endif %}
        <p class="help-block">
          {% blocktrans trimmed %}
            Enter the code you've just received by SMS
          {% endblocktrans %}
        </p>
      </div>
      <button type="submit" class="btn btn-primary col-lg-12">{% trans "Submit" %}</button>
      <a class="pull-right" id="resend_code" href="{% url 'password_reset_resend_code' %}">
        {% trans "Resend code" %}
      </a>
    </div>
  </form>
{% endblock %}

{% block extra_js %}
  <script type="text/javascript">
  $(document).ready(function () {
      $('#resend_code').click(function (evt) {
          evt.preventDefault();
          var $this = $(this);
          $.get($this.attr('href')).done(function (response) {
              alert('The code has been sent again');
          });
      });
  });
  </script>
{% endblock %}
