From 66bc0ce5609ac40476823024e16b26884572a905 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Sun, 20 Nov 2011 03:16:35 +0800 Subject: [PATCH] Modified dev.rake --- app/assets/stylesheets/stylesheets | 1 - app/models/user/user.rb | 2 +- lib/tasks/dev.rake | 29 ++++++++++++++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) delete mode 120000 app/assets/stylesheets/stylesheets diff --git a/app/assets/stylesheets/stylesheets b/app/assets/stylesheets/stylesheets deleted file mode 120000 index b4d321570..000000000 --- a/app/assets/stylesheets/stylesheets +++ /dev/null @@ -1 +0,0 @@ -stylesheets \ No newline at end of file diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 31e182acb..f582dc04e 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -52,7 +52,7 @@ class User infos = self.user_infos.detect {|info| info.key.to_s.eql?('profile') } if infos first_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('first_name') }[I18n.locale.to_s] rescue nil - last_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('family_name') }[I18n.locale.to_s] rescue nil + last_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('last_name') }[I18n.locale.to_s] rescue nil return "#{first_name} #{last_name}" else return nil diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index c905115d3..2ab64d6d9 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -12,10 +12,6 @@ namespace :dev do end.each(&:drop) Site.create( :school => 'RulingDigital Universitry', :department => 'Computer Science', :valid_locales => [ 'en', 'zh_tw' ], :in_use_locales => [ 'zh_tw', 'en' ]) - - user = User.new( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :active_role => 'teacher') - user.user_roles.build(:key => 'teacher', :discipline_en => 'Database', :discipline_zh_tw => '資料庫' ) - user.save! I18nVariable.create!( :document_class => 'language', :key => 'en', :en => 'English', :zh_tw => '英文' ) I18nVariable.create!( :document_class => 'language', :key => 'zh_tw', :en => 'Chinese', :zh_tw => '中文' ) @@ -26,7 +22,7 @@ namespace :dev do var_5 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'department', :en => 'Department', :zh_tw => '學系', :parent_id => var_4.id ) var_6 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'major', :en => 'Major', :zh_tw => '主修', :parent_id => var_4.id ) var_7 = I18nVariable.create!( :document_class => 'UserInfoModel', :key => 'profile', :en => 'Profile', :zh_tw => '個人檔案' ) - var_8 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'family_name', :en => 'Family name', :zh_tw => '姓氏', :parent_id => var_7.id ) + var_8 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'last_name', :en => 'Last name', :zh_tw => '姓氏', :parent_id => var_7.id ) var_9 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'first_name', :en => 'First name', :zh_tw => '名字', :parent_id => var_7.id ) var_10 = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁') var_11 = I18nVariable.create!( :document_class => 'Page', :key => 'about', :en => 'About', :zh_tw => '關於我們' ) @@ -45,7 +41,7 @@ namespace :dev do urm_2.attribute_models.build( :key => 'major', :locale => true, :i18n_variable_id => var_6.id, :markup => 'text_field', :list_options => [] ) urm_2.save! uim_1 = UserInfoModel.new( :key => 'profile', :i18n_variable_id => var_7.id, :built_in => true ) - uim_1.attribute_models.build( :key => 'family_name', :locale => true, :i18n_variable_id => var_8.id, :markup => 'text_field', :list_options => [], :built_in => true ) + uim_1.attribute_models.build( :key => 'last_name', :locale => true, :i18n_variable_id => var_8.id, :markup => 'text_field', :list_options => [], :built_in => true ) uim_1.attribute_models.build( :key => 'first_name', :locale => true, :i18n_variable_id => var_9.id, :markup => 'text_field', :list_options => [], :built_in => true ) uim_1.save! @@ -120,7 +116,26 @@ namespace :dev do Post.create(:title=>"1st post",:body=>"Long long time ago.....") Post.create(:title=>"2ec post",:body=>"And?.....") - + + + user = User.create( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :active_role => 'teacher' ) + user_info = UserInfo.create( :user_id => user.id, :key => 'profile' ) + user_role = UserRole.create( :user_id => user.id, :key => 'teacher' ) + AttributeValue.create( :user_attribute_id => user_info.id, :key => 'first_name', :en => 'Christophe', :zh_tw => '順發' ) + AttributeValue.create( :user_attribute_id => user_info.id, :key => 'last_name', :en => 'Vilayphiou', :zh_tw => '林' ) + AttributeValue.create( :user_attribute_id => user_role.id, :key => 'discipline', :en => 'Computer Architecture', :zh_tw => '計算機系統結構' ) + AttributeValue.create( :user_attribute_id => user_role.id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' ) + + + user = User.create( :email => 'matt@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :active_role => 'student' ) + user_info = UserInfo.create( :user_id => user.id, :key => 'profile' ) + user_role = UserRole.create( :user_id => user.id, :key => 'student' ) + AttributeValue.create( :user_attribute_id => user_info.id, :key => 'first_name', :en => 'Matt', :zh_tw => '儒淵' ) + AttributeValue.create( :user_attribute_id => user_info.id, :key => 'last_name', :en => 'Fu', :zh_tw => '傅' ) + AttributeValue.create( :user_attribute_id => user_role.id, :key => 'major', :en => 'Information management', :zh_tw => '信息化管理' ) + AttributeValue.create( :user_attribute_id => user_role.id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' ) + + end