First complete with manager and submanager
This commit is contained in:
1 parent
4df8ab6cc3
commit
4ed8a2164c
7 files changed
+52
-15
No files matched your search
@@ -1,7 +1,7 @@
|
||||
class Admin::AppAuthsController < ApplicationController
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
# before_filter :is_admin? ,:only => :index
|
||||
|
||||
def index
|
||||
# @roles = Role.all.entries
|
||||
@@ -12,13 +12,17 @@ class Admin::AppAuthsController < ApplicationController
|
||||
# obj_auth = obj.send "auth"
|
||||
# [:app_obj => app,:auth_field => obj_auth]
|
||||
# end
|
||||
@module_apps = ModuleApp.all
|
||||
if current_user.admin?
|
||||
@module_apps = ModuleApp.all
|
||||
else
|
||||
@module_apps = current_user.managing_apps.collect{|t| t.managing_app}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -37,7 +37,7 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
|
||||
|
||||
def assign_sub_manager
|
||||
unless @assign_to_user.nil?
|
||||
unless @assign_to_user.nil? || @assign_to_user.admin?
|
||||
if @module_app.assign_sub_manager(@assign_to_user,current_user)
|
||||
flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_ok')
|
||||
else
|
||||
@@ -46,12 +46,13 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
else
|
||||
flash[:notice] = t('admin.app_auth.assigning_manager.failed_no_user')
|
||||
end
|
||||
redirect_to :action => "edit"
|
||||
flash[:notice] = t('admin.app_auth.can_not_add_this_user')
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
|
||||
|
||||
def assign_manager
|
||||
unless @assign_to_user.nil?
|
||||
unless @assign_to_user.nil? || @assign_to_user.admin?
|
||||
if @module_app.assign_manager(@assign_to_user,current_user)
|
||||
flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_ok')
|
||||
else
|
||||
@@ -60,11 +61,13 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
else
|
||||
flash[:notice] = t('admin.app_auth.assigning_sub_manager.failed_no_user')
|
||||
end
|
||||
redirect_to :action => "edit"
|
||||
flash[:notice] = t('admin.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('admin.app_auth.delete_manager.success')
|
||||
else
|
||||
@@ -75,6 +78,7 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
|
||||
|
||||
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('admin.app_auth.delete_sub_manager.success')
|
||||
else
|
||||
@@ -100,7 +104,7 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
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.managers.include?(current_user) #admin or app's manager can assign app's subanager
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user