1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-05-12 01:45:04 +00:00

update view shared file

consider if is locked when determine if can edit
This commit is contained in:
lian 2021-06-16 15:36:27 +08:00
parent 2e50a22537
commit 86916cae1f

View File

@ -1132,9 +1132,22 @@ def view_shared_file(request, fileshare):
fileshare.view_cnt = F('view_cnt') + 1
fileshare.save()
if not request.user.is_authenticated:
username = ANONYMOUS_EMAIL
else:
username = request.user.username
# check file lock info
try:
is_locked, locked_by_me = check_file_lock(repo_id, path, username)
except Exception as e:
logger.error(e)
is_locked = False
locked_by_me = False
# get share link permission
can_download = fileshare.get_permissions()['can_download']
can_edit = fileshare.get_permissions()['can_edit']
can_edit = fileshare.get_permissions()['can_edit'] and not is_locked
# download shared file
if request.GET.get('dl', '') == '1':
@ -1180,19 +1193,7 @@ def view_shared_file(request, fileshare):
if filetype in (DOCUMENT, SPREADSHEET):
if not request.user.is_authenticated:
username = ANONYMOUS_EMAIL
else:
username = request.user.username
def online_office_lock_or_refresh_lock(repo_id, path, username):
# check file lock info
try:
is_locked, locked_by_me = check_file_lock(repo_id, path, username)
except Exception as e:
logger.error(e)
is_locked = False
locked_by_online_office = if_locked_by_online_office(repo_id, path)
try:
if not is_locked: