This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathsubmission_statuses_controller.rb
More file actions
105 lines (86 loc) · 2.98 KB
/
submission_statuses_controller.rb
File metadata and controls
105 lines (86 loc) · 2.98 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# frozen_string_literal: true
require 'forms/submission_statuses/report'
module V0
module MyVA
class SubmissionStatusesController < ApplicationController
service_tag 'form-submission-statuses'
def show
report = Forms::SubmissionStatuses::Report.new(
user_account: @current_user.user_account,
allowed_forms: forms_based_on_feature_toggle,
gateway_options: gateway_options_for_user
)
result = report.run
render json: serializable_from(result).to_json, status: status_from(result)
end
private
def restricted_list_of_forms
forms = []
# Always include benefits intake forms for backward compatibility
forms += restricted_benefits_intake_forms
forms += decision_reviews_forms_if_enabled
forms
end
def restricted_benefits_intake_forms
%w[20-10206 20-10207 21-0845 21-0972 21-10210 21-4142 21-4140 21-4142a 21-4502 21-8940V1 21P-0847 21P-527EZ
21P-530EZ 21P-0969 21P-535 21-2680 21-0779 21-4192 21P-530a 21-4138] + uploadable_forms
end
def decision_reviews_forms_if_enabled
return [] unless display_decision_reviews_forms?
# we use form0995_form4142 here to distinguish SC 4142s from standalone 4142s
%w[
20-0995
20-0996
10182
form0995_form4142
]
end
def uploadable_forms
FormProfile::ALL_FORMS[:form_upload]
end
def serializable_from(result)
hash = SubmissionStatusSerializer.new(result.submission_statuses).serializable_hash
hash[:errors] = result.errors
hash
end
def status_from(result)
result.errors.present? ? 296 : 200
end
def forms_based_on_feature_toggle
return nil if display_all_forms?
restricted_list_of_forms
end
def gateway_options_for_user
options = {
# ALWAYS enable benefits intake for backward compatibility
# The feature flag only controls whether to show ALL forms vs restricted list
benefits_intake_enabled: true,
decision_reviews_enabled: display_decision_reviews_forms?,
ivc_champva_enabled: display_ivc_champva_forms?
}
options[:user_email] = @current_user.email if options[:ivc_champva_enabled]
options
end
def display_all_forms?
# When this flag is true, show ALL forms without restriction (pass nil for allowed_forms)
# When false, show the restricted list of forms
Flipper.enabled?(
:my_va_display_all_lighthouse_benefits_intake_forms,
@current_user
)
end
def display_decision_reviews_forms?
Flipper.enabled?(
:my_va_display_decision_reviews_forms,
@current_user
)
end
def display_ivc_champva_forms?
Flipper.enabled?(
:benefits_claims_ivc_champva_provider,
@current_user
)
end
end
end
end