Remove old code for object auth and module app
This commit is contained in:
1 parent
82baa809ea
commit
49d0d83810
10 files changed
-358
No files matched your search
@@ -1,114 +0,0 @@
|
||||
class Admin::ModuleAppsController < OrbitBackendController
|
||||
before_filter :user_has_manager_privilege?, :only => [ :assign_manager, :remove_manager ]
|
||||
before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ]
|
||||
|
||||
helper Admin::PagePartsHelper
|
||||
def index
|
||||
@module_apps = ModuleApp.all.entries
|
||||
end
|
||||
|
||||
|
||||
|
||||
def module_auth_proc
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
end
|
||||
|
||||
def edit
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
end
|
||||
|
||||
def show
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
unless params['module_app']['enable_frontend'].nil?
|
||||
@module_app.update_attribute('enable_frontend',params['module_app']['enable_frontend'])
|
||||
@module_app.save!
|
||||
end
|
||||
@attribute = @module_app
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :action => :index }
|
||||
format.js { render 'admin/attributes/toggle_enable' }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def assign_sub_manager
|
||||
unless @assign_to_user.nil? || @assign_to_user.admin?
|
||||
if @module_app.assign_sub_manager(@assign_to_user,current_user)
|
||||
flash[:notice] = t('app_auth.assigning_manager.add_manager_ok')
|
||||
else
|
||||
flash[:notice] = t('app_auth.assigning_manager.add_manager_fail')
|
||||
end
|
||||
else
|
||||
flash[:notice] = t('app_auth.failed_no_user')
|
||||
end
|
||||
flash[:notice] = t('app_auth.can_not_add_this_user')
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
|
||||
|
||||
def assign_manager
|
||||
unless @assign_to_user.nil? || @assign_to_user.admin?
|
||||
if @module_app.assign_manager(@assign_to_user,current_user)
|
||||
flash[:notice] = t('app_auth.assigning_sub_manager.add_sub_manager_ok')
|
||||
else
|
||||
flash[:notice] = t('app_auth.assigning_sub_manager.add_sub_manager_fail')
|
||||
end
|
||||
else
|
||||
flash[:notice] = t('app_auth.failed_no_user')
|
||||
end
|
||||
flash[:notice] = t('app_auth.can_not_add_this_user')
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
|
||||
|
||||
def remove_manager
|
||||
@app_manager = AppManager.find(params[:app_manager_id])
|
||||
if @module_app.remove_manager(@app_manager.user)
|
||||
flash[:notice] = t('app_auth.delete_manager.success')
|
||||
else
|
||||
flash[:notice] = t('app_auth.delete_manager.fail')
|
||||
end
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
|
||||
|
||||
def remove_sub_manager
|
||||
@app_sub_manager = AppManager.find(params[:app_sub_manager_id])
|
||||
if @module_app.remove_sub_manager(@app_sub_manager.user)
|
||||
flash[:notice] = t('app_auth.delete_sub_manager.success')
|
||||
else
|
||||
flash[:notice] = t('app_auth.delete_sub_manager.fail')
|
||||
end
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def user_has_manager_privilege?
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
@assign_to_user = User.find params[:manager][:id] rescue nil
|
||||
if current_user.admin? #only admin can assign app's manager
|
||||
return
|
||||
end
|
||||
#user is not permited to do that
|
||||
flash[:notice] = t('app_auth.operation_not_permitted')
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
|
||||
|
||||
def user_has_sub_manager_privilege?
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
@assign_to_user = User.find params[:sub_manager][:id] rescue nil
|
||||
if current_user.admin? || @module_app.managing_users.include?(current_user) #admin or app's manager can assign app's subanager
|
||||
return
|
||||
end
|
||||
#user is not permited to do that
|
||||
flash[:notice] = t('app_auth.operation_not_permitted')
|
||||
render :nothing => true,:status => 403
|
||||
end
|
||||
end
|
||||
@@ -1,98 +0,0 @@
|
||||
class Admin::ObjectAuthsController < OrbitBackendController
|
||||
include OrbitCoreLib::PermissionUtility
|
||||
|
||||
before_filter :force_order
|
||||
# before_filter :is_admin? ,:only => :index
|
||||
|
||||
|
||||
|
||||
def index
|
||||
# if current_user.admin?
|
||||
@object_auths = ObjectAuth.all
|
||||
# else
|
||||
# @module_apps = current_user.managing_apps.collect{|t| t.managing_app}
|
||||
# end
|
||||
end
|
||||
|
||||
def new
|
||||
obj = eval(params[:type]).find params[:obj_id]
|
||||
@object_auth=obj.object_auths.build
|
||||
@object_auth_title_option = eval(params[:type]+"::ObjectAuthTitlesOptions")
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @post }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
obj = eval(params[:object_auth][:type]).find params[:object_auth][:obj_id]
|
||||
@object_auth=obj.object_auths.build :title=> params[:object_auth][:title]
|
||||
if @object_auth.save
|
||||
redirect_to edit_admin_object_auth_path(@object_auth)
|
||||
else
|
||||
flash[:error] = t('object.a_object_must_have_only_one_object_auth_profile_for_each_action')
|
||||
redirect_to (:back)
|
||||
end
|
||||
end
|
||||
|
||||
def create_role
|
||||
object_auth = ObjectAuth.find(params[:id])
|
||||
auth_all = params[:auth_all] || false
|
||||
object_auth.update_attribute(:all,auth_all)
|
||||
new_array = params[:new] || []
|
||||
new_array.each do |item|
|
||||
field = item[0]
|
||||
field_value = item[1]
|
||||
if field_value!=''
|
||||
case field
|
||||
when 'role'
|
||||
object_auth.send("add_#{field}",(Role.find field_value)) rescue nil
|
||||
when 'sub_role'
|
||||
object_auth.send("add_#{field}",(SubRole.find field_value)) rescue nil
|
||||
when 'privilege_user'
|
||||
object_auth.add_user_to_privilege_list (User.find field_value) rescue nil
|
||||
when 'blocked_user'
|
||||
object_auth.add_user_to_black_list (User.find field_value) rescue nil
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to edit_admin_object_auth_path(object_auth)
|
||||
end
|
||||
|
||||
def remove_role
|
||||
object_auth = ObjectAuth.find(params[:id])
|
||||
type = params[:type]
|
||||
field_value = params[:target_id]
|
||||
if field_value!=''
|
||||
case type
|
||||
when 'role'
|
||||
object_auth.remove_role(Role.find field_value) rescue nil
|
||||
when 'sub_role'
|
||||
object_auth.remove_sub_role(SubRole.find field_value) rescue nil
|
||||
when 'privilege_user'
|
||||
object_auth.remove_user_from_privilege_list (User.find field_value) rescue nil
|
||||
when 'blocked_user'
|
||||
object_auth.remove_user_from_black_list (User.find field_value) rescue nil
|
||||
end
|
||||
end
|
||||
redirect_to edit_admin_object_auth_path(object_auth)
|
||||
end
|
||||
|
||||
def edit
|
||||
@object_auth = ObjectAuth.find(params[:id])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def force_order
|
||||
authenticate_user!
|
||||
check_if_user_can_do_object_auth
|
||||
end
|
||||
|
||||
def check_if_user_can_do_object_auth
|
||||
unless check_permission(:manager)
|
||||
#render :nothing => true, :status => 403
|
||||
redirect_to '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user