Skip to content

Commit

Permalink
Merge branch 'master' into yoom/replicate-scm-cant-reassign
Browse files Browse the repository at this point in the history
  • Loading branch information
yoomlam committed May 6, 2021
2 parents eee36fe + 09e717e commit 95fddf8
Show file tree
Hide file tree
Showing 20 changed files with 472 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -54,7 +54,7 @@ gem "pg", platforms: :ruby
# We are not yet at version 4.x because we have not tested.
gem "puma", "~> 3.12.6"
gem "rack", "~> 2.2.3"
gem "rails", "5.2.4.5"
gem "rails", "5.2.4.6"
# Used to colorize output for rake tasks
gem "rainbow"
# React
Expand Down
93 changes: 47 additions & 46 deletions Gemfile.lock
Expand Up @@ -76,48 +76,48 @@ GEM
remote: https://rubygems.org/
specs:
aasm (4.11.0)
actioncable (5.2.4.5)
actionpack (= 5.2.4.5)
actioncable (5.2.4.6)
actionpack (= 5.2.4.6)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.4.5)
actionpack (= 5.2.4.5)
actionview (= 5.2.4.5)
activejob (= 5.2.4.5)
actionmailer (5.2.4.6)
actionpack (= 5.2.4.6)
actionview (= 5.2.4.6)
activejob (= 5.2.4.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.4.5)
actionview (= 5.2.4.5)
activesupport (= 5.2.4.5)
actionpack (5.2.4.6)
actionview (= 5.2.4.6)
activesupport (= 5.2.4.6)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.4.5)
activesupport (= 5.2.4.5)
actionview (5.2.4.6)
activesupport (= 5.2.4.6)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.4.5)
activesupport (= 5.2.4.5)
activejob (5.2.4.6)
activesupport (= 5.2.4.6)
globalid (>= 0.3.6)
activemodel (5.2.4.5)
activesupport (= 5.2.4.5)
activerecord (5.2.4.5)
activemodel (= 5.2.4.5)
activesupport (= 5.2.4.5)
activemodel (5.2.4.6)
activesupport (= 5.2.4.6)
activerecord (5.2.4.6)
activemodel (= 5.2.4.6)
activesupport (= 5.2.4.6)
arel (>= 9.0)
activerecord-import (1.0.2)
activerecord (>= 3.2)
activerecord-oracle_enhanced-adapter (5.2.8)
activerecord (~> 5.2.0)
ruby-plsql (>= 0.6.0)
activestorage (5.2.4.5)
actionpack (= 5.2.4.5)
activerecord (= 5.2.4.5)
activestorage (5.2.4.6)
actionpack (= 5.2.4.6)
activerecord (= 5.2.4.6)
marcel (~> 0.3.1)
activesupport (5.2.4.5)
activesupport (5.2.4.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand Down Expand Up @@ -321,7 +321,7 @@ GEM
httpi (2.4.4)
rack
socksify
i18n (1.8.8)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
i18n_data (0.10.0)
icalendar (2.6.1)
Expand Down Expand Up @@ -371,7 +371,7 @@ GEM
logstasher (2.1.5)
activesupport (>= 5.2)
request_store
loofah (2.9.0)
loofah (2.9.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.13)
Expand All @@ -387,11 +387,12 @@ GEM
mime-types (3.3)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mimemagic (0.3.7)
nokogiri (~> 1.11.2)
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.14.3)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_mime (1.1.0)
mini_portile2 (2.5.1)
minitest (5.14.4)
moment_timezone-rails (0.5.0)
momentjs-rails (2.20.1)
railties (>= 3.1)
Expand All @@ -407,9 +408,9 @@ GEM
thor (~> 0.19)
nenv (0.3.0)
newrelic_rpm (6.5.0.357)
nio4r (2.5.5)
nio4r (2.5.7)
no_proxy_fix (0.1.2)
nokogiri (1.11.2)
nokogiri (1.11.3)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
nori (2.6.0)
Expand Down Expand Up @@ -446,18 +447,18 @@ GEM
rack (~> 2.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.4.5)
actioncable (= 5.2.4.5)
actionmailer (= 5.2.4.5)
actionpack (= 5.2.4.5)
actionview (= 5.2.4.5)
activejob (= 5.2.4.5)
activemodel (= 5.2.4.5)
activerecord (= 5.2.4.5)
activestorage (= 5.2.4.5)
activesupport (= 5.2.4.5)
rails (5.2.4.6)
actioncable (= 5.2.4.6)
actionmailer (= 5.2.4.6)
actionpack (= 5.2.4.6)
actionview (= 5.2.4.6)
activejob (= 5.2.4.6)
activemodel (= 5.2.4.6)
activerecord (= 5.2.4.6)
activestorage (= 5.2.4.6)
activesupport (= 5.2.4.6)
bundler (>= 1.3.0)
railties (= 5.2.4.5)
railties (= 5.2.4.6)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand All @@ -469,9 +470,9 @@ GEM
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.4.5)
actionpack (= 5.2.4.5)
activesupport (= 5.2.4.5)
railties (5.2.4.6)
actionpack (= 5.2.4.6)
activesupport (= 5.2.4.6)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
Expand Down Expand Up @@ -724,7 +725,7 @@ DEPENDENCIES
pry-byebug
puma (~> 3.12.6)
rack (~> 2.2.3)
rails (= 5.2.4.5)
rails (= 5.2.4.6)
rails-erd
rainbow
rb-readline
Expand Down
87 changes: 78 additions & 9 deletions app/controllers/appeals_controller.rb
Expand Up @@ -58,14 +58,24 @@ def document_count
end

