##// END OF EJS Templates
Fixed: migrate_from_trac doesn't import timestamps of wiki and tickets (patch #882 by Andreas Neuhaus slightly edited)....
Jean-Philippe Lang -
r1287:1bb51f743a35
parent child
Show More
@@ -69,6 +69,21 namespace :redmine do
69 'developer' => developer_role
69 'developer' => developer_role
70 }
70 }
71
71
72 class ::Time
73 class << self
74 alias :real_now :now
75 def now
76 real_now - @fake_diff.to_i
77 end
78 def fake(time)
79 @fake_diff = real_now - time
80 res = yield
81 @fake_diff = 0
82 res
83 end
84 end
85 end
86
72 class TracComponent < ActiveRecord::Base
87 class TracComponent < ActiveRecord::Base
73 set_table_name :component
88 set_table_name :component
74 end
89 end
@@ -141,6 +156,7 namespace :redmine do
141 end
156 end
142
157
143 def time; Time.at(read_attribute(:time)) end
158 def time; Time.at(read_attribute(:time)) end
159 def changetime; Time.at(read_attribute(:changetime)) end
144 end
160 end
145
161
146 class TracTicketChange < ActiveRecord::Base
162 class TracTicketChange < ActiveRecord::Base
@@ -167,6 +183,8 namespace :redmine do
167 # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0)
183 # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0)
168 super.select {|column| column.name.to_s != 'readonly'}
184 super.select {|column| column.name.to_s != 'readonly'}
169 end
185 end
186
187 def time; Time.at(read_attribute(:time)) end
170 end
188 end
171
189
172 class TracPermission < ActiveRecord::Base
190 class TracPermission < ActiveRecord::Base
@@ -345,14 +363,14 namespace :redmine do
345 i.tracker = TRACKER_MAPPING[ticket.ticket_type] || DEFAULT_TRACKER
363 i.tracker = TRACKER_MAPPING[ticket.ticket_type] || DEFAULT_TRACKER
346 i.custom_values << CustomValue.new(:custom_field => custom_field_map['resolution'], :value => ticket.resolution) unless ticket.resolution.blank?
364 i.custom_values << CustomValue.new(:custom_field => custom_field_map['resolution'], :value => ticket.resolution) unless ticket.resolution.blank?
347 i.id = ticket.id unless Issue.exists?(ticket.id)
365 i.id = ticket.id unless Issue.exists?(ticket.id)
348 next unless i.save
366 next unless Time.fake(ticket.changetime) { i.save }
349 TICKET_MAP[ticket.id] = i.id
367 TICKET_MAP[ticket.id] = i.id
350 migrated_tickets += 1
368 migrated_tickets += 1
351
369
352 # Owner
370 # Owner
353 unless ticket.owner.blank?
371 unless ticket.owner.blank?
354 i.assigned_to = find_or_create_user(ticket.owner, true)
372 i.assigned_to = find_or_create_user(ticket.owner, true)
355 i.save
373 Time.fake(ticket.changetime) { i.save }
356 end
374 end
357
375
358 # Comments and status/resolution changes
376 # Comments and status/resolution changes
@@ -426,7 +444,7 namespace :redmine do
426 p.content.text = page.text
444 p.content.text = page.text
427 p.content.author = find_or_create_user(page.author) unless page.author.blank? || page.author == 'trac'
445 p.content.author = find_or_create_user(page.author) unless page.author.blank? || page.author == 'trac'
428 p.content.comments = page.comment
446 p.content.comments = page.comment
429 p.new_record? ? p.save : p.content.save
447 Time.fake(page.time) { p.new_record? ? p.save : p.content.save }
430
448
431 next if p.content.new_record?
449 next if p.content.new_record?
432 migrated_wiki_edits += 1
450 migrated_wiki_edits += 1
@@ -446,7 +464,7 namespace :redmine do
446 wiki.reload
464 wiki.reload
447 wiki.pages.each do |page|
465 wiki.pages.each do |page|
448 page.content.text = convert_wiki_text(page.content.text)
466 page.content.text = convert_wiki_text(page.content.text)
449 page.content.save
467 Time.fake(page.content.updated_on) { page.content.save }
450 end
468 end
451 end
469 end
452 puts
470 puts
General Comments 0
You need to be logged in to leave comments. Login now