mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Use ActiveJob to send cfp update mails
This commit is contained in:
parent
82e356dde0
commit
a698ce44fe
3 changed files with 19 additions and 8 deletions
|
|
@ -14,8 +14,10 @@ module Admin
|
|||
|
||||
def create
|
||||
@cfp = @program.build_cfp(cfp_params)
|
||||
send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update?
|
||||
|
||||
if @cfp.save
|
||||
ConferenceCfpUpdateMailJob.perform_later(@conference) if send_mail_on_cfp_dates_updates
|
||||
redirect_to admin_conference_program_cfp_path,
|
||||
notice: 'Call for papers successfully created.'
|
||||
else
|
||||
|
|
@ -31,7 +33,7 @@ module Admin
|
|||
send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update?
|
||||
|
||||
if @cfp.update_attributes(cfp_params)
|
||||
Mailbot.send_on_cfp_dates_updates(@conference).deliver_later if send_mail_on_cfp_dates_updates
|
||||
ConferenceCfpUpdateMailJob.perform_later(@conference) if send_mail_on_cfp_dates_updates
|
||||
redirect_to admin_conference_program_cfp_path(@conference.short_title),
|
||||
notice: 'Call for papers successfully updated.'
|
||||
else
|
||||
|
|
|
|||
9
app/jobs/conference_cfp_update_mail_job.rb
Normal file
9
app/jobs/conference_cfp_update_mail_job.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class ConferenceCfpUpdateMailJob < ActiveJob::Base
|
||||
queue_as :default
|
||||
|
||||
def perform(conference)
|
||||
conference.subscriptions.each do |subscription|
|
||||
Mailbot.conference_cfp_update_mail(conference, subscription.user).deliver_now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -71,13 +71,13 @@ class Mailbot < ActionMailer::Base
|
|||
conference.email_settings.program_schedule_public_body))
|
||||
end
|
||||
|
||||
def send_on_cfp_dates_updates(conference)
|
||||
User.joins(:subscriptions).merge(conference.subscriptions).each do |user|
|
||||
build_email(conference,
|
||||
user.email,
|
||||
conference.email_settings.cfp_dates_updated_subject,
|
||||
conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.cfp_dates_updated_body))
|
||||
end
|
||||
def conference_cfp_update_mail(conference, user)
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.cfp_dates_updated_subject,
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.cfp_dates_updated_body))
|
||||
end
|
||||
|
||||
def send_notification_email_for_comment(comment)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue