mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
repo owner and admin can unlock file (#4791)
Co-authored-by: lian <lian@seafile.com>
This commit is contained in:
@@ -493,7 +493,7 @@ export const Utils = {
|
|||||||
return list;
|
return list;
|
||||||
},
|
},
|
||||||
|
|
||||||
getFileOperationList: function(currentRepoInfo, dirent, isContextmenu) {
|
getFileOperationList: function(isRepoOwner, currentRepoInfo, dirent, isContextmenu) {
|
||||||
let list = [];
|
let list = [];
|
||||||
const { SHARE, DOWNLOAD, DELETE, RENAME, MOVE, COPY, TAGS, UNLOCK, LOCK,
|
const { SHARE, DOWNLOAD, DELETE, RENAME, MOVE, COPY, TAGS, UNLOCK, LOCK,
|
||||||
COMMENT, HISTORY, ACCESS_LOG, OPEN_VIA_CLIENT } = TextTranslation;
|
COMMENT, HISTORY, ACCESS_LOG, OPEN_VIA_CLIENT } = TextTranslation;
|
||||||
@@ -525,7 +525,7 @@ export const Utils = {
|
|||||||
|
|
||||||
if (isPro) {
|
if (isPro) {
|
||||||
if (dirent.is_locked) {
|
if (dirent.is_locked) {
|
||||||
if (dirent.locked_by_me || dirent.lock_owner == 'OnlineOffice') {
|
if (dirent.locked_by_me || dirent.lock_owner == 'OnlineOffice' || isRepoOwner || currentRepoInfo.id_admin) {
|
||||||
list.push(UNLOCK);
|
list.push(UNLOCK);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -560,7 +560,7 @@ export const Utils = {
|
|||||||
getDirentOperationList: function(isRepoOwner, currentRepoInfo, dirent, isContextmenu) {
|
getDirentOperationList: function(isRepoOwner, currentRepoInfo, dirent, isContextmenu) {
|
||||||
return dirent.type == 'dir' ?
|
return dirent.type == 'dir' ?
|
||||||
Utils.getFolderOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu) :
|
Utils.getFolderOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu) :
|
||||||
Utils.getFileOperationList(currentRepoInfo, dirent, isContextmenu);
|
Utils.getFileOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu);
|
||||||
},
|
},
|
||||||
|
|
||||||
sharePerms: function(permission) {
|
sharePerms: function(permission) {
|
||||||
|
@@ -24,7 +24,7 @@ from seahub.views import check_folder_permission
|
|||||||
from seahub.utils.file_op import check_file_lock, if_locked_by_online_office
|
from seahub.utils.file_op import check_file_lock, if_locked_by_online_office
|
||||||
from seahub.views.file import can_preview_file, can_edit_file
|
from seahub.views.file import can_preview_file, can_edit_file
|
||||||
from seahub.constants import PERMISSION_READ_WRITE
|
from seahub.constants import PERMISSION_READ_WRITE
|
||||||
from seahub.utils.repo import parse_repo_perm
|
from seahub.utils.repo import parse_repo_perm, is_repo_admin, is_repo_owner
|
||||||
from seahub.utils.file_types import MARKDOWN, TEXT
|
from seahub.utils.file_types import MARKDOWN, TEXT
|
||||||
|
|
||||||
from seahub.settings import MAX_UPLOAD_FILE_NAME_LEN, \
|
from seahub.settings import MAX_UPLOAD_FILE_NAME_LEN, \
|
||||||
@@ -57,7 +57,7 @@ class FileView(APIView):
|
|||||||
file_name = file_obj.obj_name
|
file_name = file_obj.obj_name
|
||||||
file_size = file_obj.size
|
file_size = file_obj.size
|
||||||
can_preview, error_msg = can_preview_file(file_name, file_size, repo)
|
can_preview, error_msg = can_preview_file(file_name, file_size, repo)
|
||||||
can_edit, error_msg = can_edit_file(file_name, file_size, repo)
|
can_edit, error_msg = can_edit_file(file_name, file_size, repo)
|
||||||
else:
|
else:
|
||||||
can_preview = False
|
can_preview = False
|
||||||
can_edit = False
|
can_edit = False
|
||||||
@@ -295,11 +295,9 @@ class FileView(APIView):
|
|||||||
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||||
|
|
||||||
# rename file
|
# rename file
|
||||||
new_file_name = check_filename_with_rename(repo_id, parent_dir,
|
new_file_name = check_filename_with_rename(repo_id, parent_dir, new_file_name)
|
||||||
new_file_name)
|
|
||||||
try:
|
try:
|
||||||
seafile_api.rename_file(repo_id, parent_dir, oldname,
|
seafile_api.rename_file(repo_id, parent_dir, oldname, new_file_name, username)
|
||||||
new_file_name, username)
|
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
@@ -394,8 +392,8 @@ class FileView(APIView):
|
|||||||
new_file_name = check_filename_with_rename(dst_repo_id, dst_dir, filename)
|
new_file_name = check_filename_with_rename(dst_repo_id, dst_dir, filename)
|
||||||
try:
|
try:
|
||||||
seafile_api.move_file(src_repo_id, src_dir, filename,
|
seafile_api.move_file(src_repo_id, src_dir, filename,
|
||||||
dst_repo_id, dst_dir, new_file_name, replace=False,
|
dst_repo_id, dst_dir, new_file_name, replace=False,
|
||||||
username=username, need_progress=0, synchronous=1)
|
username=username, need_progress=0, synchronous=1)
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
@@ -460,7 +458,7 @@ class FileView(APIView):
|
|||||||
new_file_name = check_filename_with_rename(dst_repo_id, dst_dir, filename)
|
new_file_name = check_filename_with_rename(dst_repo_id, dst_dir, filename)
|
||||||
try:
|
try:
|
||||||
seafile_api.copy_file(src_repo_id, src_dir, filename, dst_repo_id,
|
seafile_api.copy_file(src_repo_id, src_dir, filename, dst_repo_id,
|
||||||
dst_dir, new_file_name, username, 0, synchronous=1)
|
dst_dir, new_file_name, username, 0, synchronous=1)
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
@@ -586,7 +584,9 @@ class FileView(APIView):
|
|||||||
error_msg = _("File is not locked.")
|
error_msg = _("File is not locked.")
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
if locked_by_me or locked_by_online_office:
|
if locked_by_me or locked_by_online_office or \
|
||||||
|
is_repo_owner(request, repo_id, username) or \
|
||||||
|
is_repo_admin(username, repo_id):
|
||||||
# unlock file
|
# unlock file
|
||||||
try:
|
try:
|
||||||
seafile_api.unlock_file(repo_id, path)
|
seafile_api.unlock_file(repo_id, path)
|
||||||
|
Reference in New Issue
Block a user