Change to apply page to had object_auth

This commit is contained in:
Matthew K. Fu JuYuan authored and Christophe Vilayphiou committed 2012-05-14 12:40:50 +08:00
1 parent f0dd1eb871
commit 9ba4c2cf2f
15 files changed
+95 -11

No files matched your search

+10
View File
@@ -1,4 +1,5 @@
class AdBanner
include OrbitCoreLib::ObjectAuthable
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
@@ -14,6 +15,15 @@ class AdBanner
FX_TYPES = ["blindX","blindY","blindZ","cover","curtainX","curtainY","fade","fadeZoom","growX","growY","scrollUp","scrollDown","scrollLeft","scrollRight","scrollHorz","scrollVert","shuffle","slideX","slideY","toss","turnUp","turnDown","turnLeft","turnRight","uncover","wipe","zoom"]
attr_writer :transition_sec
AfterObjectAuthUrl = '/panel/page_content/back_end/page_contexts'
APP_NAME = 'ad_banners'
ObjectAuthTitlesOptions = %W{edit}
def pp_object
title
end
def transition_sec
self.transition_msec/1000 rescue nil
end
+12
View File
@@ -2,6 +2,7 @@ class ObjectAuth < PrototypeAuth
include OrbitCoreLib::ObjectTokenUnility
validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| }
belongs_to :obj_authable, polymorphic: true
after_save :check_user_has_app_auth
# > - Something.find_with_auth(query)
# > - or Something.find(query).auth
def auth_obj
@@ -9,4 +10,15 @@ class ObjectAuth < PrototypeAuth
class_obj.find self.obj_authable_id
end
def check_user_has_app_auth
sub_managing_users = auth_obj.app_auth.sub_managing_users
app_auth = auth_obj.app_auth
self.auth_users.each do |auth_user|
if !sub_managing_users.include? auth_user && !auth_user.admin?
app_auth.assign_sub_manager(auth_user,User.current)
app_auth.save!
end
end
end
end
+8
View File
@@ -20,6 +20,14 @@ class User
belongs_to :role
has_and_belongs_to_many :sub_roles
accepts_nested_attributes_for :attribute_values, :allow_destroy => true
def self.current
Thread.current[:user]
end
def self.current=(user)
Thread.current[:user] = user
end
def avb_apps
sub_role_ids_ary=self.sub_roles.collect{|t| t.id}