Changes for sub_roles
Issues: update doesn't create new i18n_variables, role form has bugs
This commit is contained in:
1 parent
d23cf152da
commit
d27d7a623c
62 files changed
+508
-1142
No files matched your search
+55
-48
@@ -13,55 +13,61 @@ namespace :dev do
|
||||
|
||||
Site.create( :school => 'RulingDigital Universitry', :department => 'Computer Science', :valid_locales => [ 'en', 'zh_tw' ], :in_use_locales => [ 'zh_tw', 'en' ])
|
||||
|
||||
# I18n_variables
|
||||
I18nVariable.create!( :document_class => 'language', :key => 'en', :en => 'English', :zh_tw => '英文' )
|
||||
I18nVariable.create!( :document_class => 'language', :key => 'zh_tw', :en => 'Chinese', :zh_tw => '中文' )
|
||||
var_1 = I18nVariable.create!( :document_class => 'Role', :key => 'teacher', :en => 'Teacher', :zh_tw => '老師' )
|
||||
var_2 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'discipline', :en => 'Discipline', :zh_tw => '學科', :parent_id => var_1.id )
|
||||
var_3 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'department', :en => 'Department', :zh_tw => '學系', :parent_id => var_1.id )
|
||||
var_4 = I18nVariable.create!( :document_class => 'Role', :key => 'student', :en => 'Student', :zh_tw => '學生' )
|
||||
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_1_1 = I18nVariable.create!( :document_class => 'SubRole', :key => 'good_teacher', :en => 'Good teacher', :zh_tw => '好老師', :parent_id => var_1.id )
|
||||
var_1_1_1 = I18nVariable.create!( :document_class => 'Attribute', :key => 'field', :en => 'Field', :zh_tw => '領域', :parent_id => var_1_1.id )
|
||||
var_1_1_2 = I18nVariable.create!( :document_class => 'Attribute', :key => 'department', :en => 'Department', :zh_tw => '學系', :parent_id => var_1_1.id )
|
||||
var_1_2 = I18nVariable.create!( :document_class => 'SubRole', :key => 'bad_teacher', :en => 'Bad teacher', :zh_tw => '壞老師', :parent_id => var_1.id )
|
||||
var_1_2_1 = I18nVariable.create!( :document_class => 'Attribute', :key => 'field', :en => 'Field', :zh_tw => '領域', :parent_id => var_1_2.id )
|
||||
var_1_2_2 = I18nVariable.create!( :document_class => 'Attribute', :key => 'department', :en => 'Department', :zh_tw => '學系', :parent_id => var_1_2.id )
|
||||
var_1_2_3 = I18nVariable.create!( :document_class => 'Attribute', :key => 'speciality', :en => 'Speciality', :zh_tw => '專業', :parent_id => var_1_2.id )
|
||||
var_2 = I18nVariable.create!( :document_class => 'Role', :key => 'student', :en => 'Student', :zh_tw => '學生' )
|
||||
var_2_1 = I18nVariable.create!( :document_class => 'SubRole', :key => 'undergraduate', :en => 'Undergraduate', :zh_tw => '大學部學生', :parent_id => var_2.id )
|
||||
var_2_1_1 = I18nVariable.create!( :document_class => 'Attribute', :key => 'department', :en => 'Department', :zh_tw => '學系', :parent_id => var_2_1.id )
|
||||
var_2_1_2 = I18nVariable.create!( :document_class => 'Attribute', :key => 'major', :en => 'Major', :zh_tw => '主修', :parent_id => var_2_1.id )
|
||||
var_2_2 = I18nVariable.create!( :document_class => 'SubRole', :key => 'graduate', :en => 'Graduate', :zh_tw => '研究生', :parent_id => var_2.id )
|
||||
var_2_2_1 = I18nVariable.create!( :document_class => 'Attribute', :key => 'department', :en => 'Department', :zh_tw => '學系', :parent_id => var_2_2.id )
|
||||
var_2_2_2 = I18nVariable.create!( :document_class => 'Attribute', :key => 'major', :en => 'Major', :zh_tw => '主修', :parent_id => var_2_2.id )
|
||||
var_2_2_3 = I18nVariable.create!( :document_class => 'Attribute', :key => 'thesis_subject', :en => 'Thesis subject', :zh_tw => '論文題目', :parent_id => var_2_2.id )
|
||||
var_7 = I18nVariable.create!( :document_class => 'Info', :key => 'profile', :en => 'Profile', :zh_tw => '個人檔案' )
|
||||
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_8 = I18nVariable.create!( :document_class => 'Attribute', :key => 'last_name', :en => 'Last name', :zh_tw => '姓氏', :parent_id => var_7.id )
|
||||
var_9 = I18nVariable.create!( :document_class => 'Attribute', :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 => '關於我們' )
|
||||
var_12 = I18nVariable.create!( :document_class => 'Link', :key => 'google', :en => 'Google', :zh_tw => 'Google' )
|
||||
var_13 = I18nVariable.create!( :document_class => 'PagePart', :key => 'main_content', :en => 'This is the homepage', :zh_tw => '這是首頁', :parent_id => var_10.id )
|
||||
var_14 = I18nVariable.create!( :document_class => 'PagePart', :key => 'main_content', :en => 'This is about', :zh_tw => '這是關於', :parent_id => var_11.id )
|
||||
|
||||
# User roles
|
||||
r_1 = Role.new( :key => 'teacher', :i18n_variable => var_1, :built_in => true )
|
||||
sr_1_1 = r_1.sub_roles.build( :key => 'good_teacher', :i18n_variable => var_1_1, :built_in => true )
|
||||
sr_1_1.attribute_fields.build( :key => 'field', :locale => true, :i18n_variable => var_1_1_1, :markup => 'text_field', :list_options => [], :built_in => true )
|
||||
sr_1_1.attribute_fields.build( :key => 'department', :locale => true, :i18n_variable => var_1_1_2, :markup => 'text_field', :list_options => [], :built_in => true )
|
||||
sr_1_2 = r_1.sub_roles.build( :key => 'bad_teacher', :i18n_variable => var_1_1 )
|
||||
sr_1_2.attribute_fields.build( :key => 'field', :locale => true, :i18n_variable => var_1_2_1, :markup => 'text_field', :list_options => [] )
|
||||
sr_1_2.attribute_fields.build( :key => 'department', :locale => true, :i18n_variable => var_1_2_2, :markup => 'text_field', :list_options => [] )
|
||||
sr_1_2.attribute_fields.build( :key => 'speciality', :locale => true, :i18n_variable => var_1_2_3, :markup => 'text_field', :list_options => [] )
|
||||
r_1.save!
|
||||
r_2 = Role.new( :key => 'student', :i18n_variable => var_2 )
|
||||
sr_2_1 = r_2.sub_roles.build( :key => 'undergraduate', :i18n_variable => var_2_1 )
|
||||
sr_2_1.attribute_fields.build( :key => 'department', :locale => true, :i18n_variable => var_2_1_1, :markup => 'text_field', :list_options => [] )
|
||||
sr_2_1.attribute_fields.build( :key => 'major', :locale => true, :i18n_variable => var_2_1_2, :markup => 'text_field', :list_options => [] )
|
||||
sr_2_2 = r_2.sub_roles.build( :key => 'graduate', :i18n_variable => var_2_2 )
|
||||
sr_2_2.attribute_fields.build( :key => 'department', :locale => true, :i18n_variable => var_2_2_1, :markup => 'text_field', :list_options => [] )
|
||||
sr_2_2.attribute_fields.build( :key => 'major', :locale => true, :i18n_variable => var_2_2_2, :markup => 'text_field', :list_options => [] )
|
||||
sr_2_2.attribute_fields.build( :key => 'thesis_subject', :locale => true, :i18n_variable => var_2_2_3, :markup => 'text_field', :list_options => [] )
|
||||
r_2.save!
|
||||
|
||||
# User info
|
||||
i_1 = Info.new( :key => 'profile', :i18n_variable => var_7, :built_in => true )
|
||||
i_1.attribute_fields.build( :key => 'last_name', :locale => true, :i18n_variable => var_8, :markup => 'text_field', :list_options => [], :built_in => true )
|
||||
i_1.attribute_fields.build( :key => 'first_name', :locale => true, :i18n_variable => var_9, :markup => 'text_field', :list_options => [], :built_in => true )
|
||||
i_1.save!
|
||||
|
||||
|
||||
# TODO: modify for the new model
|
||||
urm_1 = Role.new( :key => 'teacher', :i18n_variable_id => var_1.id, :built_in => true )
|
||||
urm_1.attributes.build( :key => 'discipline', :locale => true, :i18n_variable_id => var_2.id, :markup => 'text_field', :list_options => [], :built_in => true )
|
||||
urm_1.attributes.build( :key => 'department', :locale => true, :i18n_variable_id => var_3.id, :markup => 'text_field', :list_options => [], :built_in => true )
|
||||
urm_1.save!
|
||||
urm_2 = Role.new( :key => 'student', :i18n_variable_id => var_4.id )
|
||||
urm_2.attributes.build( :key => 'department', :locale => true, :i18n_variable_id => var_5.id, :markup => 'text_field', :list_options => [] )
|
||||
urm_2.attributes.build( :key => 'major', :locale => true, :i18n_variable_id => var_6.id, :markup => 'text_field', :list_options => [] )
|
||||
urm_2.save!
|
||||
uim_1 = Info.new( :key => 'profile', :i18n_variable_id => var_7.id, :built_in => true )
|
||||
uim_1.attributes.build( :key => 'last_name', :locale => true, :i18n_variable_id => var_8.id, :markup => 'text_field', :list_options => [], :built_in => true )
|
||||
uim_1.attributes.build( :key => 'first_name', :locale => true, :i18n_variable_id => var_9.id, :markup => 'text_field', :list_options => [], :built_in => true )
|
||||
uim_1.save!
|
||||
|
||||
|
||||
# layout = Layout.create!( :name => 'root', :description => 'root', :content => File.open("#{Rails.root}/lib/template/root.layout").read )
|
||||
# layout.layout_parts.create!( :name => 'header', :content => File.open("#{Rails.root}/lib/template/nav.snippet").read )
|
||||
# layout.layout_parts.create!( :name => 'main_content', :editable => true )
|
||||
# layout.layout_parts.create!( :name => 'footer', :content => File.open("#{Rails.root}/lib/template/footer.snippet").read )
|
||||
#
|
||||
# home = Page.create!( :i18n_variable_id => var_10.id, :layout_id => layout.id, :name => 'home', :is_published => true )
|
||||
# home.page_parts.create!( :name => 'main_content', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id )
|
||||
#
|
||||
# about = Page.create!( :i18n_variable_id => var_11.id, :layout_id => layout.id, :name => 'about', :is_published => true, :parent_id => home.id )
|
||||
# about.page_parts.create!( :name => 'main_content', :content => File.open("#{Rails.root}/lib/template/about.page").read, :kind => 'text', :i18n_variable_id => var_14.id )
|
||||
|
||||
# Link.create!( :i18n_variable_id => var_12.id, :name => 'google', :is_published => true, :parent_id => home.id, :url => 'www.google.com' )
|
||||
#
|
||||
# ["nav", "footer"].each do |page_name|
|
||||
# Snippet.create!( :name => page_name, :parent_id => home.id, :content => File.open("#{Rails.root}/lib/template/#{page_name}.snippet").read )
|
||||
# end
|
||||
|
||||
design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake")
|
||||
|
||||
@@ -118,18 +124,19 @@ namespace :dev do
|
||||
|
||||
|
||||
|
||||
user = User.create( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => urm_1.id )
|
||||
AttributeValue.create( :user_id => user.id, :key => 'first_name', :en => 'Christophe', :zh_tw => '順發' )
|
||||
AttributeValue.create( :user_id => user.id, :key => 'last_name', :en => 'Vilayphiou', :zh_tw => '林' )
|
||||
AttributeValue.create( :user_id => user.id, :key => 'discipline', :en => 'Computer Architecture', :zh_tw => '計算機系統結構' )
|
||||
AttributeValue.create( :user_id => user.id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' )
|
||||
user = User.create( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => r_1.id, :sub_role_id => sr_1_2.id )
|
||||
AttributeValue.create( :user => user, :attribute_field => i_1.attribute_fields[0], :key => 'first_name', :en => 'Christophe', :zh_tw => '順發' )
|
||||
AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[1].id, :key => 'last_name', :en => 'Vilayphiou', :zh_tw => '林' )
|
||||
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_1_2.attribute_fields[0].id, :key => 'field', :en => 'Computer Architecture', :zh_tw => '計算機系統結構' )
|
||||
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_1_2.attribute_fields[1].id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' )
|
||||
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_1_2.attribute_fields[2].id, :key => 'speciality', :en => 'HSR', :zh_tw => '高鐵' )
|
||||
|
||||
|
||||
user = User.create( :email => 'matt@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => urm_2.id )
|
||||
AttributeValue.create( :user_id => user.id, :key => 'first_name', :en => 'Matt', :zh_tw => '儒淵' )
|
||||
AttributeValue.create( :user_id => user.id, :key => 'last_name', :en => 'Fu', :zh_tw => '傅' )
|
||||
AttributeValue.create( :user_id => user.id, :key => 'major', :en => 'Information management', :zh_tw => '信息化管理' )
|
||||
AttributeValue.create( :user_id => user.id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' )
|
||||
user = User.create( :email => 'matt@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => r_2.id, :sub_role_id => sr_2_1.id )
|
||||
AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[0].id, :key => 'first_name', :en => 'Matt', :zh_tw => '儒淵' )
|
||||
AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[1].id, :key => 'last_name', :en => 'Fu', :zh_tw => '傅' )
|
||||
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_2_1.attribute_fields[0].id, :key => 'major', :en => 'Information management', :zh_tw => '信息化管理' )
|
||||
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_2_1.attribute_fields[1].id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' )
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user