Skip to content

Commit

Permalink
feat(rfh): add new triage questions
Browse files Browse the repository at this point in the history
Jira: PWNN-1554
  • Loading branch information
EdwinKruglov authored and serenaabbott11 committed Oct 5, 2023
1 parent 4fc0883 commit 81bd014
Show file tree
Hide file tree
Showing 141 changed files with 2,839 additions and 724 deletions.
41 changes: 28 additions & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# This configuration was generated by
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
# using RuboCop version 1.44.1.
# using RuboCop version 1.55.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedMethods, AllowedPatterns.
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/models/exit_survey_response_spec.rb'
- 'spec/services/support/messages/outlook/resync_email_ids_spec.rb'

# Offense count: 8
# Configuration parameters: AllowedPatterns, IgnoredPatterns.
# Configuration parameters: AllowedPatterns.
# SupportedStyles: snake_case, camelCase
Naming/MethodName:
EnforcedStyle: snake_case
Expand All @@ -36,29 +37,37 @@ RSpec/AnyInstance:
- 'spec/support/shared/notify_email_templates.rb'
- 'spec/support/sign_in_helpers.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/controllers/support_agents_spec.rb'

# Offense count: 3
# Offense count: 11
RSpec/LetSetup:
Enabled: false
Exclude:
- 'spec/jobs/support/send_exit_survey_job_spec.rb'
- 'spec/services/support/messages/outlook/synchronisation/message_case_detection_spec.rb'
- 'spec/support/shared/duplicate_email_attachments.rb'
- 'spec/support/shared/support_agent.rb'

# Offense count: 4
RSpec/SubjectStub:
Exclude:
- 'spec/forms/framework_requests/special_requirements_form_spec.rb'
- 'spec/services/support/messages/outlook/synchronisation/message_case_detection_spec.rb'

# Offense count: 115
# Offense count: 125
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Enabled: false

# Offense count: 13
# Offense count: 14
# Configuration parameters: Database, Include.
# SupportedDatabases: mysql, postgresql
# Include: db/migrate/*.rb
# Include: db/**/*.rb
Rails/BulkChangeTable:
Exclude:
- 'db/migrate/20210118110545_change_options_to_jsonb.rb'
Expand All @@ -74,21 +83,23 @@ Rails/BulkChangeTable:
- 'db/migrate/20230919092926_update_lot_frameworks_framework.rb'
- 'db/migrate/20230919144709_add_reference_sequence_to_frameworks_framework.rb'

# Offense count: 2
# Offense count: 5
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb, app/mailers/**/*.rb
Rails/LexicallyScopedActionFilter:
Exclude:
- 'app/controllers/all_cases_survey/satisfaction_reason_controller.rb'
- 'app/controllers/framework_requests/bill_uploads_controller.rb'
- 'app/controllers/framework_requests/document_uploads_controller.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: db/migrate/*.rb
# Include: db/**/*.rb
Rails/NotNullColumn:
Exclude:
- 'db/migrate/20210107122307_add_liquid_template_to_journey.rb'

# Offense count: 3
# Offense count: 4
# Configuration parameters: Include.
# Include: db/**/*.rb
Rails/ReversibleMigration:
Expand Down Expand Up @@ -123,5 +134,9 @@ Style/DateTime:
- 'lib/microsoft_graph/transformer/message.rb'
- 'lib/microsoft_graph/transformer/update_message.rb'

Rails/UniqueValidationWithoutIndex:
Enabled: false
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowModifier.
Style/SoleNestedConditional:
Exclude:
- 'app/models/framework_request_flow.rb'
8 changes: 2 additions & 6 deletions app/controllers/framework_requests/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ def sign_in_path
confirm_sign_in_framework_requests_path
end

def last_energy_path
return energy_alternative_framework_requests_path(framework_support_form: form.common) if framework_request.energy_alternative.present?
return energy_bill_framework_requests_path(framework_support_form: form.common) if framework_request.have_energy_bill.present?
return energy_request_about_framework_requests_path(framework_support_form: form.common) if framework_request.energy_request_about.present?

energy_request_framework_requests_path(framework_support_form: form.common)
def flow
framework_request.reload.flow
end

def create_redirect_path; end
Expand Down
21 changes: 16 additions & 5 deletions app/controllers/framework_requests/bill_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module FrameworkRequests
class BillUploadsController < BaseController
skip_before_action :authenticate_user!

before_action :edit_back_url, only: %i[update]

