diff --git a/Gemfile b/Gemfile
index 906fa408..e83da25d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -31,7 +31,7 @@ gem 'resque' # background jobs
gem 'resque-scheduler' # job scheduling
gem 'resque-restriction'
#gem 'rb-readline'
-gem 'ruby-debug19'
+# gem 'ruby-debug19'
gem 'rubyzip'
gem 'sunspot_mongo'
@@ -68,6 +68,11 @@ end
group :test, :development do
+ gem 'pry'
+ gem 'pry-remote'
+ gem 'pry-stack_explorer'
+ gem 'pry-debugger'
+
gem "sunspot-rails-tester"
gem 'spork'
gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing.
diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb
index 2a227d27..dd22b9df 100644
--- a/app/models/user/attribute_field.rb
+++ b/app/models/user/attribute_field.rb
@@ -9,13 +9,47 @@ class AttributeField
field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
- field :title, localize: true
-
+ #field :title, localize: true
+
+ field :locale_title, localize: true
+ field :neutral_title
+
belongs_to :attribute
+ belongs_to :role
has_many :attribute_values
# validates_uniqueness_of :key
+ def title_translations
+ if locale
+ return locale_title_translations
+ else
+ return Hash[VALID_LOCALES.map{|d| [d,neutral_title]}]
+ end
+ end
+
+ def title_translations=(var)
+ if locale
+ self.locale_title = var
+ end
+ end
+
+ def title
+ if locale
+ return self.locale_title
+ else
+ return self.neutral_title
+ end
+ end
+ def title=(var)
+ binding.pry
+ if locale
+ self.locale_title = var
+ else
+ self.neutral_title = var
+ end
+ end
+
# Convert the string list_options into an array
def select_list_options=(var)
self.list_options = var.gsub(' ', '').split(',')
diff --git a/app/models/user/role.rb b/app/models/user/role.rb
index bbcedfc7..438e2dab 100644
--- a/app/models/user/role.rb
+++ b/app/models/user/role.rb
@@ -10,6 +10,8 @@ class Role
has_many :sub_roles, :autosave => true, :dependent => :destroy
has_many :users
+ has_many :statuses, :autosave => true, :dependent => :destroy
+ has_many :attribute_fields, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :sub_roles, :allow_destroy => true
def is_built_in?
diff --git a/app/models/user/status.rb b/app/models/user/status.rb
new file mode 100644
index 00000000..9022a4f1
--- /dev/null
+++ b/app/models/user/status.rb
@@ -0,0 +1,11 @@
+class Status
+
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ belongs_to :role
+ has_and_belongs_to_many :sub_roles
+
+ field :title, localize: true
+
+end
\ No newline at end of file
diff --git a/app/models/user/sub_role.rb b/app/models/user/sub_role.rb
index cdefb5f5..8ff91b3f 100644
--- a/app/models/user/sub_role.rb
+++ b/app/models/user/sub_role.rb
@@ -2,7 +2,7 @@ class SubRole < Attribute
belongs_to :role
has_and_belongs_to_many :users
-
+ has_and_belongs_to_many :statuses, :autosave => true, :dependent => :destroy
# Get an sub_role from key
def self.get_sub_role_from_key(key)
self.first(:conditions => {:key => key})
diff --git a/app/views/admin/attributes/_attribute_field.html.erb b/app/views/admin/attributes/_attribute_field.html.erb
index b2e94344..7fd85285 100644
--- a/app/views/admin/attributes/_attribute_field.html.erb
+++ b/app/views/admin/attributes/_attribute_field.html.erb
@@ -9,10 +9,13 @@
<% end %>
<% end %>
+
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
>
<%= t('admin.options') %>:
- <%= f.select "select_list_options", attribute_field.select_list_options, :style => "width:130px" %>
+ <%= f.select "select_list_options", {'1'=>"A",'2'=>"B",'3'=>"C"}, :style => "width:130px" %>
+ <%#= collection_select(:select_list_options, method, collection, value_method, text_method, options = {}, html_options = {}) %>
+
|
diff --git a/app/views/admin/users_new_interface/_plugin_summary.html.erb b/app/views/admin/users_new_interface/_plugin_summary.html.erb
new file mode 100644
index 00000000..09871ad8
--- /dev/null
+++ b/app/views/admin/users_new_interface/_plugin_summary.html.erb
@@ -0,0 +1,46 @@
+
\ No newline at end of file
diff --git a/app/views/admin/users_new_interface/_user_role.html.erb b/app/views/admin/users_new_interface/_user_role.html.erb
new file mode 100644
index 00000000..05ef4bb1
--- /dev/null
+++ b/app/views/admin/users_new_interface/_user_role.html.erb
@@ -0,0 +1,16 @@
+
+
+
+ <%= t(i18n)%>
+
+
+
+ <% items.each do |item| %>
+
+ <%= item[:name] %> |
+ <%= item[:value] %> |
+
+ <% end -%>
+
+
+
diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb
index d6a83048..a1f5fdee 100644
--- a/app/views/admin/users_new_interface/show.html.erb
+++ b/app/views/admin/users_new_interface/show.html.erb
@@ -1,135 +1,58 @@
-
-
-
- <%= image_tag(@user.avatar.url) %>
+
+
-
+
+ <% binding.pry%>
+ <%= render :partial=> 'plugin_summary'%>
+ <%= render :partial=> 'plugin_summary'%>
+ <%= render :partial=> 'plugin_summary'%>
+
+
+
+
+
+
+
+
+ <% test_items = [ {:name=> "1",:value =>"Matt"},{:name=> "2",:value =>"Mark"},{:name=> "3",:value =>"Luke"},{:name=> "4",:value =>"John"} ]%>
+ <%= render :partial=> "user_role",:locals=>{:role_class=>"basic",:i18n=>"admin.new_admin.users.profile",:items=>test_items} %>
+ <%= render :partial=> "user_role",:locals=>{:role_class=>"teacher",:i18n=>"admin.new_admin.users.roles.teacher",:items=>test_items} %>
+ <%= render :partial=> "user_role",:locals=>{:role_class=>"student",:i18n=>"admin.new_admin.users.roles.student",:items=>test_items}%>
+ <%= render :partial=> "user_role",:locals=>{:role_class=>"staff",:i18n=>"admin.new_admin.users.roles.staff",:items=>test_items} %>
+
+
-
-
-
-
-
- staff
-
-
- student
-
-
-
-
\ No newline at end of file
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 81f974f5..b56dd33b 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -217,6 +217,13 @@ zh_tw:
user_roles: 角色
user_info: 使用者資訊
user: 會員
+ users:
+ all_plugin_summary: 全部
+ profile: 基本資料
+ roles:
+ staff: 職員資料
+ student: 學生資料
+ teacher: 教師資料
action:
add: 新增
edit: 編輯
diff --git a/lib/tasks/build_new_member.rake b/lib/tasks/build_new_member.rake
new file mode 100644
index 00000000..390a0030
--- /dev/null
+++ b/lib/tasks/build_new_member.rake
@@ -0,0 +1,82 @@
+# 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
|