cache privilege user list.
This commit is contained in:
parent
1bbf89a354
commit
97e289f823
|
@ -4,7 +4,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||||
|
|
||||||
|
|
||||||
def setting
|
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]
|
@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] }
|
@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 []
|
@users_array = @ob_auth.privilege_users rescue []
|
||||||
|
|
|
@ -2,7 +2,7 @@ class User
|
||||||
|
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable
|
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable
|
||||||
|
|
||||||
mount_uploader :avatar, AvatarUploader
|
mount_uploader :avatar, AvatarUploader
|
||||||
|
@ -10,6 +10,10 @@ class User
|
||||||
field :admin, :type => Boolean, :default => true
|
field :admin, :type => Boolean, :default => true
|
||||||
field :active_role
|
field :active_role
|
||||||
|
|
||||||
|
# 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 :attribute_values, :autosave => true, :dependent => :destroy
|
||||||
has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists
|
has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists
|
||||||
has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth"
|
has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth"
|
||||||
|
@ -21,6 +25,22 @@ class User
|
||||||
has_and_belongs_to_many :sub_roles
|
has_and_belongs_to_many :sub_roles
|
||||||
accepts_nested_attributes_for :attribute_values, :allow_destroy => true
|
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
|
def self.current
|
||||||
Thread.current[:user]
|
Thread.current[:user]
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do -%>
|
<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do %>
|
||||||
<% @sys_users.each do |sys_user| -%>
|
<% @sys_users.each do |sys_user| %>
|
||||||
|
<div class="checkblock">
|
||||||
<div class="checkblock">
|
<div class="for_unit" style="display:none;"> <%= sys_user.cache_dept[I18n.locale.to_s] %></div>
|
||||||
|
<%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => sys_user.cache_dept[I18n.locale.to_s]},:class=>"checkbox clear" do %>
|
||||||
<% sys_user.sub_roles.each do |sr| %>
|
|
||||||
<div class="for_unit" style="display:none;"> <%= sr.key %></div>
|
|
||||||
<% end %>
|
|
||||||
<%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => "#{sys_user.sub_roles.collect{|sr| sr.i18n_variable[I18n.locale]}.join(',')}"},:class=>"checkbox clear" do %>
|
|
||||||
<div class="check-icon">
|
<div class="check-icon">
|
||||||
</div>
|
</div>
|
||||||
<div class='member-avatar'>
|
<div class='member-avatar'>
|
||||||
|
@ -18,8 +14,7 @@
|
||||||
</div>
|
</div>
|
||||||
<%= label_tag "lab-user-#{sys_user.id}", (sys_user.name rescue ''),:class=>"member-name",:id=>nil -%>
|
<%= label_tag "lab-user-#{sys_user.id}", (sys_user.name rescue ''),:class=>"member-name",:id=>nil -%>
|
||||||
<%= check_box_tag "[users][#{sys_user.id}]", 'true',users.include?(sys_user),:class => "check" -%>
|
<%= check_box_tag "[users][#{sys_user.id}]", 'true',users.include?(sys_user),:class => "check" -%>
|
||||||
<%end -%>
|
<%end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
<% end -%>
|
<% end %>
|
||||||
<% end -%>
|
|
Loading…
Reference in New Issue