Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KG - Remove "Get a Cost Estimate" Button / Default Status #2278

Merged
merged 9 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 2 additions & 10 deletions app/controllers/service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class ServiceRequestsController < ApplicationController
respond_to :js, :json, :html

before_action :initialize_service_request, except: [:approve_changes]
before_action :validate_step, only: [:navigate, :protocol, :service_details, :service_subsidy, :document_management, :review, :obtain_research_pricing, :confirmation]
before_action :setup_navigation, only: [:navigate, :catalog, :protocol, :service_details, :service_subsidy, :document_management, :review, :obtain_research_pricing, :confirmation]
before_action :validate_step, only: [:navigate, :protocol, :service_details, :service_subsidy, :document_management, :review, :confirmation]
before_action :setup_navigation, only: [:navigate, :catalog, :protocol, :service_details, :service_subsidy, :document_management, :review, :confirmation]
before_action :authorize_identity, except: [:approve_changes, :show]
before_action :authenticate_identity!, except: [:catalog, :add_service, :remove_service]
before_action :find_locked_org_ids, only: [:catalog]
Expand Down Expand Up @@ -107,14 +107,6 @@ def review
end
end

def obtain_research_pricing
@protocol = @service_request.protocol
@service_request.previous_submitted_at = @service_request.submitted_at

NotifierLogic.delay.obtain_research_pricing_logic(@service_request, current_user)
render :confirmation
end

def confirmation
respond_to do |format|
format.js # Nothing needed but rendering a modal
Expand Down
4 changes: 1 addition & 3 deletions app/helpers/notifier_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ def intro_determination(status)
case status
when 'ssr_destroyed'
render "notifier/deleted_all_services_from_cart"
when 'get_a_cost_estimate'
render "notifier/welcome"
when 'submitted'
render "notifier/welcome_for_submitted_status"
render "notifier/welcome"
when 'request_amendment'
render "notifier/request_amendment"
end
Expand Down
14 changes: 0 additions & 14 deletions app/lib/notifier_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def self.confirmation_logic(service_request, current_user, ssrids)
NotifierLogic.new(service_request, current_user, ssrids).update_ssrs_and_send_emails
end

def self.obtain_research_pricing_logic(service_request, current_user)
NotifierLogic.new(service_request, current_user).update_status_and_send_get_a_cost_estimate_email
end

def initialize(service_request, current_user, ssrids=[])
@service_request = service_request
@current_user = current_user
Expand Down Expand Up @@ -56,16 +52,6 @@ def update_ssrs_and_send_emails
send_initial_submission_email
end

def update_status_and_send_get_a_cost_estimate_email
to_notify = @service_request.update_status('get_a_cost_estimate', @current_user)
sub_service_requests = @service_request.sub_service_requests.where(id: to_notify)
if !sub_service_requests.empty? # if nothing is set to notify then we shouldn't send out e-mails
send_user_notifications(request_amendment: false, admin_delete_ssr: false, deleted_ssr: nil)
send_admin_notifications(sub_service_requests, request_amendment: false)
send_service_provider_notifications(sub_service_requests, request_amendment: false)
end
end

def send_ssr_service_provider_notifications(sub_service_request, ssr_destroyed: false, request_amendment: false)
audit_report = request_amendment ? sub_service_request.audit_line_items(@current_user) : nil
sub_service_request.organization.service_providers.where("(`service_providers`.`hold_emails` != 1 OR `service_providers`.`hold_emails` IS NULL)").each do |service_provider|
Expand Down
6 changes: 0 additions & 6 deletions app/mailers/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ def account_status_change identity, approved
mail(:to => email_to, :from => email_from, :subject => subject)
end

def obtain_research_pricing service_provider, service_request

end

def provide_feedback feedback
@feedback = feedback

Expand Down Expand Up @@ -286,8 +282,6 @@ def status(ssr_destroyed, request_amendment, service_request)

def email_title(status, protocol, ssr)
email_status = case status
when 'get_a_cost_estimate'
"Get Cost Estimate"
when 'request_amendment'
"Amendment Submitted"
when 'ssr_destroyed'
Expand Down
9 changes: 5 additions & 4 deletions app/views/notifier/_welcome.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS~
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~
- welcome_text = I18n.t('notifier.welcome_obtain_research_pricing')

- welcome_text = I18n.t('notifier.welcome_submit')

- if @role != 'none'
%p= I18n.t('notifier.body1', :full_name => @full_name)
%p.inline
= raw(I18n.t('notifier.non_service_provider_message', :welcome => welcome_text, :href => link_to( t(:notifier)[:sparc_dashboard],@portal_link), :application_title => t(:mailer)[:application_title], :root_url => Setting.get_value("root_url"), :protocol_type => @protocol.type.downcase))
= raw(I18n.t('notifier.non_service_provider_submitted_message', :welcome => welcome_text, :href => link_to( t(:notifier)[:sparc_dashboard],@portal_link), :application_title => t(:mailer)[:application_title], :root_url => Setting.get_value("root_url"), :protocol_type => @protocol.type.downcase))
%p= t(:notifier)[:epic_notice]
- else
%p= I18n.t('notifier.body1', :full_name => @full_name)
%p.inline
= raw(I18n.t('notifier.service_provider_message', :welcome => welcome_text, :href => link_to( t(:notifier)[:sparc_dashboard],@portal_link), :application_title => t(:mailer)[:application_title], :root_url => Setting.get_value("root_url"), :protocol_type => @protocol.type.downcase))
= raw(I18n.t('notifier.service_provider_submitted_message', :welcome => welcome_text, :href => link_to( t(:notifier)[:sparc_dashboard],@portal_link), :application_title => t(:mailer)[:application_title], :root_url => Setting.get_value("root_url"), :protocol_type => @protocol.type.downcase))
%br
- if @portal_text
%p
%a.link{href: @portal_link}=@portal_text
%br
%br
35 changes: 0 additions & 35 deletions app/views/notifier/_welcome_for_submitted_status.html.haml

This file was deleted.

5 changes: 1 addition & 4 deletions app/views/service_requests/confirmation.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
%h3.mb-0
= t(:proper)[:confirmation][:service_requests_notice]
.alert.alert-success.mb-0.rounded-0
- if action_name == 'obtain_research_pricing'
= t(:proper)[:confirmation][:cost_estimate_warning]
- else
= raw t('proper.confirmation.confirmation_warning', department_name: Setting.get_value('contact_us_department'), phone: Setting.get_value('contact_us_phone'), email: Setting.get_value('contact_us_mail_to'))
= raw t('proper.confirmation.confirmation_warning', department_name: Setting.get_value('contact_us_department'), phone: Setting.get_value('contact_us_phone'), email: Setting.get_value('contact_us_mail_to'))
%table.table.table-bordered.mb-0#request-ssrs-table
%thead.bg-light
%tr
Expand Down
11 changes: 5 additions & 6 deletions app/views/service_requests/navigation/_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
%footer.card.w-100.sticky-bottom.mt-3#serviceRequestFooter
.card-body.py-2
.row
- if ['obtain_research_pricing', 'confirmation'].include?(action_name)
- if action_name == 'confirmation'
.col-3.offset-3
= link_to service_request_path(srid: @service_request.id, format: :xlsx, report_type: 'request_report'), class: 'btn btn-lg btn-block btn-secondary' do
= succeed t(:proper)[:confirmation][:download_request] do
Expand All @@ -38,13 +38,12 @@
= link_to t(:proper)[:navigation][:bottom][:back][:small], @back, class: ['btn btn-lg btn-link d-inline-block d-sm-none px-0', @current_page == 'catalog' ? 'invisible' : '']
- unless @current_page == 'catalog'
.col.text-center
= link_to t('proper.cart.back_to_catalog'), catalog_service_request_path(srid: @service_request.id), class: 'btn btn-lg btn-outline-primary'
- if @service_request.submitted_at.blank? && @service_request.protocol.present?
= link_to catalog_service_request_path(srid: @service_request.id), class: 'btn btn-lg btn-outline-primary' do
= icon('fas', 'book')
= t('proper.cart.back_to_catalog')
- if !@service_request.previously_submitted? && @service_request.protocol.present?
.col.text-center
= save_as_draft_button(@service_request)
- if controller.action_name == 'review'
.col.text-center
= link_to t("proper.navigation.bottom.get_cost_estimate"),obtain_research_pricing_service_request_path(srid: @service_request.id), class: 'btn btn-lg btn-outline-secondary', id: 'getCostEstimate'
.col.text-right
- if action_name == 'review'
= link_to confirmation_service_request_path(srid: @service_request.id), remote: @service_request.previously_submitted?, class: 'btn btn-lg btn-outline-success', id: 'submitRequest' do
Expand Down
5 changes: 2 additions & 3 deletions app/views/service_requests/navigation/_steps.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@

