2018-12-01 13:42:36 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-24 16:40:10 -04:00
|
|
|
require 'csv'
|
2018-12-01 13:42:36 -05:00
|
|
|
|
2019-06-23 11:59:44 -04:00
|
|
|
federal_subjects_filename = Rails.root.join 'config', 'federal_subjects.csv'
|
2019-03-24 16:40:10 -04:00
|
|
|
|
2019-06-23 11:59:44 -04:00
|
|
|
CSV.foreach federal_subjects_filename,
|
2019-03-24 20:45:00 -04:00
|
|
|
col_sep: '|' do |(english_name, native_name)|
|
2019-03-24 17:13:56 -04:00
|
|
|
native_name.strip!
|
2019-03-24 16:40:10 -04:00
|
|
|
english_name.strip!
|
2018-12-01 13:42:36 -05:00
|
|
|
|
2019-06-23 11:54:41 -04:00
|
|
|
FederalSubject.where(english_name: english_name)
|
2019-06-23 11:59:44 -04:00
|
|
|
.first_or_create! do |new_federal_subject|
|
|
|
|
new_federal_subject.native_name = native_name
|
2019-04-27 08:40:12 -04:00
|
|
|
end
|
2018-12-01 13:42:36 -05:00
|
|
|
end
|
2018-12-03 20:57:16 -05:00
|
|
|
|
2018-12-08 22:56:06 -05:00
|
|
|
Rails.application.settings(:superuser).tap do |config|
|
2018-12-08 22:07:39 -05:00
|
|
|
User.where(email: config[:email]).first_or_create! do |new_user|
|
|
|
|
new_user.password = config[:password]
|
2018-12-08 21:14:33 -05:00
|
|
|
new_user.confirmed_at = Time.zone.now
|
2019-02-01 18:09:59 -05:00
|
|
|
new_user.account = Account.create!(
|
2019-04-28 09:34:46 -04:00
|
|
|
nickname: config[:nickname],
|
2019-02-01 18:09:59 -05:00
|
|
|
public_name: config[:public_name],
|
2019-04-28 09:34:46 -04:00
|
|
|
biography: config[:biography],
|
2019-02-01 18:09:59 -05:00
|
|
|
)
|
2018-12-08 21:14:33 -05:00
|
|
|
end.account.add_role :superuser
|
|
|
|
end
|