mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 10:58:33 +00:00
Merge pull request #1169 from haiwen/admin-sort-pub-link
sort admin pub links
This commit is contained in:
@@ -11,8 +11,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th width="25%">{% trans "Name" %}</th>
|
<th width="25%">{% trans "Name" %}</th>
|
||||||
<th width="25%">{% trans "Owner" %}</th>
|
<th width="25%">{% trans "Owner" %}</th>
|
||||||
<th width="20%">{% trans "Create At" %}</th>
|
<th width="20%"><a class="table-sort-op by-time" href="#">{% trans "Create At" %} {% if sort_by == 'time_down' %}<span class="sort-icon icon-caret-down"></span>{% elif sort_by == 'time_up' %}<span class="sort-icon icon-caret-up"></span>{% endif %}</a></th>
|
||||||
<th width="12%">{% trans "Count" %}</th>
|
<th width="12%"><a class="table-sort-op by-count" href="#">{% trans "Count" %} {% if sort_by == 'count_down' %}<span class="sort-icon icon-caret-up"></span>{% elif sort_by == 'count_up' %}<span class="sort-icon icon-caret-down"></span>{% endif %}</a></th>
|
||||||
<th width="18%">{% trans "Operations" %}</th>
|
<th width="18%">{% trans "Operations" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for publink in publinks %}
|
{% for publink in publinks %}
|
||||||
@@ -28,7 +28,33 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% include "snippets/admin_paginator.html" %}
|
<div id="paginator">
|
||||||
|
{% if current_page != 1 %}
|
||||||
|
<a href="?page={{ prev_page }}&per_page={{ per_page }}&sort_by={{ sort_by }}">{% trans "Previous" %}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if page_next %}
|
||||||
|
<a href="?page={{ next_page }}&per_page={{ per_page }}&sort_by={{ sort_by }}">{% 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="?per_page=25&sort_by={{ sort_by }}" class="per-page">25</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if per_page == 50 %}
|
||||||
|
<span> 50 </span>
|
||||||
|
{% else %}
|
||||||
|
<a href="?per_page=50&sort_by={{ sort_by }}" class="per-page">50</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if per_page == 100 %}
|
||||||
|
<span> 100 </span>
|
||||||
|
{% else %}
|
||||||
|
<a href="?per_page=100&sort_by={{ sort_by }}" class="per-page">100</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans "Empty" %}</p>
|
<p>{% trans "Empty" %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -52,5 +78,24 @@ $('.rm-link').click(function() {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var sort_by = '{{ sort_by }}';
|
||||||
|
var url = '{% url 'sys_publink_admin' %}' + '?per_page={{ per_page }}';
|
||||||
|
$(".by-time").on('click', function () {
|
||||||
|
if (sort_by == 'time_down') {
|
||||||
|
location.href = url + '&sort_by=time_up';
|
||||||
|
} else {
|
||||||
|
location.href = url + '&sort_by=time_down';
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$(".by-count").on('click', function () {
|
||||||
|
if (sort_by == 'count_down') {
|
||||||
|
location.href = url + '&sort_by=count_up';
|
||||||
|
} else {
|
||||||
|
location.href = url + '&sort_by=count_down';
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -17,7 +17,6 @@ from django.http import HttpResponse, Http404, HttpResponseRedirect, HttpRespons
|
|||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.template.defaultfilters import filesizeformat
|
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
import seaserv
|
import seaserv
|
||||||
@@ -29,8 +28,7 @@ from seahub.base.accounts import User
|
|||||||
from seahub.base.models import UserLastLogin
|
from seahub.base.models import UserLastLogin
|
||||||
from seahub.base.decorators import sys_staff_required, require_POST
|
from seahub.base.decorators import sys_staff_required, require_POST
|
||||||
from seahub.base.sudo_mode import update_sudo_mode_ts
|
from seahub.base.sudo_mode import update_sudo_mode_ts
|
||||||
from seahub.base.templatetags.seahub_tags import tsstr_sec, email2nickname, \
|
from seahub.base.templatetags.seahub_tags import tsstr_sec, email2nickname
|
||||||
translate_seahub_time_str
|
|
||||||
from seahub.auth import authenticate
|
from seahub.auth import authenticate
|
||||||
from seahub.auth.decorators import login_required, login_required_ajax
|
from seahub.auth.decorators import login_required, login_required_ajax
|
||||||
from seahub.constants import GUEST_USER, DEFAULT_USER
|
from seahub.constants import GUEST_USER, DEFAULT_USER
|
||||||
@@ -74,10 +72,6 @@ logger = logging.getLogger(__name__)
|
|||||||
@login_required
|
@login_required
|
||||||
@sys_staff_required
|
@sys_staff_required
|
||||||
def sysadmin(request):
|
def sysadmin(request):
|
||||||
"""
|
|
||||||
"""
|
|
||||||
username = request.user.username
|
|
||||||
|
|
||||||
max_upload_file_size = get_max_upload_file_size()
|
max_upload_file_size = get_max_upload_file_size()
|
||||||
|
|
||||||
folder_perm_enabled = True if is_pro_version() and settings.ENABLE_FOLDER_PERM else False
|
folder_perm_enabled = True if is_pro_version() and settings.ENABLE_FOLDER_PERM else False
|
||||||
@@ -1771,7 +1765,16 @@ def sys_publink_admin(request):
|
|||||||
|
|
||||||
offset = per_page * (current_page -1)
|
offset = per_page * (current_page -1)
|
||||||
limit = per_page + 1
|
limit = per_page + 1
|
||||||
publinks = FileShare.objects.all()[offset:offset+limit]
|
sort_by = request.GET.get('sort_by', 'time_up')
|
||||||
|
|
||||||
|
if sort_by == 'time_down':
|
||||||
|
publinks = FileShare.objects.all().order_by('ctime')[offset:offset+limit]
|
||||||
|
elif sort_by == 'count_up':
|
||||||
|
publinks = FileShare.objects.all().order_by('-view_cnt')[offset:offset+limit]
|
||||||
|
elif sort_by == 'count_down':
|
||||||
|
publinks = FileShare.objects.all().order_by('view_cnt')[offset:offset+limit]
|
||||||
|
else:
|
||||||
|
publinks = FileShare.objects.all().order_by('-ctime')[offset:offset+limit]
|
||||||
|
|
||||||
if len(publinks) == per_page + 1:
|
if len(publinks) == per_page + 1:
|
||||||
page_next = True
|
page_next = True
|
||||||
@@ -1792,6 +1795,8 @@ def sys_publink_admin(request):
|
|||||||
'next_page': current_page+1,
|
'next_page': current_page+1,
|
||||||
'per_page': per_page,
|
'per_page': per_page,
|
||||||
'page_next': page_next,
|
'page_next': page_next,
|
||||||
|
'per_page': per_page,
|
||||||
|
'sort_by': sort_by,
|
||||||
},
|
},
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user