CSC/ECE 517 Fall 2019 - E1940. Improving email notification: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 21: | Line 21: | ||
===Issue 1 - New user email=== | ===Issue 1 - New user email=== | ||
'''app/models/assignment_participant.rb''' | |||
* Call method to send mail after user imported successfully. | |||
<pre> | |||
password = user.reset_password | |||
MailerHelper.send_mail_to_user(user, "Your Expertiza account has been created.", "user_welcome", password).deliver | |||
</pre> | |||
===Issue2 - No submission email to reviewer after deadline=== | ===Issue2 - No submission email to reviewer after deadline=== | ||
*'''Before fixing this issue, we had to write the logic to send emails to reviewers on submissions.''' | |||
<br> | |||
'''app/controllers/submitted_content_controller.rb''' | |||
*Added the logic to check for last review date to the function '''submit_hyperlink''' | |||
<pre> | |||
# get current date and time | |||
cur_date = Time.now | |||
# get the last due date for the review | |||
max_due_date = DueDate.where(parent_id: @participant.assignment.id,deadline_type_id: 2).maximum("due_at") | |||
# send mail only if the last due date has not passed | |||
if cur_date <= max_due_date | |||
email_submission_reviewers(@participant) | |||
end | |||
</pre> | |||
<pre> | |||
def email_submission_reviewers(participant) | |||
if participant.reviewers.length != 0 | |||
participant.reviewers.each do |reviewer| | |||
rev_res_map = ReviewResponseMap.where(['reviewer_id = ? and reviewee_id = ?', reviewer.id, participant.team.id]).first | |||
all_responses = Response.where(:map_id => rev_res_map.id).order("updated_at DESC").first | |||
user = User.find(reviewer.user_id) | |||
if user.email_on_submission? | |||
MailerHelper.submission_mail_to_reviewr(user, | |||
"New submission available to review.", | |||
"update").deliver | |||
end | |||
end | |||
end | |||
end | |||
</pre> | |||
<pre> | |||
def self.submission_mail_to_reviewr(user, subject, mail_partial) | |||
Mailer.notify_reviewer_for_new_submission ({ | |||
to: user.email, | |||
subject: subject, | |||
body: { | |||
user: user, | |||
#first_name: ApplicationHelper.get_user_first_name(user), | |||
message: "", | |||
partial_name: mail_partial | |||
} | |||
}) | |||
end | |||
</pre> | |||
<pre> | |||
def notify_reviewer_for_new_submission(defn) | |||
@partial_name = defn[:body][:partial_name] | |||
@user = defn[:body][:user] | |||
#@first_name = defn[:body][:first_name] | |||
@message = defn[:body][:message] | |||
mail(subject: defn[:subject], | |||
to: defn[:to]) | |||
end | |||
</pre> | |||
<pre> | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> | |||
</head> | |||
<body> | |||
<%= render :partial => 'mailer/partials/'+@partial_name+'_html' %> | |||
<hr> | |||
</body> | |||
</html> | |||
</pre> | |||
===Issue3 - Adding relevant links to reminder emails.=== | ===Issue3 - Adding relevant links to reminder emails.=== |
Revision as of 23:00, 28 October 2019
E1940 Improving e-mail notification
Team members :
- Adarsh Trivedi (atrived)
- Dheeraj
- Prachi
Brief Introduction
- E1940 Improving e-mail notification.
- The forked git repository for this project can be found [1]
Problem Statement
The following tasks were accomplished in this project:
- Issue1: Send new account welcome email to user, when imported from CSV through assignment page.
- Issue2: Don't send email to reviewers for a new submission after review deadline has passed.
- Issue3: Adding relevant links to reminder emails.
Issue 1 - New user email
app/models/assignment_participant.rb
- Call method to send mail after user imported successfully.
password = user.reset_password MailerHelper.send_mail_to_user(user, "Your Expertiza account has been created.", "user_welcome", password).deliver
Issue2 - No submission email to reviewer after deadline
- Before fixing this issue, we had to write the logic to send emails to reviewers on submissions.
app/controllers/submitted_content_controller.rb
- Added the logic to check for last review date to the function submit_hyperlink
# get current date and time cur_date = Time.now # get the last due date for the review max_due_date = DueDate.where(parent_id: @participant.assignment.id,deadline_type_id: 2).maximum("due_at") # send mail only if the last due date has not passed if cur_date <= max_due_date email_submission_reviewers(@participant) end
def email_submission_reviewers(participant) if participant.reviewers.length != 0 participant.reviewers.each do |reviewer| rev_res_map = ReviewResponseMap.where(['reviewer_id = ? and reviewee_id = ?', reviewer.id, participant.team.id]).first all_responses = Response.where(:map_id => rev_res_map.id).order("updated_at DESC").first user = User.find(reviewer.user_id) if user.email_on_submission? MailerHelper.submission_mail_to_reviewr(user, "New submission available to review.", "update").deliver end end end end
def self.submission_mail_to_reviewr(user, subject, mail_partial) Mailer.notify_reviewer_for_new_submission ({ to: user.email, subject: subject, body: { user: user, #first_name: ApplicationHelper.get_user_first_name(user), message: "", partial_name: mail_partial } }) end
def notify_reviewer_for_new_submission(defn) @partial_name = defn[:body][:partial_name] @user = defn[:body][:user] #@first_name = defn[:body][:first_name] @message = defn[:body][:message] mail(subject: defn[:subject], to: defn[:to]) end
<!DOCTYPE html> <html> <head> <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> </head> <body> <%= render :partial => 'mailer/partials/'+@partial_name+'_html' %> <hr> </body> </html>