mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 10:58:33 +00:00
[useradmin] add "shared links" tab
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{% extends "admin_base.html" %}
|
||||
{% load i18n avatar_tags %}
|
||||
{% load i18n avatar_tags seahub_tags %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block extra_style %}
|
||||
@@ -63,8 +63,9 @@
|
||||
<div id="tabs" class="tab-tabs">
|
||||
<div class="hd ovhd">
|
||||
<ul class="tab-tabs-nav fleft">
|
||||
<li class="tab"><a href="#owned" class="a">{% trans "Owned" %}</a></li>
|
||||
<li class="tab"><a href="#shared" class="a">{% trans "Shared" %}</a></li>
|
||||
<li class="tab"><a href="#owned" class="a">{% trans "Owned Repos" %}</a></li>
|
||||
<li class="tab"><a href="#shared" class="a">{% trans "Shared Repos" %}</a></li>
|
||||
<li class="tab"><a href="#shared-links" class="a">{% trans "Shared Links" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -117,6 +118,55 @@
|
||||
<p>{% trans "None" %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div id="shared-links">
|
||||
{% if user_shared_links%}
|
||||
<table class="sharelink-list">
|
||||
<tr>
|
||||
<th width="5%"><!--icon--></th>
|
||||
<th width="30%">{% trans "Name"%}</th>
|
||||
<th width="20%">{% trans "Size"%}</th>
|
||||
<th width="20%">{% trans "Type"%}</th>
|
||||
<th width="10%">{% trans "Visits"%}</th>
|
||||
<th width="15%">{% trans "Operations"%}</th>
|
||||
</tr>
|
||||
{% for link in user_shared_links %}
|
||||
<tr>
|
||||
{% if link.s_type%}
|
||||
{% if link.s_type == 'f' %}
|
||||
<td class="alc"><img src="{{ MEDIA_URL }}img/file/{{ link.filename|file_icon_filter }}" alt="{% trans "File"%}" /></td>
|
||||
<td><a href="{% url 'repo_view_file' link.repo.id %}?p={{ link.path|urlencode }}">{{ link.filename }}</a></td>
|
||||
<td>{{ link.file_size|filesizeformat}}</td>
|
||||
{% else %}
|
||||
<td class="alc"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory icon"%}" /></td>
|
||||
<td><a href="{% url 'repo' link.repo.id %}?p={{ link.path|urlencode }}">{{ link.filename }}</a></td>
|
||||
<td>{{ link.dir_size|filesizeformat}}</td>
|
||||
{% endif %}
|
||||
<td>DownLoad</td>
|
||||
<td>{{ link.view_cnt }}</td>
|
||||
<td>
|
||||
<a class="op vh" href="{% url 'remove_shared_link' %}?t={{ link.token }}">{% trans "Remove"%}</a>
|
||||
</td>
|
||||
{% else %}
|
||||
<td class="alc"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory icon"%}" /></td>
|
||||
<td><a href="{% url 'repo' link.repo.id %}?p={{ link.path|urlencode }}">{{ link.dir_name }}</a></td>
|
||||
<td>//</td>
|
||||
<td>Upload</td>
|
||||
<td>{{ link.view_cnt }}</td>
|
||||
<td>
|
||||
<a class="op vh" href="{% url 'remove_shared_upload_link' %}?t={{ link.token }}">{% trans "Remove"%}</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="empty-tips">
|
||||
<h2 class="alc">{% trans "You don't have any shared link"%}</h2>
|
||||
<p>{% trans "You can generate an share link from any dir/file. People receive this link can download/upload zipped dir or files." %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include 'snippets/repo_del_popup.html' %}
|
||||
|
@@ -28,13 +28,14 @@ from seahub.utils import IS_EMAIL_CONFIGURED, string2list, is_valid_username
|
||||
from seahub.views import get_system_default_repo_id
|
||||
from seahub.forms import SetUserQuotaForm, AddUserForm, BatchAddUserForm
|
||||
from seahub.profile.models import Profile, DetailedProfile
|
||||
from seahub.share.models import FileShare
|
||||
from seahub.share.models import FileShare, UploadLinkShare
|
||||
|
||||
import seahub.settings as settings
|
||||
from seahub.settings import INIT_PASSWD, SITE_NAME, \
|
||||
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER, SEND_EMAIL_ON_RESETTING_USER_PASSWD, \
|
||||
ENABLE_GUEST
|
||||
from seahub.utils import send_html_email, get_user_traffic_list, get_server_id
|
||||
from seahub.utils import send_html_email, get_user_traffic_list, get_server_id, \
|
||||
gen_file_share_link, gen_dir_share_link, gen_shared_upload_link
|
||||
from seahub.utils.sysinfo import get_platform_name
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -361,6 +362,63 @@ def user_info(request, email):
|
||||
profile = Profile.objects.get_profile_by_user(email)
|
||||
d_profile = DetailedProfile.objects.get_detailed_profile_by_user(email)
|
||||
|
||||
user_shared_links = []
|
||||
# download links
|
||||
fileshares = FileShare.objects.filter(username=email)
|
||||
|
||||
for fs in fileshares:
|
||||
r = seafile_api.get_repo(fs.repo_id)
|
||||
if not r:
|
||||
fs.delete()
|
||||
continue
|
||||
|
||||
if fs.s_type == 'f':
|
||||
if seafile_api.get_file_id_by_path(r.id, fs.path) is None:
|
||||
fs.delete()
|
||||
continue
|
||||
fs.filename = os.path.basename(fs.path)
|
||||
fs.shared_link = gen_file_share_link(fs.token)
|
||||
|
||||
path = fs.path.rstrip('/') # Normalize file path
|
||||
obj_id = seafile_api.get_file_id_by_path(r.id, path)
|
||||
file_size = seafile_api.get_file_size(r.store_id, r.version, obj_id)
|
||||
fs.file_size = file_size
|
||||
else:
|
||||
if seafile_api.get_dir_id_by_path(r.id, fs.path) is None:
|
||||
fs.delete()
|
||||
continue
|
||||
fs.filename = os.path.basename(fs.path.rstrip('/'))
|
||||
fs.shared_link = gen_dir_share_link(fs.token)
|
||||
|
||||
path = fs.path
|
||||
if path[-1] != '/': # Normalize dir path
|
||||
path += '/'
|
||||
#get dir size
|
||||
dir_id = seafserv_threaded_rpc.get_dirid_by_path (r.id,
|
||||
r.head_cmmt_id,
|
||||
path.encode('utf-8'))
|
||||
dir_size = seafserv_threaded_rpc.get_dir_size(r.store_id, r.version,
|
||||
dir_id)
|
||||
fs.dir_size = dir_size
|
||||
|
||||
fs.repo = r
|
||||
user_shared_links.append(fs)
|
||||
|
||||
# upload links
|
||||
uploadlinks = UploadLinkShare.objects.filter(username=email)
|
||||
for link in uploadlinks:
|
||||
r = seafile_api.get_repo(link.repo_id)
|
||||
if not r:
|
||||
link.delete()
|
||||
continue
|
||||
if seafile_api.get_dir_id_by_path(r.id, link.path) is None:
|
||||
link.delete()
|
||||
continue
|
||||
link.dir_name = os.path.basename(link.path.rstrip('/'))
|
||||
link.shared_link = gen_shared_upload_link(link.token)
|
||||
link.repo = r
|
||||
user_shared_links.append(link)
|
||||
|
||||
return render_to_response(
|
||||
'sysadmin/userinfo.html', {
|
||||
'owned_repos': owned_repos,
|
||||
@@ -374,6 +432,7 @@ def user_info(request, email):
|
||||
'profile': profile,
|
||||
'd_profile': d_profile,
|
||||
'org_name': org_name,
|
||||
"user_shared_links": user_shared_links,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required_ajax
|
||||
|
Reference in New Issue
Block a user