diff --git a/app/controllers/admin/e_paper_criterias_controller.rb b/app/controllers/admin/e_paper_criterias_controller.rb index 55480e1..c7ec817 100644 --- a/app/controllers/admin/e_paper_criterias_controller.rb +++ b/app/controllers/admin/e_paper_criterias_controller.rb @@ -60,7 +60,13 @@ def initialize # rake = Rake::Task['epaper:send_email'].invoke([params[:id], request.host_with_port]) paper = PaperCriteria.find(params[:id]) rescue nil if !paper.nil? && paper.invalid_emails.blank? - render :json => {"success" => true}.to_json + email_sentdate = paper.get_email_sentdate + if paper.get_email_sentdate + msg = I18n.t('e_paper.newsletter_will_be_sent', {time: email_sentdate.strftime("%Y-%m-%d %H:%M")}) + else + msg = I18n.t('e_paper.newsletter_sent') + end + render :json => {"success" => true, "msg": msg}.to_json else invalid_email_list = paper.invalid_emails rescue 'can not find paper' render :json => {"success" => false,"invalid_emails"=>invalid_email_list}.to_json diff --git a/app/models/paper_criteria.rb b/app/models/paper_criteria.rb index 283f131..b8fd8c4 100644 --- a/app/models/paper_criteria.rb +++ b/app/models/paper_criteria.rb @@ -16,6 +16,7 @@ class PaperCriteria field :other_emails field :invalid_emails, type: Array, :default => [] field :send_failed_emails, type: Array, :default => [] + field :email_sentdate, :type => DateTime mount_uploader :image, ImageUploader @@ -32,5 +33,13 @@ class PaperCriteria return [] end end + + def get_email_sentdate + _email_sentdate = self.email_sentdate + if _email_sentdate && _email_sentdate < DateTime.now + _email_sentdate = nil + end + _email_sentdate + end end \ No newline at end of file diff --git a/app/views/admin/e_paper_criterias/_form.html.erb b/app/views/admin/e_paper_criterias/_form.html.erb index 42ca732..00c01fe 100644 --- a/app/views/admin/e_paper_criterias/_form.html.erb +++ b/app/views/admin/e_paper_criterias/_form.html.erb @@ -96,6 +96,14 @@