Commit d8e450dd authored by Jiri Strojil's avatar Jiri Strojil
Browse files

Resolved conflict

parents 4280ae83 79b44ab7
Pipeline #30186 failed with stage
in 27 minutes and 52 seconds
......@@ -41,7 +41,7 @@ class SemesterProcessesController < ApplicationController
@semester_process.build_volunteers_hours_feedbacks_and_mails
if @semester_process.save
redirect_to semester_process_volunteers_path, notice: 'Semester process was successfully created.'
redirect_to semester_process_volunteers_path, notice: 'Semester process was successfully created and emails delivered.'
else
render :new
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
......@@ -34,8 +34,8 @@ class EmailTemplate < ApplicationRecord
trial: ReminderMailing::TEMPLATE_VARNAMES,
half_year: ReminderMailing::TEMPLATE_VARNAMES,
termination: ReminderMailing::TEMPLATE_VARNAMES,
half_year_process_email: ReminderMailing::TEMPLATE_VARNAMES + [:Semester],
half_year_process_overdue: ReminderMailing::TEMPLATE_VARNAMES + [:Semester]
half_year_process_email: SemesterProcessMail.template_varnames[:mail],
half_year_process_overdue: SemesterProcessMail.template_varnames[:reminder]
}
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') }
......@@ -10,10 +12,20 @@ class SemesterProcessMail < ApplicationRecord
delegate :volunteer, to: :semester_process_volunteer
delegate :semester_process, to: :semester_process_volunteer
TEMPLATE_VARNAMES = [
:Anrede,
:Name,
:Einsatz,
:FeedbackLink,
:EmailAbsender,
:Semester
].freeze
def self.template_varnames
{
mail: EmailTemplate::template_varnames[:half_year_process_email],
reminder: EmailTemplate::template_varnames[:half_year_process_overdue]
mail: TEMPLATE_VARNAMES,
reminder: TEMPLATE_VARNAMES
}
end
......@@ -48,11 +60,6 @@ class SemesterProcessMail < ApplicationRecord
"#{ I18n.l(semester_process.semester.begin)} - #{I18n.l(semester_process.semester.end)}"
end
def einsatz_start
#I18n.l(reminder_mailable.period_start) if reminder_mailable.period_start
''
end
def einsatz
''
end
......@@ -72,7 +79,18 @@ class SemesterProcessMail < ApplicationRecord
end
def feedback_url(options = {})
''
action = :review_semester
path = semester_process_volunteer
Rails.application.routes.url_helpers.polymorphic_url(
path,
ActionMailer::Base.default_url_options.merge(action: action)
)
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"
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