- subsidy = @service_request.eligible_for_subsidy?

- unless ['obtain_research_pricing', 'confirmation'].include?(action_name)
- unless action_name == 'confirmation'
%nav.nav.w-100.mb-1#stepsNav{ class: subsidy ? 'has-subsidy' : '' }
.steps-container.d-flex.w-100{ class: subsidy ? 'even' : '' }
- Step::CONFIG.each do |step, _|
- next if ['obtain_research_pricing', 'confirmation'].include?(step)
- next if !subsidy && step == 'service_subsidy'
- next if step == 'confirmation' || (!subsidy && step == 'service_subsidy')
- config = Step.get(step)
= render 'service_requests/navigation/step_arrow', text: config[:step_text], link: eval("#{step}_service_request_path(#{@service_request.new_record? ? "" : "srid: " + @service_request.id.to_s})"), color: config[:css_class], active: @current_page == step
10 changes: 5 additions & 5 deletions config/application.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# sparc_forms: ['SPARCForms', '127.0.0.1:3000/surveyor/responses']

# ### Statuses ###
# updatable_statuses: ['first_draft', 'draft', 'get_a_cost_estimate', 'awaiting_pi_approval']
# updatable_statuses: ['first_draft', 'draft', 'awaiting_pi_approval']
# finished_statuses: ['complete', 'withdrawn']

# ### Other Generic Settings ###
Expand Down Expand Up @@ -173,7 +173,7 @@
# sparc_forms: ['SPARCForms', '127.0.0.1:3000/surveyor/responses']

# ### Statuses ###
# updatable_statuses: ['first_draft', 'draft', 'get_a_cost_estimate', 'awaiting_pi_approval']
# updatable_statuses: ['first_draft', 'draft', 'awaiting_pi_approval']
# finished_statuses: ['complete', 'withdrawn']

# ### Other Generic Settings ###
Expand Down Expand Up @@ -297,7 +297,7 @@
# sparc_forms: ['SPARCForms', '127.0.0.1:3000/surveyor/responses']

# ### Statuses ###
# updatable_statuses: ['first_draft', 'draft', 'get_a_cost_estimate', 'awaiting_pi_approval']
# updatable_statuses: ['first_draft', 'draft', 'awaiting_pi_approval']
# finished_statuses: ['complete', 'withdrawn']

# ### Other Generic Settings ###
Expand Down Expand Up @@ -421,7 +421,7 @@ development:
sparc_forms: ['SPARCForms', '127.0.0.1:3000/surveyor/responses']

### Statuses ###
updatable_statuses: ['first_draft', 'draft', 'get_a_cost_estimate', 'awaiting_pi_approval']
updatable_statuses: ['first_draft', 'draft', 'awaiting_pi_approval']
finished_statuses: ['complete', 'withdrawn']

### Other Generic Settings ###
Expand Down Expand Up @@ -545,7 +545,7 @@ test:
sparc_forms: ['SPARCForms', '127.0.0.1:3000/surveyor/responses']

### Statuses ###
updatable_statuses: ['first_draft', 'draft', 'get_a_cost_estimate', 'awaiting_pi_approval']
updatable_statuses: ['first_draft', 'draft', 'awaiting_pi_approval']
finished_statuses: ['complete', 'withdrawn']

