Class: LcpRuby::ApprovalTasksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lcp_ruby/approval_tasks_controller.rb

Constant Summary

Constants included from Controller::BearerAuthentication

Controller::BearerAuthentication::BASIC_PREFIX_LENGTH, Controller::BearerAuthentication::BEARER_PREFIX_LENGTH

Instance Method Summary collapse

Methods included from Controller::Authorization

#current_evaluator

Instance Method Details

#approveObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/lcp_ruby/approval_tasks_controller.rb', line 6

def approve
  authorize @record, :show?

  Workflow::Approval::TaskManager.approve_task(
    @task, user: current_user, comment: params[:comment].presence
  )

  redirect_to resource_path(@record), status: :see_other,
    notice: I18n.t("lcp_ruby.flash.approval_task_approved",
      default: "Task approved successfully.")
end

#claimObject



42
43
44
45
46
47
48
49
50
# File 'app/controllers/lcp_ruby/approval_tasks_controller.rb', line 42

def claim
  authorize @record, :show?

  Workflow::Approval::TaskManager.claim_task(@task, user: current_user)

  redirect_to resource_path(@record), status: :see_other,
    notice: I18n.t("lcp_ruby.flash.approval_task_claimed",
      default: "Task claimed successfully.")
end

#delegateObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/lcp_ruby/approval_tasks_controller.rb', line 52

def delegate
  authorize @record, :show?

  delegate_to = params[:delegate_to_user_id]
  raise Workflow::TaskActionError, "delegate_to_user_id is required" if delegate_to.blank?

  Workflow::Approval::TaskManager.delegate_task(
    @task, user: current_user, delegate_to_user_id: delegate_to.to_i
  )

  redirect_to resource_path(@record), status: :see_other,
    notice: I18n.t("lcp_ruby.flash.approval_task_delegated",
      default: "Task delegated successfully.")
end

#rejectObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/lcp_ruby/approval_tasks_controller.rb', line 18

def reject
  authorize @record, :show?

  Workflow::Approval::TaskManager.reject_task(
    @task, user: current_user, comment: params[:comment].presence
  )

  redirect_to resource_path(@record), status: :see_other,
    notice: I18n.t("lcp_ruby.flash.approval_task_rejected",
      default: "Task rejected.")
end

#return_taskObject



30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/lcp_ruby/approval_tasks_controller.rb', line 30

def return_task
  authorize @record, :show?

  Workflow::Approval::TaskManager.return_task(
    @task, user: current_user, comment: params[:comment].presence
  )

  redirect_to resource_path(@record), status: :see_other,
    notice: I18n.t("lcp_ruby.flash.approval_task_returned",
      default: "Task returned for rework.")
end