-
Notifications
You must be signed in to change notification settings - Fork 19
/
bva_dispatch_task.rb
37 lines (30 loc) · 1.19 KB
/
bva_dispatch_task.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true
##
# Task assigned to BVA Dispatch team members whenever a judge completes a case review.
# This indicates that an appeal is decided and the appellant is about to be notified of the decision.
class BvaDispatchTask < Task
def available_actions(user)
return [] unless user
actions = super(user)
if assigned_to == user || parent.task_is_assigned_to_organization_user_administers?(user)
actions.unshift(Constants.TASK_ACTIONS.DISPATCH_RETURN_TO_JUDGE.to_h)
actions.delete(Constants.TASK_ACTIONS.ASSIGN_TO_TEAM.to_h)
end
actions
end
def task_is_assigned_to_organization_user_administers?(user)
task_is_assigned_to_users_organization?(user) && user.administered_teams.include?(assigned_to)
end
class << self
def create_from_root_task(root_task)
create!(assigned_to: BvaDispatch.singleton, parent_id: root_task.id, appeal: root_task.appeal)
end
def outcode(appeal, params, user)
if appeal.is_a?(Appeal)
AmaAppealDispatch.new(appeal: appeal, user: user, params: params).call
elsif appeal.is_a?(LegacyAppeal)
LegacyAppealDispatch.new(appeal: appeal, params: params).call
end
end
end
end