Skip to content

Commit

Permalink
Merge pull request #86 from bmic-development/jl-finished-statuses
Browse files Browse the repository at this point in the history
Jl finished statuses
  • Loading branch information
Stuart-Johnson committed Feb 15, 2017
2 parents 79f8788 + f01d9d6 commit 9460289
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/controllers/service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def add_service
li.update_attribute(:sub_service_request_id, ssr.id)
if @service_request.status == 'first_draft'
ssr.update_attribute(:status, 'first_draft')
elsif ssr.status.nil? || (ssr.can_be_edited? && ssr_has_changed?(@service_request, ssr) && (ssr.status != 'complete'))
elsif ssr.status.nil? || (ssr.can_be_edited? && ssr_has_changed?(@service_request, ssr))
previous_status = ssr.status
ssr.update_attribute(:status, 'draft')
end
Expand Down Expand Up @@ -512,7 +512,7 @@ def authorize_protocol_edit_request
def find_or_create_sub_service_request(line_item, service_request)
organization = line_item.service.process_ssrs_organization
service_request.sub_service_requests.each do |ssr|
if (ssr.organization == organization) && (ssr.status != 'complete')
if (ssr.organization == organization) && !ssr.is_complete?
return ssr
end
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 @@ -529,8 +529,8 @@ def audit_report( identity, start_date=self.previous_submitted_at.utc, end_date=
end

def cart_sub_service_requests
active = self.sub_service_requests.where.not(status: 'complete')
complete = self.sub_service_requests.where(status: 'complete')
active = self.sub_service_requests.select{ |ssr| !ssr.is_complete? }
complete = self.sub_service_requests.select{ |ssr| ssr.is_complete? }

{ active: active, complete: complete }
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/sub_service_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def can_be_edited?
end

def is_complete?
return status == 'complete'
return FINISHED_STATUSES.include?(status)
end

def find_editable_id(id)
Expand Down
2 changes: 2 additions & 0 deletions config/application.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ development:
editable_statuses: { 14: ['first_draft', 'draft', 'submitted', nil, 'get_a_cost_estimate', 'awaiting_pi_approval', 'complete'],
48: ['draft', 'submitted', 'complete'] }
updatable_statuses: [ 'first_draft', 'draft', 'get_a_cost_estimate', 'awaiting_pi_approval']
finished_statuses: ['complete', 'withdrawn']
navbar_links: { sparc_request: ['SPARCRequest', 'http://localhost:3000/'],
sparc_dashboard: ['SPARCDashboard', 'http://localhost:3000/dashboard'],
sparc_fulfillment: ['SPARCFulfillment', 'https://cwf-d.obis.musc.edu/identities/sign_in'],
Expand Down Expand Up @@ -114,6 +115,7 @@ test:
editable_statuses: { 14: ['first_draft', 'draft', 'submitted', nil, 'get_a_cost_estimate', 'awaiting_pi_approval'],
48: ['draft', 'submitted'] }
updatable_statuses: [ 'first_draft', 'draft', 'get_a_cost_estimate', 'awaiting_pi_approval']
finished_statuses: ['complete', 'withdrawn']
navbar_links: { sparc_request: ['SPARCRequest', 'http://localhost:3000/'],
sparc_dashboard: ['SPARCDashboard', 'http://localhost:3000/dashboard'],
sparc_fulfillment: ['SPARCFulfillment', 'https://cwf-d.obis.musc.edu/identities/sign_in'],
Expand Down
1 change: 1 addition & 0 deletions config/initializers/01_obis_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
NO_REPLY_FROM = application_config['no_reply_from']
EDITABLE_STATUSES = application_config['editable_statuses'] || {}
UPDATABLE_STATUSES = application_config['updatable_statuses'] || []
FINISHED_STATUSES = application_config['finished_statuses'] || []
REMOTE_SERVICE_NOTIFIER_PROTOCOL = application_config['remote_service_notifier_protocol']
REMOTE_SERVICE_NOTIFIER_HOST = application_config['remote_service_notifier_host']
REMOTE_SERVICE_NOTIFIER_PATH = application_config['remote_service_notifier_path']
Expand Down

0 comments on commit 9460289

Please sign in to comment.