### Other Generic Settings ###
Expand Down
2 changes: 1 addition & 1 deletion config/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@
},
{
"key": "updatable_statuses",
"value": "[\"first_draft\", \"draft\", \"get_a_cost_estimate\", \"awaiting_pi_approval\"]",
"value": "[\"first_draft\", \"draft\", \"awaiting_pi_approval\"]",
"friendly_name": "Updatable Statuses",
"description": "This defines the statuses that a SubServiceRequest can be updated from. Any other statuses are considered \"un-updatable\".",
"group": "",
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ en:
p_title: "Project Title"
triggered_by: "Current Identity:"
u_info: "User Information"
welcome_obtain_research_pricing: "A request has been made for a budget review (Get Cost Estimate)"
welcome_submit: "A request has been submitted to start services"

# Service Request approve epic rights
Expand Down
8 changes: 1 addition & 7 deletions config/locales/proper.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ en:
ssr_resubmission:
header: "Select Requests to Resubmit"
confirmation_warning: "An email has been sent to each of your Service Providers and they should be contacting you soon.<br>If you have any questions or concerns, please don't hesitate to contact the %{department_name} at %{phone} or <a href='mailto:%{email}'>%{email}</a>"
cost_estimate_warning: " Emails have been submitted on your behalf and we will respond to your request shortly. Should you have any questions regarding your request, please contact the Service Providers listed below."
service_requests_notice: "My Service Requests"
download_request: "Download Request"
to_protocol: "Go to Protocol"
Expand All @@ -142,7 +141,7 @@ en:
header: "My Services"
add_service: "Add to cart"
remove_service: "Remove from cart"
back_to_catalog: "Back to Catalog"
back_to_catalog: "Return to Catalog"
tabs:
active:
header: "Current"
Expand Down Expand Up @@ -212,9 +211,6 @@ en:
xs: "Step 5"
header: "Step 5: Review Your Request"
sub_header: "Review your request and make changes if necessary"
obtain_research_pricing:
header: "Get a Cost Estimate"
sub_header: "You have successfully submitted a request to get a cost estimate"
confirmation:
header: "Submission Confirmation"
sub_header: "Thank you for submitting your request through SPARCRequest"
Expand All @@ -223,14 +219,12 @@ en:
full: "Go Back"
small: "Back"
save_as_draft: "Save as Draft"
get_cost_estimate: "Get a Cost Estimate"
save_and_continue:
full: "Save and Continue"
small: "Continue"
submit: "Submit Request"
saving: "Saving..."
submitting: "Submitting..."
getting_cost: "Getting Cost..."
save_as_draft:
title: "Save as Draft?"
text: "This Protocol will be saved as a draft and no notifications or emails will be sent to service providers.<br><br>Are you sure you want to proceed?"
3 changes: 0 additions & 3 deletions config/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,5 @@ review:
back: "document_management"
forward: "confirmation"

obtain_research_pricing:
css_class: "success"

confirmation:
css_class: "success"
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
get :service_subsidy
get :document_management
get :review
get :obtain_research_pricing
get :confirmation
get :approve_changes
get :system_satisfaction_survey
Expand Down
49 changes: 49 additions & 0 deletions db/migrate/20200402195743_remove_get_a_cost_estimate_default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class RemoveGetACostEstimateDefault < ActiveRecord::Migration[5.2]
def up
ServiceRequest.reset_column_information
SubServiceRequest.reset_column_information

if pv = PermissibleValue.find_by_key('get_a_cost_estimate')
pv.update_attribute(:default, false)
end

if s = Setting.find_by_key('updatable_statuses')
# This should be an array but for some reason on Travis
# it's being treated as the raw string value
if s.value.is_a?(String)
statuses = s.value.gsub("\"get_a_cost_estimate\",", "")
else
statuses = s.value.reject{ |status| status == 'get_a_cost_estimate' }
end
s.update_attribute(:value, statuses)
end

ServiceRequest.eager_load(:sub_service_requests).where(status: 'get_a_cost_estimate').each do |sr|
if sr.previously_submitted?
sr.update_attribute(:status, 'submitted')
sr.update_attribute(:submitted_at, Time.now)

sr.sub_service_requests.select{ |ssr| ssr.status == 'get_a_cost_estimate' }.each do |ssr|
ssr.update_attribute(:status, 'submitted')
ssr.update_attribute(:submitted_at, Time.now)
end
else
sr.update_attribute(:status, 'draft')
sr.sub_service_requests.select{ |ssr| ssr.status == 'get_a_cost_estimate' }.each do |ssr|
ssr.update_attribute(:status, 'draft')
end
end
end
end

def down
if pv = PermissibleValue.find_by_key('get_a_cost_estimate')
pv.update_attribute(:default, true)
end

if s = Setting.find_by_key('updatable_statuses')
statuses = s.value.append('get_a_cost_estimate')
s.update_attribute(:value, statuses)
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_03_11_190154) do
ActiveRecord::Schema.define(version: 2020_04_02_195743) do

create_table "admin_rates", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.bigint "line_item_id"
Expand Down