Expired locks

This commit is contained in:
Karel Picman 2016-06-10 13:58:20 +02:00
parent 2fd955183d
commit 8238a4f33f
13 changed files with 24 additions and 16 deletions

View File

@ -254,8 +254,12 @@ class DmsfFilesController < ApplicationController
if @file.locked? if @file.locked?
flash[:warning] = l(:warning_file_already_locked) flash[:warning] = l(:warning_file_already_locked)
else else
begin
@file.lock! @file.lock!
flash[:notice] = l(:notice_file_locked) flash[:notice] = l(:notice_file_locked)
rescue Exception => e
flash[:error] = e.message
end
end end
redirect_to :back redirect_to :back
end end
@ -265,8 +269,12 @@ class DmsfFilesController < ApplicationController
flash[:warning] = l(:warning_file_not_locked) flash[:warning] = l(:warning_file_not_locked)
else else
if @file.locks[0].user == User.current || User.current.allowed_to?(:force_file_unlock, @file.project) if @file.locks[0].user == User.current || User.current.allowed_to?(:force_file_unlock, @file.project)
begin
@file.unlock! @file.unlock!
flash[:notice] = l(:notice_file_unlocked) flash[:notice] = l(:notice_file_unlocked)
rescue Exception => e
flash[:error] = e.message
end
else else
flash[:error] = l(:error_only_user_that_locked_file_can_unlock_it) flash[:error] = l(:error_only_user_that_locked_file_can_unlock_it)
end end

View File

@ -319,7 +319,7 @@ de:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ en:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ es:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ fr:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ ja:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ pl:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ pt-BR:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ ru:
error_resource_or_parent_locked: Невозможно выполнить блокировку - ресурс (или родительская запись) заблокированы error_resource_or_parent_locked: Невозможно выполнить блокировку - ресурс (или родительская запись) заблокированы
error_parent_locked: Невозможно выполнить блокировку - родительская запись заблокирована error_parent_locked: Невозможно выполнить блокировку - родительская запись заблокирована
error_resource_locked: Невозможно выполнить блокировку - ресурс заблокирован error_resource_locked: Невозможно выполнить блокировку - ресурс заблокирован
error_lock_exclusively: невозможно эксклюзивно заблокировать уже забловированный ресурс error_lock_exclusively: Невозможно эксклюзивно заблокировать уже забловированный ресурс
error_unlock_parent_locked: Разблокировка не удалась - родительская запись заблокирована error_unlock_parent_locked: Разблокировка не удалась - родительская запись заблокирована
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ sl:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ zh-TW:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -319,7 +319,7 @@ zh:
error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked error_resource_or_parent_locked: Unable to complete lock - resource (or parent) is locked
error_parent_locked: Unable to complete lock - resource parent is locked error_parent_locked: Unable to complete lock - resource parent is locked
error_resource_locked: Unable to complete lock - resource is locked error_resource_locked: Unable to complete lock - resource is locked
error_lock_exclusively: unable to lock exclusively an already-locked resource error_lock_exclusively: Unable to lock exclusively an already-locked resource
error_unlock_parent_locked: Unlock failed - resource parent is locked error_unlock_parent_locked: Unlock failed - resource parent is locked
field_dmsf_tree_view: Navigate folders in a tree field_dmsf_tree_view: Navigate folders in a tree

View File

@ -45,7 +45,7 @@ module RedmineDmsf
def lock!(scope = :scope_exclusive, type = :type_write, expire = nil) def lock!(scope = :scope_exclusive, type = :type_write, expire = nil)
# Raise a lock error if entity is locked, but its not at resource level # Raise a lock error if entity is locked, but its not at resource level
existing = locks(false) existing = lock(false)
raise DmsfLockError.new(l(:error_resource_or_parent_locked)) if self.locked? && existing.empty? raise DmsfLockError.new(l(:error_resource_or_parent_locked)) if self.locked? && existing.empty?
unless existing.empty? unless existing.empty?
if (existing[0].lock_scope == :scope_shared) && (scope == :scope_shared) if (existing[0].lock_scope == :scope_shared) && (scope == :scope_shared)