Created
November 18, 2010 18:11
-
-
Save blackxored/705364 to your computer and use it in GitHub Desktop.
Import CSV users into redmine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# csv_import_users.rake | |
# Bulk user provisioning for Redmine using CSV file | |
# Copyright (C) 2010 - Adrian Perez <[email protected]> | |
# Licensed under GPL 3. | |
require 'csv' | |
namespace :redmine do | |
task :csv_import_users => :environment do | |
@first_row = true | |
$PROJECT = Project.find_by_identifier('myproject') | |
$GROUP = Group.find_by_lastname('mygroup') | |
$PASSWORD = 'mypassword' | |
CSV.open('~/my_users.csv', 'r') do |row| | |
if not @first_row | |
username = row[0] | |
firstname = row[1] | |
lastname = row[2] | |
email = row[3] | |
puts "Creating user '#{username}'..." | |
@user = User.new | |
@user.login = username | |
@user.firstname = firstname | |
@user.lastname = lastname | |
@user.password = $PASSWORD | |
@user.password_confirmation = $PASSWORD | |
@user.mail = email | |
@user.language = 'tr' | |
# add to project and group | |
@user.groups << $GROUP | |
@user.save! | |
# TODO: add user role | |
end | |
@first_row = nil | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment