Mercurial > hg > soundsoftware-site
comparison lib/tasks/migrate_from_mantis.rake @ 511:107d36338b70 live
Merge from branch "cannam"
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:43:07 +0100 |
parents | 0579821a129a |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
451:a9f6345cb43d | 511:107d36338b70 |
---|---|
86 class MantisUser < ActiveRecord::Base | 86 class MantisUser < ActiveRecord::Base |
87 set_table_name :mantis_user_table | 87 set_table_name :mantis_user_table |
88 | 88 |
89 def firstname | 89 def firstname |
90 @firstname = realname.blank? ? username : realname.split.first[0..29] | 90 @firstname = realname.blank? ? username : realname.split.first[0..29] |
91 @firstname.gsub!(/[^\w\s\'\-]/i, '') | |
92 @firstname | 91 @firstname |
93 end | 92 end |
94 | 93 |
95 def lastname | 94 def lastname |
96 @lastname = realname.blank? ? '-' : realname.split[1..-1].join(' ')[0..29] | 95 @lastname = realname.blank? ? '-' : realname.split[1..-1].join(' ')[0..29] |
97 @lastname.gsub!(/[^\w\s\'\-]/i, '') | |
98 @lastname = '-' if @lastname.blank? | 96 @lastname = '-' if @lastname.blank? |
99 @lastname | 97 @lastname |
100 end | 98 end |
101 | 99 |
102 def email | 100 def email |
222 def format | 220 def format |
223 read_attribute :type | 221 read_attribute :type |
224 end | 222 end |
225 | 223 |
226 def name | 224 def name |
227 read_attribute(:name)[0..29].gsub(/[^\w\s\'\-]/, '-') | 225 read_attribute(:name)[0..29] |
228 end | 226 end |
229 end | 227 end |
230 | 228 |
231 class MantisCustomFieldProject < ActiveRecord::Base | 229 class MantisCustomFieldProject < ActiveRecord::Base |
232 set_table_name :mantis_custom_field_project_table | 230 set_table_name :mantis_custom_field_project_table |
287 | 285 |
288 # Project versions | 286 # Project versions |
289 project.versions.each do |version| | 287 project.versions.each do |version| |
290 v = Version.new :name => encode(version.version), | 288 v = Version.new :name => encode(version.version), |
291 :description => encode(version.description), | 289 :description => encode(version.description), |
292 :effective_date => version.date_order.to_date | 290 :effective_date => (version.date_order ? version.date_order.to_date : nil) |
293 v.project = p | 291 v.project = p |
294 v.save | 292 v.save |
295 versions_map[version.id] = v.id | 293 versions_map[version.id] = v.id |
296 end | 294 end |
297 | 295 |