Skip to content

Commit

Permalink
Merge pull request #798 from sparc-request/jl-step-4-status-bug
Browse files Browse the repository at this point in the history
On the confirmation page, the status of the request should change to …
  • Loading branch information
jleonardw9 committed Dec 9, 2016
2 parents 4f83138 + 5985d2d commit 5afe57d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions app/controllers/service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def confirmation
@sub_service_request.update_attributes(status: 'submitted', nursing_nutrition_approved: false,
lab_approved: false, imaging_approved: false, committee_approved: false) if UPDATABLE_STATUSES.include?(@sub_service_request.status)
else
to_notify = update_service_request_status(@service_request, 'submitted')
to_notify = update_service_request_status(@service_request, 'submitted', true, true)

@service_request.update_arm_minimum_counts
@service_request.sub_service_requests.update_all(nursing_nutrition_approved: false, lab_approved: false, imaging_approved: false, committee_approved: false)
Expand Down Expand Up @@ -614,20 +614,19 @@ def send_epic_notification_for_user_approval(protocol)
Notifier.notify_for_epic_user_approval(protocol).deliver unless QUEUE_EPIC
end

def update_service_request_status(service_request, status, validate=true)
def update_service_request_status(service_request, status, validate=true, submit=false)
requests = []
service_request.sub_service_requests.each do |ssr|
if UPDATABLE_STATUSES.include?(ssr.status)
if UPDATABLE_STATUSES.include?(ssr.status) || !submit
requests << ssr
end
end

if (status == 'submitted')
service_request.previous_submitted_at = service_request.submitted_at
service_request.update_attribute(:submitted_at, Time.now)
requests.each { |ssr| ssr.update_attributes(submitted_at: Time.now) }
end
to_notify = service_request.update_status(status, validate)
to_notify = service_request.update_status(status, validate, submit)

to_notify
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/service_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def additional_detail_services

# Change the status of the service request and all the sub service
# requests to the given status.
def update_status(new_status, use_validation=true)
def update_status(new_status, use_validation=true, submit=false)
to_notify = []

self.assign_attributes(status: new_status)
Expand All @@ -435,7 +435,7 @@ def update_status(new_status, use_validation=true)
changeable = available & editable

if changeable.include?(new_status)
if (ssr.status != new_status) && UPDATABLE_STATUSES.include?(ssr.status)
if (ssr.status != new_status) && (UPDATABLE_STATUSES.include?(ssr.status) || !submit)
ssr.update_attribute(:status, new_status)
to_notify << ssr.id
end
Expand Down

0 comments on commit 5afe57d

Please sign in to comment.