User role and sub_role simple interface complete
This commit is contained in:
1 parent
25cbe0c2a5
commit
afbb9e266a
4 files changed
+88
-12
No files matched your search
@@ -19,6 +19,49 @@ class Admin::AppAuthsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
app_auth = AppAuth.find_or_create_by(module_app_id: params[:module_app_id])
|
||||
params[:new].each do |item|
|
||||
field = item[0]
|
||||
field_value = item[1]
|
||||
if field_value!=''
|
||||
case field
|
||||
when 'role'
|
||||
app_auth.send("add_#{field}",(Role.find field_value)) rescue nil
|
||||
when 'sub_role'
|
||||
app_auth.send("add_#{field}",(SubRole.find field_value)) rescue nil
|
||||
when 'privilege_user'
|
||||
app_auth.add_user_to_privilege_list (User.find field_value) rescue nil
|
||||
when 'blocked_user'
|
||||
app_auth.add_user_to_black_list (User.find field_value) rescue nil
|
||||
end
|
||||
end
|
||||
end
|
||||
app = ModuleApp.find params[:module_app_id] rescue nil
|
||||
redirect_to edit_admin_module_app_path(app)
|
||||
end
|
||||
|
||||
def remove
|
||||
app_auth = AppAuth.find( params[:id] )
|
||||
type = params[:type]
|
||||
field_value = params[:target_id]
|
||||
if field_value!=''
|
||||
case type
|
||||
when 'role'
|
||||
app_auth.remove_role(Role.find field_value) rescue nil
|
||||
when 'sub_role'
|
||||
app_auth.remove_sub_role(SubRole.find field_value) rescue nil
|
||||
when 'privilege_user'
|
||||
app_auth.remove_user_from_privilege_list (User.find field_value) rescue nil
|
||||
when 'blocked_user'
|
||||
app_auth.remove_user_from_black_list (User.find field_value) rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
app = ModuleApp.find params[:module_app_id] rescue nil
|
||||
redirect_to edit_admin_module_app_path(app)
|
||||
end
|
||||
|
||||
def edit
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
end
|
||||
|
||||
@@ -18,7 +18,6 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
|
||||
def edit
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -91,7 +90,7 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
private
|
||||
def user_has_manager_privilege?
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
@assign_to_user = User.find params[:manager_id] rescue nil
|
||||
@assign_to_user = User.find params[:manager][:id] rescue nil
|
||||
if current_user.admin? #only admin can assign app's manager
|
||||
return
|
||||
end
|
||||
@@ -103,7 +102,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
|
||||
@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
|
||||
|
||||
Reference in new issue
Block a user