diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-06 20:43:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-06 20:43:31 +0000 |
commit | 9a2ec76a81d2c97c0ccc33452c2ef4557016a0a5 (patch) | |
tree | c3693f7c42be126d906eb485f8160352f744809f | |
parent | c80c1e1eada561326d36f2c0d115eb9ea76d16dd (diff) | |
download | redmine-9a2ec76a81d2c97c0ccc33452c2ef4557016a0a5.tar.gz redmine-9a2ec76a81d2c97c0ccc33452c2ef4557016a0a5.zip |
Mantis importer: few fixes in user mapping.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1127 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/tasks/migrate_from_mantis.rake | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake index 36e7e1514..af8892a6b 100644 --- a/lib/tasks/migrate_from_mantis.rake +++ b/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 '.'
|