1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 17:02:47 +00:00

[del-dirents] update perm check

This commit is contained in:
lian
2015-05-15 17:19:08 +08:00
parent 595d0cd82f
commit 0528bfe85c
2 changed files with 8 additions and 9 deletions

View File

@@ -733,14 +733,13 @@ def delete_dirents(request, repo_id):
# permission checking # permission checking
username = request.user.username username = request.user.username
if check_folder_permission(request, repo.id, parent_dir) != 'rw':
err_msg = _(u'Permission denied.')
return HttpResponse(json.dumps({'error': err_msg}),
status=403, content_type=content_type)
deleted = [] deleted = []
undeleted = [] undeleted = []
for dirent_name in dirents_names: for dirent_name in dirents_names:
full_path = os.path.join(parent_dir, dirent_name)
if check_folder_permission(request, repo.id, full_path) != 'rw':
undeleted.append(dirent_name)
continue
try: try:
seafile_api.del_file(repo_id, parent_dir, dirent_name, username) seafile_api.del_file(repo_id, parent_dir, dirent_name, username)
deleted.append(dirent_name) deleted.append(dirent_name)

View File

@@ -550,7 +550,7 @@ define([
_this.$('#multi-dirents-op').hide(); _this.$('#multi-dirents-op').hide();
} else { } else {
$(selected_dirents).each(function() { $(selected_dirents).each(function() {
if (this.get('obj_name') in data['deleted']) { if (data['deleted'].indexOf(this.get('obj_name')) != -1) {
dirents.remove(this); dirents.remove(this);
} }
}); });
@@ -567,11 +567,11 @@ define([
} }
if (not_del_len > 0) { if (not_del_len > 0) {
if (not_del_len == 1) { if (not_del_len == 1) {
msg_f = gettext("Internal error. Failed to delete %(name)s."); msg_f = gettext("Failed to delete %(name)s.");
} else if (not_del_len == 2) { } else if (not_del_len == 2) {
msg_f = gettext("Internal error. Failed to delete %(name)s and 1 other item."); msg_f = gettext("Failed to delete %(name)s and 1 other item.");
} else { } else {
msg_f = gettext("Internal error. Failed to delete %(name)s and %(amount)s other items."); msg_f = gettext("Failed to delete %(name)s and %(amount)s other items.");
} }
msg_f = msg_f.replace('%(name)s', Common.HTMLescape(data['undeleted'][0])).replace('%(amount)s', not_del_len - 1); msg_f = msg_f.replace('%(name)s', Common.HTMLescape(data['undeleted'][0])).replace('%(amount)s', not_del_len - 1);
Common.feedback(msg_f, 'error'); Common.feedback(msg_f, 'error');