Import contact networks
This commit is contained in:
parent
ac42930306
commit
29a1c6355d
15
db/seeds.rb
15
db/seeds.rb
|
@ -3,6 +3,7 @@
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
federal_subjects_filename = Rails.root.join 'config', 'federal_subjects.csv'
|
federal_subjects_filename = Rails.root.join 'config', 'federal_subjects.csv'
|
||||||
|
contact_networks_filename = Rails.root.join 'config', 'contact_networks.csv'
|
||||||
|
|
||||||
CSV.foreach(
|
CSV.foreach(
|
||||||
federal_subjects_filename,
|
federal_subjects_filename,
|
||||||
|
@ -24,6 +25,20 @@ CSV.foreach(
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
CSV.foreach(
|
||||||
|
contact_networks_filename,
|
||||||
|
col_sep: '|',
|
||||||
|
) do |(id, nickname, public_name)|
|
||||||
|
id = Integer(id.strip)
|
||||||
|
nickname.strip!
|
||||||
|
public_name.strip!
|
||||||
|
|
||||||
|
ContactNetwork.where(id: id).first_or_create! do |new_contact_network|
|
||||||
|
new_contact_network.nickname = nickname
|
||||||
|
new_contact_network.public_name = public_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Rails.application.settings(:superuser).tap do |config|
|
Rails.application.settings(:superuser).tap do |config|
|
||||||
User.where(email: config[:email]).first_or_create! do |new_user|
|
User.where(email: config[:email]).first_or_create! do |new_user|
|
||||||
new_user.password = config[:password]
|
new_user.password = config[:password]
|
||||||
|
|
Reference in New Issue