Skip to content

Commit

Permalink
Merge pull request #1595 from sparc-request/kg-email_description_and_…
Browse files Browse the repository at this point in the history
…notes

KG - Submission Email Project Description + Notes Table
  • Loading branch information
Stuart-Johnson committed Nov 13, 2018
2 parents 92c12ac + 7a89841 commit 67741fb
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 97 deletions.
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Expand Up @@ -37,6 +37,10 @@ def show_welcome_message(current_user, bootstrap = false)
raw(returning_html)
end

def format_date(date)
date.try(:strftime, '%D') || ""
end

def css_class(organization)
case organization.type
when 'Institution'
Expand Down
8 changes: 0 additions & 8 deletions app/helpers/dashboard/application_helper.rb
Expand Up @@ -20,14 +20,6 @@

module Dashboard::ApplicationHelper

def format_date date
if date.present?
date.strftime('%D')
else
''
end
end

def format_datetime date
if date.present?
date.strftime('%D %I:%M:%S %p')
Expand Down
4 changes: 0 additions & 4 deletions app/helpers/notifier_helper.rb
Expand Up @@ -54,10 +54,6 @@ def display_audit_table(status, audit_report)
end
end

def display_notes?(status, role, notes)
(status == "submitted" || status == "request_amendment") && role == 'none' && !notes.empty?
end

