Skip to content
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

796 format accepted mailers grad #813

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions app/mailers/workflow_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
# frozen_string_literal: true

class WorkflowMailer < ActionMailer::Base
class InvalidPartner < StandardError; end
extend MailerActions

APPROVER_WORKFLOW = "#{EtdUrls.new.workflow}/approver".freeze
AUTHOR_WORKFLOW = "#{EtdUrls.new.workflow}/author".freeze
COMMENCEMENT_URL = I18n.t("#{current_partner.id}.partner.commencement_url")
DEADLINE_URL = I18n.t("#{current_partner.id}.partner.deadline_url")
EXPLORE_SITE = EtdUrls.new.explore.to_s
PAYMENT_PORTAL_URL = I18n.t("#{current_partner.id}.partner.payment_portal_url")
THESIS_GUIDE = I18n.t("#{current_partner.id}.partner.thesis_guide_pdf")

def format_review_received(submission)
@submission = submission
@author = submission.author
@payment_portal_url = PAYMENT_PORTAL_URL

mail to: @author.psu_email_address,
from: current_partner.email_address,
subject: "Your format review has been received"
end

def format_review_accepted(submission)
raise InvalidPartner unless current_partner.sset? || current_partner.honors?
raise InvalidPartner unless current_partner.sset? || current_partner.honors? || current_partner.graduate?

@submission = submission
@author = submission.author
@deadline_url = DEADLINE_URL
@etd_site = AUTHOR_WORKFLOW
@thesis_guide = THESIS_GUIDE

mail to: @author.psu_email_address,
from: current_partner.email_address,
subject: "Your format review has been accepted"
end

def format_review_rejected(submission)
raise InvalidPartner unless current_partner.sset? || current_partner.honors?
raise InvalidPartner unless current_partner.sset? || current_partner.honors? || current_partner.graduate?

@submission = submission
@author = submission.author
@deadline_link = DEADLINE_URL
@etd_site = AUTHOR_WORKFLOW
@thesis_guide = THESIS_GUIDE

mail to: @author.psu_email_address,
from: current_partner.email_address,
Expand All @@ -45,7 +62,9 @@ def final_submission_received(submission)
def final_submission_approved(submission)
@submission = submission
@author = submission.author
@url = EtdUrls.new.explore.to_s
@commencement_url = COMMENCEMENT_URL
@etd_site = AUTHOR_WORKFLOW
@explore_site = EXPLORE_SITE

mail to: @author.psu_email_address,
from: current_partner.email_address,
Expand All @@ -55,7 +74,9 @@ def final_submission_approved(submission)
def final_submission_rejected(submission)
@submission = submission
@author = submission.author
@url = "#{EtdUrls.new.workflow}/author"
@etd_site = AUTHOR_WORKFLOW
@thesis_guide = THESIS_GUIDE
@deadline_url = DEADLINE_URL

mail to: @author.psu_email_address,
from: current_partner.email_address,
Expand All @@ -65,7 +86,7 @@ def final_submission_rejected(submission)
def release_for_publication(submission)
@submission = submission
@author = submission.author
@explore_url = "#{EtdUrls.new.explore}/catalog/#{submission.public_id}"
@explore_url = EXPLORE_SITE

mail to: [@author.psu_email_address, @author.alternate_email_address],
from: current_partner.email_address,
Expand All @@ -75,7 +96,7 @@ def release_for_publication(submission)
def release_for_publication_metadata_only(submission)
@submission = submission
@author = submission.author
@explore_url = "#{EtdUrls.new.explore}/catalog/#{submission.public_id}"
@explore_url = EXPLORE_SITE

mail to: [@author.psu_email_address, @author.alternate_email_address],
from: current_partner.email_address,
Expand Down Expand Up @@ -126,7 +147,7 @@ def committee_member_review_request(submission, committee_member)
@submission = submission
@committee_member = committee_member
@author = submission.author
@review_url = "#{EtdUrls.new.workflow}/approver"
@review_url = APPROVER_WORKFLOW

@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 Expand Up @@ -159,7 +180,7 @@ def committee_member_review_reminder(submission, committee_member)
@submission = submission
@committee_member = committee_member
@author = submission.author
@review_url = "#{EtdUrls.new.workflow}/approver"
@review_url = APPROVER_WORKFLOW

@committee_member.update approval_started_at: DateTime.now if @committee_member.approval_started_at.blank?
@committee_member.update_last_reminder_at DateTime.now
Expand All @@ -170,10 +191,12 @@ def committee_member_review_reminder(submission, committee_member)
end

def nonvoting_approval_reminder(submission, committee_member)
raise InvalidPartner unless current_partner.graduate?

@submission = submission
@committee_member = committee_member
@author = submission.author
@review_url = "#{EtdUrls.new.workflow}/approver"
@review_url = APPROVER_WORKFLOW

