-
Notifications
You must be signed in to change notification settings - Fork 26
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 - ServiceRequestController#remove_service #1030
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
85b7385
refactor remove_service [#149644637]
34daa7d
Merge remote-tracking branch 'origin/kg-jm-authorize-identity-bug' in…
9b10f63
fixes to make remove_service work [#149644637]
bfd46cf
adding just-in-case check, specs [#149644637]
86b7c48
Merge branch 'v3.0.0' into kg-remove_service_bug
8803903
fix remove service js [#149644637]
9ad40e6
Merge branch 'v3.0.0' into kg-remove_service_bug
a4bf021
add check for service [#149644637]
6538a21
merge conflicts
62e9fe5
fix bug [#149644637]
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,62 +198,35 @@ def add_service | |
@duplicate_service = true | ||
else | ||
add_service.generate_new_service_request | ||
@line_items_count = @sub_service_request ? @sub_service_request.line_items.count : @service_request.line_items.count | ||
@line_items_count = (@sub_service_request || @service_request).line_items.count | ||
@sub_service_requests = @service_request.cart_sub_service_requests | ||
end | ||
end | ||
|
||
def remove_service | ||
line_item = @service_request.line_items.find( params[:line_item_id] ) | ||
line_items = @sub_service_request ? @sub_service_request.line_items : @service_request.line_items | ||
service = line_item.service | ||
ssr = line_item.sub_service_request | ||
|
||
line_item_service_ids = @service_request.line_items.map(&:service_id) | ||
|
||
# look at related services and set them to optional | ||
# TODO POTENTIAL ISSUE: what if another service has the same related service | ||
service.related_services.each do |rs| | ||
if line_item_service_ids.include? rs.id | ||
@service_request.line_items.find_by_service_id(rs.id).update_attribute(:optional, true) | ||
end | ||
end | ||
line_item = @service_request.line_items.find(params[:line_item_id]) | ||
ssr = line_item.sub_service_request | ||
|
||
line_items.where(service_id: service.id).each do |li| | ||
if li.status != 'complete' | ||
if ssr.can_be_edited? && ssr.status != 'first_draft' | ||
ssr.update_attribute(:status, 'draft') | ||
end | ||
li.destroy | ||
end | ||
end | ||
if ssr.can_be_edited? | ||
ssr.line_items.where(service: line_item.service.related_services).update_all(optional: true) | ||
|
||
line_items.reload | ||
line_item.destroy | ||
|
||
@service_request.reload | ||
@page = previous_page | ||
|
||
# Have the protocol clean up the arms | ||
@service_request.protocol.arm_cleanup if @service_request.protocol | ||
|
||
# clean up sub_service_requests | ||
@service_request.reload | ||
@service_request.previous_submitted_at = @service_request.submitted_at | ||
@protocol = @service_request.protocol | ||
|
||
#notify service providers and admin of a destroyed ssr upon deletion of ssr | ||
if ssr.line_items.empty? | ||
notifier_logic = NotifierLogic.new(@service_request, nil, current_user) | ||
notifier_logic.ssr_deletion_emails(ssr, ssr_destroyed: true, request_amendment: false) | ||
ssr.destroy | ||
if ssr.line_items.any? | ||
ssr.update_attribute(:status, 'draft') unless ssr.status == 'first_draft' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kyle-glick Get with me when you're back in town about lines 215-216. This impacts how emails are sent out. I'll explain further in person :) |
||
else | ||
NotifierLogic.new(@service_request, nil, current_user).ssr_deletion_emails(ssr, ssr_destroyed: true, request_amendment: false) | ||
ssr.destroy | ||
end | ||
end | ||
|
||
@service_request.reload | ||
@line_items_count = @sub_service_request ? @sub_service_request.line_items.count : @service_request.line_items.count | ||
|
||
@line_items_count = (@sub_service_request || @service_request).line_items.count | ||
@sub_service_requests = @service_request.cart_sub_service_requests | ||
|
||
respond_to do |format| | ||
format.js {render layout: false} | ||
format.js { render layout: false } | ||
end | ||
end | ||
|
||
|
@@ -283,11 +256,6 @@ def approve_changes | |
|
||
private | ||
|
||
def previous_page | ||
# we need for pages other than the catalog | ||
request.referrer.split('/').last | ||
end | ||
|
||
def feedback_params | ||
params.require(:feedback).permit(:email, :message) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged from #1029 to be able to test