2012-05-17 14:02:47 +08:00
|
|
|
{% extends "admin_base.html" %}
|
2013-04-20 14:34:40 +08:00
|
|
|
{% load seahub_tags i18n %}
|
2012-03-22 20:33:27 +08:00
|
|
|
{% block nav_useradmin_class %}class="cur"{% endblock %}
|
2012-03-09 10:31:35 +08:00
|
|
|
|
2013-04-20 14:34:40 +08:00
|
|
|
{% block main_panel %}
|
|
|
|
|
2012-11-01 15:09:14 +08:00
|
|
|
<h3>{% trans "All Members" %}</h3>
|
2013-04-23 10:25:44 +08:00
|
|
|
<button class="add" id="add-user-btn">{% trans "Add new user" %}</button>
|
2013-10-14 14:13:15 +08:00
|
|
|
<button class="icon-search fright" id="search-user-btn"> {% trans "Search" %}</button>
|
2013-09-07 11:44:21 +08:00
|
|
|
|
2013-05-03 11:37:57 +08:00
|
|
|
<form id="add-user-form" action="" method="post" class="hide">{% csrf_token %}
|
2013-04-23 10:25:44 +08:00
|
|
|
<h3>{% trans "Add new user" %}</h3>
|
|
|
|
<label for="id_email">{% trans "Email" %}</label><br />
|
|
|
|
<input type="text" name="email" id="id_email" class="input" /><br />
|
|
|
|
<label for="id_password1">{% trans "Password" %}</label><br />
|
|
|
|
<input type="password" name="password1" id="id_password1" class="input" /><br />
|
|
|
|
<label for="id_password2">{% trans "Confirm Password" %}</label><br />
|
|
|
|
<input type="password" name="password2" id="id_password2" class="input" /><br />
|
|
|
|
<p class="error hide"></p>
|
|
|
|
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
|
|
|
</form>
|
2013-04-20 14:34:40 +08:00
|
|
|
|
2013-10-17 11:11:08 +08:00
|
|
|
{% include "sysadmin/useradmin_table.html"%}
|
2012-02-21 17:11:58 +08:00
|
|
|
|
2012-07-27 11:39:55 +08:00
|
|
|
<div id="paginator">
|
|
|
|
{% if current_page != 1 %}
|
2012-11-01 15:09:14 +08:00
|
|
|
<a href="{{ SITE_ROOT }}sys/useradmin/?page={{ prev_page }}&per_page={{ per_page }}">{% trans "Previous" %}</a>
|
2012-07-27 11:39:55 +08:00
|
|
|
{% endif %}
|
|
|
|
{% if page_next %}
|
2012-11-01 15:09:14 +08:00
|
|
|
<a href="{{ SITE_ROOT }}sys/useradmin/?page={{ next_page }}&per_page={{ per_page }}">{% trans "Next" %}</a>
|
|
|
|
{% endif %}
|
|
|
|
{% if current_page != 1 or page_next %}
|
|
|
|
|
|
2012-07-27 11:39:55 +08:00
|
|
|
{% endif %}
|
2012-11-01 15:09:14 +08:00
|
|
|
<span>{% trans "Per page: " %}</span>
|
2012-07-27 11:39:55 +08:00
|
|
|
{% if per_page == 25 %}
|
|
|
|
<span> 25 </span>
|
|
|
|
{% else %}
|
|
|
|
<a href="{{ SITE_ROOT}}sys/useradmin/?per_page=25" class="per-page">25</a>
|
|
|
|
{% endif %}
|
|
|
|
{% if per_page == 50 %}
|
|
|
|
<span> 50 </span>
|
|
|
|
{% else %}
|
|
|
|
<a href="{{ SITE_ROOT}}sys/useradmin/?per_page=50" class="per-page">50</a>
|
|
|
|
{% endif %}
|
|
|
|
{% if per_page == 100 %}
|
|
|
|
<span> 100 </span>
|
|
|
|
{% else %}
|
|
|
|
<a href="{{ SITE_ROOT}}sys/useradmin/?per_page=100" class="per-page">100</a>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
|
2012-02-21 17:11:58 +08:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block extra_script %}
|
2012-03-22 20:33:27 +08:00
|
|
|
<script type="text/javascript">
|
2013-09-07 11:44:21 +08:00
|
|
|
$('#search-user-btn').click(function() {
|
|
|
|
location.href = "{% url 'user_search' %}";
|
|
|
|
});
|
|
|
|
|
2013-04-23 10:25:44 +08:00
|
|
|
$('#add-user-form').submit(function() {
|
|
|
|
var form = $(this),
|
|
|
|
form_id = $(this).attr('id'),
|
|
|
|
email = $.trim(form.children('[name="email"]').val()),
|
|
|
|
pwd1 = $.trim(form.children('[name="password1"]').val()),
|
|
|
|
pwd2 = $.trim(form.children('[name="password2"]').val());
|
|
|
|
|
|
|
|
if (!email) {
|
2013-04-24 17:09:46 +08:00
|
|
|
apply_form_error(form_id, "{% trans "Email cannot be blank" %}");
|
2013-04-23 10:25:44 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!pwd1) {
|
2013-04-24 17:09:46 +08:00
|
|
|
apply_form_error(form_id, "{% trans "Password cannot be blank" %}");
|
2013-04-23 10:25:44 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!pwd2) {
|
2013-04-24 17:09:46 +08:00
|
|
|
apply_form_error(form_id, "{% trans "Please enter the password again" %}");
|
2013-04-23 10:25:44 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (pwd1 != pwd2) {
|
2013-10-17 11:11:08 +08:00
|
|
|
apply_form_error(form_id, "{% trans "Passwords do not match" %}");
|
2013-04-23 10:25:44 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-17 11:11:08 +08:00
|
|
|
var submit_btn = $(this).find('input[type="submit"]');
|
|
|
|
disable(submit_btn);
|
2013-04-23 10:25:44 +08:00
|
|
|
$.ajax({
|
|
|
|
url: '{% url 'user_add' %}',
|
|
|
|
type: 'POST',
|
2013-05-17 13:41:37 +08:00
|
|
|
datatype: 'json',
|
2013-04-23 10:25:44 +08:00
|
|
|
cache: 'false',
|
|
|
|
beforeSend: prepareCSRFToken,
|
|
|
|
data: {
|
|
|
|
'email': email,
|
|
|
|
'password1': pwd1,
|
|
|
|
'password2': pwd2
|
2013-05-17 13:41:37 +08:00
|
|
|
},
|
2013-04-23 10:25:44 +08:00
|
|
|
success: function(data) {
|
|
|
|
if (data['success']) {
|
|
|
|
location.reload(true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
|
|
if (jqXHR.responseText) {
|
|
|
|
apply_form_error(form_id, $.parseJSON(jqXHR.responseText).err);
|
|
|
|
} else {
|
2013-04-24 17:09:46 +08:00
|
|
|
apply_form_error(form_id, "{% trans "Failed. Please check the network." %}");
|
2013-04-23 10:25:44 +08:00
|
|
|
}
|
2013-10-17 11:11:08 +08:00
|
|
|
enable(submit_btn);
|
2013-04-23 10:25:44 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
2013-10-17 11:11:08 +08:00
|
|
|
|
|
|
|
{% include "sysadmin/useradmin_js.html" %}
|
2012-02-21 17:11:58 +08:00
|
|
|
</script>
|
|
|
|
{% endblock %}
|