2018-12-01 18:42:36 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-24 20:40:10 +00:00
|
|
|
require 'csv'
|
2018-12-01 18:42:36 +00:00
|
|
|
|
2019-03-24 20:40:10 +00:00
|
|
|
country_states_filename = Rails.root.join 'config', 'country_states.csv'
|
|
|
|
|
2019-03-24 21:13:56 +00:00
|
|
|
CSV.foreach country_states_filename,
|
|
|
|
col_sep: '|' do |(native_name, english_name)|
|
|
|
|
native_name.strip!
|
2019-03-24 20:40:10 +00:00
|
|
|
english_name.strip!
|
2018-12-01 18:42:36 +00:00
|
|
|
|
2019-03-24 21:13:56 +00:00
|
|
|
next if CountryState.where(english_name: english_name).exists?
|
2018-12-01 18:42:36 +00:00
|
|
|
|
2019-03-24 21:13:56 +00:00
|
|
|
CountryState.create! english_name: english_name, native_name: native_name
|
2018-12-01 18:42:36 +00:00
|
|
|
end
|
2018-12-04 01:57:16 +00:00
|
|
|
|
2018-12-09 03:56:06 +00:00
|
|
|
Rails.application.settings(:superuser).tap do |config|
|
2018-12-09 03:07:39 +00:00
|
|
|
User.where(email: config[:email]).first_or_create! do |new_user|
|
|
|
|
new_user.password = config[:password]
|
2018-12-09 02:14:33 +00:00
|
|
|
new_user.confirmed_at = Time.zone.now
|
2019-02-01 23:09:59 +00:00
|
|
|
new_user.account = Account.create!(
|
2019-03-24 19:27:06 +00:00
|
|
|
nickname: config[:nickname],
|
2019-02-01 23:09:59 +00:00
|
|
|
public_name: config[:public_name],
|
|
|
|
biography: config[:biography],
|
|
|
|
)
|
2018-12-09 02:14:33 +00:00
|
|
|
end.account.add_role :superuser
|
|
|
|
end
|