Skip to content

Commit

Permalink
Fix call to process_tasks to run the right thing
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Apr 10, 2018
1 parent 3d19c53 commit 79271cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/models/mixins/process_tasks_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module ProcessTasksMixin
extend ActiveSupport::Concern
include RetirementMixin

module ClassMethods
# Processes tasks received from the UI and queues them
def process_tasks(options)
raise _("No ids given to process_tasks") if options[:ids].blank?
if options[:task] == "refresh_ems" && respond_to?("refresh_ems")
if options[:task] == 'retire_now'
name.constantize.make_retire_request(options[:ids])
elsif options[:task] == "refresh_ems" && respond_to?("refresh_ems")
refresh_ems(options[:ids])
msg = "'#{options[:task]}' initiated for #{options[:ids].length} #{ui_lookup(:table => base_class.name).pluralize}"
task_audit_event(:success, options, :message => msg)
Expand Down
6 changes: 3 additions & 3 deletions app/models/mixins/retirement_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module RetirementMixin
end

module ClassMethods
def make_retire_request
options = {:task => task, :userid => current_user, :ids => objs, :src_ids => objs}
(klass.to_s + "RetireRequest").constantize.make_request(@request_id, options, current_user)
def make_retire_request(*options)
options = {:src_ids => options.present? ? options.first : id, :src_klass => name}
(name + "RetireRequest").constantize.make_request(nil, options, User.current_user, true)
end

def retire(ids, options = {})
Expand Down

0 comments on commit 79271cf

Please sign in to comment.