<!DOCTYPE html>
{% load compress %}
<html lang="en">
<head>
  <title>Django Simple Forum</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  {% compress css %}
  <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/login.css">
  {% endcompress %}
</head>
<body>

<body>
<div class="container">
      <div class="col-md-offset-3 col-md-6 col-md-offset-3 login">
        <span class="text">
          <span class="login_page_heading">Django Simple Forum</span>
        </span>
        <form id="loginform" name="loginform" method="post">
          {% csrf_token %}
          <section id='sign_in' class="sign-in">
              <h5 class="content-group">Login to your account <small class="display-block">Please put your credentials</small></h5>
              <div class="form-group">
                <div class="input-group">
                  <div class="input-group-addon"><i class="fa fa-envelope"></i></div>
                  <input type="email" name="{{form.username.html_name}}" id="{{ form.username.auto_id }}"  class="form-control" placeholder="Email">
                  <span class="error">{{form.username.errors.as_text}}</span>
                </div>
              </div>
              <div class="form-group">
                <div class="input-group">
                  <div class="input-group-addon"><i class="fa fa-lock"></i></div>
                  <input type="password"name="{{form.password.html_name}}" id="{{ form.password.auto_id }}" class="form-control" placeholder="Password">
              <span class="error">{{form.password.errors.as_text}}</span>
                </div>
              </div>
              <!--<div class="row mar-r-l">
                <div class="col-sm-6 text-right forgot">
                  <a href="#">Forgot password?</a>
                </div>
              </div>-->
              <div class="button_row_login">
                <button class="sign_in_button" type="submit"><i class="fa fa-sign-in"></i>Sign In</button>
              </div>
            </section>
        </form>
      </div>
  </div>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
    <script type="text/javascript">
      $('form#loginform').submit(function(e){
        e.preventDefault();
        $.post('.', $('form#loginform').serialize(), function(data){
          if(data.error){
            alert(data.response);
          }
          else{
            window.location = "{% url "django_simple_forum:dashboard" %}";
          }
        }, 'json');
      });
    </script>
</body>
</html>
