mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 19:08:21 +00:00
[admin] lib/user search: modified ui & clean up the code
This commit is contained in:
@@ -2607,15 +2607,13 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
#plan-form input[type=radio] {
|
#plan-form input[type=radio] {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
#search-repo-form label,
|
||||||
#search-repo-form label{
|
#search-user-form label {
|
||||||
display:block;
|
width:3.5em;
|
||||||
text-align:right;
|
|
||||||
width:40px;
|
|
||||||
float:left;
|
|
||||||
}
|
}
|
||||||
#search-repo-form input[type=text] {
|
#search-repo-form .submit,
|
||||||
margin: 4px 4px;
|
#search-user-form .submit {
|
||||||
|
margin-left:3.5em;
|
||||||
}
|
}
|
||||||
#enable-mods {
|
#enable-mods {
|
||||||
color:#888;
|
color:#888;
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
<li class="tabnav-tab"><a href="{% url 'sys_repo_admin' %}">{% trans "All" %}</a></li>
|
<li class="tabnav-tab"><a href="{% url 'sys_repo_admin' %}">{% trans "All" %}</a></li>
|
||||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Orphan" %}</li>
|
<li class="tabnav-tab tabnav-tab-cur">{% trans "Orphan" %}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<button class="icon-search fright" id="search-repo-btn">{% trans "Search Library" %}</button>
|
<button class="icon-search fright" id="search-repo-btn"> {% trans "Search" %}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "All" %}</li>
|
<li class="tabnav-tab tabnav-tab-cur">{% trans "All" %}</li>
|
||||||
<li class="tabnav-tab"><a href="{% url 'sys_list_orphan' %}">{% trans "Orphan" %}</a></li>
|
<li class="tabnav-tab"><a href="{% url 'sys_list_orphan' %}">{% trans "Orphan" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<button class="icon-search fright" id="search-repo-btn">{% trans "Search Library" %}</button>
|
<button class="icon-search fright" id="search-repo-btn"> {% trans "Search" %}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -40,10 +40,10 @@
|
|||||||
|
|
||||||
<div id="paginator">
|
<div id="paginator">
|
||||||
{% if current_page != 1 %}
|
{% if current_page != 1 %}
|
||||||
<a href="{{ SITE_ROOT }}sys/seafadmin/?page={{ prev_page }}&per_page={{ per_page }}">{% trans "Previous" %}</a>
|
<a href="?page={{ prev_page }}&per_page={{ per_page }}">{% trans "Previous" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if page_next %}
|
{% if page_next %}
|
||||||
<a href="{{ SITE_ROOT }}sys/seafadmin/?page={{ next_page }}&per_page={{ per_page }}">{% trans "Next" %}</a>
|
<a href="?page={{ next_page }}&per_page={{ per_page }}">{% trans "Next" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if current_page != 1 or page_next %}
|
{% if current_page != 1 or page_next %}
|
||||||
|
|
|
|
||||||
@@ -52,17 +52,17 @@
|
|||||||
{% if per_page == 25 %}
|
{% if per_page == 25 %}
|
||||||
<span> 25 </span>
|
<span> 25 </span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ SITE_ROOT }}sys/seafadmin/?per_page=25" class="per-page">25</a>
|
<a href="?per_page=25" class="per-page">25</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if per_page == 50 %}
|
{% if per_page == 50 %}
|
||||||
<span> 50 </span>
|
<span> 50 </span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ SITE_ROOT }}sys/seafadmin/?per_page=50" class="per-page">50</a>
|
<a href="?per_page=50" class="per-page">50</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if per_page == 100 %}
|
{% if per_page == 100 %}
|
||||||
<span> 100 </span>
|
<span> 100 </span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ SITE_ROOT }}sys/seafadmin/?per_page=100" class="per-page">100</a>
|
<a href="?per_page=100" class="per-page">100</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@@ -5,17 +5,13 @@
|
|||||||
<h3>{% trans "Search Library"%}</h3>
|
<h3>{% trans "Search Library"%}</h3>
|
||||||
|
|
||||||
<form id="search-repo-form" method="get" action=".">
|
<form id="search-repo-form" method="get" action=".">
|
||||||
<label>{% trans "Name" %}</label>
|
<p class="tip">{% trans "Tip: you can search by keyword in name or owner or both." %}</p>
|
||||||
<input type="text" name="name" id="id_name" class="input" value="{{name}}"/><br />
|
<label>{% trans "Name" %}</label><input type="text" name="name" class="input" value="{{name}}"/><br />
|
||||||
<label>{% trans "Owner" %}</label>
|
<label>{% trans "Owner" %}</label><input type="text" name="owner" class="input" value="{{owner}}"/><br />
|
||||||
<input type="text" name="owner" id="id_owner" class="input" value="{{owner}}"/><br />
|
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||||
|
|
||||||
<p class="error hide"></p>
|
|
||||||
|
|
||||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
|
||||||
<input type="reset" value="{% trans "Reset" %}" class="submit" />
|
|
||||||
</form>
|
</form>
|
||||||
<h3>{% trans "Library List"%}</h3>
|
|
||||||
|
<h3>{% trans "Result"%}</h3>
|
||||||
{% if repos %}
|
{% if repos %}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -36,44 +32,20 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans "Empty" %}</p>
|
<p>{% trans "No result" %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function disable_owner() {
|
|
||||||
$('#id_owner').prop('disabled', true).addClass('input-disabled').val('');
|
|
||||||
};
|
|
||||||
|
|
||||||
function enable_owner() {
|
|
||||||
$('#id_owner').prop('disabled', false).removeClass('input-disabled');
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
if($('#orphan_yes').is(':checked')) {
|
|
||||||
disable_owner();
|
|
||||||
}
|
|
||||||
if($('#orphan_no').is(':checked')) {
|
|
||||||
enable_owner();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#orphan_yes').click(function () {
|
|
||||||
disable_owner();
|
|
||||||
});
|
|
||||||
$('#orphan_no').click(function () {
|
|
||||||
enable_owner();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#search-repo-form').submit(function() {
|
$('#search-repo-form').submit(function() {
|
||||||
var form = $(this),
|
var form = $(this),
|
||||||
form_id = $(this).attr('id'),
|
name = $.trim($('[name="name"]', form).val()),
|
||||||
name = $.trim(form.children('[name="name"]').val()),
|
owner = $.trim($('[name="owner"]', form).val());
|
||||||
owner = $.trim(form.children('[name="owner"]').val()),
|
|
||||||
orphan = form.children('[name="orphan"]:checked').val();
|
|
||||||
|
|
||||||
form.submit();
|
if (!name && !owner) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<h3>{% trans "All Members" %}</h3>
|
<h3>{% trans "All Members" %}</h3>
|
||||||
<button class="add" id="add-user-btn">{% trans "Add new user" %}</button>
|
<button class="add" id="add-user-btn">{% trans "Add new user" %}</button>
|
||||||
<button class="icon-search fright" id="search-user-btn">{% trans "Search User" %}</button>
|
<button class="icon-search fright" id="search-user-btn"> {% trans "Search" %}</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>
|
||||||
|
@@ -5,15 +5,11 @@
|
|||||||
<h3>{% trans "Search User"%}</h3>
|
<h3>{% trans "Search User"%}</h3>
|
||||||
|
|
||||||
<form id="search-user-form" method="get" action=".">
|
<form id="search-user-form" method="get" action=".">
|
||||||
<label>{% trans "Email" %}</label>
|
|
||||||
<input type="text" name="email" id="id_email" class="input" value="{{email}}"/><br />
|
|
||||||
<p class="error hide"></p>
|
|
||||||
|
|
||||||
<p class="tip">{% trans "Tip: Use * to match any number of characters." %}</p>
|
<p class="tip">{% trans "Tip: Use * to match any number of characters." %}</p>
|
||||||
|
<label>{% trans "Email" %}</label><input type="text" name="email" class="input" value="{{email}}" /><br />
|
||||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||||
<input type="reset" value="{% trans "Reset" %}" class="submit" />
|
|
||||||
</form>
|
</form>
|
||||||
<h3>{% trans "User List"%}</h3>
|
<h3>{% trans "Result"%}</h3>
|
||||||
{% if users %}
|
{% if users %}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -50,56 +46,22 @@
|
|||||||
<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 %}
|
||||||
</td>
|
</td
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans "Empty" %}</p>
|
<p>{% trans "No result" %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div id="paginator">
|
|
||||||
{% if current_page != 1 %}
|
|
||||||
<a href="?email={{email}}&page={{ prev_page }}&per_page={{ per_page }}">{% trans "Previous" %}</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if page_next %}
|
|
||||||
<a href="?email={{email}}&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="?email={{email}}&per_page=25" class="per-page">25</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if per_page == 50 %}
|
|
||||||
<span> 50 </span>
|
|
||||||
{% else %}
|
|
||||||
<a href="?email={{email}}&per_page=50" class="per-page">50</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if per_page == 100 %}
|
|
||||||
<span> 100 </span>
|
|
||||||
{% else %}
|
|
||||||
<a href="?email={{email}}&per_page=100" class="per-page">100</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$('#search-user-form').submit(function() {
|
$('#search-user-form').submit(function() {
|
||||||
var form = $(this),
|
if (!$.trim($('[name="email"]', $(this)).val())) {
|
||||||
form_id = $(this).attr('id'),
|
|
||||||
email = $.trim(form.children('[name="email"]').val());
|
|
||||||
|
|
||||||
if (!email) {
|
|
||||||
apply_form_error(form_id, "{% trans "Email cannot be blank" %}");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
form.submit();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -480,30 +480,12 @@ def user_search(request):
|
|||||||
email = request.GET.get('email', '')
|
email = request.GET.get('email', '')
|
||||||
email_patt = email.replace('*', '%')
|
email_patt = email.replace('*', '%')
|
||||||
|
|
||||||
# Make sure page request is an int. If not, deliver first page.
|
users = ccnet_threaded_rpc.search_emailusers(
|
||||||
try:
|
email_patt, -1, -1)
|
||||||
current_page = int(request.GET.get('page', '1'))
|
|
||||||
per_page = int(request.GET.get('per_page', '100'))
|
|
||||||
except ValueError:
|
|
||||||
current_page = 1
|
|
||||||
per_page = 100
|
|
||||||
users_plus_one = ccnet_threaded_rpc.search_emailusers(
|
|
||||||
email_patt, per_page * (current_page - 1), per_page + 1)
|
|
||||||
if len(users_plus_one) == per_page + 1:
|
|
||||||
page_next = True
|
|
||||||
else:
|
|
||||||
page_next = False
|
|
||||||
|
|
||||||
users = users_plus_one[:per_page]
|
|
||||||
|
|
||||||
return render_to_response('sysadmin/user_search.html', {
|
return render_to_response('sysadmin/user_search.html', {
|
||||||
'users': users,
|
'users': users,
|
||||||
'email': email,
|
'email': email,
|
||||||
'current_page': current_page,
|
|
||||||
'prev_page': current_page-1,
|
|
||||||
'next_page': current_page+1,
|
|
||||||
'per_page': per_page,
|
|
||||||
'page_next': page_next,
|
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
Reference in New Issue
Block a user