Locked documnts on My page #663
This commit is contained in:
parent
197b9a52a2
commit
88b9cfcda5
@ -22,6 +22,7 @@ Changelog for Redmine DMSF
|
|||||||
Global title format for downloading
|
Global title format for downloading
|
||||||
New columns in the main DMSF view; columns are configurable from the plugin settings
|
New columns in the main DMSF view; columns are configurable from the plugin settings
|
||||||
|
|
||||||
|
* Bug: #663 - Locked documnts on My page
|
||||||
* Bug: #662 - Broken paging on the Add approver form
|
* Bug: #662 - Broken paging on the Add approver form
|
||||||
* Bug: #651 - Incomplete copy of a file to another project
|
* Bug: #651 - Incomplete copy of a file to another project
|
||||||
* New: #641 - Documents export
|
* New: #641 - Documents export
|
||||||
|
|||||||
@ -46,8 +46,7 @@ class DmsfLock < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def expired?
|
def expired?
|
||||||
return false if expires_at.nil?
|
return expires_at && (expires_at <= Time.now)
|
||||||
return expires_at <= Time.now
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_uuid
|
def generate_uuid
|
||||||
@ -55,7 +54,7 @@ class DmsfLock < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.delete_expired
|
def self.delete_expired
|
||||||
self.delete_all ["#{DmsfLock.table_name}.expires_at IS NOT NULL && #{DmsfLock.table_name}.expires_at < ?", Time.now]
|
DmsfLock.where(['expires_at < ?', Time.now]).delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
# Let's allow our UUID to be searchable
|
# Let's allow our UUID to be searchable
|
||||||
|
|||||||
@ -22,12 +22,14 @@
|
|||||||
|
|
||||||
<% folders = [] %>
|
<% folders = [] %>
|
||||||
<% files = [] %>
|
<% files = [] %>
|
||||||
<% folders = DmsfFolder.joins(
|
<% folders = DmsfFolder.visible.joins(
|
||||||
'JOIN dmsf_locks ON dmsf_folders.id = dmsf_locks.entity_id').where(
|
'JOIN dmsf_locks ON dmsf_folders.id = dmsf_locks.entity_id').where(
|
||||||
'dmsf_locks.entity_type' => 1, 'dmsf_locks.user_id' => @user.id).all if @user %>
|
['dmsf_locks.entity_type = ? AND dmsf_locks.user_id = ? AND (dmsf_locks.expires_at IS NULL OR dmsf_locks.expires_at > ?)',
|
||||||
<% files = DmsfFile.joins(
|
1, @user.id, Time.now]).all if @user %>
|
||||||
|
<% files = DmsfFile.visible.joins(
|
||||||
'JOIN dmsf_locks ON dmsf_files.id = dmsf_locks.entity_id').where(
|
'JOIN dmsf_locks ON dmsf_files.id = dmsf_locks.entity_id').where(
|
||||||
'dmsf_locks.entity_type' => 0, 'dmsf_locks.user_id' => @user.id).all if @user %>
|
['dmsf_locks.entity_type = ? AND dmsf_locks.user_id = ? AND (dmsf_locks.expires_at IS NULL OR dmsf_locks.expires_at > ?)',
|
||||||
|
0, @user.id, Time.now]).all if @user %>
|
||||||
<h3><%= l(:locked_documents)%> (<%= folders.count %>/<%= files.count %>)</h3>
|
<h3><%= l(:locked_documents)%> (<%= folders.count %>/<%= files.count %>)</h3>
|
||||||
<% if folders.any? || files.any?%>
|
<% if folders.any? || files.any?%>
|
||||||
<%= form_tag({}) do %>
|
<%= form_tag({}) do %>
|
||||||
|
|||||||
@ -69,7 +69,8 @@ module RedmineDmsf
|
|||||||
l.lock_scope = scope
|
l.lock_scope = scope
|
||||||
l.user = User.current
|
l.user = User.current
|
||||||
l.expires_at = expire
|
l.expires_at = expire
|
||||||
l.revision = self.last_revision.id unless self.is_a?(DmsfFolder)
|
# TODO: @carlolars
|
||||||
|
# l.revision = self.last_revision.id unless self.is_a?(DmsfFolder)
|
||||||
l.save!
|
l.save!
|
||||||
reload
|
reload
|
||||||
locks.reload
|
locks.reload
|
||||||
|
|||||||
@ -113,4 +113,14 @@ class DmsfLockTest < RedmineDmsf::Test::UnitTest
|
|||||||
User.current = nil
|
User.current = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_expired
|
||||||
|
User.current = @jsmith
|
||||||
|
lock = DmsfLock.new
|
||||||
|
assert !lock.expired?
|
||||||
|
lock.expires_at = Time.now
|
||||||
|
assert lock.expired?
|
||||||
|
lock.expires_at = Time.now + 1.hour
|
||||||
|
assert !lock.expired?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user