def power_of_attorney
render json: {
representative_type: appeal.representative_type,
representative_name: appeal.representative_name,
representative_address: appeal.representative_address,
representative_email_address: appeal.representative_email_address,
representative_tz: appeal.representative_tz,
poa_last_synced_at: appeal.poa_last_synced_at
}
render json: power_of_attorney_data
end

def update_power_of_attorney
if cooldown_period_remaining > 0
message = "Information is current at this time. Please try again in #{cooldown_period_remaining} minutes"
render json: {
status: "info",
message: message,
power_of_attorney: power_of_attorney_data
}
elsif appeal.is_a?(Appeal)
poa = BgsPowerOfAttorney.find(params[:poaId])
render json: update_ama_poa(poa)
else
poa = appeal.power_of_attorney
render json: update_legacy_poa(poa)
end
end

def most_recent_hearing
Expand Down Expand Up @@ -175,7 +185,7 @@ def set_application
def json_appeals(appeal)
if appeal.is_a?(Appeal)
WorkQueue::AppealSerializer.new(appeal, params: { user: current_user }).serializable_hash
elsif appeal.is_a?(LegacyAppeal)
else
WorkQueue::LegacyAppealSerializer.new(appeal, params: { user: current_user }).serializable_hash
end
end
Expand Down Expand Up @@ -240,4 +250,63 @@ def access_error_message
def docket_number?(search)
!search.nil? && search.match?(/\d{6}-{1}\d+$/)
end

def power_of_attorney_data
poa_data = {
representative_type: appeal.representative_type,
representative_name: appeal.representative_name,
representative_address: appeal.representative_address,
representative_email_address: appeal.representative_email_address,
representative_tz: appeal.representative_tz,
poa_last_synced_at: appeal.poa_last_synced_at
}
unless appeal.power_of_attorney.is_a?(UnrecognizedPowerOfAttorney)
poa_data[:representative_id] = appeal.power_of_attorney&.id if appeal.is_a?(Appeal)
poa_data[:representative_id] = appeal.power_of_attorney&.bgs_id if appeal.is_a?(LegacyAppeal)
end
poa_data
end

def update_ama_poa(poa)
begin
message = poa.update_or_delete
{
status: "success",
message: message,
power_of_attorney: power_of_attorney_data
}
rescue ActiveRecord::RecordNotUnique
{
status: "error",
message: "Something went wrong"
}
end
end

