Commit 3aaf67b1 authored by Jiri Strojil's avatar Jiri Strojil
Browse files

Delivering of emails done

parent 392a1931
......@@ -26,5 +26,4 @@ module SemesterProcessVolunteerHelper
@semester_process_volunteer.commited_by = nil
@semester_process_volunteer.commited_at = nil
end
end
......@@ -37,4 +37,10 @@ class VolunteerMailer < ApplicationMailer
reminder_mailing_volunteer.update(email_sent: true)
mail(to: @volunteer.contact.primary_email, subject: @subject)
end
def half_year_process_email(semester_process_mail)
@volunteer = semester_process_mail.volunteer
@subject, @body = semester_process_mail.process_template.values_at(:subject, :body)
mail(to: @volunteer.contact.primary_email, subject: @subject)
end
end
......@@ -2,6 +2,8 @@ class SemesterProcessMail < ApplicationRecord
belongs_to :semester_process_volunteer
belongs_to :sent_by, class_name: 'User', inverse_of: 'semester_process_mails'
after_create :send_email
enum kind: { mail: 0, reminder: 1 }
scope :mail, -> { where(kind: 'mail') }
......@@ -75,4 +77,10 @@ class SemesterProcessMail < ApplicationRecord
''
end
private
def send_email
VolunteerMailer.half_year_process_email(self).deliver
self.update(sent_at: Time.zone.now)
end
end
== "#{@subject} \r\n\r\n"
== "#{markdown_plain_text(@body)} \r\n\r\n"
......@@ -100,6 +100,7 @@ Rails.application.routes.draw do
resources :semester_process_volunteers do
get :review_semester, on: :member
patch :submit_review, on: :member
get :email_preview, on: :member
end
resources :semester_processes, except: [:destroy]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment