CSC/ECE 517 Fall 2019 - E1940. Improving email notification
E1940 Improving e-mail notification
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
- Function to identify the reviewers and send mails.
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
app/helpers/mailer_helper.rb
- Helper function to mail reviewers
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
app/mailers/mailer.rb
- Mailer function to send the mail.
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
app/views/mailer/notify_reviewer_for_new_submission.erb
- Email template for the mail
<!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>
Issue3 - Adding relevant links to reminder emails.
Team Member Details
Team members :
- Adarsh Trivedi (atrived)
- Dheeraj Makam (drmakam)
- Prachi Sheoran (psheora)