mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 08:53:14 +00:00
[repo-download]add seafile_access_check
This commit is contained in:
@@ -11,10 +11,7 @@ function addConfirmTo(ele) {
|
|||||||
$('#yes-btn').click(function() {
|
$('#yes-btn').click(function() {
|
||||||
location.href = Del_url;
|
location.href = Del_url;
|
||||||
});
|
});
|
||||||
|
|
||||||
//handle table
|
//handle table
|
||||||
$("table tr:nth-child(even)").addClass("even");
|
$("table tr:nth-child(even)").addClass("even");
|
||||||
$("table tr:nth-child(odd)").addClass("odd");
|
$("table tr:nth-child(odd)").addClass("odd");
|
||||||
//open download btn in new window or tab
|
|
||||||
$(".download-btn").click(function() {
|
|
||||||
window.open($(this).attr("data"));
|
|
||||||
});
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td>
|
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td>
|
||||||
<td>{{ repo.props.desc }}</td>
|
<td>{{ repo.props.desc }}</td>
|
||||||
<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="{{ repo.props.id }}" class="repo-share-btn">共享</button>
|
||||||
<button data="{{ SITE_ROOT }}repo/remove/{{ repo.props.id }}/" class="repo-delete-btn">删除</button>
|
<button data="{{ SITE_ROOT }}repo/remove/{{ repo.props.id }}/" class="repo-delete-btn">删除</button>
|
||||||
</td>
|
</td>
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
<td>{{ repo.props.shared_email }}</td>
|
<td>{{ repo.props.shared_email }}</td>
|
||||||
<td>{{ repo.props.desc }}</td>
|
<td>{{ repo.props.desc }}</td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -138,6 +138,11 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addConfirmTo($('.repo-delete-btn'));
|
addConfirmTo($('.repo-delete-btn'));
|
||||||
|
|
||||||
|
$(".download-btn").click(function() {
|
||||||
|
window.open('/seafile_access_check/?repo_id=' + $(this).attr('data'));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -100,5 +100,9 @@ $('#public-access-start-cancel-btn').click(function() {
|
|||||||
$('.view-btn').click(function() {
|
$('.view-btn').click(function() {
|
||||||
location.href = $(this).attr('data');
|
location.href = $(this).attr('data');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".download-btn").click(function() {
|
||||||
|
window.open($(this).attr("data"));
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
32
templates/seafile_access_check.html
Normal file
32
templates/seafile_access_check.html
Normal 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 %}
|
3
urls.py
3
urls.py
@@ -7,7 +7,7 @@ from seahub.views import root, peers, groups, myhome, \
|
|||||||
role_add, role_remove, activate_user, user_add, user_remove, \
|
role_add, role_remove, activate_user, user_add, user_remove, \
|
||||||
ownerhome, remove_fetched_repo, \
|
ownerhome, remove_fetched_repo, \
|
||||||
repo_list_dir, user_info, repo_set_access_property, repo_operation_file, \
|
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:
|
# Uncomment the next two lines to enable the admin:
|
||||||
#from django.contrib import admin
|
#from django.contrib import admin
|
||||||
@@ -44,6 +44,7 @@ urlpatterns = patterns('',
|
|||||||
(r'^repo/dir/(?P<repo_id>[^/]+)/$', repo_list_dir),
|
(r'^repo/dir/(?P<repo_id>[^/]+)/$', repo_list_dir),
|
||||||
(r'^repo/(?P<op>[^/]+)/(?P<repo_id>[^/]+)/(?P<obj_id>[^/]+)/$', repo_operation_file),
|
(r'^repo/(?P<op>[^/]+)/(?P<repo_id>[^/]+)/(?P<obj_id>[^/]+)/$', repo_operation_file),
|
||||||
(r'^download/repo/$', repo_download),
|
(r'^download/repo/$', repo_download),
|
||||||
|
(r'^seafile_access_check/$', seafile_access_check),
|
||||||
|
|
||||||
(r'^seafadmin/$', seafadmin),
|
(r'^seafadmin/$', seafadmin),
|
||||||
url(r'^useradmin/$', useradmin, name='useradmin'),
|
url(r'^useradmin/$', useradmin, name='useradmin'),
|
||||||
|
14
views.py
14
views.py
@@ -480,7 +480,19 @@ def repo_download(request):
|
|||||||
ccnet_applet_root, repo_id, relay_id, quote_repo_name, enc)
|
ccnet_applet_root, repo_id, relay_id, quote_repo_name, enc)
|
||||||
|
|
||||||
return HttpResponseRedirect(redirect_url)
|
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
|
@login_required
|
||||||
def repo_remove_share(request):
|
def repo_remove_share(request):
|
||||||
repo_id = request.GET.get('repo_id', '')
|
repo_id = request.GET.get('repo_id', '')
|
||||||
|
Reference in New Issue
Block a user