Mantis importer: few fixes in user mapping.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1127 e93f8b46-1217-0410-a6f0-8f06a7374b81
pull/351/head
Jean-Philippe Lang 17 years ago
parent c80c1e1ead
commit 9a2ec76a81
  1. 18
      lib/tasks/migrate_from_mantis.rake

@ -87,18 +87,24 @@ task :migrate_from_mantis => :environment do
set_table_name :mantis_user_table
def firstname
realname.blank? ? username : realname.split.first[0..29]
@firstname = realname.blank? ? username : realname.split.first[0..29]
@firstname.gsub!(/[^\w\s\'\-]/i, '')
@firstname
end
def lastname
realname.blank? ? username : realname.split[1..-1].join(' ')[0..29]
@lastname = realname.blank? ? username : realname.split[1..-1].join(' ')[0..29]
@lastname.gsub!(/[^\w\s\'\-]/i, '')
@lastname = '-' if @lastname.blank?
@lastname
end
def email
if read_attribute(:email).match(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)
read_attribute(:email)
if read_attribute(:email).match(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i) &&
!User.find_by_mail(read_attribute(:email))
@email = read_attribute(:email)
else
"#{username}@foo.bar"
@email = "#{username}@foo.bar"
end
end
@ -246,7 +252,7 @@ task :migrate_from_mantis => :environment do
u.password = 'mantis'
u.status = User::STATUS_LOCKED if user.enabled != 1
u.admin = true if user.access_level == 90
next unless u.save
next unless u.save!
users_migrated += 1
users_map[user.id] = u.id
print '.'

Loading…
Cancel
Save