Class: UserImport

Inherits:
Import
  • Object
show all
Defined in:
app/models/user_import.rb

Overview

Redmine - project management software Copyright © 2006-2022 Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Constant Summary collapse

AUTO_MAPPABLE_FIELDS =
{
  'login' => 'field_login',
  'firstname' => 'field_firstname',
  'lastname' => 'field_lastname',
  'mail' => 'field_mail',
  'language' => 'field_language',
  'admin' => 'field_admin',
  'auth_source' => 'field_auth_source',
  'password' => 'field_password',
  'must_change_passwd' => 'field_must_change_passwd',
  'status' => 'field_status'
}

Constants inherited from Import

Import::DATE_FORMATS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Import

#add_callback, #columns_options, #do_callbacks, #file=, #file_exists?, #filepath, #first_rows, #headers, #initialize, #mapping, #parse_file, #read_items, #run, #saved_items, #set_default_settings, #to_param, #unsaved_items

Constructor Details

This class inherits a constructor from Import

Class Method Details

.authorized?(user) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/user_import.rb', line 42

def self.authorized?(user)
  user.admin?
end

.layoutObject



38
39
40
# File 'app/models/user_import.rb', line 38

def self.layout
  'admin'
end


34
35
36
# File 'app/models/user_import.rb', line 34

def self.menu_item
  :users
end

Instance Method Details

#mappable_custom_fieldsObject



51
52
53
# File 'app/models/user_import.rb', line 51

def mappable_custom_fields
  UserCustomField.all
end

#saved_objectsObject

Returns the objects that were imported



47
48
49
# File 'app/models/user_import.rb', line 47

def saved_objects
  User.where(:id => saved_items.pluck(:obj_id)).order(:id)
end