first version of mid_site_sync for new i18n var
This commit is contained in:
parent
b5dc7515f7
commit
9c1eef6ce4
|
@ -18,12 +18,10 @@ namespace :mid_site do
|
|||
sub_role = role.sub_roles.get_sub_role_from_key(key)
|
||||
if sub_role.nil?
|
||||
ut_data = ut_query.find{|ut_data| ut_data["ut_cod"] == key }
|
||||
# debugger
|
||||
i18n_for_new_sub_role = I18nVariable.create!( :document_class => 'SubRole', :key => key, :en => (ut_data["ut_eng_m"] rescue ''), :zh_tw => (ut_data["ut_chi_m"] rescue ''), :parent_id => role.i18n_variable.id )
|
||||
sub_role = role.sub_roles.create!(:key => key)
|
||||
sub_role.i18n_variable = i18n_for_new_sub_role
|
||||
sub_role.title_translations ={"en" => (ut_data["ut_eng_m"] rescue ''), "zh_tw" => (ut_data["ut_chi_m"] rescue '')}
|
||||
sub_role.save!
|
||||
p "Created SubRole(key: #{key}): EN: #{sub_role.i18n_variable.en}, CH: #{sub_role.i18n_variable.zh_tw} ParentRole(#{role.i18n_variable.key}): #{role.i18n_variable.en}"
|
||||
p "Created SubRole(key: #{key}): EN: #{sub_role.title_translations['en']}, CH: #{sub_role.title_translations['zh_tw']} ParentRole(#{role.key}): #{role.title_translations['en']}"
|
||||
end
|
||||
sub_role
|
||||
end
|
||||
|
@ -64,10 +62,10 @@ namespace :mid_site do
|
|||
user_model_mapper = Hash[:ut_cod => mid_user["ut_cod"] ,:up_ut_cod => mid_user["up_ut_cod"],:email => mid_user["eml_adr"],:off_tel_ext => mid_user["off_tel_ext"],:sta_num => mid_user["sta_num"]]
|
||||
user_model_mapper[:admin] = false
|
||||
local_user.update_attributes(user_model_mapper)
|
||||
|
||||
i18n_department_admin = I18nVariable.find_or_create_by( :document_class => 'Role', :key => 'department_admin', :en => 'Department Admin', :zh_tw => '系所使用者' )
|
||||
|
||||
|
||||
local_user.role = Role.find_or_create_by( :key => "department_admin",:build_in => true)
|
||||
local_user.role.i18n_variable = i18n_department_admin
|
||||
local_user.role.title_translations = {"en" => 'Department Admin', "zh_tw" => '系所使用者' }
|
||||
|
||||
|
||||
unless local_user.ut_cod == local_user.up_ut_cod #if the ut_cod has additions info for up ut
|
||||
|
@ -128,15 +126,15 @@ namespace :mid_site do
|
|||
|
||||
task :before_instll_admin => :environment do
|
||||
|
||||
var_1 = I18nVariable.find_or_create_by( :document_class => 'Role', :key => 'administrator', :en => 'Administrator', :zh_tw => '管理員' )
|
||||
var_1_1 = I18nVariable.find_or_create_by( :document_class => 'SubRole', :key => 'computer_center', :en => 'Computer Center', :zh_tw => '計算機中心', :parent_id => var_1.id )
|
||||
var_1 = {"en" => 'Administrator', "zh_tw" => '管理員' }
|
||||
var_1_1 = {"en" => 'Computer Center', "zh_tw" => '計算機中心'}
|
||||
|
||||
admin_role = Role.find_or_create_by( :key => 'administrator',:built_in => true)
|
||||
admin_role.i18n_variable =var_1
|
||||
admin_role.title_translations =var_1
|
||||
admin_role.save!
|
||||
|
||||
sub_role = admin_role.sub_roles.find_or_create_by(:key => 'computer_center', :built_in => true)
|
||||
sub_role.i18n_variable =var_1_1
|
||||
sub_role.title_translations =var_1_1
|
||||
sub_role.save!
|
||||
|
||||
#var_1_1_1 = I18nVariable.create!( :document_class => 'Attribute', :key => 'field', :en => 'Field', :zh_tw => '領域', :parent_id => var_1_1.id )
|
||||
|
|
Loading…
Reference in New Issue