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] {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#search-repo-form label{
|
||||
display:block;
|
||||
text-align:right;
|
||||
width:40px;
|
||||
float:left;
|
||||
#search-repo-form label,
|
||||
#search-user-form label {
|
||||
width:3.5em;
|
||||
}
|
||||
#search-repo-form input[type=text] {
|
||||
margin: 4px 4px;
|
||||
#search-repo-form .submit,
|
||||
#search-user-form .submit {
|
||||
margin-left:3.5em;
|
||||
}
|
||||
#enable-mods {
|
||||
color:#888;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<li class="tabnav-tab"><a href="{% url 'sys_repo_admin' %}">{% trans "All" %}</a></li>
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Orphan" %}</li>
|
||||
</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>
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "All" %}</li>
|
||||
<li class="tabnav-tab"><a href="{% url 'sys_list_orphan' %}">{% trans "Orphan" %}</a></li>
|
||||
</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>
|
||||
|
||||
{% endblock %}
|
||||
@@ -40,10 +40,10 @@
|
||||
|
||||
<div id="paginator">
|
||||
{% 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 %}
|
||||
{% 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 %}
|
||||
{% if current_page != 1 or page_next %}
|
||||
|
|
||||
@@ -52,17 +52,17 @@
|
||||
{% if per_page == 25 %}
|
||||
<span> 25 </span>
|
||||
{% 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 %}
|
||||
{% if per_page == 50 %}
|
||||
<span> 50 </span>
|
||||
{% 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 %}
|
||||
{% if per_page == 100 %}
|
||||
<span> 100 </span>
|
||||
{% 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 %}
|
||||
</div>
|
||||
{% else %}
|
||||
|
@@ -5,17 +5,13 @@
|
||||
<h3>{% trans "Search Library"%}</h3>
|
||||
|
||||
<form id="search-repo-form" method="get" action=".">
|
||||
<label>{% trans "Name" %}</label>
|
||||
<input type="text" name="name" id="id_name" class="input" value="{{name}}"/><br />
|
||||
<label>{% trans "Owner" %}</label>
|
||||
<input type="text" name="owner" id="id_owner" class="input" value="{{owner}}"/><br />
|
||||
|
||||
<p class="error hide"></p>
|
||||
|
||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||
<input type="reset" value="{% trans "Reset" %}" class="submit" />
|
||||
<p class="tip">{% trans "Tip: you can search by keyword in name or owner or both." %}</p>
|
||||
<label>{% trans "Name" %}</label><input type="text" name="name" class="input" value="{{name}}"/><br />
|
||||
<label>{% trans "Owner" %}</label><input type="text" name="owner" class="input" value="{{owner}}"/><br />
|
||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||
</form>
|
||||
<h3>{% trans "Library List"%}</h3>
|
||||
|
||||
<h3>{% trans "Result"%}</h3>
|
||||
{% if repos %}
|
||||
<table>
|
||||
<tr>
|
||||
@@ -36,44 +32,20 @@
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<p>{% trans "Empty" %}</p>
|
||||
<p>{% trans "No result" %}</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<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() {
|
||||
var form = $(this),
|
||||
form_id = $(this).attr('id'),
|
||||
name = $.trim(form.children('[name="name"]').val()),
|
||||
owner = $.trim(form.children('[name="owner"]').val()),
|
||||
orphan = form.children('[name="orphan"]:checked').val();
|
||||
name = $.trim($('[name="name"]', form).val()),
|
||||
owner = $.trim($('[name="owner"]', form).val());
|
||||
|
||||
form.submit();
|
||||
if (!name && !owner) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
<h3>{% trans "All Members" %}</h3>
|
||||
<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 %}
|
||||
<h3>{% trans "Add new user" %}</h3>
|
||||
|
@@ -5,15 +5,11 @@
|
||||
<h3>{% trans "Search User"%}</h3>
|
||||
|
||||
<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>
|
||||
<label>{% trans "Email" %}</label><input type="text" name="email" class="input" value="{{email}}" /><br />
|
||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||
<input type="reset" value="{% trans "Reset" %}" class="submit" />
|
||||
</form>
|
||||
<h3>{% trans "User List"%}</h3>
|
||||
<h3>{% trans "Result"%}</h3>
|
||||
{% if users %}
|
||||
<table>
|
||||
<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>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</td
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<p>{% trans "Empty" %}</p>
|
||||
<p>{% trans "No result" %}</p>
|
||||
{% 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 %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
$('#search-user-form').submit(function() {
|
||||
var form = $(this),
|
||||
form_id = $(this).attr('id'),
|
||||
email = $.trim(form.children('[name="email"]').val());
|
||||
|
||||
if (!email) {
|
||||
apply_form_error(form_id, "{% trans "Email cannot be blank" %}");
|
||||
if (!$.trim($('[name="email"]', $(this)).val())) {
|
||||
return false;
|
||||
}
|
||||
form.submit();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@@ -480,30 +480,12 @@ def user_search(request):
|
||||
email = request.GET.get('email', '')
|
||||
email_patt = email.replace('*', '%')
|
||||
|
||||
# Make sure page request is an int. If not, deliver first page.
|
||||
try:
|
||||
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]
|
||||
users = ccnet_threaded_rpc.search_emailusers(
|
||||
email_patt, -1, -1)
|
||||
|
||||
return render_to_response('sysadmin/user_search.html', {
|
||||
'users': users,
|
||||
'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))
|
||||
|
||||
@login_required
|
||||
|
Reference in New Issue
Block a user