signup_modal.html 7.51 KB
Newer Older
Galen Frechette committed
1
<%namespace name='static' file='static_content.html'/>
2 3 4 5 6 7 8 9
<%!
from django.conf import settings
from django.core.urlresolvers import reverse
from django_countries import countries
from student.models import UserProfile
from datetime import date
import calendar
%>
Galen Frechette committed
10

11
<section id="signup-modal" class="modal signup-modal">
Galen Frechette committed
12
  <div class="inner-wrapper">
13
    <button class="close-modal">
14
      <span class="icon fa fa-remove" aria-hidden="true"></span>
15 16
      <span class="sr">
        ## Translators: this is a control to allow users to exit out of this modal interface (a menu or piece of UI that takes the full focus of the screen)
17
        ${_('Close')}
18 19
      </span>
    </button>
20

21
    <div id="register">
22
      <header>
23 24
        <h2>
	  ${_('Sign Up for {platform_name}').format(
25
	      platform_name=u'<span class="edx">{}</span>'.format(settings.PLATFORM_NAME)
26 27
	  )}
	</h2>
28 29
        <hr>
      </header>
Galen Frechette committed
30

31
      <form id="register_form" class="register_form" method="post" data-remote="true" action="/create_account">
Matthew Mongeau committed
32
        <div class="notice"></div>
33 34
        <div id="register_error" class="modal-form-error" name="register_error"></div>
        <div id="register_error" name="register_error"></div>
35 36

        <div class="input-group">
ichuang committed
37
	  % if has_extauth_info is UNDEFINED:
38
          <label data-field="email" for="signup_email">${_('E-mail')} + ' *'</label>
39 40
	    <input id="signup_email" type="email" name="email" placeholder="${_('e.g. yourname@domain.com')}" required />

41
          <label data-field="password" for="signup_password">${_('Password')} + ' *'</label>
42
	    <input id="signup_password" type="password" name="password" placeholder="&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;" required />
43

44
	  <label data-field="username" for="signup_username">${_('Public Username')} + ' *'</label>
45 46
	    <input id="signup_username" type="text" name="username" placeholder="${_('e.g. yourname (shown on forums)')}" required />

47
          <label data-field="name" for="signup_fullname">${_('Full Name')} + ' *'</label>
48
	    <input id="signup_fullname" type="text" name="name" placeholder="${_('e.g. Your Name (for certificates)')}" required />
ichuang committed
49
	  % else:
50 51 52
	  <p>${_('<i>Welcome</i> {name}').format(name=extauth_id)}</p><br/>
	  <p><i>${_('Enter a public username:')}</i></p>

53
          <label data-field="username" for="signup_username">${_('Public Username')} + ' *'</label>
54
	      <input id="signup_username" type="text" name="username" value="${extauth_username}" placeholder="${_('e.g. yourname (shown on forums)')}" required />
55 56

          % if ask_for_email:
57
            <label data-field="email" for="signup_email">${_('E-mail')} + ' *'</label>
58
            <input id="signup_email" type="email" name="email" placeholder="${_('e.g. yourname@domain.com')}" required />
59 60
          % endif

61

62
          % if ask_for_fullname:
63 64
            <label data-field="name" for="signup_fullname">${_("Full Name *")}</label>
            <input id="signup_fullname" type="text" name="name" placeholder="${_('e.g. Your Name (for certificates)')}" required />
65
          % endif
66

ichuang committed
67
	  % endif
68 69 70
        </div>

        <div class="input-group">
71

72
          % if settings.REGISTRATION_EXTRA_FIELDS['level_of_education'] != 'hidden':
73
          <section class="citizenship">
74
            <label data-field="level_of_education" for="signup_ed_level">${_("Ed. Completed")}</label>
75
            <div class="input-wrapper">
76
              <select id="signup_ed_level" name="level_of_education">
77
                  <option value="">--</option>
78
                  %for code, ed_level in UserProfile.LEVEL_OF_EDUCATION_CHOICES:
79
                      <option value="${code}">${_(ed_level)}</option>
80 81 82 83
                  %endfor
              </select>
            </div>
          </section>
84
          % endif
85

86
          % if settings.REGISTRATION_EXTRA_FIELDS['gender'] != 'hidden':