mail to: @committee_member.email,
from: current_partner.email_address,
Expand Down Expand Up @@ -230,6 +253,7 @@ def advisor_funding_discrepancy(submission)
def pending_returned_author(submission)
@submission = submission
@author = submission.author
@etd_site = AUTHOR_WORKFLOW

mail to: @author.psu_email_address,
from: current_partner.email_address,
Expand All @@ -254,6 +278,7 @@ def committee_rejected_author(submission)
@submission = submission
@author = submission.author
@review_results = ReviewResultsEmail.new(submission).generate
@etd_site = AUTHOR_WORKFLOW
to = if current_partner.graduate?
[@author.psu_email_address, submission.advisor&.email, submission.chairs&.pluck(:email)].flatten.uniq.compact
else
Expand Down Expand Up @@ -296,7 +321,7 @@ def committee_rejected_committee(submission)
def committee_approved(submission)
@submission = submission
@author = submission.author
@explore_url = EtdUrls.new.explore.to_s
@explore_url = EXPLORE_SITE

mail to: @author.psu_email_address,
cc: [@submission.committee_email_list.uniq, current_partner.email_address].flatten,
Expand Down
4 changes: 2 additions & 2 deletions app/services/format_review_update_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def respond_format_review
UpdateSubmissionService.admin_update_submission(submission, current_remote_user, format_review_params)
submission.update! format_review_approved_at: Time.zone.now
status_giver.collecting_final_submission_files!
WorkflowMailer.format_review_accepted(@submission).deliver if current_partner.sset? || current_partner.honors?
WorkflowMailer.format_review_accepted(@submission).deliver unless current_partner.milsch?
msg = "The submission\'s format review information was successfully approved and returned to the author to collect final submission information."
elsif update_actions.rejected?
UpdateSubmissionService.admin_update_submission(submission, current_remote_user, format_review_params)
submission.update! format_review_rejected_at: Time.zone.now
status_giver.collecting_format_review_files_rejected!
WorkflowMailer.format_review_rejected(@submission).deliver if current_partner.sset? || current_partner.honors?
WorkflowMailer.format_review_rejected(@submission).deliver unless current_partner.milsch?
msg = "The submission\'s format review information was successfully rejected and returned to the author for revision."
end
if update_actions.record_updated?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Dear <%= @submission.author.full_name %>,
partner_name: current_partner.name,
author_name: @author.full_name,
review_results: @review_results,
url: @url,) %>
etd_site: @etd_site) %>
4 changes: 3 additions & 1 deletion app/views/workflow_mailer/final_submission_approved.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ Dear <%= @author.full_name %>,
degree_type: @submission.degree_type,
partner_name: current_partner.name,
author_email: @author.psu_email_address,
url: @url,
etd_site: @etd_site,
explore_site: @explore_site,
commencement_url: @commencement_url,
committee_email_list: @submission.committee_email_list.join(", ") ) %>
4 changes: 3 additions & 1 deletion app/views/workflow_mailer/final_submission_rejected.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ Dear <%= @author.full_name %>,
degree_type: @submission.degree_type,
partner_name: current_partner.name,
author_email: @author.psu_email_address,
url: @url,
etd_site: @etd_site,
thesis_guide: @thesis_guide,
deadline_url: @deadline_url,
committee_email_list: @submission.committee_email_list.join(", ") ) %>
3 changes: 2 additions & 1 deletion app/views/workflow_mailer/format_review_accepted.text.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Dear <%= @author.full_name %>,

<%= t( "#{current_partner.id}.partner.email.format_review_accepted.message", degree_type: @submission.degree_type) %>
<%= t( "#{current_partner.id}.partner.email.format_review_accepted.message", degree_type: @submission.degree_type,
deadline_url: @deadline_url, etd_site: @etd_site, thesis_guide: @thesis_guide) %>
3 changes: 1 addition & 2 deletions app/views/workflow_mailer/format_review_received.text.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Dear <%= @author.full_name %>,

<%= t( "#{current_partner.id}.partner.email.format_review_received.message",
degree_type: @submission.degree_type) %>

degree_type: @submission.degree_type, payment_portal_url: @payment_portal_url) %>
3 changes: 2 additions & 1 deletion app/views/workflow_mailer/format_review_rejected.text.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Dear <%= @author.full_name %>,

<%= t( "#{current_partner.id}.partner.email.format_review_rejected.message", degree_type: @submission.degree_type, url: @url,) %>
<%= t( "#{current_partner.id}.partner.email.format_review_rejected.message",
deadline_url: @deadline_url, etd_site: @etd_site, thesis_guide: @thesis_guide,) %>
3 changes: 2 additions & 1 deletion app/views/workflow_mailer/pending_returned_author.text.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Dear <%= @author.full_name %>,

<%= t( "#{current_partner.id}.partner.email.pending_returned_author.message", degree_type: @submission.degree_type) %>
<%= t( "#{current_partner.id}.partner.email.pending_returned_author.message", degree_type: @submission.degree_type,
etd_site: @etd_site ) %>
Loading