* work on Issue 153: Losing revision history across a move
git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@244 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
parent
9771aa4f59
commit
c30809169f
@ -76,6 +76,7 @@ class DmsfFilesController < ApplicationController
|
||||
@revision = DmsfFileRevision.new(params[:dmsf_file_revision])
|
||||
|
||||
@revision.file = @file
|
||||
@revision.project = @file.project
|
||||
last_revision = @file.last_revision
|
||||
@revision.source_revision = last_revision
|
||||
@revision.user = User.current
|
||||
|
||||
@ -75,6 +75,7 @@ class DmsfFilesCopyController < ApplicationController
|
||||
new_revision = DmsfFileRevision.new
|
||||
new_revision.folder = @target_folder
|
||||
new_revision.file = file
|
||||
new_revision.project = file.project
|
||||
new_revision.user = User.current
|
||||
new_revision.name = name
|
||||
new_revision.title = @file.title
|
||||
|
||||
@ -99,6 +99,7 @@ class DmsfUploadController < ApplicationController
|
||||
|
||||
commited_disk_filepath = "#{DmsfHelper.temp_dir}/#{commited_file["disk_filename"].gsub(/[\/\\]/,'')}"
|
||||
|
||||
new_revision.project = @project
|
||||
new_revision.folder = @folder
|
||||
new_revision.file = file
|
||||
new_revision.user = User.current
|
||||
|
||||
@ -23,6 +23,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :folder, :class_name => "DmsfFolder", :foreign_key => "dmsf_folder_id"
|
||||
belongs_to :deleted_by_user, :class_name => "User", :foreign_key => "deleted_by_user_id"
|
||||
belongs_to :project
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_dmsf_updated)}: #{o.file.dmsf_path_str}"},
|
||||
:url => Proc.new {|o| {:controller => 'dmsf_files', :action => 'show', :id => o.file}},
|
||||
@ -97,10 +98,6 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
"#{self.major_version}.#{self.minor_version}"
|
||||
end
|
||||
|
||||
def project
|
||||
self.file.project
|
||||
end
|
||||
|
||||
def disk_file
|
||||
"#{DmsfFile.storage_path}/#{self.disk_filename}"
|
||||
end
|
||||
@ -116,6 +113,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
def clone
|
||||
new_revision = DmsfFileRevision.new
|
||||
new_revision.file = self.file
|
||||
new_revision.project = self.project
|
||||
new_revision.disk_filename = self.disk_filename
|
||||
new_revision.size = self.size
|
||||
new_revision.mime_type = self.mime_type
|
||||
|
||||
45
db/migrate/06_dmsf_1_2_0.rb
Normal file
45
db/migrate/06_dmsf_1_2_0.rb
Normal file
@ -0,0 +1,45 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Dmsf120 < ActiveRecord::Migration
|
||||
|
||||
class DmsfFileRevision < ActiveRecord::Base
|
||||
belongs_to :file, :class_name => "DmsfFile", :foreign_key => "dmsf_file_id"
|
||||
belongs_to :source_revision, :class_name => "DmsfFileRevision", :foreign_key => "source_dmsf_file_revision_id"
|
||||
belongs_to :user
|
||||
belongs_to :folder, :class_name => "DmsfFolder", :foreign_key => "dmsf_folder_id"
|
||||
belongs_to :deleted_by_user, :class_name => "User", :foreign_key => "deleted_by_user_id"
|
||||
belongs_to :project
|
||||
end
|
||||
|
||||
def self.up
|
||||
add_column :dmsf_file_revisions, :project_id, :integer, :null => true
|
||||
|
||||
DmsfFileRevision.find_each do |revision|
|
||||
revision.project = revision.file.project
|
||||
revision.save
|
||||
end
|
||||
|
||||
change_column :dmsf_file_revisions, :project_id, :integer, :null => false
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :dmsf_file_revisions, :project_id
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user