def determine_ssr(last_change, action_name, deleted_ssrs)
ssr_id = last_change.audited_changes['sub_service_request_id']
if last_change.action == 'destroy'
Expand Down
6 changes: 3 additions & 3 deletions app/mailers/notifier.rb
Expand Up @@ -46,7 +46,7 @@ def notify_user(project_role, service_request, ssr, approval, user_current, audi
### END ATTACHMENTS ###

@status = status(admin_delete_ssr, audit_report.present?, individual_ssr, ssr, @service_request)
@notes = []
@notes = @protocol.notes.eager_load(:identity)
@identity = project_role.identity
@role = project_role.role
@full_name = @identity.full_name
Expand Down Expand Up @@ -83,7 +83,7 @@ def notify_admin(submission_email_address, user_current, ssr, audit_report=nil,
### END ATTACHMENTS ###

@ssr_deleted = false
@notes = @protocol.notes
@notes = @protocol.notes.eager_load(:identity)

@status = status(ssr_destroyed, audit_report.present?, individual_ssr, ssr, @service_request)

Expand All @@ -109,7 +109,7 @@ def notify_admin(submission_email_address, user_current, ssr, audit_report=nil,
def notify_service_provider(service_provider, service_request, user_current, ssr, audit_report=nil, ssr_destroyed=false, request_amendment=false, individual_ssr=false)
@protocol = service_request.protocol
@service_request = service_request
@notes = @protocol.notes
@notes = @protocol.notes.eager_load(:identity)

@status = status(ssr_destroyed, request_amendment, individual_ssr, ssr, @service_request)

Expand Down
6 changes: 3 additions & 3 deletions app/views/notifier/_deleted_srid_information.html.haml
Expand Up @@ -29,11 +29,11 @@
%tbody
- @ssrs_to_be_displayed.each do |ssr|
%tr.skinny-black-border
%td.skinny-black-border.center
%td.skinny-black-border.center<
%strike= ssr.display_id
%td.skinny-black-border.center
%td.skinny-black-border.center<
%strike= ssr.org_tree_display
%td.skinny-black-border.center
%td.skinny-black-border.center<
%strike= ssr.service_requester.try(&:full_name) || 'N/A'
%br
%br
43 changes: 43 additions & 0 deletions app/views/notifier/_notes.html.haml
@@ -0,0 +1,43 @@
-# Copyright © 2011-2018 MUSC Foundation for Research Development~
-# All rights reserved.~
-# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:~
-# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.~
-# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following~
-# disclaimer in the documentation and/or other materials provided with the distribution.~
-# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products~
-# derived from this software without specific prior written permission.~
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,~
-# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT~
-# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL~
-# 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.~
%table.table{cellpadding: 3}
%thead
%tr.skinny-black-border
%th.table-header.left{colspan: 5}<
= t('notifier.protocol_notes', type: protocol.type)
%tr.skinny-black-border
%th.table-header.center{colspan: 1}<
= t(:notifier)[:note_user]
%th.table-header.center{colspan: 1}<
= t(:notifier)[:note_date]
%th.table-header.center{colspan: 2}<
= t(:notifier)[:note]
%tbody
- notes.each do |note|
%tr.skinny-black-border
%td.skinny-black-border.center{colspan: 1}<
= note.identity.full_name
%td.skinny-black-border.center{colspan: 1}<
= format_date(note.created_at)
%td.skinny-black-border.center{colspan: 2}<
= note.body
%br
%br
6 changes: 3 additions & 3 deletions app/views/notifier/_notification_email.html.haml
Expand Up @@ -45,8 +45,8 @@
/***** END EMAIL TABLES *****
/***** OTHER EMAIL TIDBITS *****
- if display_notes?(@status, @role, @notes)
%p= t(:notifier)[:notes_present]
- if @notes.any?
= render 'notes', notes: @notes, protocol: @protocol
- if @status != 'ssr_destroyed'
%p= t(:notifier)[:body6]
Expand All @@ -55,4 +55,4 @@
- if @role != 'none'
= render "acknowledgments"
/***** END OTHER EMAIL TIDBITS *****
/***** END OTHER EMAIL TIDBITS *****
10 changes: 6 additions & 4 deletions app/views/notifier/_protocol_information.html.haml
Expand Up @@ -46,9 +46,11 @@
%th.table-header.left= t(:notifier)[:s_name]
%td.skinny-black-border= protocol.sponsor_name
%tr.skinny-black-border
%th.table-header.left<
= protocol.funding_status == 'funded' ? t(:notifier)[:source] : t(:notifier)[:potential_source]
%td.skinny-black-border<
= protocol.display_funding_source_value
%th.table-header.left= protocol.funding_status == 'funded' ? t(:notifier)[:source] : t(:notifier)[:potential_source]
%td.skinny-black-border= protocol.display_funding_source_value
- if protocol.type.capitalize == "Project"
%tr.skinny-black-border
%th.table-header.left= t(:notifier)[:description]
%td.skinny-black-border= protocol.brief_description
%br
%br
2 changes: 1 addition & 1 deletion app/views/notifier/_welcome_for_submitted_status.html.haml
Expand Up @@ -23,7 +23,7 @@
%p= I18n.t('notifier.body1', :full_name => @full_name)
%p.inline
= 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)[:note]
%p= t(:notifier)[:epic_notice]
- else
%p= I18n.t('notifier.body1', :full_name => @full_name)
%p.inline
Expand Down
6 changes: 5 additions & 1 deletion app/views/user_mailer/_protocol_info_table.html.haml
Expand Up @@ -47,4 +47,8 @@
%td{:style => 'border: 1px solid black;'}= @protocol.try(:sponsor_name)
%tr{:style => 'border: 1px solid black;'}
%th{:style => 'border: 1px solid black; width:200px; text-align:left;'}= t(:notifier)[:source]
%td{:style => 'border: 1px solid black;'}= (@protocol.funding_source or @protocol.potential_funding_source or "").capitalize
%td{:style => 'border: 1px solid black;'}= (@protocol.funding_source or @protocol.potential_funding_source or "").capitalize
- if @protocol.type == 'Project'
%tr{:style => 'border: 1px solid black;'}
%th{:style => 'border: 1px solid black; width:200px; text-align:left;'}= t(:notifier)[:description]
%td{:style => 'border: 1px solid black;'}= protocol.brief_description
8 changes: 6 additions & 2 deletions config/locales/en.yml
Expand Up @@ -1378,16 +1378,19 @@ en:
body6: "A list of requested services is attached."
body7: "To approve the charges associated with the selected services please click"
contact_info: "Contact Information"
description: "Brief Description"
deleted_all_services_from_cart: "All services have been deleted in SPARCRequest for the %{protocol_type} below to which you have been granted access."
epic_access: "Epic Access"
epic_notice: "*Note: upon submission, services selected to go to Epic will be sent daily at 4:30pm."
link: "HERE"
name: "User Name"
non_service_provider_message: "%{welcome} in SPARCRequest. You can review or edit this request in %{href}. An email has been sent to the service provider(s) to review and ensure the services are appropriate. <b>Please note the services will not start until this request is submitted through SPARCDashboard.</b>"
service_provider_message: "%{welcome} in SPARCRequest and is awaiting your review in %{href}. Please ensure services chosen are appropriate and can be provided. Communicate any necessary changes to the study team and request they “Submit to Start Services” once ready to proceed."
non_service_provider_submitted_message: "%{welcome} in SPARCRequest. Visit %{href} to view the status or make any updates to your request."
service_provider_submitted_message: "%{welcome} in SPARCRequest and is awaiting your review in %{href}."
note: "*Note: upon submission, services selected to go to Epic will be sent daily at 4:30pm."
notes_present: "*Note(s) are included with this submission."
note: "Note"
note_date: "Date"
note_user: "User"
notice:
approve: "Approve Account"
body1: "Request for new SPARCRequest account submitted and awaiting approval"
Expand All @@ -1403,6 +1406,7 @@ en:
p_id: "Project ID"
p_info: "Project Information"
p_title: "Project Title"
protocol_notes: "%{type} Notes"
proxy: "Proxy Rights:"
request_amendment: "Request Amendment"
request_amendment_intro: "Services have been added or deleted in SPARCRequest and is awaiting your review in"
Expand Down
20 changes: 2 additions & 18 deletions spec/mailers/notifier/deleted_all_services_spec.rb
Expand Up @@ -34,22 +34,6 @@
@institution = create(:institution, name: 'Institution')
@provider = create(:provider, parent: @institution, name: 'Provider')
service_requester = create(:identity)

pricing_setup = {id: '',
display_date: '2016-06-27',
effective_date: '2016-06-28',
federal: '100',
corporate: '100',
other: '100',
member: '100',
college_rate_type: 'federal',
federal_rate_type: 'federal',
foundation_rate_type: 'federal',
industry_rate_type: 'federal',
investigator_rate_type: 'federal',
internal_rate_type: 'federal',
unfunded_rate_type: 'federal',
newly_created: 'true'}
@organization = create(:program_with_pricing_setup, parent: @provider, name: 'Organize')
create(:pricing_setup_without_validations, organization_id: @organization.id)
@service = create(:service, organization: @organization, one_time_fee: true, pricing_map_count: 1)
Expand All @@ -58,6 +42,7 @@
@service_request = create(:service_request_without_validations, protocol: @protocol, submitted_at: Time.now.yesterday, status: 'submitted')
@sub_service_request = create(:sub_service_request_without_validations, service_request: @service_request, protocol: @protocol, organization: @organization, service_requester: service_requester)
@line_item = create(:line_item_without_validations, sub_service_request: @sub_service_request, service_request: @service_request, service: @service)
@note = create(:note_without_validations, identity: identity, notable: @protocol)

@service_request.reload

Expand All @@ -80,8 +65,7 @@
assert_notification_email_tables_for_service_provider_with_all_services_deleted
end

it 'should have a notes reminder message but not a submission reminder' do
does_not_have_a_reminder_note(@mail)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail)
end

Expand Down
18 changes: 6 additions & 12 deletions spec/mailers/notifier/get_a_cost_estimate_spec.rb
Expand Up @@ -56,8 +56,8 @@
assert_notification_email_tables_for_service_provider
end

it 'should NOT have a notes reminder message' do
get_a_cost_estimate_does_not_have_notes(@mail)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail)
end
end

Expand All @@ -70,7 +70,6 @@
@service_request = create(:service_request_without_validations, protocol: @protocol, status: 'get_a_cost_estimate')
@sub_service_request = create(:sub_service_request_without_validations, service_request: @service_request, protocol: @protocol, organization: @organization, service_requester: service_requester)
@submission_email = create(:submission_email, email: 'success@musc.edu', organization: @organization)
@note = create(:note_without_validations, identity: identity, notable: @protocol)
@mail = Notifier.notify_service_provider(@service_provider, @service_request, identity, @sub_service_request)

@service_request.reload
Expand All @@ -90,7 +89,6 @@
@service_request = create(:service_request_without_validations, protocol: @protocol, status: 'get_a_cost_estimate')
@sub_service_request = create(:sub_service_request_without_validations, service_request: @service_request, protocol: @protocol, organization: @organization, service_requester: service_requester)
@submission_email = create(:submission_email, email: 'success@musc.edu', organization: @organization)
@note = create(:note_without_validations, identity: identity, notable: @protocol)
@mail = Notifier.notify_service_provider(@service_provider, @service_request, identity, @sub_service_request)

@service_request.reload
Expand Down Expand Up @@ -127,8 +125,8 @@
assert_notification_email_tables_for_user
end

it 'should NOT have a notes reminder message' do
get_a_cost_estimate_does_not_have_notes(@mail.body.parts.first.body)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail.body.parts.first.body)
end
end

Expand All @@ -141,7 +139,6 @@
@service_request = create(:service_request_without_validations, protocol: @protocol, status: 'get_a_cost_estimate')
@sub_service_request = create(:sub_service_request_without_validations, service_request: @service_request, protocol: @protocol, organization: @organization, service_requester: service_requester)
@approval = create(:approval, service_request: @service_request)
@note = create(:note_without_validations, identity: identity, notable: @protocol)
@mail = Notifier.notify_user(@project_role, @service_request, nil, @approval, identity)

@service_request.reload
Expand All @@ -161,7 +158,6 @@
@service_request = create(:service_request_without_validations, protocol: @protocol, status: 'get_a_cost_estimate')
@sub_service_request = create(:sub_service_request_without_validations, service_request: @service_request, protocol: @protocol, organization: @organization, service_requester: service_requester)
@approval = create(:approval, service_request: @service_request)
@note = create(:note_without_validations, identity: identity, notable: @protocol)
@mail = Notifier.notify_user(@project_role, @service_request, nil, @approval, identity)

@service_request.reload
Expand Down Expand Up @@ -198,8 +194,8 @@
assert_notification_email_tables_for_admin
end

it 'should NOT have a notes reminder message' do
get_a_cost_estimate_does_not_have_notes(@mail.body.parts.first.body)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail.body.parts.first.body)
end
end

Expand All @@ -212,7 +208,6 @@
@service_request = create(:service_request_without_validations, protocol: @protocol, status: 'get_a_cost_estimate')
@sub_service_request = create(:sub_service_request_without_validations, service_request: @service_request, protocol: @protocol, organization: @organization, service_requester: service_requester)
@submission_email = create(:submission_email, email: 'success@musc.edu', organization: @organization)
@note = create(:note_without_validations, identity: identity, notable: @protocol)
@mail = Notifier.notify_admin(@submission_email, identity, @sub_service_request)

@service_request.reload
Expand All @@ -232,7 +227,6 @@
@service_request = create(:service_request_without_validations, protocol: @protocol, status: 'get_a_cost_estimate')
@sub_service_request = create(:sub_service_request_without_validations, service_request: @service_request, protocol: @protocol, organization: @organization, service_requester: service_requester)
@submission_email = create(:submission_email, email: 'success@musc.edu', organization: @organization)
@note = create(:note_without_validations, identity: identity, notable: @protocol)
@mail = Notifier.notify_admin(@submission_email, identity, @sub_service_request)

@service_request.reload
Expand Down
18 changes: 6 additions & 12 deletions spec/mailers/notifier/request_amendment_spec.rb
Expand Up @@ -68,8 +68,7 @@
assert_email_request_amendment_for_deleted(@mail.body.parts.first.body)
end

it 'should not have a reminder note or submission reminder' do
does_not_have_a_reminder_note(@mail)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail)
end
end
Expand Down Expand Up @@ -133,8 +132,7 @@
assert_email_request_amendment_for_added(@mail.body.parts.first.body)
end

it 'should not have a reminder note or submission reminder' do
does_not_have_a_reminder_note(@mail)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail)
end
end
Expand Down Expand Up @@ -197,8 +195,7 @@
assert_email_request_amendment_for_added(@mail.body.parts.first.body, true)
end

it 'should not have a reminder note or submission reminder' do
does_not_have_a_reminder_note(@mail)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail)
end
end
Expand Down Expand Up @@ -294,8 +291,7 @@
assert_email_request_amendment_for_deleted(@mail.body.parts.first.body)
end

it 'should not have a reminder note or submission reminder' do
does_not_have_a_reminder_note(@mail)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail)
end
end
Expand Down Expand Up @@ -358,8 +354,7 @@
assert_email_request_amendment_for_deleted(@mail.body.parts.first.body, true)
end

it 'should not have a reminder note or submission reminder' do
does_not_have_a_reminder_note(@mail)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail)
end
end
Expand Down Expand Up @@ -457,8 +452,7 @@
assert_email_request_amendment_for_deleted(@mail.body.parts.first.body)
end

it 'should have a notes reminder message but not a submission reminder' do
does_have_a_reminder_note(@mail)
it 'should not have a submission reminder' do
does_not_have_a_submission_reminder(@mail)
end
end
Expand Down

0 comments on commit 67741fb

Please sign in to comment.