1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 16:36:15 +00:00
Files
seahub/templates/sys_useradmin.html

157 lines
5.7 KiB
HTML

{% extends "admin_base.html" %}
{% load seahub_tags i18n %}
{% load url from future %}
{% block nav_useradmin_class %}class="cur"{% endblock %}
{% block main_panel %}
<h3>{% trans "All Members" %}</h3>
<button class="add" id="add-user-btn">{% trans "Add new user" %}</button>
<form id="add-user-form" action="" method="post" class="hide">
<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>
<table>
<tr>
<th width="40%">{% trans "Email" %}</th>
<th width="12%">{% trans "Status" %}</th>
<th width="18%">{% trans "Create At" %}</th>
<th width="30%">{% trans "Operations" %}</th>
</tr>
{% for user in users %}
<tr>
<td><a href="{{ SITE_ROOT }}useradmin/info/{{ user.props.email }}/">{{ user.email }}</a></td>
{% if user.props.is_active %}
<td>{% trans "Activated" %}</td>
{% else %}
<td><a href="{{ SITE_ROOT }}useradmin/activate/{{ user.props.id }}/" class="activate op">{% trans "Active" %}</a></td>
{% endif %}
<td>{{ user.ctime|tsstr_sec }}</td>
<td>
{% if not user.is_self %}
<a href="#" class="remove-user-btn op" data-url="{{ SITE_ROOT }}useradmin/remove/{{ user.props.id }}/" data-target="{{ user.props.email }}">{% trans "Delete" %}</a>
<a href="#" class="reset-user-btn op" data-url="{% url 'user_reset' user.id %}" data-target="{{ user.props.email }}">{% trans "ResetPwd" %}</a>
{% if user.is_staff %}
<a href="#" data-url="{% url 'user_remove_admin' user.id %}" data-target="{{ user.props.email }}" class="revoke-admin-btn op">{% trans "Revoke Admin" %}</a>
{% else %}
<a href="#" data-url="{% url 'user_make_admin' user.id %}" data-target="{{ user.props.email }}" class="set-admin-btn op">{% trans "Set Admin" %}</a>
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
<div id="paginator">
{% if current_page != 1 %}
<a href="{{ SITE_ROOT }}sys/useradmin/?page={{ prev_page }}&per_page={{ per_page }}">{% trans "Previous" %}</a>
{% endif %}
{% if page_next %}
<a href="{{ SITE_ROOT }}sys/useradmin/?page={{ next_page }}&per_page={{ per_page }}">{% trans "Next" %}</a>
{% endif %}
{% if current_page != 1 or page_next %}
|
{% endif %}
<span>{% trans "Per page: " %}</span>
{% 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>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
addConfirmTo($('.remove-user-btn'), {
'title':'{% trans "Delete User" %}',
'con':'{% trans "Are you sure you want to delete %s ?" %}'
});
addConfirmTo($('.reset-user-btn'), {
'title':'{% trans "Password Reset" %}',
'con':'{% trans "Are you sure you want to reset the password of %s ?" %}'
});
addConfirmTo($('.revoke-admin-btn'), {
'title':'{% trans "Revoke Admin" %}',
'con':'{% trans "Are you sure you want to revoke the admin permission of %s ?" %}'
});
addConfirmTo($('.set-admin-btn'), {
'title':'{% trans "Set Admin" %}',
'con':'{% trans "Are you sure you want to set %s as admin?" %}'
});
$('#add-user-btn').click(function() {$('#add-user-form').modal();});
$('#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) {
apply_form_error(form_id, '{% trans "Email cannot be blank" %}');
return false;
}
if (!pwd1) {
apply_form_error(form_id, '{% trans "Password cannot be blank" %}');
return false;
}
if (!pwd2) {
apply_form_error(form_id, '{% trans "Please enter the password again" %}');
return false;
}
if (pwd1 != pwd2) {
apply_form_error(form_id, "{% trans "Passwords don't match" %}");
return false;
}
$.ajax({
url: '{% url 'user_add' %}',
type: 'POST',
dataType: 'json',
cache: 'false',
contentType: 'application/json; charset=utf-8',
beforeSend: prepareCSRFToken,
data: {
'email': email,
'password1': pwd1,
'password2': pwd2
},
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 {
apply_form_error(form_id, '{% trans "Failed. Please check the network." %}');
}
}
});
return false;
});
</script>
{% endblock %}