orbit-basic/lib/tasks/build_new_member.rake

83 lines
3.0 KiB
Ruby

# encoding: utf-8
namespace :build_new_member do
task :module_app => :environment do
ModuleApp.create!(:key=>"new_member",
:title=>"new_member",
:version=> "0.1",
:organization => "Rulingcom",
:author => "RD dep",
:intro => "New interface for member menagement",
:enable_frontend => true)
end
task :sub_role => :environment do
teacher_role = Role.first({conditions:{key: 'teacher'}})
teacher_role.sub_roles.destroy_all
teacher_sub_roles ={
:professor => {"zh_tw"=>"教授", "en"=>"Professor"},
:lecturer => {"zh_tw"=>"講師", "en"=>"Lecturer"},
:associate_professor => {"zh_tw"=>"副教授", "en"=>"Associate Professor"},
:assistant_professor => {"zh_tw"=>"助理教授", "en"=>"Assistant Professor"}
}
teacher_sub_roles.each do |key,title|
teacher_role.sub_roles.build :key=>key,:title_translations=>title,:built_in=>true
puts "=SubRole key:#{key}\t Title:#{title}"
end
teacher_role.save
p "==Finished building sub_roles for Teachers"
student_role = Role.first({conditions:{key: 'student'}})
student_role.sub_roles.destroy_all
student_sub_roles ={
:ph_d => {"zh_tw"=>"博士班", "en"=>"Ph.D"},
:master => {"zh_tw"=>"碩士班", "en"=>"Master"},
:bachelor => {"zh_tw"=>"學士班", "en"=>"Bachelor"},
}
student_sub_roles.each do |key,title|
student_role.sub_roles.build :key=>key,:title_translations=>title,:built_in=>true
puts "=SubRole key:#{key}\t Title:#{title}"
end
student_role.save
p "==Finished building sub_roles for Students"
end
task :status => :environment do
teacher_role = Role.first({conditions:{key: 'teacher'}})
teacher_role.statuses.destroy_all
teacher_status ={
:fulltime => {"en"=>"Full Time", "zh_tw"=>"全職"},
:adjunct => {"en"=>"Adjunct", "zh_tw"=>"兼職"},
:co_hiring => {"en"=>"Co Hiring", "zh_tw"=>"合聘"},
:distinguished => {"en"=>"Distinguished", "zh_tw"=>"特聘"}
}
teacher_status.each do |key,title|
teacher_role.statuses.build :key=>key,:title_translations=>title
puts "=Status key:#{key}\t Title:#{title}"
end
teacher_role.save
p "==Finished building status for Teachers"
student_role = Role.first({conditions:{key: 'student'}})
student_status.statuses.destroy_all
student_status ={
:studying => {"en"=>"Studying", "zh_tw"=>"在學"},
:drop_out => {"en"=>"Drop-out", "zh_tw"=>"休學"},
:alumi => {"en"=>"Alumi", "zh_tw"=>"校友"},
:suspended => {"en"=>"Suspended", "zh_tw"=>"未完成"}
}
student_status.each do |key,title|
student_role.statuses.build :key=>key,:title_translations=>title
puts "=Status key:#{key}\t Title:#{title}"
end
student_role.save
p "==Finished building status for Students"
end
end