diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb index bc546ac8..42e82b47 100644 --- a/app/controllers/admin/object_auths_new_interface_controller.rb +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -4,7 +4,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController def setting - @sys_users = User.all(conditions: {admin: false}) + @sys_users = User.all(conditions: {admin: false}).includes(:avatar) @ob_auth = ObjectAuth.find params[:object_auth_id] @options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] } @users_array = @ob_auth.privilege_users rescue [] diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 9cbd9967..7c1e4c63 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -2,7 +2,7 @@ class User include Mongoid::Document include Mongoid::Timestamps - + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable mount_uploader :avatar, AvatarUploader @@ -11,6 +11,10 @@ class User field :active_role field :nccu_ldap_uid + # field :cache_dept + # has_one :cache_dept, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + field :cache_dept,type: Hash + has_many :attribute_values, :autosave => true, :dependent => :destroy has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth" @@ -22,6 +26,22 @@ class User has_and_belongs_to_many :sub_roles accepts_nested_attributes_for :attribute_values, :allow_destroy => true + def create_dept_cache + dept_hash = {} + + VALID_LOCALES.each do |loc| + locale = loc.to_sym + # debugger + # if(self.cache_dept.nil?) + # self.build_cache_dept key: "dept_cache_user_#{self.id}" + # end + dept_hash[locale] = sub_roles.collect{|sr| sr.i18n_variable[locale]}.join(',') + # self.cache_dept[locale] = sub_roles.collect{|sr| sr.i18n_variable[locale]}.join(',') + end + self.cache_dept = dept_hash + self.save! + end + def self.current Thread.current[:user] end diff --git a/app/views/admin/object_auths_new_interface/_privilege_user.html.erb b/app/views/admin/object_auths_new_interface/_privilege_user.html.erb index 90f5cb65..5d5f6e7f 100644 --- a/app/views/admin/object_auths_new_interface/_privilege_user.html.erb +++ b/app/views/admin/object_auths_new_interface/_privilege_user.html.erb @@ -1,12 +1,8 @@ -<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do -%> - <% @sys_users.each do |sys_user| -%> - -