diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb
index 1bbb5a2e..cb3340fd 100644
--- a/app/controllers/admin/app_auths_controller.rb
+++ b/app/controllers/admin/app_auths_controller.rb
@@ -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
diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb
index 914c5138..56c2523f 100644
--- a/app/controllers/admin/module_apps_controller.rb
+++ b/app/controllers/admin/module_apps_controller.rb
@@ -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
diff --git a/app/views/admin/module_apps/edit.html.erb b/app/views/admin/module_apps/edit.html.erb
index 96859a21..9429e963 100644
--- a/app/views/admin/module_apps/edit.html.erb
+++ b/app/views/admin/module_apps/edit.html.erb
@@ -6,9 +6,11 @@
+