def update_legacy_poa(poa)
begin
bgs_poa = BgsPowerOfAttorney.find_or_create_by_file_number(poa.file_number)
message = bgs_poa.update_or_delete(appeal.claimant)
appeal.power_of_attorney.clear_bgs_power_of_attorney!
{
status: "success",
message: message,
power_of_attorney: power_of_attorney_data
}
rescue ActiveRecord::RecordNotUnique
{
status: "error",
message: "Something went wrong"
}
end
end

def cooldown_period_remaining
next_update_allowed_at = appeal.poa_last_synced_at + 10.minutes if appeal.poa_last_synced_at.present?
if next_update_allowed_at && next_update_allowed_at > Time.zone.now
return ((next_update_allowed_at - Time.zone.now) / 60).ceil
end

0
end
end
2 changes: 2 additions & 0 deletions app/models/appeal.rb
Expand Up @@ -419,6 +419,8 @@ def power_of_attorney
:representative_address,
:representative_email_address,
:poa_last_synced_at,
:update_cached_attributes!,
:save_with_updated_bgs_record!,
to: :power_of_attorney, allow_nil: true

def power_of_attorneys
Expand Down
14 changes: 14 additions & 0 deletions app/models/bgs_power_of_attorney.rb
Expand Up @@ -149,6 +149,20 @@ def found?
bgs_record.keys.any?
end

def update_or_delete(claimant = nil)
if bgs_record == :not_found
if claimant && !claimant.is_a?(Hash) && claimant.should_delete_power_of_attorney?
claimant_poa.destroy
else
destroy
end
"Successfully refreshed. No power of attorney information was found at this time."
else
save_with_updated_bgs_record!
"POA Updated Successfully"
end
end

private

def person
Expand Down
6 changes: 6 additions & 0 deletions app/models/claimant.rb
Expand Up @@ -55,6 +55,12 @@ def power_of_attorney
@power_of_attorney ||= find_power_of_attorney
end

def should_delete_power_of_attorney?
return true if power_of_attorney && power_of_attorney.bgs_record == :not_found

false
end

def representative_participant_id
power_of_attorney&.participant_id
end
Expand Down
5 changes: 5 additions & 0 deletions app/models/legacy_appeal.rb
Expand Up @@ -340,12 +340,17 @@ def disposition_remand_priority
:representative_is_organization?,
:representative_is_vso?,
:representative_is_colocated_vso?,
:fetch_bgs_record,
to: :legacy_appeal_representative

def representative_email_address
power_of_attorney.bgs_representative_email_address
end

def representative_id
power_of_attorney.vacols_id
end

def poa_last_synced_at
power_of_attorney.bgs_poa_last_synced_at
end
Expand Down
5 changes: 5 additions & 0 deletions app/models/power_of_attorney.rb
Expand Up @@ -32,6 +32,7 @@ class PowerOfAttorney
:representative_email_address,
:participant_id,
:poa_last_synced_at,
:id,
to: :bgs_power_of_attorney, prefix: :bgs

class << self
Expand Down Expand Up @@ -63,6 +64,10 @@ def update_vacols_rep_info!(appeal:, representative_type:, representative_name:,
end
end

def clear_bgs_power_of_attorney!
@bgs_power_of_attorney = nil
end

private

def bgs_power_of_attorney
Expand Down
2 changes: 1 addition & 1 deletion app/views/queue/index.html.erb
Expand Up @@ -31,8 +31,8 @@
editNodDate: FeatureToggle.enabled?(:edit_nod_date, user: current_user),
fnod_badge: FeatureToggle.enabled?(:fnod_badge, user: current_user),
fnod_banner: FeatureToggle.enabled?(:fnod_banner, user: current_user),
poa_sync_date: FeatureToggle.enabled?(:poa_sync_date, user: current_user),
view_nod_date_updates: FeatureToggle.enabled?(:view_nod_date_updates, user: current_user),
poa_refresh: FeatureToggle.enabled?(:poa_refresh, user: current_user),
recognized_granted_substitution_after_dd: FeatureToggle.enabled?(:recognized_granted_substitution_after_dd, user: current_user)
}
}) %>
Expand Down

0 comments on commit 95fddf8

Please sign in to comment.