Skip to content

Commit

Permalink
Merge branch 'master' into nanotone/14839-current-rating-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
va-bot authored Sep 4, 2020
2 parents 497cc42 + 962a860 commit b8f9078
Show file tree
Hide file tree
Showing 85 changed files with 52,486 additions and 2,600 deletions.
7 changes: 7 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ if git.lines_of_code > 500
)
end

if git.modified_files.grep(/app\/services\//).any?
warn(
"This PR appears to affect one or more integrations. Make sure to test code in UAT before merging. "\
"See these [instructions for deploying a custom branch to UAT](https://github.com/department-of-veterans-affairs/appeals-deployment/wiki/Appeals-Deployment---Deploy-Custom-Branch-to-UAT)."
)
end

# Don't let testing shortcuts get into master by accident
if `git diff #{github.base_commit} spec/ | grep -E '(:focus => true)|(focus: true)'`.length > 1
fail("focus: true is left in test")
Expand Down
75 changes: 40 additions & 35 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,6 @@ def deny_non_bva_admins
redirect_to "/unauthorized" unless Bva.singleton.user_has_access?(current_user)
end

def manage_teams_menu_items
current_user.administered_teams.map do |team|
title = if team.type == DvcTeam.name
"#{team.name} DVC team management"
elsif team.type == JudgeTeam.name
"#{team.name} Judge team management"
else
"#{team.name} team management"
end

{
title: title,
link: team.user_admin_path
}
end
end

def admin_menu_items
[
{
title: COPY::TEAM_MANAGEMENT_PAGE_DROPDOWN_LINK,
link: url_for(controller: "/team_management", action: "index")
}, {
title: COPY::USER_MANAGEMENT_PAGE_DROPDOWN_LINK,
link: url_for(controller: "/user_management", action: "index")
}
]
end

def handle_non_critical_error(endpoint, err)
Rails.logger.error "#{err.message}\n#{err.backtrace.join("\n")}"

Expand Down Expand Up @@ -144,22 +115,56 @@ def application_urls
end
helper_method :application_urls

def dropdown_urls
urls = [
def defult_menu_items
[
{ title: "Help", link: help_url },
{ title: "Send Feedback", link: feedback_url, target: "_blank" },
{ title: "Release History", link: release_history_url, target: "_blank" }
]
end

urls.concat(manage_teams_menu_items) if current_user&.administered_teams&.any?
urls.concat(admin_menu_items) if Bva.singleton.user_has_access?(current_user)
def manage_teams_menu_items
current_user.administered_teams.map do |team|
{
title: "#{team.name} team management",
link: team.user_admin_path
}
end
end

def manage_all_teams_menu_item
{
title: COPY::TEAM_MANAGEMENT_PAGE_DROPDOWN_LINK,
link: url_for(controller: "/team_management", action: "index")
}
end

if ApplicationController.dependencies_faked? && current_user.present?
urls.append(title: "Switch User", link: url_for(controller: "/test/users", action: "index"))
def manage_users_menu_item
{
title: COPY::USER_MANAGEMENT_PAGE_DROPDOWN_LINK,
link: url_for(controller: "/user_management", action: "index")
}
end

def admin_menu_items
admin_urls = []
admin_urls.concat(manage_teams_menu_items) if current_user&.administered_teams&.any?
admin_urls.push(manage_users_menu_item) if current_user&.can_view_user_management?
if current_user&.can_view_team_management? || current_user&.can_view_judge_team_management?
admin_urls.unshift(manage_all_teams_menu_item)
end
admin_urls.flatten
end

def dropdown_urls
urls = defult_menu_items
urls.concat(admin_menu_items)

if current_user.present?
urls.append(title: "Sign Out", link: url_for(controller: "/sessions", action: "destroy"), border: true)
if ApplicationController.dependencies_faked?
urls.append(title: "Switch User", link: url_for(controller: "/test/users", action: "index"))
end
else
urls.append(title: "Sign In", link: url_for("/search"), border: true)
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class TasksController < ApplicationController
AttorneyQualityReviewTask: AttorneyQualityReviewTask,
AttorneyRewriteTask: AttorneyRewriteTask,
AttorneyTask: AttorneyTask,
BlockedSpecialCaseMovementTask: BlockedSpecialCaseMovementTask,
ChangeHearingDispositionTask: ChangeHearingDispositionTask,
ColocatedTask: ColocatedTask,
EvidenceSubmissionWindowTask: EvidenceSubmissionWindowTask,
Expand Down Expand Up @@ -231,7 +232,8 @@ def parent_tasks_from_params
def create_params
@create_params ||= [params.require("tasks")].flatten.map do |task|
appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(task[:external_id])
task = task.permit(:type, :instructions, :assigned_to_id,
task = task.merge(instructions: [task[:instructions]].flatten.compact)
task = task.permit(:type, { instructions: [] }, :assigned_to_id,
:assigned_to_type, :parent_id, business_payloads: [:description, values: {}])
.merge(assigned_by: current_user)
.merge(appeal: appeal)
Expand Down
47 changes: 29 additions & 18 deletions app/controllers/team_management_controller.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
# frozen_string_literal: true

class TeamManagementController < ApplicationController
before_action :deny_non_bva_admins
before_action :verify_access

def index
respond_to do |format|
format.html { render template: "queue/index" }
format.json do
render json: {
dvc_teams: DvcTeam.all.order(:id).map { |dt| serialize_org(dt) },
judge_teams: JudgeTeam.all.order(:id).map { |jt| serialize_org(jt) },
private_bars: PrivateBar.all.order(:id).map { |private_bar| serialize_org(private_bar) },
vsos: Vso.all.order(:id).map { |vso| serialize_org(vso) },
other_orgs: other_orgs.map { |org| serialize_org(org) }
}
render json: current_user.can_view_team_management? ? all_teams : judge_teams
end
end
end
Expand Down Expand Up @@ -79,21 +73,38 @@ def create_field_vso
private

def update_params
params.require(:organization).permit(:name, :participant_id, :url)
params.require(:organization).permit(:name, :participant_id, :url, :accepts_priority_pushed_cases)
end

def judge_teams
{
judge_teams: JudgeTeam.order(:name).map { |jt| serialize_org(jt) }
}
end

def all_teams
judge_teams.merge(
dvc_teams: DvcTeam.order(:name).map { |dt| serialize_org(dt) },
private_bars: PrivateBar.order(:name).map { |private_bar| serialize_org(private_bar) },
vsos: Vso.order(:name).map { |vso| serialize_org(vso) },
other_orgs: other_orgs.map { |org| serialize_org(org) }
)
end

def other_orgs
Organization.all.order(:id).reject { |org| org.is_a?(JudgeTeam) || org.is_a?(DvcTeam) || org.is_a?(Representative) }
Organization.order(:name).reject { |org| org.is_a?(JudgeTeam) || org.is_a?(DvcTeam) || org.is_a?(Representative) }
end

def serialize_org(org)
{
id: org.id,
name: org.name,
participant_id: org.participant_id,
type: org.type,
url: org.url,
user_admin_path: org.user_admin_path
}
org.serialize.merge(
current_user_can_toggle_priority_pushed_cases: current_user.can_view_judge_team_management?,
user_admin_path: current_user.can_view_team_management? ? org.user_admin_path : nil
)
end

def verify_access
unless current_user.can_view_team_management? || current_user.can_view_judge_team_management?
redirect_to "/unauthorized"
end
end
end
4 changes: 4 additions & 0 deletions app/models/appeal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ def veteran_middle_initial
veteran_middle_name&.first
end

def cavc?
false if cavc == "not implemented for AMA"
end

def cavc
"not implemented for AMA"
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/ama_case_distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def ama_distribution

# Distribute legacy cases tied to a judge down to the board provided limit of 30, regardless of the legacy docket
# range
if FeatureToggle.enabled?(:priority_acd)
if FeatureToggle.enabled?(:priority_acd, user: judge)
distribute_appeals(:legacy, @rem, priority: false, genpop: "not_genpop", bust_backlog: true)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/end_product_establishment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def potential_decision_ratings
def cancel!
transaction do
# delete end product in bgs & set sync status to canceled
BGSService.new.cancel_end_product(veteran_file_number, code, modifier)
BGSService.new.cancel_end_product(veteran_file_number, code, modifier, payee_code, benefit_type_code)
update!(synced_status: CANCELED_STATUS)
handle_cancelled_ep!
end
Expand Down
16 changes: 4 additions & 12 deletions app/models/legacy_appeal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,8 @@ class UnknownLocationError < StandardError; end
end

# To match Appeals AOD behavior
def aod?
aod
end

def advanced_on_docket?
aod
end
alias aod? aod
alias advanced_on_docket? aod

cache_attribute :dic do
issues.map(&:dic).include?(true)
Expand All @@ -110,9 +105,6 @@ def advanced_on_docket?
# Note: If any of the names here are changed, they must also be changed in SpecialIssues.js 'specialIssue` value
# rubocop:disable Metrics/LineLength
SPECIAL_ISSUES = {
blue_water: "Blue Water",
burn_pit: "Burn Pit",
us_court_of_appeals_for_veterans_claims: "US Court of Appeals for Veterans Claims (CAVC)",
contaminated_water_at_camp_lejeune: "Contaminated Water at Camp LeJeune",
dic_death_or_accrued_benefits_united_states: "DIC - death, or accrued benefits - United States",
education_gi_bill_dependents_educational_assistance_scholars: "Education - GI Bill, dependents educational assistance, scholarship, transfer of entitlement",
Expand All @@ -124,10 +116,8 @@ def advanced_on_docket?
incarcerated_veterans: "Incarcerated Veterans",
insurance: "Insurance",
manlincon_compliance: "Manlincon Compliance",
military_sexual_trauma: "Military Sexual Trauma (MST)",
mustard_gas: "Mustard Gas",
national_cemetery_administration: "National Cemetery Administration",
no_special_issues: "No Special Issues",
nonrating_issue: "Non-rating issue",
pension_united_states: "Pension - United States",
private_attorney_or_agent: "Private Attorney or Agent",
Expand Down Expand Up @@ -785,6 +775,8 @@ def cavc
type == "Court Remand"
end

alias cavc? cavc

# Adding anything to this to_hash can trigger a lazy load which slows down
# welcome gate dramatically. Don't add anything to it without also adding it to
# the query in VACOLS::CaseAssignment.
Expand Down
2 changes: 1 addition & 1 deletion app/models/legacy_hearing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def vacols_hearing_exists?
self.class.repository.load_vacols_data(self)
true
rescue Caseflow::Error::VacolsRecordNotFound => error
capture_exception(error)
Raven.capture_exception(error)
false
end
end
Expand Down
14 changes: 13 additions & 1 deletion app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Organization < CaseflowRecord
has_many :judge_team_roles, through: :organizations_users
has_many :non_admin_users, -> { non_admin }, class_name: "OrganizationsUser"
require_dependency "dvc_team"

validates :name, presence: true
validates :url, presence: true, uniqueness: true

Expand Down Expand Up @@ -137,6 +137,18 @@ def completed_tasks_tab
::OrganizationCompletedTasksTab.new(assignee: self, show_regional_office_column: show_regional_office_in_queue?)
end

def serialize
{
accepts_priority_pushed_cases: accepts_priority_pushed_cases,
id: id,
name: name,
participant_id: participant_id,
type: type,
url: url,
user_admin_path: user_admin_path
}
end

private

def clean_url
Expand Down
4 changes: 4 additions & 0 deletions app/models/organizations/dvc_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ def can_receive_task?(_task)
def selectable_in_queue?
false
end

def serialize
super.merge(name: dvc.full_name.titleize)
end
end
4 changes: 4 additions & 0 deletions app/models/organizations/judge_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def selectable_in_queue?
false
end

def serialize
super.merge(name: judge.full_name.titleize)
end

private

def use_judge_team_roles?
Expand Down
31 changes: 28 additions & 3 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ def joins_with_cached_appeals_clause
"on #{CachedAppeal.table_name}.appeal_id = #{Task.table_name}.appeal_id "\
"and #{CachedAppeal.table_name}.appeal_type = #{Task.table_name}.appeal_type"
end

def order_by_appeal_priority_clause
Arel.sql(
"CASE WHEN #{CachedAppeal.table_name}.is_aod = TRUE THEN 0 ELSE 1 END, "\
"CASE WHEN #{CachedAppeal.table_name}.case_type = 'Court Remand' THEN 0 ELSE 1 END, "\
"#{Task.table_name}.created_at"
)
end
end

########################################################################################
Expand Down Expand Up @@ -389,8 +397,10 @@ def same_task_type?(task_to_check)
type.eql?(task_to_check&.type)
end

def cancel_descendants
descendants.select(&:open?).each { |desc| desc.update!(status: Constants.TASK_STATUSES.cancelled) }
def cancel_descendants(instructions: [])
descendants.select(&:open?).each do |desc|
desc.update_with_instructions(status: Constants.TASK_STATUSES.cancelled, instructions: instructions)
end
end

def create_twin_of_type(_params)
Expand Down Expand Up @@ -421,7 +431,7 @@ def hide_from_queue_table_view
end

def duplicate_org_task
assigned_to.is_a?(Organization) && children.any? do |child_task|
assigned_to.is_a?(Organization) && descendants.any? do |child_task|
User.name == child_task.assigned_to_type && type == child_task.type
end
end
Expand Down Expand Up @@ -599,6 +609,21 @@ def reassign_clears_overtime?
false
end

def serialize_for_cancellation
assignee_display_name = if assigned_to.is_a?(Organization)
assigned_to.name
else
"#{assigned_to.full_name.titlecase} (#{assigned_to.css_id})"
end

{
id: id,
assigned_to_email: assigned_to.is_a?(Organization) ? assigned_to.admins.first&.email : assigned_to.email,
assigned_to_name: assignee_display_name,
type: type
}
end

# currently only defined by ScheduleHearingTask and AssignHearingDispositionTask for virtual hearing related updates
def alerts
@alerts ||= []
Expand Down
Loading

0 comments on commit b8f9078

Please sign in to comment.