e_paper/app/controllers/admin/subscribers_controller.rb

31 lines
772 B
Ruby
Raw Normal View History

2017-07-05 09:16:55 +00:00
class Admin::SubscribersController < OrbitAdminController
def build_email(subscriber)
@topic = Topic.find params[:id]
if subscriber.email_sent
if subscriber.email.nil?
email = Email.new
email.save
end
is_sent = subscriber.email.is_sent
is_sent = !params[:resend_mail].eql?("true") if !params[:resend_mail].blank?
subscriber.email.update_attributes(
:mail_to=>subscriber.email,
:mail_sentdate=>subscriber.email_sentdate,
:mail_subject=>@topic.episode,
:template=>"e_papers/email",
:template_date=>{
"host" => request.host_with_port,
"title" => @topic.episode,
"url" => page_for_topic(subscriber)
},
:is_sent=>is_sent
)
else
subscriber.email.destroy if !subscriber.email.nil?
end
end
end