login.html 3.56 KB
Newer Older
1
<%inherit file="base.html" />
2
<%def name="online_help_token()"><% return "login" %></%def>
3 4 5 6
<%!
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
%>
David Baumgold committed
7
<%block name="title">${_("Sign In")}</%block>
8
<%block name="bodyclass">not-signedin view-signin</%block>
9

10
<%block name="content">
11

12 13
<div class="wrapper-content wrapper">
  <section class="content">
14
    <header>
David Baumgold committed
15 16
      <h1 class="title title-1">${_("Sign In to edX Studio")}</h1>
      <a href="${reverse('signup')}" class="action action-signin">${_("Don't have a Studio Account? Sign up!")}</a>
17
    </header>
18 19 20

    <article class="content-primary" role="main">
      <form id="login_form" method="post" action="login_post">
David Baumgold committed
21

22
        <fieldset>
David Baumgold committed
23 24
          <legend class="sr">${_("Required Information to Sign In to edX Studio")}</legend>

25 26
          <ol class="list-input">
            <li class="field text required" id="field-email">
David Baumgold committed
27 28
              <label for="email">${_("Email Address")}</label>
              <input id="email" type="email" name="email" placeholder="e.g. jane.doe@gmail.com" />
29 30 31
            </li>

            <li class="field text required" id="field-password">
David Baumgold committed
32 33 34
              <a href="${forgot_password_link}" class="action action-forgotpassword" tabindex="-1">${_("Forgot password?")}</a>
              <label for="password">${_("Password")}</label>
              <input id="password" type="password" name="password" />
35 36 37 38 39
            </li>
          </ol>
        </fieldset>

        <div class="form-actions">
David Baumgold committed
40
          <button type="submit" id="submit" name="submit" class="action action-primary">${_("Sign In to edX Studio")}</button>
41 42 43 44 45 46 47 48
        </div>

        <!-- no honor code for CMS, but need it because we're using the lms student object -->
        <input name="honor_code" type="checkbox" value="true" checked="true" hidden="true">
      </form>
    </article>

    <aside class="content-supplementary" role="complimentary">
David Baumgold committed
49
      <h2 class="sr">${_("Studio Support")}</h2>
50 51

      <div class="bit">
David Baumgold committed
52 53
        <h3 class="title-3">${_("Need Help?")}</h3>
        <p>${_('Having trouble with your account? Use {link_start}our support center{link_end} to look over self help steps, find solutions others have found to the same problem, or let us know of your issue.').format(link_start='<a href="http://help.edge.edx.org" rel="external">', link_end='</a>')}</p>
54
      </div>
55 56 57 58
    </aside>
  </section>
</div>
</%block>
59

60
<%block name="jsextra">
61
<script type="text/javascript">
62
require(["jquery", "jquery.cookie", "utility"], function($) {
63 64 65 66 67 68
  function postJSON(url, data, callback) {
    $.ajax({type:'POST',
      url: url,
      dataType: 'json',
      data: data,
      success: callback,
69
      headers : {'X-CSRFToken':$.cookie('csrftoken')}
70 71
    });
  }
72

73 74 75
  $('form#login_form').submit(function(e) {
    e.preventDefault();
    var submit_data = $('#login_form').serialize();
76

77 78 79 80
    postJSON('/login_post',
      submit_data,
      function(json) {
        if(json.success) {
81
          var next = /next=([^&]*)/g.exec(decodeURIComponent(window.location.search));
82
          if (next && next.length > 1 && !isExternal(next[1])) {
83 84 85
            location.href = next[1];
          }
          else location.href = "${reverse('homepage')}";
86
        } else if($('#login_error').length == 0) {
87 88
          $('#login_form').prepend('<div id="login_error" class="message message-status error">' + json.value + '</span></div>');
          $('#login_error').addClass('is-shown');
89
        } else {
90
          $('#login_error').stop().addClass('is-shown');
91
          $('#login_error').html(json.value);
92
        }
93 94 95
      }
    );
  });
96
});
97
</script>
David Baumgold committed
98
</%block>