-
Notifications
You must be signed in to change notification settings - Fork 19
/
judge_team.rb
58 lines (45 loc) · 1.42 KB
/
judge_team.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true
class JudgeTeam < Organization
scope :pushed_priority_cases_allowed, -> { active.where(accepts_priority_pushed_cases: true) }
class << self
def for_judge(user)
# This could be replaced with user.administered_judge_teams.first
user.administered_judge_teams.detect { |team| team.judge.eql?(user) }
end
def create_for_judge(user, ama_only_push = false, ama_only_request = false)
fail(Caseflow::Error::DuplicateJudgeTeam, user_id: user.id) if JudgeTeam.for_judge(user)
create!(name: user.css_id,
url: user.css_id.downcase,
accepts_priority_pushed_cases: true,
ama_only_push: ama_only_push,
ama_only_request: ama_only_request).tap do |org|
OrganizationsUser.make_user_admin(user, org)
end
end
def judge_ids_with_exclude_appeals_from_affinity
judges_with_exclude_appeals_from_affinity.pluck(:id)
end
def judges_with_exclude_appeals_from_affinity
return [] unless FeatureToggle.enabled?(:acd_exclude_from_affinity)
active.where(exclude_appeals_from_affinity: true).flat_map(&:judge).compact
end
end
def judge
admin
end
def attorneys
non_admins
end
def admin
admins.first
end
def can_receive_task?(_task)
false
end
def selectable_in_queue?
false
end
def serialize
super.merge(name: judge&.full_name&.titleize)
end
end