1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

Add basic download feature

This commit is contained in:
xiez
2012-04-24 22:31:24 +08:00
parent f4002df715
commit e4fad50b43
4 changed files with 27 additions and 15 deletions

View File

@@ -13,18 +13,17 @@
{% if owned_repos %}
<table class="repo-list">
<tr>
<th width="12%">名字</th>
<th width="33%">ID</th>
<th width="40%">描述</th>
<th width="15%">操作</th>
<th width="30%">名字</th>
<th width="50%">描述</th>
<th width="20%">操作</th>
</tr>
{% for repo in owned_repos %}
<tr>
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}">{{ repo.props.name }}</a></td>
<td>{{ repo.props.id }}</td>
<td>{{ repo.props.desc }}</td>
<td>
<button data="{{ SITE_ROOT }}repo/download/{{ repo.props.id }}/" class="repo-download-btn">下载</button>
<button data="{{ repo.props.id }}" class="repo-share-btn">共享</button>
<button data="{{ SITE_ROOT }}repo/remove/{{ repo.props.id }}/" class="repo-delete-btn">删除</button>
</td>
@@ -39,18 +38,17 @@
{% if fetched_repos %}
<table class="repo-list">
<tr>
<th width="12%">名字</th>
<th width="33%">ID</th>
<th width="40%">描述</th>
<th width="15%">操作</th>
<th width="30%">名字</th>
<th width="50%">描述</th>
<th width="20%">操作</th>
</tr>
{% for repo in fetched_repos %}
<tr>
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}">{{ repo.props.name }}</a></td>
<td>{{ repo.props.id }}</td>
<td>{{ repo.props.desc }}</td>
<td>
<button data="{{ SITE_ROOT }}repo/download/{{ repo.props.id }}/" class="repo-download-btn">下载</button>
<button data="{{ SITE_ROOT }}repo/removefetched/{{ repo.userid }}/{{ repo.props.id }}/" class="repo-delete-btn">删除</button>
</td>
</tr>
@@ -60,7 +58,7 @@
<p>暂无</p>
{% endif %}
<form id="repo-share-form" action="/repo/addshare/" method="post" name="repo-share-form" class="hide">
<form id="repo-share-form" action="{{ SITE_ROOT }}shareadmin/addshare/" method="post" name="repo-share-form" class="hide">
<label>邮箱</label><br />
<input id="to_email" type="text" name="to_email" value="" maxlength="40" /><br/>
<input id="share_repo_id" type="hidden" name="share_repo_id" value="" />
@@ -77,6 +75,10 @@ $(".repo-share-btn").click(function() {
$("#repo-share-form").modal({appendTo: "#main", containerCss:{padding:18}});
});
$(".repo-download-btn").click(function() {
location.href = $(this).attr("data");
});
addConfirmTo($('.repo-delete-btn'));
</script>
{% endblock %}

View File

@@ -45,7 +45,7 @@
<td>{{ repo.props.shared_email }}</td>
<td>{{ repo.props.desc }}</td>
<td>
<a href="#">下载</a>
<a href="{{ SITE_ROOT }}repo/download/{{ repo.props.id }}/" target="_blank">下载</a>
</td>
</tr>
{% endfor %}

View File

@@ -7,7 +7,7 @@ from seahub.views import root, peers, groups, myhome, \
role_add, role_remove, activate_user, user_add, user_remove, \
ownerhome, remove_fetched_repo, repo_set_public, repo_unset_public, \
repo_list_dir, user_info, repo_set_access_property, repo_operation_file, \
repo_add_share, repo_list_share, repo_remove_share
repo_add_share, repo_list_share, repo_remove_share, repo_download
# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
@@ -29,9 +29,9 @@ urlpatterns = patterns('',
(r'^$', root),
url(r'^home/my/$', myhome, name='myhome'),
url(r'^home/owner/(?P<owner_name>[^/]+)/$', ownerhome, name='ownerhome'),
url(r'^repo/addshare/$', repo_add_share, name='repo_add_share'),
url(r'^shareadmin/$', repo_list_share, name='repo_list_share'),
(r'^shareadmin/remove/(?P<repo_id>[^/]+)/(?P<to_email>[^/]+)/$', repo_remove_share),
url(r'^shareadmin/addshare/$', repo_add_share, name='repo_add_share'), (r'^shareadmin/remove/(?P<repo_id>[^/]+)/(?P<to_email>[^/]+)/$', repo_remove_share),
(r'^download/$', direct_to_template, { 'template': 'download.html' } ),
(r'^repo/(?P<repo_id>[^/]+)/$', repo),
@@ -43,6 +43,7 @@ urlpatterns = patterns('',
(r'^repo/setap/(?P<repo_id>[^/]+)/(?P<ap>[^/]+)/$', repo_set_access_property),
(r'^repo/dir/(?P<repo_id>[^/]+)/$', repo_list_dir),
(r'^repo/(?P<op>[^/]+)/(?P<repo_id>[^/]+)/(?P<obj_id>[^/]+)/(?P<file_name>[^/]+)/$', repo_operation_file),
(r'^repo/download/(?P<repo_id>[^/]+)/$', repo_download),
(r'^seafadmin/$', seafadmin),
url(r'^useradmin/$', useradmin, name='useradmin'),

View File

@@ -355,6 +355,15 @@ def repo_list_share(request):
"in_repos": in_repos,
}, context_instance=RequestContext(request))
@login_required
def repo_download(request, repo_id):
relay_id = cclient.props.id
token = 'default'
redirect_url = "http://localhost:8083/repo/download/?repo_id=%s&token=%s&relay_id=%s" % (repo_id, token, relay_id)
return HttpResponseRedirect(redirect_url)
@login_required
def repo_remove_share(request, repo_id, to_email):
if not validate_owner(request, repo_id):