1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
{% extends "base.html" %}
{% block title %}Rhizi - Sign up{% endblock %}
{% block head %}
{{ super() }}
<script
src="/static/lib/jquery.js"
type="text/javascript"></script>
<script type="text/javascript">
function signup_form___submit() {
function validate_data(data) {
var err_msg_row = $('#err_msg_row'); // reset
err_msg_row.children().remove();
if (data.password_first != data.password_second) {
err_msg_row.append($('<p>passwords do not match</p>'));
err_msg_row.css('display', 'block');
return false;
}
if (data.password_first.length < 8) {
err_msg_row.append($('<p>password too short - must be at least 8 charachters long</p>'));
err_msg_row.css('display', 'block');
return false;
}
// TODO validate email
err_msg_row.css('display', 'none');
return true;
}
var data = {
first_name : $('#signup_form___first_name').val(),
last_name : $('#signup_form___last_name').val(),
rhizi_username : $('#signup_form___rhizi_username').val(),
email_address : $('#signup_form___email_address').val(),
password_first : $('#signup_form___password_first').val(),
password_second : $('#signup_form___password_second').val(),
};
if (false == validate_data(data)) {
return;
}
$.ajax({
type : "POST",
url : '/signup',
async : false,
cache : false,
data : JSON.stringify(data),
dataType : 'json',
contentType : "application/json; charset=utf-8",
success : function(data, status, xhr) {
var signup_form__ajax_response = $('#signup_form__ajax_response'); // reset
signup_form__ajax_response.children().remove();
signup_form__ajax_response.append($(data.response__html));
},
error : function(xhr, status, err_thrown) {
var signup_form__ajax_response = $('#signup_form__ajax_response'); // reset
signup_form__ajax_response.children().remove();
signup_form__ajax_response.append($(data.response__html));
}
});
}
</script>
<style type='text/css'>
#user_signup_form_panel {
width: 550px;
text-align: center;
margin-left: auto;
margin-right: auto;
display: block;
margin-top: 20%;
}
#signup_form___submit_button {
alpha: 0.8;
background-color: #DCEDFD;
border-radius: 3px;
border: 1px solid #4B7CBD;
cursor: pointer;
float: right;
font-weight: bold;
margin: 20px;
padding: 5px;
text-align: center;
width: 140px;
}
.signup_form__row {
overflow: auto;
width: 100%;
}
.signup_form__field {
border-radius: 3px;
border: 1px solid #4B7CBD;
float: left;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
padding-right: 10px;
margin: 5px;
}
.signup_form__row_sharing_field {
display: inline-block;
}
.signup_form__field input {
background-color: inherit;
border: none;
}
.signup_form__field input:focus {
outline: none;
}
#signup_form__title {
margin-bottom: 30px;
}
#signup_form___submit_button_row {
overflow: auto;
}
#signup_form___submit_button:hover {
alpha: 1.0;
}
#signup_form__ajax_response {
margin-top: 30px;
margin: 10px;
}
#err_msg_row {
display: none;
background-color: #DF5C5C;
margin: 10px;
vertical-align: middle;
}
</style>
{% endblock %}
{% block content %}
<div id="user_signup_form_panel">
<h1 id="signup_form__title">Sign up</h1>
{% if 'activation_success' == state %}
<div>
<p>
Congratulations! your account has been activated.<br>Please
head over to the <a href="/login">login page</a> to access
your account.
</p>
</div>
{% elif 'activation_failure' == state %}
<div>
<p>{{ html_str__err }}</p>
</div>
{% else %}
<div
class="signup_form__row"
id="err_msg_row"></div>
<div class="signup_form__row">
<div class="signup_form__field signup_form__row_sharing_field">
<input
id="signup_form___first_name"
placeholder="First name">
</div>
<div class="signup_form__field signup_form__row_sharing_field">
<input
id="signup_form___last_name"
placeholder="Last name">
</div>
</div>
<div class="signup_form__row">
<div class="signup_form__field">
<input
id="signup_form___rhizi_username"
placeholder="Rhizi username">
</div>
</div>
<div class="signup_form__row">
<div class="signup_form__field">
<input
id="signup_form___email_address"
type="email"
placeholder="Email">
</div>
</div>
<div class="signup_form__row">
<div class="signup_form__field">
<input
id="signup_form___password_first"
type="password"
placeholder="password">
</div>
</div>
<div class="signup_form__row">
<div class="signup_form__field">
<input
id="signup_form___password_second"
type="password"
placeholder="password repeat">
</div>
</div>
<div id="signup_form___submit_button_row">
<div
id="signup_form___submit_button"
onclick="signup_form___submit();">Submit</div>
</div>
<div id="signup_form__ajax_response"></div>
{% endif %}
</div>
{% endblock %}
|