mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 19:08:21 +00:00
Add pagination in institutions
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% if users %}
|
||||
<table>
|
||||
<tr>
|
||||
<th width="36%">{% trans "Email" %}</th>
|
||||
@@ -52,6 +53,11 @@
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% include "snippets/admin_paginator.html" %}
|
||||
{% else %}
|
||||
<p>{% trans "Empty" %}</p>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
|
@@ -48,9 +48,23 @@ def info(request):
|
||||
def useradmin(request):
|
||||
"""List users in the institution.
|
||||
"""
|
||||
# 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', '25'))
|
||||
except ValueError:
|
||||
current_page = 1
|
||||
per_page = 25
|
||||
|
||||
offset = per_page * (current_page - 1)
|
||||
inst = request.user.institution
|
||||
usernames = [x.user for x in Profile.objects.filter(institution=inst.name)]
|
||||
users = [User.objects.get(x) for x in usernames]
|
||||
usernames = [x.user for x in Profile.objects.filter(institution=inst.name)[offset:offset + per_page + 1]]
|
||||
if len(usernames) == per_page + 1:
|
||||
page_next = True
|
||||
else:
|
||||
page_next = False
|
||||
users = [User.objects.get(x) for x in usernames[:per_page]]
|
||||
|
||||
last_logins = UserLastLogin.objects.filter(username__in=[x.username for x in users])
|
||||
for u in users:
|
||||
if u.username == request.user.username:
|
||||
@@ -65,6 +79,11 @@ def useradmin(request):
|
||||
return render_to_response('institutions/useradmin.html', {
|
||||
'inst': inst,
|
||||
'users': users,
|
||||
'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))
|
||||
|
||||
@inst_admin_required
|
||||
|
@@ -8,6 +8,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% if users %}
|
||||
<table>
|
||||
<tr>
|
||||
<th width="25%">{% trans "Email" %}</th>
|
||||
@@ -41,6 +42,10 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% include "snippets/admin_paginator.html" %}
|
||||
{% else %}
|
||||
<p>{% trans "Empty" %}</p>
|
||||
{% endif %}
|
||||
|
||||
<div id="activate-msg" class="hide">
|
||||
<p>{% trans "Activating..., please wait" %}</p>
|
||||
|
@@ -2272,8 +2272,7 @@ def sys_inst_admin(request):
|
||||
per_page = 100
|
||||
|
||||
offset = per_page * (current_page - 1)
|
||||
limit = per_page + 1
|
||||
insts = Institution.objects.all()[offset:offset + limit]
|
||||
insts = Institution.objects.all()[offset:offset + per_page + 1]
|
||||
|
||||
if len(insts) == per_page + 1:
|
||||
page_next = True
|
||||
@@ -2282,7 +2281,7 @@ def sys_inst_admin(request):
|
||||
|
||||
return render_to_response(
|
||||
'sysadmin/sys_inst_admin.html', {
|
||||
'insts': insts,
|
||||
'insts': insts[:per_page],
|
||||
'current_page': current_page,
|
||||
'prev_page': current_page - 1,
|
||||
'next_page': current_page + 1,
|
||||
@@ -2316,9 +2315,23 @@ def sys_inst_info_user(request, inst_id):
|
||||
except Institution.DoesNotExist:
|
||||
raise Http404
|
||||
|
||||
# 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', '25'))
|
||||
except ValueError:
|
||||
current_page = 1
|
||||
per_page = 25
|
||||
|
||||
offset = per_page * (current_page - 1)
|
||||
inst_admins = [x.user for x in InstitutionAdmin.objects.filter(institution=inst)]
|
||||
usernames = [x.user for x in Profile.objects.filter(institution=inst.name)]
|
||||
users = [User.objects.get(x) for x in usernames]
|
||||
usernames = [x.user for x in Profile.objects.filter(institution=inst.name)[offset:offset + per_page + 1]]
|
||||
if len(usernames) == per_page + 1:
|
||||
page_next = True
|
||||
else:
|
||||
page_next = False
|
||||
users = [User.objects.get(x) for x in usernames[:per_page]]
|
||||
|
||||
last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
|
||||
for u in users:
|
||||
_populate_user_quota_usage(u)
|
||||
@@ -2340,6 +2353,11 @@ def sys_inst_info_user(request, inst_id):
|
||||
'inst': inst,
|
||||
'users': users,
|
||||
'users_count': users_count,
|
||||
'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