{% extends "base.html" %}
{% block title %} Añadir alumnos | {{super}}{%endblock %}

{%block escoge-asignatura%}
  {{informacion.asignatura.slug}}
{%endblock%}

{% block navbar%}
{%include "app/include/menu.html"%}
{%endblock%}

{%block content %} 


    <div class="span8">



  <h1>Añadir listado de alumnos</h1>
  <br>

               <form method="POST" action="{%url aniadir_alumnos_asignatura informacion.asignatura%}" class="form-horizontal">
                  {% csrf_token %}
              

          <div class="control-group">
                                <textarea class="x-large" style="width:100%;"cols="10" rows="10" value="" name="lista"></textarea>
                  </div>


                <div class="form-actions">
                  <div class="pull-right">
                    <input type="submit" class="btn btn-primary btn-large btn-success" value="Crear alumnos" id="salvar" />

                     {%if informacion.atras %}
                      <a href="{{informacion.atras}}" class="btn btn-primary btn-large btn-danger">Volver</a>

                     {% else%}
                     <a href="{%url ver_asignatura asignatura.slug  %}" class="btn btn-primary btn-large btn-danger">Volver</a>
                     {%endif%}
            </div>


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


</div>


{%endblock%}

{% block extra_js%}

  {{super}}

  <script>
$(document).ready(function($) {
    $('button[type=submit]').bind('click', function(e) {
        e.preventDefault() // previene que sea enviado varias veces
        $('#salvar').attr('disabled','true'); // desactiva el boton
        // Envia la peticion
        var args = { type:"POST", url:'{%url aniadir_alumnos_asignatura informacion.asignatura%}', data:$('form').serialize()};
        $.ajax(args);

    });
    $('body').ajaxComplete(function(e, xhr, settings) {
          if (xhr.status == 278) {
              window.location.href = xhr.getResponseHeader("Location").replace(/\?.*$/, "?next="+window.location.pathname);
          }
      });

});
</script>
{% endblock %}