diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb
index 30f8a0237..f0aaef739 100644
--- a/app/controllers/admin/users_new_interface_controller.rb
+++ b/app/controllers/admin/users_new_interface_controller.rb
@@ -5,20 +5,63 @@ class Admin::UsersNewInterfaceController < ApplicationController
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
- @users = User.all.entries
+ get_tags
+ get_sub_roles
+
+ page_num = params[:page] || 1
+ @users = []
render case params[:at]
when 'summary'
+ @users=User.page(page_num).per(12).includes('avatar')
"index_summary"
when 'thumbnail'
+ @users=User.page(page_num).per(36).includes('avatar')
"index_thumbnail"
else
+ @users=User.page(page_num).per(10).includes('avatar')
"index"
end
end
def show
@user = User.find(params[:id])
+ @profile_data = []
+ @teacher_data = []
+ @student_data = []
+ @staff_data = []
+
+ @user.attribute_values.each{|att_val|
+ @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]}) if att_val.attribute_field.attribute.key=="profile" rescue false
+ }
+
+ @user.attribute_values.each{|att_val|
+ @teacher_data.push({:name => att_val.attribute_field.title,:value => eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="teacher"rescue false
+ }
+
+ @user.attribute_values.each{|att_val|
+ @student_data.push({:name => att_val.attribute_field.title,:value =>eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="student"rescue false
+ }
+
+ @user.attribute_values.each{|att_val|
+ @staff_data.push({:name => att_val.attribute_field.title,:value =>eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="staff_data"rescue false
+ }
+
+ # binding.pry
+ # @user.attribute_values.each{|att_val|
+ # @teacher_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
+ # }
+
+ # @user.attribute_values.each{|att_val|
+ # @student_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
+ # }
+
+ # @user.attribute_values.each{|att_val|
+ # @staff_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
+ # }
+
+ # [ {:name=> "1",:value =>"Matt"},{:name=> "2",:value =>"Mark"},{:name=> "3",:value =>"Luke"},{:name=> "4",:value =>"John"} ]
+
get_info_and_roles
end
@@ -74,7 +117,14 @@ class Admin::UsersNewInterfaceController < ApplicationController
end
protected
-
+ def get_tags
+ @sub_role_tags = SubRoleTag.all
+ end
+
+ def get_sub_roles
+ @sub_roles = SubRole.all
+ end
+
def get_info_and_roles
@infos = Info.excludes('disabled' => true)
@roles = Role.excludes('disabled' => true)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index fa06948d8..7be0e2d70 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -260,4 +260,13 @@ module ApplicationHelper
wrap_mark = options[:wrap_mark] || "
"
str.scan((/.{0,#{line_width}}/)).join(wrap_mark)
end
+
+ def show_avatar(user)
+ if (user.avatar? rescue false)
+ image_tag(user.avatar.thumb.url)
+ else
+ image_tag "person.png"
+ end
+ end
+
end
diff --git a/app/models/proto_tag.rb b/app/models/proto_tag.rb
new file mode 100644
index 000000000..b5724acbd
--- /dev/null
+++ b/app/models/proto_tag.rb
@@ -0,0 +1,40 @@
+class ProtoTag
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include Impressionist::Impressionable
+
+ is_impressionable :counter_cache => { :column_name => :view_count }
+
+ field :key
+ field :view_count, :type => Integer, :default => 0
+ #field :cloud_amper,:type: Integer,:default=> 0
+
+ def self.sorted_for_cloud
+ tags = {}
+ self.all.each{ |tag|
+ tags.merge!({tag => self.get_impressionist(tag)})
+ }
+ if !tags.blank?
+ sorted_tags = tags.sort{|a,b| a[1]<=>b[1]}.reverse
+ sorted_tags[0][1] = :hot1
+ offset = (sorted_tags.size - 1) / 3
+ i = 1
+ class_i = 2
+ sorted_tags[1..-1].collect!{ |x|
+ x[1] = "hot#{class_i}"
+ i == offset ? i = 1 : i += 1 if class_i < 4
+ class_i += 1 if i == offset && class_i < 4
+ }
+ sorted_tags
+ else
+ []
+ end
+ end
+
+ protected
+
+ def self.get_impressionist(item_tag = self)
+ item_tag.impressions.where(:created_at.gte=> 14.days.ago,:created_at.lte => Time.now).count
+ end
+
+end
diff --git a/app/models/sub_role_tag.rb b/app/models/sub_role_tag.rb
new file mode 100644
index 000000000..f2ff6b7b1
--- /dev/null
+++ b/app/models/sub_role_tag.rb
@@ -0,0 +1,4 @@
+class SubRoleTag < ProtoTag
+ has_and_belongs_to_many :sub_roles
+
+end
diff --git a/app/models/tag.rb b/app/models/tag.rb
index eb7e1f77d..ad63434bd 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -1,41 +1,4 @@
-class Tag
- include Mongoid::Document
- include Mongoid::Timestamps
- include Impressionist::Impressionable
-
- is_impressionable :counter_cache => { :column_name => :view_count }
-
- field :key
- field :view_count, :type => Integer, :default => 0
- #field :cloud_amper,:type: Integer,:default=> 0
+class Tag < ProtoTag
belongs_to :module_app
- def self.sorted_for_cloud
- tags = {}
- self.all.each{ |tag|
- tags.merge!({tag => self.get_impressionist(tag)})
- }
- if !tags.blank?
- sorted_tags = tags.sort{|a,b| a[1]<=>b[1]}.reverse
- sorted_tags[0][1] = :hot1
- offset = (sorted_tags.size - 1) / 3
- i = 1
- class_i = 2
- sorted_tags[1..-1].collect!{ |x|
- x[1] = "hot#{class_i}"
- i == offset ? i = 1 : i += 1 if class_i < 4
- class_i += 1 if i == offset && class_i < 4
- }
- sorted_tags
- else
- []
- end
- end
-
- protected
-
- def self.get_impressionist(item_tag = self)
- item_tag.impressions.where(:created_at.gte=> 14.days.ago,:created_at.lte => Time.now).count
- end
-
end
diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb
index dd22b9dfc..0bda602d4 100644
--- a/app/models/user/attribute_field.rb
+++ b/app/models/user/attribute_field.rb
@@ -4,7 +4,7 @@ class AttributeField
include Mongoid::Timestamps
field :key
- field :markup
+ field :markup #[select,text_field,email,date,addr]
field :locale, :type => Boolean, :default => true
field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false
@@ -15,10 +15,14 @@ class AttributeField
field :neutral_title
belongs_to :attribute
- belongs_to :role
+ # belongs_to :role
has_many :attribute_values
# validates_uniqueness_of :key
+ def role
+ self.attribute.role
+ end
+
def title_translations
if locale
return locale_title_translations
@@ -29,7 +33,7 @@ class AttributeField
def title_translations=(var)
if locale
- self.locale_title = var
+ self.locale_title_translations = var
end
end
diff --git a/app/models/user/status.rb b/app/models/user/status.rb
index 9022a4f16..f9f194208 100644
--- a/app/models/user/status.rb
+++ b/app/models/user/status.rb
@@ -2,9 +2,12 @@ class Status
include Mongoid::Document
include Mongoid::Timestamps
+
+ has_and_belongs_to_many :users
+
belongs_to :role
- has_and_belongs_to_many :sub_roles
+ # has_and_belongs_to_many :sub_roles
field :title, localize: true
diff --git a/app/models/user/sub_role.rb b/app/models/user/sub_role.rb
index 8ff91b3fa..6bd3cf0d6 100644
--- a/app/models/user/sub_role.rb
+++ b/app/models/user/sub_role.rb
@@ -2,7 +2,9 @@ class SubRole < Attribute
belongs_to :role
has_and_belongs_to_many :users
- has_and_belongs_to_many :statuses, :autosave => true, :dependent => :destroy
+ #has_and_belongs_to_many :statuses, :autosave => true, :dependent => :destroy
+ has_and_belongs_to_many :tags, :class_name => "SubRoleTag", :autosave => true
+
# Get an sub_role from key
def self.get_sub_role_from_key(key)
self.first(:conditions => {:key => key})
diff --git a/app/models/user/user.rb b/app/models/user/user.rb
index f2dcd2794..1aa789bf8 100644
--- a/app/models/user/user.rb
+++ b/app/models/user/user.rb
@@ -14,6 +14,7 @@ class User
# field :cache_dept
# has_one :cache_dept, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
field :cache_dept,type: Hash
+ field :status_record,type: Hash
has_many :attribute_values, :autosave => true, :dependent => :destroy
has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists
@@ -25,9 +26,9 @@ class User
has_many :other_accounts, :autosave => true, :dependent => :destroy
has_many :journals, :autosave => true, :dependent => :destroy
has_many :papers, :autosave => true, :dependent => :destroy
+ has_and_belongs_to_many :sub_role_tags
-
- belongs_to :role
+ has_and_belongs_to_many :statuses
has_and_belongs_to_many :roles
has_and_belongs_to_many :sub_roles
accepts_nested_attributes_for :attribute_values, :allow_destroy => true
diff --git a/app/views/admin/users_new_interface/_deled_quick_edit.html.erb b/app/views/admin/users_new_interface/_deled_quick_edit.html.erb
new file mode 100644
index 000000000..a898148bc
--- /dev/null
+++ b/app/views/admin/users_new_interface/_deled_quick_edit.html.erb
@@ -0,0 +1,16 @@
+