Skip to content

Commit

Permalink
Merge branch 'master' into 97128-improve-accessibility-of-generated-pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
opticbob committed Dec 17, 2024
2 parents 27552d0 + cb209cf commit 4e7c6cb
Show file tree
Hide file tree
Showing 82 changed files with 18,692 additions and 1,397 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ app/services/mhv_account_type_service.rb @department-of-veterans-affairs/octo-id
app/services/mhv_logging_service.rb @department-of-veterans-affairs/octo-identity
app/services/rapid_ready_for_decision @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/services/sign_in @department-of-veterans-affairs/octo-identity
app/services/submission_pdf_url_service.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/services/terms_of_use @department-of-veterans-affairs/octo-identity
app/services/users @department-of-veterans-affairs/octo-identity
app/swagger/readme.md @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ GEM
actionpack (>= 5.2, < 8.1)
railties (>= 5.2, < 8.1)
rtesseract (3.1.3)
rubocop (1.69.1)
rubocop (1.69.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -960,7 +960,7 @@ GEM
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.36.2)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def separation_locations
:all_users,
:get_separation_locations
) do
provider = Flipper.enabled?(:disability_compensation_staging_lighthouse_brd) ? :lighthouse_staging : nil
api_provider = ApiProviderFactory.call(
type: ApiProviderFactory::FACTORIES[:brd],
provider: nil,
provider:,
options: {},
current_user: @current_user,
feature_toggle: ApiProviderFactory::FEATURE_TOGGLE_BRD
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/v0/my_va/submission_pdf_urls_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# frozen_string_literal: true

require 'forms/submission_statuses/pdf_urls'

module V0
module MyVA
class SubmissionPdfUrlsController < ApplicationController
before_action :check_flipper_flag
service_tag 'form-submission-pdf'

def create
url = SubmissionPdfUrlService.new(
url = Forms::SubmissionStatuses::PdfUrls.new(
form_id: request_params[:form_id],
submission_guid: request_params[:submission_guid]
).fetch_url
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/submission_status_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
class SubmissionStatusSerializer
include JSONAPI::Serializer

attributes :id, :detail, :form_type, :message, :status, :created_at, :updated_at
attributes :id, :detail, :form_type, :message, :status, :created_at, :updated_at, :pdf_support
end
26 changes: 0 additions & 26 deletions app/services/submission_pdf_url_service.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/sidekiq/benefits_intake_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def monitor_failure(form_id, saved_claim_id, bi_uuid)
}
call_location = caller_locations.first

if %w[21P-530EZ].include?(form_id)
if %w[21P-530EZ 21P-530V2].include?(form_id)
claim = SavedClaim::Burial.find(saved_claim_id)
if claim
Burials::NotificationEmail.new(claim.id).deliver(:error)
Expand Down
4 changes: 3 additions & 1 deletion app/swagger/swagger/requests/my_va/submission_statuses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class SubmissionStatuses
property :detail, type: [:string, 'null'], example: '',
description: 'Error details (only when errors are present)'
property :form_type, type: :string, example: '21-0845', description: 'The type of form'
property :message, type: [:string, 'null']
property :message, type: [:string, 'null'], example: 'Descriptive message'
property :status, type: [:string, 'null'], enum: [
nil,
'pending',
Expand All @@ -115,6 +115,8 @@ class SubmissionStatuses
description: 'The submission record created in VA.gov'
property :updated_at, type: [:string, 'null'], example: '2023-12-15T20:40:54.474Z',
description: 'The last time the submission status was updated'
property :pdf_support, type: :boolean, example: true,
description: 'True if submission supports archived pdf downloads'
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ features:
caregiver_retry_form_validation:
actor_type: user
description: Enables 1010CG to retry schema validation
disability_compensation_staging_lighthouse_brd:
actor_type: user
description: Switches to Lighthouse Staging BRD Service. NEVER ENABLE IN PRODUCTION.
hca_browser_monitoring_enabled:
actor_type: user
description: Enables browser monitoring for the health care application.
Expand Down
42 changes: 42 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
require 'disability_compensation/providers/brd/brd_provider'
require 'disability_compensation/providers/brd/evss_brd_provider'
require 'disability_compensation/providers/brd/lighthouse_brd_provider'
require 'disability_compensation/providers/brd/lighthouse_staging_brd_provider'
require 'disability_compensation/providers/generate_pdf/generate_pdf_provider'
require 'disability_compensation/providers/generate_pdf/evss_generate_pdf_provider'
require 'disability_compensation/providers/generate_pdf/lighthouse_generate_pdf_provider'
Expand All @@ -28,7 +29,8 @@ class UndefinedFactoryTypeError < StandardError; end

API_PROVIDER = {
evss: :evss,
lighthouse: :lighthouse
lighthouse: :lighthouse,
lighthouse_staging: :lighthouse_staging
}.freeze

FACTORIES = {
Expand Down Expand Up @@ -166,6 +168,8 @@ def brd_service_provider
EvssBRDProvider.new(@current_user)
when API_PROVIDER[:lighthouse]
LighthouseBRDProvider.new(@current_user)
when API_PROVIDER[:lighthouse_staging]
LighthouseStagingBRDProvider.new(@current_user)
else
raise NotImplementedError, 'No known BRD Api Provider type provided'
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require 'disability_compensation/providers/brd/lighthouse_brd_provider'
require 'lighthouse/benefits_reference_data_staging/service'

class LighthouseStagingBRDProvider < LighthouseBRDProvider
def initialize(_current_user)
super
@service = BenefitsReferenceData::Staging::Service.new
end
end
12 changes: 11 additions & 1 deletion lib/forms/submission_statuses/formatter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative 'pdf_urls'

module Forms
module SubmissionStatuses
class Formatter
Expand Down Expand Up @@ -46,10 +48,18 @@ def build_submissions_map(submissions)
message: nil,
status: nil,
created_at: submission.created_at,
updated_at: nil
updated_at: nil,
pdf_support: pdf_supported?(submission)
)
end
end

def pdf_supported?(submission)
PdfUrls.new(
form_id: submission.form_type,
submission_guid: submission.benefits_intake_uuid
).supported?
end
end
end
end
38 changes: 38 additions & 0 deletions lib/forms/submission_statuses/pdf_urls.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

require 'simple_forms_api/form_remediation/configuration/vff_config'

module Forms
module SubmissionStatuses
class PdfUrls
VFF_FORMS = %w[20-10206 20-10207 21-0845 21-0966 21-0972 21-10210 21-4138 21-4142 21P-0847 26-4555 40-0247
40-10007].freeze

def initialize(form_id:, submission_guid:)
@form_id = form_id
@submission_guid = submission_guid
end

def fetch_url
config = determine_config
SimpleFormsApi::FormRemediation::S3Client.fetch_presigned_url(@submission_guid, config:)
end

def supported?
determine_config
rescue Common::Exceptions::Forbidden
false
else
true
end

private

def determine_config
return SimpleFormsApi::FormRemediation::Configuration::VffConfig.new if VFF_FORMS.include?(@form_id)

raise Common::Exceptions::Forbidden, detail: "Form '#{@form_id}' does not support pdf downloads"
end
end
end
end
68 changes: 68 additions & 0 deletions lib/lighthouse/benefits_reference_data_staging/configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# frozen_string_literal: true

require 'common/client/configuration/rest'
require 'faraday/multipart'

module BenefitsReferenceData
##
# HTTP client configuration for the {BenefitsReferenceData::Service},
# sets the base path, the base request headers, and a service name for breakers and metrics.

module Staging
class Configuration < Common::Client::Configuration::REST
self.read_timeout = Settings.lighthouse.benefits_reference_data.timeout || 20

##
# @return [String] Base path for benefits_reference_data URLs.
#
def base_path
settings = Settings.lighthouse.benefits_reference_data
url = settings.staging_url
path = settings.path
version = settings.version
safe_slash_merge(url, path, version)
end

##
# @return [String] Service name to use in breakers and metrics.
#
def service_name
'BenefitsReferenceDataStaging'
end

##
# @return [Hash] The basic headers required for any benefits_reference_data API call.
#
def self.base_request_headers
key = Settings.lighthouse.staging_api_key
message = "No api_key set for LH benefits_reference_data_staging. Please set 'lighthouse.staging_api_key'"
raise message if key.nil?

super.merge('apiKey' => key)
end

##
# Creates the a connection with parsing json and adding breakers functionality.
#
# @return [Faraday::Connection] a Faraday connection instance.
#
def connection
@conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|
faraday.use :breakers
faraday.use Faraday::Response::RaiseError

faraday.request :multipart
faraday.request :json
faraday.response :json
faraday.adapter Faraday.default_adapter
end
end

private

def safe_slash_merge(*url_segments)
url_segments.map { |segment| segment.sub(%r{^/}, '').chomp('/') }.join('/')
end
end
end
end
Loading

0 comments on commit 4e7c6cb

Please sign in to comment.