mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-09 02:47:51 +00:00
[share] Sort share links
This commit is contained in:
parent
75eabf7583
commit
b64a55c490
@ -534,14 +534,14 @@ def list_shared_links(request):
|
|||||||
|
|
||||||
# download links
|
# download links
|
||||||
fileshares = FileShare.objects.filter(username=username)
|
fileshares = FileShare.objects.filter(username=username)
|
||||||
p_fileshares = [] # personal file share
|
fs_files, fs_dirs = [], []
|
||||||
for fs in fileshares:
|
for fs in fileshares:
|
||||||
r = seafile_api.get_repo(fs.repo_id)
|
r = seafile_api.get_repo(fs.repo_id)
|
||||||
if not r:
|
if not r:
|
||||||
fs.delete()
|
fs.delete()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if fs.s_type == 'f':
|
if fs.is_file_share_link():
|
||||||
if seafile_api.get_file_id_by_path(r.id, fs.path) is None:
|
if seafile_api.get_file_id_by_path(r.id, fs.path) is None:
|
||||||
fs.delete()
|
fs.delete()
|
||||||
continue
|
continue
|
||||||
@ -561,7 +561,9 @@ def list_shared_links(request):
|
|||||||
if fs.expire_date is not None and timezone.now() > fs.expire_date:
|
if fs.expire_date is not None and timezone.now() > fs.expire_date:
|
||||||
fs.is_expired = True
|
fs.is_expired = True
|
||||||
|
|
||||||
p_fileshares.append(fs)
|
fs_files.append(fs) if fs.is_file_share_link() else fs_dirs.append(fs)
|
||||||
|
fs_files.sort(lambda x, y: cmp(x.filename, y.filename))
|
||||||
|
fs_dirs.sort(lambda x, y: cmp(x.filename, y.filename))
|
||||||
|
|
||||||
# upload links
|
# upload links
|
||||||
uploadlinks = UploadLinkShare.objects.filter(username=username)
|
uploadlinks = UploadLinkShare.objects.filter(username=username)
|
||||||
@ -581,9 +583,10 @@ def list_shared_links(request):
|
|||||||
link.shared_link = gen_shared_upload_link(link.token)
|
link.shared_link = gen_shared_upload_link(link.token)
|
||||||
link.repo = r
|
link.repo = r
|
||||||
p_uploadlinks.append(link)
|
p_uploadlinks.append(link)
|
||||||
|
p_uploadlinks.sort(lambda x, y: cmp(x.dir_name, y.dir_name))
|
||||||
|
|
||||||
return render_to_response('share/links.html', {
|
return render_to_response('share/links.html', {
|
||||||
"fileshares": p_fileshares,
|
"fileshares": fs_dirs + fs_files,
|
||||||
"uploadlinks": p_uploadlinks,
|
"uploadlinks": p_uploadlinks,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user