Skip to content

Commit

Permalink
Adds "7 Days" warning to email sent to core committee to request revi…
Browse files Browse the repository at this point in the history
…ew (#499)

* Adds "7 Days" warning to email sent to core committee to request review

* "7 Days" warning to initial email to special committee review request

* putting back the committee member review request stuff
  • Loading branch information
Banu Kutlu authored Jun 6, 2022
1 parent 9e046c1 commit b4202f2
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/mailers/workflow_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def committee_member_review_request(submission, committee_member)
@committee_member.update approval_started_at: DateTime.now if @committee_member.approval_started_at.blank?
@committee_member.update_last_reminder_at DateTime.now

@core_member_note = @committee_member.core_committee_member? ? "You have seven days to complete your review." : ""

mail to: @committee_member.email,
from: current_partner.email_address,
subject: "#{current_partner.name} #{submission.degree_type} Review Request"
Expand All @@ -154,6 +156,8 @@ def special_committee_review_request(submission, committee_member)
@author = submission.author
@review_url = "#{EtdUrls.new.workflow}/special_committee/#{@token}"

@seven_day_note = @committee_member.approval_started_at.blank? ? "You have seven days to complete your review." : ""

@committee_member.update approval_started_at: DateTime.now if @committee_member.approval_started_at.blank?
@committee_member.update_last_reminder_at DateTime.now

Expand Down
4 changes: 4 additions & 0 deletions app/models/committee_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def name=(new_name)
super(new_name.strip)
end

def core_committee_member?
!(is_program_head || (self == submission.advisor && current_partner.graduate?))
end

private

def one_head_of_program_check
Expand Down
3 changes: 1 addition & 2 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ def head_of_program_is_approving?
def committee_review_requests_init
seen_access_ids = []
committee_members.each do |committee_member|
next if committee_member.is_program_head ||
(committee_member == committee_member.submission.advisor && current_partner.graduate?)
next unless committee_member.core_committee_member?

committee_member.update! approval_started_at: DateTime.now
next if seen_access_ids.include?(committee_member.access_id) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
title: @submission.title,
degree_type: @submission.degree_type,
review_url: @review_url,
committee_member_name: @committee_member.name) %>
committee_member_name: @committee_member.name,
core_member_note: @core_member_note) %>
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
degree_type: @submission.degree_type,
token: @token,
review_url: @review_url,
committee_member_name: @committee_member.name) %>
committee_member_name: @committee_member.name,
seven_day_note: @seven_day_note) %>
2 changes: 2 additions & 0 deletions config/locales/partners/en/graduate/graduate.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ en:
listed as a committee member.
Please login to %{review_url} and complete this request.
If you are serving on this committee in multiple roles, you will only need to submit your review once.
%{core_member_note}
If you have any further questions please contact [email protected].
Sincerely,
The Graduate School
Expand All @@ -132,6 +133,7 @@ en:
In order to proceed and provide input on their work, please follow this link:
%{review_url}
or you can copy and paste this into your browser.
%{seven_day_note}
If you have any further questions please contact [email protected].
Sincerely,
The Graduate School of The Pennsylvania State University
Expand Down
2 changes: 1 addition & 1 deletion config/locales/partners/en/honors/honors.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ en:
digitally sign a proposed work for which you have been listed as a committee member.
In order to proceed and provide input on their work, please follow this link:
%{review_url}
or you can copy and paste this into your browser.
or you can copy and paste this into your browser. %{seven_day_note}
Sincerely,
The Schreyer Honors College
Expand Down
2 changes: 1 addition & 1 deletion config/locales/partners/en/milsch/milsch.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ en:
digitally sign a proposed work for which you have been listed as a committee member.
In order to proceed and provide input on their work, please follow this link:
%{review_url}
or you can copy and paste this into your browser.
or you can copy and paste this into your browser. %{seven_day_note}
Sincerely,
The Millennium Scholars Program
Expand Down
2 changes: 1 addition & 1 deletion config/locales/partners/en/sset/sset.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ en:
digitally sign a proposed work for which you have been listed as a committee member.
In order to proceed and provide input on their work, please follow this link:
%{review_url}
or you can copy and paste this into your browser.
or you can copy and paste this into your browser. %{seven_day_note}
Sincerely,
The School of Science, Engineering, and Technology
Expand Down
27 changes: 27 additions & 0 deletions spec/mailers/previews/workflow_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,31 @@ def seventh_day_to_author
submission = Submission.where(status: 'waiting for committee review').sample
WorkflowMailer.seventh_day_to_author(submission)
end

def committee_member_review_request_to_core_members
submission = Submission.where(status: 'waiting for committee review').sample
committee_member = submission.committee_members.select(&:core_committee_member?).first
WorkflowMailer.send_committee_review_requests(submission, committee_member)
end

def committee_member_review_request_to_other_members
submission = Submission.where(status: 'waiting for committee review').sample
committee_member = submission.committee_members.reject(&:core_committee_member?).first
WorkflowMailer.send_committee_review_requests(submission, committee_member)
end

def special_committee_review_request_initial
submission = Submission.where(status: 'waiting for committee review').first
committee_member = submission.committee_members.first
committee_member.approval_started_at = nil
submission.save

WorkflowMailer.special_committee_review_request(submission, committee_member)
end

def special_committee_review_request_reminder
submission = Submission.where(status: 'waiting for committee review').first
committee_member = submission.committee_members.first
WorkflowMailer.special_committee_review_request(submission, committee_member)
end
end
29 changes: 29 additions & 0 deletions spec/mailers/workflow_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,19 @@
email.deliver
expect(committee_member.approval_started_at.to_date).to eq timestamp.to_date
end

it "has the seven day warning note for core committee members" do
expect(email.body).to match(/seven days/)
end

context "non-core committee members" do
let(:cm_role) { FactoryBot.create :committee_role, is_program_head: true }
let(:committee_member) { FactoryBot.create :committee_member, committee_role: cm_role, submission: submission }

it "does not have the seven day note for other committee members" do
expect(email.body).not_to match(/seven days/)
end
end
end

describe '#special_committee_review_reminder' do
Expand Down Expand Up @@ -667,6 +680,22 @@
email.deliver
expect(committee_member.approval_started_at.to_date).to eq timestamp.to_date
end

context "initial request" do
it "has the seven day warning note" do
expect(email.body).to match(/seven days/)
end
end

context "reminder email" do
it "does not have the seven day note for other committee members" do
timestamp = (DateTime.now - 1.day)
committee_member.update approval_started_at: timestamp
committee_member.reload
email.deliver
expect(email.body).not_to match(/seven days/)
end
end
end

context "when committee member token doesn't exist" do
Expand Down

0 comments on commit b4202f2

Please sign in to comment.