From 635f82db2ff1ea38f78982c2f11c4e264da07afe Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Wed, 13 Nov 2013 09:53:21 +0800 Subject: [PATCH] Updated Approvable to work for submanager role also --- app/controllers/orbit_backend_controller.rb | 2 +- app/controllers/orbit_member_controller.rb | 2 +- app/helpers/orbit_backend_helper.rb | 4 ++-- app/models/module_app.rb | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 3b83c45f..3a6a7594 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -14,7 +14,7 @@ class OrbitBackendController < ApplicationController status << 'is_top' status << 'is_hot' status << 'is_hidden' unless is_guest? - if @module_app.is_approvable && is_manager? + if @module_app.is_approvable && (is_manager? || is_sub_manager?) status << 'is_pending' status << 'is_checked' status << 'is_rejected' diff --git a/app/controllers/orbit_member_controller.rb b/app/controllers/orbit_member_controller.rb index 67af71f5..b59b7848 100644 --- a/app/controllers/orbit_member_controller.rb +++ b/app/controllers/orbit_member_controller.rb @@ -14,7 +14,7 @@ class OrbitMemberController < ApplicationController status << 'is_top' status << 'is_hot' status << 'is_hidden' unless is_guest? - if @module_app.is_approvable && is_manager? + if @module_app.is_approvable && (is_manager? || is_sub_manager?) status << 'is_pending' status << 'is_checked' status << 'is_rejected' diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index 00dea4c3..3116d136 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -12,13 +12,13 @@ module OrbitBackendHelper def show_form_status_field(object) #by_object = (!object.is_expired? and object.is_pending?) - by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin?) + by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin? or is_sub_manager?) by_user end def show_approval_link(object) by_object = (!object.is_expired? and object.is_pending?) - by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin?) + by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin? or is_sub_manager?) by_object and by_user end diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 8218731b..006b8404 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -196,7 +196,6 @@ class ModuleApp def update_auth_sub_manager_users user_ids = self.auth_sub_managers.inject([]) do |users, auth| - auth = auth.class.find(auth.id) users += auth.authorized_users.map{|user| user.id} end self.update_attribute(:auth_sub_manager_users, user_ids.uniq)