mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 02:48:51 +00:00
Modified sys user admin and search
This commit is contained in:
@@ -15,13 +15,16 @@
|
|||||||
{% block main_panel %}
|
{% block main_panel %}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="80%">{% trans "Email" %}</th>
|
<th width="65%">{% trans "Email" %}</th>
|
||||||
|
<th width="15%">{% trans "Create At / Last Login" %}</th>
|
||||||
<th width="20%">{% trans "Space Used" %}</th>
|
<th width="20%">{% trans "Space Used" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr>
|
<tr>
|
||||||
<td data="{{user.id}}"><a href="{{ SITE_ROOT }}useradmin/info/{{ user.props.email }}/">{{ user.email }}</a></td>
|
<td data="{{user.id}}"><a href="{{ SITE_ROOT }}useradmin/info/{{ user.props.email }}/">{{ user.email }}</a></td>
|
||||||
|
<td style="font-size:11px;"> -- / {% if user.last_login %}{{user.last_login|translate_seahub_time}} {% else %} -- {% endif %}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if CALC_SHARE_USAGE %}
|
{% if CALC_SHARE_USAGE %}
|
||||||
{{ user.self_usage|filesizeformat }} + {{ user.share_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
{{ user.self_usage|filesizeformat }} + {{ user.share_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
<button class="add" id="add-user-btn">{% trans "Add new user" %}</button>
|
<button class="add" id="add-user-btn">{% trans "Add new user" %}</button>
|
||||||
|
|
||||||
|
|
||||||
<form id="add-user-form" action="" method="post" class="hide">{% csrf_token %}
|
<form id="add-user-form" action="" method="post" class="hide">{% csrf_token %}
|
||||||
<h3>{% trans "Add new user" %}</h3>
|
<h3>{% trans "Add new user" %}</h3>
|
||||||
<label for="id_email">{% trans "Email" %}</label><br />
|
<label for="id_email">{% trans "Email" %}</label><br />
|
||||||
@@ -35,6 +34,9 @@
|
|||||||
{% include "sysadmin/useradmin_table.html"%}
|
{% include "sysadmin/useradmin_table.html"%}
|
||||||
{% include "sysadmin/useradmin_paginator.html" %}
|
{% include "sysadmin/useradmin_paginator.html" %}
|
||||||
|
|
||||||
|
<div id="activate-msg" class="hide">
|
||||||
|
<p>{% trans "Activating..., please wait" %}</p>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
|
@@ -11,64 +11,15 @@
|
|||||||
</form>
|
</form>
|
||||||
<h3>{% trans "Result"%}</h3>
|
<h3>{% trans "Result"%}</h3>
|
||||||
{% if users %}
|
{% if users %}
|
||||||
<table>
|
{% include "sysadmin/useradmin_table.html"%}
|
||||||
<tr>
|
|
||||||
<th width="30%">{% trans "Email" %}</th>
|
|
||||||
<th width="10%">{% trans "Status" %}</th>
|
|
||||||
<th width="20%">{% trans "Space Used" %}</th>
|
|
||||||
<th width="15%">{% trans "Create At" %}</th>
|
|
||||||
<th width="25%">{% trans "Operations" %}</th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
{% for user in users %}
|
|
||||||
<tr>
|
|
||||||
<td data="{{user.id}}"><a href="{{ SITE_ROOT }}useradmin/info/{{ user.props.email }}/">{{ user.email }}</a></td>
|
|
||||||
<td>
|
|
||||||
{% if user.source != 'LDAP' %}
|
|
||||||
<div class="user-status">
|
|
||||||
{% if user.is_active %}
|
|
||||||
<span class="user-status-cur-value">{% trans "Active" %}</span>
|
|
||||||
{% else %}
|
|
||||||
<span class="user-status-cur-value">{% trans "Inactive" %}</span>
|
|
||||||
{% endif %}
|
|
||||||
<img src="{{MEDIA_URL}}img/edit_12.png" alt="{% trans "Edit"%}" title="{% trans "Edit"%}" class="user-status-edit-icon vh" />
|
|
||||||
</div>
|
|
||||||
<select name="permission" class="user-status-select hide">
|
|
||||||
<option value="1" {%if user.is_active %}selected="selected"{% endif %}>{% trans "Active" %}</option>
|
|
||||||
<option value="0" {%if not user.is_active %}selected="selected"{% endif %}>{% trans "Inactive"%}</option>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
{% if CALC_SHARE_USAGE %}
|
|
||||||
{{ user.self_usage|filesizeformat }} + {{ user.share_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
|
||||||
{% else %}
|
|
||||||
{{ user.self_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>{% if user.source != 'LDAP' %}{{ user.ctime|tsstr_sec }}{% endif %}</td>
|
|
||||||
<td>
|
|
||||||
{% if user.source != 'LDAP' %}
|
|
||||||
{% 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 %}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans "No result" %}</p>
|
<p>{% trans "No result" %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="activate-msg" class="hide">
|
||||||
|
<p>{% trans "Activating..., please wait" %}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
|
@@ -43,6 +43,14 @@ $('.user-status-select').change(function() {
|
|||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
cache: false,
|
cache: false,
|
||||||
|
beforeSend: function() {
|
||||||
|
if (select_val == 1) {
|
||||||
|
console.log('activating user..please wait');
|
||||||
|
// show activating popup
|
||||||
|
$('#activate-msg').modal();
|
||||||
|
$('#simplemodal-container').css({'height':'auto'});
|
||||||
|
}
|
||||||
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data['email_sent']) {
|
if (data['email_sent']) {
|
||||||
feedback("{% trans "Edit succeeded, an email has been sent." %}", 'success');
|
feedback("{% trans "Edit succeeded, an email has been sent." %}", 'success');
|
||||||
@@ -58,11 +66,13 @@ $('.user-status-select').change(function() {
|
|||||||
|
|
||||||
select.addClass('hide');
|
select.addClass('hide');
|
||||||
select.prev().removeClass('hide');
|
select.prev().removeClass('hide');
|
||||||
|
$.modal.close();
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
feedback("{% trans "Edit failed." %}", 'error');
|
feedback("{% trans "Edit failed." %}", 'error');
|
||||||
select.addClass('hide');
|
select.addClass('hide');
|
||||||
select.prev().removeClass('hide');
|
select.prev().removeClass('hide');
|
||||||
|
$.modal.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
<th width="30%">{% trans "Email" %}</th>
|
<th width="30%">{% trans "Email" %}</th>
|
||||||
<th width="10%">{% trans "Status" %}</th>
|
<th width="10%">{% trans "Status" %}</th>
|
||||||
<th width="20%">{% trans "Space Used" %}</th>
|
<th width="20%">{% trans "Space Used" %}</th>
|
||||||
<th width="15%">{% trans "Create At" %}</th>
|
<th width="15%">{% trans "Create At / Last Login" %}</th>
|
||||||
<th width="25%">{% trans "Operations" %}</th>
|
<th width="25%">{% trans "Operations" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
<td data="{{user.id}}"><a href="{{ SITE_ROOT }}useradmin/info/{{ user.props.email }}/">{{ user.email }}</a></td>
|
<td data="{{user.id}}"><a href="{{ SITE_ROOT }}useradmin/info/{{ user.props.email }}/">{{ user.email }}</a></td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
{% if user.source != 'LDAP' %}
|
||||||
<div class="user-status">
|
<div class="user-status">
|
||||||
{% if user.is_active %}
|
{% if user.is_active %}
|
||||||
<span class="user-status-cur-value">{% trans "Active" %}</span>
|
<span class="user-status-cur-value">{% trans "Active" %}</span>
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
<option value="0" {%if not user.is_active %}selected="selected"{% endif %}>{% trans "Inactive"%}</option>
|
<option value="0" {%if not user.is_active %}selected="selected"{% endif %}>{% trans "Inactive"%}</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
@@ -35,8 +37,12 @@
|
|||||||
{{ user.self_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
{{ user.self_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ user.ctime|tsstr_sec }}</td>
|
<td style="font-size:11px;">{% if user.source != 'LDAP' %}
|
||||||
|
{{ user.ctime|tsstr_sec }} / {% if user.last_login %}{{user.last_login|translate_seahub_time}} {% else %} -- {% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
{% if user.source != 'LDAP' %}
|
||||||
{% if not user.is_self %}
|
{% 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="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>
|
<a href="#" class="reset-user-btn op" data-url="{% url 'user_reset' user.id %}" data-target="{{ user.props.email }}">{% trans "ResetPwd" %}</a>
|
||||||
@@ -46,6 +52,7 @@
|
|||||||
<a href="#" data-url="{% url 'user_make_admin' user.id %}" data-target="{{ user.props.email }}" class="set-admin-btn op">{% trans "Set Admin" %}</a>
|
<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 %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@@ -21,6 +21,7 @@ from seaserv import seafile_api
|
|||||||
from pysearpc import SearpcError
|
from pysearpc import SearpcError
|
||||||
|
|
||||||
from seahub.base.accounts import User
|
from seahub.base.accounts import User
|
||||||
|
from seahub.base.models import UserLastLogin
|
||||||
from seahub.base.decorators import sys_staff_required
|
from seahub.base.decorators import sys_staff_required
|
||||||
from seahub.auth.decorators import login_required
|
from seahub.auth.decorators import login_required
|
||||||
from seahub.utils import IS_EMAIL_CONFIGURED
|
from seahub.utils import IS_EMAIL_CONFIGURED
|
||||||
@@ -140,6 +141,7 @@ def sys_user_admin(request):
|
|||||||
page_next = False
|
page_next = False
|
||||||
|
|
||||||
users = users_plus_one[:per_page]
|
users = users_plus_one[:per_page]
|
||||||
|
last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
|
||||||
for user in users:
|
for user in users:
|
||||||
if user.props.id == request.user.id:
|
if user.props.id == request.user.id:
|
||||||
user.is_self = True
|
user.is_self = True
|
||||||
@@ -151,6 +153,11 @@ def sys_user_admin(request):
|
|||||||
user.self_usage = -1
|
user.self_usage = -1
|
||||||
user.share_usage = -1
|
user.share_usage = -1
|
||||||
user.quota = -1
|
user.quota = -1
|
||||||
|
# populate user last login time
|
||||||
|
user.last_login = None
|
||||||
|
for last_login in last_logins:
|
||||||
|
if last_login.username == user.email:
|
||||||
|
user.last_login = last_login.last_login
|
||||||
|
|
||||||
have_ldap = True if len(get_emailusers('LDAP', 0, 1)) > 0 else False
|
have_ldap = True if len(get_emailusers('LDAP', 0, 1)) > 0 else False
|
||||||
|
|
||||||
@@ -186,6 +193,7 @@ def sys_ldap_user_admin(request):
|
|||||||
page_next = False
|
page_next = False
|
||||||
|
|
||||||
users = users_plus_one[:per_page]
|
users = users_plus_one[:per_page]
|
||||||
|
last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
|
||||||
for user in users:
|
for user in users:
|
||||||
if user.props.id == request.user.id:
|
if user.props.id == request.user.id:
|
||||||
user.is_self = True
|
user.is_self = True
|
||||||
@@ -197,6 +205,13 @@ def sys_ldap_user_admin(request):
|
|||||||
user.self_usage = -1
|
user.self_usage = -1
|
||||||
user.share_usage = -1
|
user.share_usage = -1
|
||||||
user.quota = -1
|
user.quota = -1
|
||||||
|
|
||||||
|
# populate user last login time
|
||||||
|
user.last_login = None
|
||||||
|
for last_login in last_logins:
|
||||||
|
if last_login.username == user.email:
|
||||||
|
user.last_login = last_login.last_login
|
||||||
|
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
'sysadmin/sys_ldap_useradmin.html', {
|
'sysadmin/sys_ldap_useradmin.html', {
|
||||||
@@ -597,8 +612,14 @@ def user_search(request):
|
|||||||
email = request.GET.get('email', '')
|
email = request.GET.get('email', '')
|
||||||
email_patt = email.replace('*', '%')
|
email_patt = email.replace('*', '%')
|
||||||
|
|
||||||
users = ccnet_threaded_rpc.search_emailusers(
|
users = ccnet_threaded_rpc.search_emailusers(email_patt, -1, -1)
|
||||||
email_patt, -1, -1)
|
last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
|
||||||
|
for user in users:
|
||||||
|
# populate user last login time
|
||||||
|
user.last_login = None
|
||||||
|
for last_login in last_logins:
|
||||||
|
if last_login.username == user.email:
|
||||||
|
user.last_login = last_login.last_login
|
||||||
|
|
||||||
return render_to_response('sysadmin/user_search.html', {
|
return render_to_response('sysadmin/user_search.html', {
|
||||||
'users': users,
|
'users': users,
|
||||||
|
Reference in New Issue
Block a user