Patch #2504 ยป import_trac_ticket_keywords.diff
| migrate_from_trac.rake (copie de travail) | ||
|---|---|---|
|
r.save!
|
||
|
custom_field_map['resolution'] = r
|
||
|
|
||
|
# Trac 'keywords' field as a Redmine custom field
|
||
|
r = IssueCustomField.find(:first, :conditions => { :name => "Keywords" })
|
||
|
r = IssueCustomField.new(:name => 'Keywords',
|
||
|
:field_format => 'string',
|
||
|
:is_filter => true) if r.nil?
|
||
|
r.trackers = Tracker.find(:all)
|
||
|
r.projects << @target_project
|
||
|
#r.possible_values = (r.possible_values + %w(fixed invalid wontfix duplicate worksforme)).flatten.compact.uniq
|
||
|
r.save!
|
||
|
custom_field_map['keywords'] = r
|
||
|
# Tickets
|
||
|
print "Migrating tickets"
|
||
|
TracTicket.find(:all, :order => 'id ASC').each do |ticket|
|
||
| ... | ... | |
|
i.status = STATUS_MAPPING[ticket.status] || DEFAULT_STATUS
|
||
|
i.tracker = TRACKER_MAPPING[ticket.ticket_type] || DEFAULT_TRACKER
|
||
|
i.custom_values << CustomValue.new(:custom_field => custom_field_map['resolution'], :value => ticket.resolution) unless ticket.resolution.blank?
|
||
|
i.custom_values << CustomValue.new(:custom_field => custom_field_map['keywords'], :value => ticket.keywords) unless ticket.keywords.blank?
|
||
|
i.id = ticket.id unless Issue.exists?(ticket.id)
|
||
|
next unless Time.fake(ticket.changetime) { i.save }
|
||
|
TICKET_MAP[ticket.id] = i.id
|
||
| ... | ... | |
|
Time.fake(ticket.changetime) { i.save }
|
||
|
end
|
||
|
|
||
|
# Comments and status/resolution changes
|
||
|
# Comments and status/resolution/keywords changes
|
||
|
ticket.changes.group_by(&:time).each do |time, changeset|
|
||
|
status_change = changeset.select {|change| change.field == 'status'}.first
|
||
|
resolution_change = changeset.select {|change| change.field == 'resolution'}.first
|
||
|
keywords_change = changeset.select {|change| change.field == 'keywords'}.first
|
||
|
comment_change = changeset.select {|change| change.field == 'comment'}.first
|
||
|
|
||
|
n = Journal.new :notes => (comment_change ? convert_wiki_text(encode(comment_change.newvalue)) : ''),
|
||
| ... | ... | |
|
:old_value => resolution_change.oldvalue,
|
||
|
:value => resolution_change.newvalue)
|
||
|
end
|
||
|
if keywords_change
|
||
|
n.details << JournalDetail.new(:property => 'cf',
|
||
|
:prop_key => custom_field_map['keywords'].id,
|
||
|
:old_value => keywords_change.oldvalue,
|
||
|
:value => keywords_change.newvalue)
|
||
|
end
|
||
|
n.save unless n.details.empty? && n.notes.blank?
|
||
|
end
|
||
|
|
||