def list
files = framework_request.energy_bills.map do |bill|
{
Expand Down Expand Up @@ -53,19 +55,28 @@ def update_data
end

def create_redirect_path
message_framework_requests_path(framework_support_form: form.common)
special_requirements_framework_requests_path(framework_support_form: form.common)
end

def back_url
@back_url = determine_back_path
end

def determine_back_path
@current_user = UserPresenter.new(current_user)
return email_framework_requests_path(framework_support_form: form.common) if @current_user.guest?
return last_energy_path if @current_user.single_org?
return energy_alternative_framework_requests_path(framework_support_form: form.common) if framework_request.energy_alternative.present?

energy_bill_framework_requests_path(framework_support_form: form.common)
end

select_organisation_framework_requests_path(framework_support_form: form.common)
def edit_back_url
@back_url =
if @form.source.change_link?
framework_request_path
elsif framework_request.energy_alternative.nil?
edit_framework_request_energy_bill_path(framework_request)
else
edit_framework_request_energy_alternative_path(framework_request)
end
end
end
end
31 changes: 24 additions & 7 deletions app/controllers/framework_requests/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def update

if @form.final_category?
@form.save!
redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
if flow.unfinished?
redirect_to edit_framework_request_contract_length_path(framework_request)
else
redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
end
else
redirect_to edit_framework_request_category_path(framework_request, **@form.slugs)
end
Expand All @@ -42,8 +46,8 @@ def back_url = @back_url = determine_back_path

def create_redirect_path
if @form.final_category?
if @form.allow_bill_upload?
special_requirements_framework_requests_path(framework_support_form: @form.common)
if flow.energy_or_services?
contract_length_framework_requests_path(framework_support_form: @form.common)
else
procurement_amount_framework_requests_path(framework_support_form: @form.common)
end
Expand All @@ -60,10 +64,23 @@ def edit_back_url
end

def determine_back_path
return categories_framework_requests_path(framework_support_form: @form.common.merge(category_slug: "multiple")) if category_path == "multiple"
return message_framework_requests_path(framework_support_form: @form.common) if category_path.nil?

categories_framework_requests_path(category_path: @form.parent_category_path, framework_support_form: @form.common)
@current_user = UserPresenter.new(current_user)

if category_path == "multiple"
categories_framework_requests_path(framework_support_form: @form.common.merge(category_slug: "multiple"))
elsif category_path.nil?
if @current_user.guest?
email_framework_requests_path(framework_support_form: @form.common)
elsif form.eligible_for_school_picker?
confirm_schools_framework_requests_path(framework_support_form: @form.common)
elsif @current_user.single_org?
confirm_sign_in_framework_requests_path(framework_support_form: @form.common)
else
select_organisation_framework_requests_path(framework_support_form: @form.common)
end
else
categories_framework_requests_path(category_path: @form.parent_category_path, framework_support_form: @form.common)
end
end

def form_params = %i[category_slug category_other]
Expand Down
16 changes: 11 additions & 5 deletions app/controllers/framework_requests/confirm_schools_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def update
if @form.valid?
if @form.school_urns_confirmed?
@form.save!
redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
update_redirect_path
else
redirect_to edit_framework_request_school_picker_path(framework_request)
end
Expand All @@ -45,12 +45,18 @@ def form_params
end

def create_redirect_path
if @form.allow_bill_upload?
bill_uploads_framework_requests_path(framework_support_form: @form.common)
elsif current_user.guest?
if current_user.guest?
name_framework_requests_path(framework_support_form: @form.common)
else
message_framework_requests_path(framework_support_form: @form.common)
categories_framework_requests_path(framework_support_form: @form.common)
end
end

def update_redirect_path
if flow.unfinished?
redirect_to edit_framework_request_same_supplier_path(framework_request)
else
redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ def create_redirect_path
@current_user = UserPresenter.new(current_user)
return select_organisation_framework_requests_path(framework_support_form: form.common) unless @current_user.single_org?
return school_picker_framework_requests_path(framework_support_form: form.common) if @current_user.belongs_to_trust_or_federation? && @current_user.org.organisations.present?
return bill_uploads_framework_requests_path(framework_support_form: form.common) if @form.allow_bill_upload?

message_framework_requests_path(framework_support_form: form.common)
categories_framework_requests_path(framework_support_form: form.common)
end

def set_inferred_attrbutes
Expand Down
47 changes: 47 additions & 0 deletions app/controllers/framework_requests/contract_lengths_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module FrameworkRequests
class ContractLengthsController < BaseController
skip_before_action :authenticate_user!

before_action :edit_back_url, only: %i[update]

def update
if @form.valid?
@form.save!
if flow.unfinished?
redirect_to edit_framework_request_contract_start_date_path(framework_request)
else
redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
end
else
render :edit
end
end

private

def form
@form ||= FrameworkRequests::ContractLengthForm.new(all_form_params)
end

def form_params
[:contract_length]
end

def create_redirect_path
contract_start_date_framework_requests_path(framework_support_form: form.common)
end

def back_url
@back_url = categories_framework_requests_path(category_path: framework_request.category&.ancestors_slug, framework_support_form: @form.common)
end

def edit_back_url
@back_url =
if flow.unfinished?
edit_framework_request_category_path(framework_support_form: form.common)
else
framework_request_path(form.framework_request)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module FrameworkRequests
class ContractStartDatesController < BaseController
include Support::Concerns::HasDateParams

skip_before_action :authenticate_user!

before_action :edit_back_url, only: %i[update]

def update
if @form.valid?
@form.save!
if flow.unfinished?
if framework_request.multischool_with_multiple_selections?
redirect_to edit_framework_request_same_supplier_path(framework_request)
else
redirect_to framework_request.energy_category? ? edit_framework_request_energy_bill_path(framework_request) : edit_framework_request_documents_path(framework_request)
end
else
redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
end
else
render :edit
end
end

private

def form
@form ||= FrameworkRequests::ContractStartDateForm.new(all_form_params)
end

def form_params
%i[contract_start_date_known contract_start_date]
end

def all_form_params
super
.except("contract_start_date(3i)", "contract_start_date(2i)", "contract_start_date(1i)")
.merge(contract_start_date: date_param(:framework_support_form, :contract_start_date).compact_blank)
end

def create_redirect_path
if framework_request.multischool_with_multiple_selections?
same_supplier_framework_requests_path(framework_support_form: form.common)
else
procurement_amount_framework_requests_path(framework_support_form: form.common)
end
end

def back_url
@back_url = contract_length_framework_requests_path(ramework_support_form: @form.common)
end

def edit_back_url
@back_url =
if flow.unfinished?
edit_framework_request_contract_length_path(framework_support_form: form.common)
else
framework_request_path(form.framework_request)
end
end
end
end
Loading

0 comments on commit 81bd014

Please sign in to comment.