Change to apply page to had object_auth
This commit is contained in:
1 parent
e696516aae
commit
e1450ec748
15 files changed
+95
-11
No files matched your search
@@ -1,4 +1,4 @@
|
||||
class Admin::ObjectAuthsNewInterfaceController < ApplicationController
|
||||
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
include OrbitCoreLib::PermissionUnility
|
||||
layout "new_admin"
|
||||
before_filter :force_order
|
||||
@@ -33,8 +33,9 @@ class Admin::ObjectAuthsNewInterfaceController < ApplicationController
|
||||
|
||||
protected
|
||||
def update_setting_by_params
|
||||
user_sat = []
|
||||
oa = ObjectAuth.find params[:ob_auth][:id]
|
||||
user_sat = User.find params[:users].keys
|
||||
user_sat += User.find params[:users].keys if params.has_key? :users
|
||||
users_to_new = user_sat - oa.auth_users
|
||||
users_to_remove = oa.auth_users - user_sat
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ class ApplicationController < ActionController::Base
|
||||
helper :all
|
||||
before_filter :set_locale, :set_site
|
||||
|
||||
def set_current_user
|
||||
User.current = current_user
|
||||
end
|
||||
|
||||
def front_end_available(module_app_title='')
|
||||
app_controller = ModuleApp.first(conditions: {:key => module_app_title} )
|
||||
unless app_controller.enable_frontend?
|
||||
|
||||
@@ -10,6 +10,7 @@ class OrbitBackendController< ApplicationController
|
||||
|
||||
def setup_vars
|
||||
@app_title = request.fullpath.split('/')[2]
|
||||
@app_title = request.fullpath.split('/')[1] if(@app_title == "back_end")
|
||||
@module_app = ModuleApp.first(conditions: {:key => @app_title} )
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
module Admin::PageContentHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
|
||||
|
||||
def show_page_context_edit_auth_link(page_context)
|
||||
type = 'Edit'
|
||||
# debugger
|
||||
# a=1
|
||||
oa = page_context.get_object_auth_by_title(type)
|
||||
if oa.nil?
|
||||
page_context.object_auths.new(title: type ).save rescue
|
||||
oa = page_context.get_object_auth_by_title(type)
|
||||
end
|
||||
# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa)
|
||||
link_to t('admin.page_context.ob_auth.edit'),admin_object_auth_ob_auth_path(oa)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<div class="clear">
|
||||
<%= content_tag :div do -%>
|
||||
<% form_tag admin_object_auth_ob_auth_path do %>
|
||||
<%#= render :partial => "privilege_user", :locals => {:users => @users_array} %>
|
||||
<%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
|
||||
<div class="form-actions form-fixed pagination-right">
|
||||
<%= submit_tag "Update", :class => 'btn btn-primary' %>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user