Code cleanup, use UserInfo.current_user_id now.
This commit is contained in:
parent
47400286b3
commit
f956948299
1 changed files with 8 additions and 31 deletions
|
@ -61,6 +61,8 @@ returns
|
||||||
|
|
||||||
admin_user = User.find(1)
|
admin_user = User.find(1)
|
||||||
|
|
||||||
|
UserInfo.current_user_id = admin_user.id
|
||||||
|
|
||||||
# set Settings
|
# set Settings
|
||||||
if auto_wizard_hash['Settings']
|
if auto_wizard_hash['Settings']
|
||||||
auto_wizard_hash['Settings'].each { |setting_data|
|
auto_wizard_hash['Settings'].each { |setting_data|
|
||||||
|
@ -71,17 +73,7 @@ returns
|
||||||
# create Organizations
|
# create Organizations
|
||||||
if auto_wizard_hash['Organizations']
|
if auto_wizard_hash['Organizations']
|
||||||
auto_wizard_hash['Organizations'].each { |organization_data|
|
auto_wizard_hash['Organizations'].each { |organization_data|
|
||||||
|
Organization.create_or_update(organization_data.symbolize_keys)
|
||||||
organization_data_symbolized = organization_data.symbolize_keys.merge(
|
|
||||||
{
|
|
||||||
updated_by_id: admin_user.id,
|
|
||||||
created_by_id: admin_user.id
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Organization.create_or_update(
|
|
||||||
organization_data_symbolized
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,19 +99,15 @@ returns
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: groups,
|
groups: groups,
|
||||||
updated_by_id: admin_user.id,
|
|
||||||
created_by_id: admin_user.id
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
created_user = User.create_or_update(user_data_symbolized)
|
||||||
created_user = User.create_or_update(
|
|
||||||
user_data_symbolized
|
|
||||||
)
|
|
||||||
|
|
||||||
# use first created user as admin
|
# use first created user as admin
|
||||||
next if admin_user.id != 1
|
next if admin_user.id != 1
|
||||||
|
|
||||||
admin_user = created_user
|
admin_user = created_user
|
||||||
|
UserInfo.current_user_id = admin_user.id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -132,21 +120,10 @@ returns
|
||||||
model_map.each {|map_name, model|
|
model_map.each {|map_name, model|
|
||||||
next if !auto_wizard_hash[map_name]
|
next if !auto_wizard_hash[map_name]
|
||||||
auto_wizard_hash[map_name].each {|data|
|
auto_wizard_hash[map_name].each {|data|
|
||||||
data_symbolized = data.symbolize_keys.merge(
|
if data['id'] || data['name']
|
||||||
{
|
Kernel.const_get(model).create_or_update(data.symbolize_keys)
|
||||||
updated_by_id: admin_user.id,
|
|
||||||
created_by_id: admin_user.id
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if data_symbolized[:id] || data_symbolized[:name]
|
|
||||||
Kernel.const_get(model).create_or_update(
|
|
||||||
data_symbolized
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
Kernel.const_get(model).create(
|
Kernel.const_get(model).create(data.symbolize_keys)
|
||||||
data_symbolized
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue