Converting Documents to DMSF is not working #471
This commit is contained in:
parent
c9dba81db8
commit
1b39c077a2
@ -41,12 +41,20 @@ class DmsfConvertDocuments
|
||||
|
||||
projects = options[:project] ? [Project.find(options[:project])] : Project.find(:all)
|
||||
|
||||
projects.reject! {|project| project.module_enabled?('dmsf') }
|
||||
projects.reject! {|project| !project.module_enabled?('documents') }
|
||||
if projects
|
||||
prjs = projects.reject {|project| project.module_enabled?('dmsf') }
|
||||
diff = (projects - prjs)
|
||||
if diff.count > 0
|
||||
puts "Projects skiped due to already enabled module DMSF: #{diff.collect{|p| p.name }.join(' ,')}"
|
||||
end
|
||||
projects = prjs.reject {|project| !project.module_enabled?('documents') }
|
||||
diff = (prjs - projects)
|
||||
if diff.count > 0
|
||||
puts "Projects skiped due to not enabled module Documents: #{diff.collect{|p| p.name }.join(' ,')}"
|
||||
end
|
||||
|
||||
unless projects.nil? || projects.empty?
|
||||
projects.each do |project|
|
||||
puts "Processing project: #{project.identifier}"
|
||||
puts "Processing project: #{project}"
|
||||
|
||||
project.enabled_module_names = (project.enabled_module_names << 'dmsf').uniq unless dry
|
||||
project.save! unless dry
|
||||
@ -59,7 +67,7 @@ class DmsfConvertDocuments
|
||||
folder = DmsfFolder.new
|
||||
|
||||
folder.project = project
|
||||
folder.user = (a = document.attachments.find(:first, :order => 'created_on ASC')) ? a.author : User.find(:first)
|
||||
folder.user = document.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author)
|
||||
|
||||
folder.title = document.title
|
||||
folder.title.gsub!(/[\/\\\?":<>]/, '-') if replace
|
||||
@ -102,7 +110,7 @@ class DmsfConvertDocuments
|
||||
|
||||
file.name = attachment.filename
|
||||
i = 1
|
||||
suffix = ""
|
||||
suffix = ''
|
||||
while files.index{|f| f.name == (DmsfFileRevision.remove_extension(file.name) + suffix + File.extname(file.name))}
|
||||
i+=1
|
||||
suffix = "_#{i}"
|
||||
@ -122,7 +130,7 @@ class DmsfConvertDocuments
|
||||
file.id = attachment.id # Just to have an ID there
|
||||
puts "Dry check file: #{file.name}"
|
||||
if file.invalid?
|
||||
file.errors.each {|e,msg| puts "#{e}: #{msg}"}
|
||||
file.errors.each {|e, msg| puts "#{e}: #{msg}"}
|
||||
end
|
||||
else
|
||||
file.save!
|
||||
@ -151,7 +159,7 @@ class DmsfConvertDocuments
|
||||
if dry
|
||||
puts "Dry check revision: #{revision.title}"
|
||||
if revision.invalid?
|
||||
revision.errors.each {|e,msg| puts "#{e}: #{msg}"}
|
||||
revision.errors.each {|e, msg| puts "#{e}: #{msg}"}
|
||||
end
|
||||
else
|
||||
revision.save!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user