Mercurial > hg > soundsoftware-site
comparison lib/tasks/.svn/text-base/migrate_from_trac.rake.svn-base @ 119:8661b858af72
* Update to Redmine trunk rev 4705
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 14:12:06 +0000 |
parents | 513646585e45 |
children | cd2282d2aa55 |
comparison
equal
deleted
inserted
replaced
39:150ceac17a8d | 119:8661b858af72 |
---|---|
165 # ticket changes: only migrate status changes and comments | 165 # ticket changes: only migrate status changes and comments |
166 has_many :changes, :class_name => "TracTicketChange", :foreign_key => :ticket | 166 has_many :changes, :class_name => "TracTicketChange", :foreign_key => :ticket |
167 has_many :attachments, :class_name => "TracAttachment", | 167 has_many :attachments, :class_name => "TracAttachment", |
168 :finder_sql => "SELECT DISTINCT attachment.* FROM #{TracMigrate::TracAttachment.table_name}" + | 168 :finder_sql => "SELECT DISTINCT attachment.* FROM #{TracMigrate::TracAttachment.table_name}" + |
169 " WHERE #{TracMigrate::TracAttachment.table_name}.type = 'ticket'" + | 169 " WHERE #{TracMigrate::TracAttachment.table_name}.type = 'ticket'" + |
170 ' AND #{TracMigrate::TracAttachment.table_name}.id = \'#{id}\'' | 170 ' AND #{TracMigrate::TracAttachment.table_name}.id = \'#{TracMigrate::TracAttachment.connection.quote_string(id.to_s)}\'' |
171 has_many :customs, :class_name => "TracTicketCustom", :foreign_key => :ticket | 171 has_many :customs, :class_name => "TracTicketCustom", :foreign_key => :ticket |
172 | 172 |
173 def ticket_type | 173 def ticket_type |
174 read_attribute(:type) | 174 read_attribute(:type) |
175 end | 175 end |
205 set_primary_key :name | 205 set_primary_key :name |
206 | 206 |
207 has_many :attachments, :class_name => "TracAttachment", | 207 has_many :attachments, :class_name => "TracAttachment", |
208 :finder_sql => "SELECT DISTINCT attachment.* FROM #{TracMigrate::TracAttachment.table_name}" + | 208 :finder_sql => "SELECT DISTINCT attachment.* FROM #{TracMigrate::TracAttachment.table_name}" + |
209 " WHERE #{TracMigrate::TracAttachment.table_name}.type = 'wiki'" + | 209 " WHERE #{TracMigrate::TracAttachment.table_name}.type = 'wiki'" + |
210 ' AND #{TracMigrate::TracAttachment.table_name}.id = \'#{id}\'' | 210 ' AND #{TracMigrate::TracAttachment.table_name}.id = \'#{TracMigrate::TracAttachment.connection.quote_string(id.to_s)}\'' |
211 | 211 |
212 def self.columns | 212 def self.columns |
213 # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0) | 213 # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0) |
214 super.select {|column| column.name.to_s != 'readonly'} | 214 super.select {|column| column.name.to_s != 'readonly'} |
215 end | 215 end |
244 name =~ (/(.*)(\s+\w+)?/) | 244 name =~ (/(.*)(\s+\w+)?/) |
245 fn = $1.strip | 245 fn = $1.strip |
246 ln = ($2 || '-').strip | 246 ln = ($2 || '-').strip |
247 | 247 |
248 u = User.new :mail => mail.gsub(/[^-@a-z0-9\.]/i, '-'), | 248 u = User.new :mail => mail.gsub(/[^-@a-z0-9\.]/i, '-'), |
249 :firstname => fn[0, limit_for(User, 'firstname')].gsub(/[^\w\s\'\-]/i, '-'), | 249 :firstname => fn[0, limit_for(User, 'firstname')], |
250 :lastname => ln[0, limit_for(User, 'lastname')].gsub(/[^\w\s\'\-]/i, '-') | 250 :lastname => ln[0, limit_for(User, 'lastname')] |
251 | 251 |
252 u.login = username[0,limit_for(User, 'login')].gsub(/[^a-z0-9_\-@\.]/i, '-') | 252 u.login = username[0,limit_for(User, 'login')].gsub(/[^a-z0-9_\-@\.]/i, '-') |
253 u.password = 'trac' | 253 u.password = 'trac' |
254 u.admin = true if TracPermission.find_by_username_and_action(username, 'admin') | 254 u.admin = true if TracPermission.find_by_username_and_action(username, 'admin') |
255 # finally, a default user is used if the new user is not valid | 255 # finally, a default user is used if the new user is not valid |