87
          <section class="gender">
88
            <label data-field="gender" for="signup_gender">${_("Gender")}</label>
89
            <div class="input-wrapper">
90
              <select id="signup_gender" name="gender">
91
                  <option value="">--</option>
92
                  %for code, gender in UserProfile.GENDER_CHOICES:
93
                      <option value="${code}">${_(gender)}</option>
94 95 96 97
                  %endfor
              </select>
            </div>
          </section>
98
          % endif
99

100
          % if settings.REGISTRATION_EXTRA_FIELDS['year_of_birth'] != 'hidden':
101
          <section class="date-of-birth">
102
            <label data-field="date-of-birth" for="signup_birth_year">${_("Year of birth")}</label>
103
            <div class="input-wrapper">
104
              <select id="signup_birth_year" name="year_of_birth">
105 106 107 108 109 110
                <option value="">--</option>
                %for year in UserProfile.VALID_YEARS:
                  <option value="${year}">${year}</option>
                %endfor
              </select>
              ##<input name="year_of_birth" type="text" placeholder="Year of birth">
111 112
            </div>
          </section>
113
          % endif
114

115
          % if settings.REGISTRATION_EXTRA_FIELDS['mailing_address'] != 'hidden':
116
          <label data-field="mailing_address" for="signup_mailing_address">${_("Mailing address")}</label>
117
	    <textarea id="signup_mailing_address" name="mailing_address"></textarea>
118
          % endif
119

120
          % if settings.REGISTRATION_EXTRA_FIELDS['goals'] != 'hidden':
121
          <label data-field="goals" for="signup_goals">${_("Goals in signing up for {platform_name}").format(platform_name=settings.PLATFORM_NAME)}</label>
122
	    <textarea name="goals" id="signup_goals"></textarea>
123
          % endif
124

125 126 127
        </div>

        <div class="input-group">
128 129
          <label data-field="terms_of_service" class="terms-of-service" for="signup_tos">
            <input id="signup_tos" name="terms_of_service" type="checkbox" value="true">
130
            ${_('I agree to the {link_start}Terms of Service{link_end}').format(
131
              link_start='<a href="{url}" target="_blank">'.format(url=reverse('tos')),
132
              link_end='</a>') + ' *'}
133 134
          </label>

135
          % if settings.REGISTRATION_EXTRA_FIELDS['honor_code'] != 'hidden':
136 137
          <label data-field="honor_code" class="honor-code" for="signup_honor">
            <input id="signup_honor" name="honor_code" type="checkbox" value="true">
138
            ${_('I agree to the {link_start}Honor Code{link_end}').format(
139
              link_start='<a href="{url}" target="_blank">'.format(url=reverse('honor')),
140
              link_end='</a>') + ' *'}
141
          </label>
142
          % endif
143
        </div>
Galen Frechette committed
144

145
        <div class="submit">
146
          <input name="submit" type="submit" value="${_('Create My Account')}">
147 148 149
        </div>
      </form>

ichuang committed
150
      % if has_extauth_info is UNDEFINED:
151 152
      <section class="login-extra">
        <p>
153
          <span>${_("Already have an account?")} <a href="#login-modal" class="close-signup" rel="leanModal">${_("Login.")}</a></span>
154 155
        </p>
      </section>
ichuang committed
156
      % endif
157 158

    </div>
Galen Frechette committed
159 160
  </div>
</section>
Matthew Mongeau committed
161 162 163

<script type="text/javascript">
  (function() {
164
   $(document).delegate('#register_form', 'ajax:success', function(data, json, xhr) {
165 166 167 168 169 170 171
     location.href="${reverse('dashboard')}";
    });
   $(document).delegate('#register_form', 'ajax:error', function(event, jqXHR, textStatus) {
     json = $.parseJSON(jqXHR.responseText);
     $(".field-error").removeClass('field-error');
     $('#register_error').html(json.value).stop().css("display", "block");
     $("[data-field='"+json.field+"']").addClass('field-error')
Matthew Mongeau committed
172
    });
173

174 175 176 177
   // removing close link's default behavior
   $('#login-modal .close-modal').click(function(e) {
    e.preventDefault();
   });
Matthew Mongeau committed
178 179
  })(this)
</script>