1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 16:10:26 +00:00

[repo-download]add seafile_access_check

This commit is contained in:
llj
2012-05-14 21:51:55 +08:00
parent 77bf3cf392
commit c6c864b8c1
6 changed files with 59 additions and 8 deletions

View File

@@ -11,10 +11,7 @@ function addConfirmTo(ele) {
$('#yes-btn').click(function() {
location.href = Del_url;
});
//handle table
$("table tr:nth-child(even)").addClass("even");
$("table tr:nth-child(odd)").addClass("odd");
//open download btn in new window or tab
$(".download-btn").click(function() {
window.open($(this).attr("data"));
});

View File

@@ -33,7 +33,7 @@
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td>
<td>{{ repo.props.desc }}</td>
<td>
<button data="{{ SITE_ROOT }}download/repo/?repo_id={{ repo.props.id }}" class="download-btn">下载</button>
<button data="{{ repo.props.id }}" class="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>
@@ -60,7 +60,7 @@
<td>{{ repo.props.shared_email }}</td>
<td>{{ repo.props.desc }}</td>
<td>
<button data="{{ SITE_ROOT }}download/repo/?repo_id={{ repo.props.id }}" class="download-btn">下载</button>
<button data="{{ repo.props.id }}" class="download-btn">下载</button>
</td>
</tr>
{% endfor %}
@@ -138,6 +138,11 @@ $(function() {
});
addConfirmTo($('.repo-delete-btn'));
$(".download-btn").click(function() {
window.open('/seafile_access_check/?repo_id=' + $(this).attr('data'));
});
});
</script>
{% endblock %}

View File

@@ -100,5 +100,9 @@ $('#public-access-start-cancel-btn').click(function() {
$('.view-btn').click(function() {
location.href = $(this).attr('data');
});
$(".download-btn").click(function() {
window.open($(this).attr("data"));
});
</script>
{% endblock %}

View File

@@ -0,0 +1,32 @@
{% extends "myhome_base.html" %}
{% block right_panel %}
<p class="error hide">请确认本地Seafile程序已启动。</p>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
$(function() {
var req_success = false;
$.ajax({
url: 'http://localhost:8081/seafile_access_check/',
dataType: 'jsonp',
jsonpCallback: 'xx',
crossDomain: true,
error: function() {
$('.error').removeClass('hide');
},
success: function() {
req_success = true;
location.href = '/download/repo/?repo_id={{ repo_id }}';
}
});
setTimeout(function() {
if (!req_success) {
$('.error').removeClass('hide');
}
}, 300);
});
</script>
{% endblock %}

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_list_dir, user_info, repo_set_access_property, repo_operation_file, \
repo_add_share, repo_list_share, repo_remove_share, repo_download, back_local
repo_add_share, repo_list_share, repo_remove_share, repo_download, seafile_access_check, back_local
# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
@@ -44,6 +44,7 @@ urlpatterns = patterns('',
(r'^repo/dir/(?P<repo_id>[^/]+)/$', repo_list_dir),
(r'^repo/(?P<op>[^/]+)/(?P<repo_id>[^/]+)/(?P<obj_id>[^/]+)/$', repo_operation_file),
(r'^download/repo/$', repo_download),
(r'^seafile_access_check/$', seafile_access_check),
(r'^seafadmin/$', seafadmin),
url(r'^useradmin/$', useradmin, name='useradmin'),

View File

@@ -481,6 +481,18 @@ def repo_download(request):
return HttpResponseRedirect(redirect_url)
def seafile_access_check(request):
repo_id = request.GET.get('repo_id', '')
return render_to_response(
'seafile_access_check.html', {
'repo_id': repo_id,
},
context_instance=RequestContext(request))
@login_required
def repo_remove_share(request):
repo_id = request.GET.get('repo_id', '')