ntue emailer app and bulletin app mail send fix

This commit is contained in:
Spen 2013-07-19 14:40:45 +08:00
parent 17b8207033
commit d56d52828b
16 changed files with 124 additions and 52 deletions

View File

@ -7,6 +7,7 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
def preview_and_approve def preview_and_approve
email_group_data
@bulletin = Bulletin.find params[:bulletin_id] @bulletin = Bulletin.find params[:bulletin_id]
end end
@ -112,7 +113,8 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
:mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}#{bulletin.title}", :mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}#{bulletin.title}",
:mail_to => @group_mail.join(','), :mail_to => @group_mail.join(','),
:mail_content => @mail_content , :mail_content => @mail_content ,
:mail_sentdate => bulletin.email_sentdate, # :mail_sentdate => bulletin.email_sentdate,
:mail_sentdate => DateTime.now,
:create_user_id => bulletin.create_user_id, :create_user_id => bulletin.create_user_id,
:update_user_id => bulletin.create_user_id :update_user_id => bulletin.create_user_id
} }
@ -121,6 +123,8 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
@mail_cron.save @mail_cron.save
MailCron.send_mail_now(@mail_cron.id)
end end
end end

View File

@ -153,12 +153,12 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
respond_to do |format| respond_to do |format|
if @bulletin.save if @bulletin.save
if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected # if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected
send_email_data(@bulletin) # send_email_data(@bulletin)
@bulletin.email_sent = false # @bulletin.email_sent = false
@bulletin.save # @bulletin.save
end # end
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) } format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin } format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
@ -241,12 +241,12 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin.de_pending! @bulletin.de_pending!
end end
if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected # if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected
send_email_data(@bulletin) # send_email_data(@bulletin)
@bulletin.email_sent = false # @bulletin.email_sent = false
@bulletin.save # @bulletin.save
end # end
# if (params[:bulletin][:is_checked] == "false") # if (params[:bulletin][:is_checked] == "false")
# @bulletin.is_rejected = true # @bulletin.is_rejected = true
@ -356,7 +356,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
:mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}#{bulletin.title}", :mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}#{bulletin.title}",
:mail_to => @group_mail.join(','), :mail_to => @group_mail.join(','),
:mail_content => @mail_content , :mail_content => @mail_content ,
:mail_sentdate => bulletin.email_sentdate, # :mail_sentdate => bulletin.email_sentdate,
:mail_sentdate => DateTime.now,
:create_user_id => bulletin.create_user_id, :create_user_id => bulletin.create_user_id,
:update_user_id => bulletin.create_user_id :update_user_id => bulletin.create_user_id
} }
@ -365,6 +366,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@mail_cron.save @mail_cron.save
MailCron.send_mail_now(@mail_cron.id)
end end
end end

View File

@ -221,6 +221,32 @@ class Bulletin
preview_object preview_object
end end
def get_email_group_data(email_group_data)
group_mail = Array.new
self.email_group.each do |egroup|
if email_group_data.include?(egroup) and (egroup == '0' or egroup == '1' or egroup == '2' or egroup == '3')
group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})"
elsif email_group_data.include?(egroup) and egroup == '4'
self.other_mailaddress.split(",").each do |otmail|
group_mail << "#{otmail}(#{email_group_data[egroup]["name"]})"
end
end
end
group_mail.join("<br />").html_safe
end
protected protected

View File

@ -14,6 +14,12 @@
<%# preview_block_ad_images_helper(bulletin).each do |ad_image| -%> <%# preview_block_ad_images_helper(bulletin).each do |ad_image| -%>
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || bulletin.context || " ")) %> <%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || bulletin.context || " ")) %>
<%# end -%> <%# end -%>
<% if !@bulletin.email_group.blank? %>
<%= label_tag 'group_mail' %>
<%= @bulletin.get_email_group_data(@email_group_data) %>
<% end %>
</p> </p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -278,7 +278,7 @@
<div id="content-box"> <div id="content-box">
<hr /> <hr />
<%= f.datetime_picker :email_sentdate, :picker_type => 'separated', :label => t("announcement.email_sentdate") %> <%#= f.datetime_picker :email_sentdate, :picker_type => 'separated', :label => t("announcement.email_sentdate") %>
<br /> <br />

View File

@ -6,6 +6,7 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
def preview_and_approve def preview_and_approve
email_group_data
@email_er = EmailEr.find params[:email_er_id] @email_er = EmailEr.find params[:email_er_id]
end end
@ -102,7 +103,8 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
:mail_subject => email_er.mail_subject, :mail_subject => email_er.mail_subject,
:mail_to => @group_mail.join(','), :mail_to => @group_mail.join(','),
:mail_content => @mail_content , :mail_content => @mail_content ,
:mail_sentdate => email_er.mail_sentdate, # :mail_sentdate => email_er.mail_sentdate,
:mail_sentdate => DateTime.now,
:create_user_id => email_er.create_user_id, :create_user_id => email_er.create_user_id,
:update_user_id => email_er.create_user_id :update_user_id => email_er.create_user_id
} }
@ -128,6 +130,8 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
@mail_cron.save @mail_cron.save
MailCron.send_mail_now(@mail_cron.id)
end end
end end
@ -137,4 +141,5 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
@email_group_data = EmailEr.email_group_data @email_group_data = EmailEr.email_group_data
end end
end end

View File

@ -56,6 +56,9 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
# GET /email_ers/1.xml # GET /email_ers/1.xml
def show def show
email_group_data
@item = Page.find(params[:page_id]) rescue nil @item = Page.find(params[:page_id]) rescue nil
if params[:preview] == "true" if params[:preview] == "true"
preview_content preview_content
@ -123,9 +126,9 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
respond_to do |format| respond_to do |format|
if @email_er.save if @email_er.save
if @email_er.is_checked == true and !@email_er.is_rejected # if @email_er.is_checked == true and !@email_er.is_rejected
send_email_data(@email_er) # send_email_data(@email_er)
end # end
format.html { redirect_to(panel_er_email_back_end_email_ers_url) } format.html { redirect_to(panel_er_email_back_end_email_ers_url) }
format.xml { render :xml => @email_er, :status => :created, :location => @email_er } format.xml { render :xml => @email_er, :status => :created, :location => @email_er }
@ -212,12 +215,29 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end end
def test_send_email
if params[:id]
@email_er = EmailEr.find(params[:id])
if (@email_er.create_user_id == current_or_guest_user.id) || is_manager?
if current_or_guest_user.admin? || (!@email_er.is_rejected? && !@email_er.is_checked?)
if @email_er.is_pending
send_email_data( @email_er , true )
end
end
end
end
redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end
protected protected
def send_email_data(email_er) def send_email_data(email_er , test_send = false)
@user = User.find(email_er.create_user_id) @user = User.find(email_er.create_user_id)
if !test_send
email_group_data email_group_data
@group_mail = Array.new @group_mail = Array.new
@ -236,6 +256,13 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
end end
else
# @group_mail = ["spen@rulingcom.com"]
@group_mail = [@user.email]
end
if !@group_mail.join.blank? if !@group_mail.join.blank?
@mail_content = { @mail_content = {
@ -249,7 +276,8 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
:mail_subject => email_er.mail_subject, :mail_subject => email_er.mail_subject,
:mail_to => @group_mail.join(','), :mail_to => @group_mail.join(','),
:mail_content => @mail_content , :mail_content => @mail_content ,
:mail_sentdate => email_er.mail_sentdate, # :mail_sentdate => email_er.mail_sentdate,
:mail_sentdate => DateTime.now,
:create_user_id => email_er.create_user_id, :create_user_id => email_er.create_user_id,
:update_user_id => email_er.create_user_id :update_user_id => email_er.create_user_id
} }
@ -275,6 +303,8 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
@mail_cron.save @mail_cron.save
MailCron.send_mail_now(@mail_cron.id)
end end
end end

View File

@ -35,6 +35,8 @@ class EmailEr
accepts_nested_attributes_for :email_er_files, :allow_destroy => true accepts_nested_attributes_for :email_er_files, :allow_destroy => true
validates :mail_subject,presence:{message:'blank is not allowed'} validates :mail_subject,presence:{message:'blank is not allowed'}
validates :other_mailaddress,
:length => {:maximum => 1000, :message => I18n.t("er_email.other_mailaddress_note_limit")}
def proc_check(check,not_pass_info = "") def proc_check(check,not_pass_info = "")
self.is_checked = true self.is_checked = true

View File

@ -10,6 +10,12 @@
<iframe src=<%= panel_er_email_back_end_email_er_path(email_er, :category_id => email_er.email_er_category.id ,:preview=>true) %> style="width:1024px;height:300px" > <iframe src=<%= panel_er_email_back_end_email_er_path(email_er, :category_id => email_er.email_er_category.id ,:preview=>true) %> style="width:1024px;height:300px" >
</iframe> </iframe>
<% if !@email_er.email_group.blank? %>
<%= label_tag 'group_mail' %>
<%= @email_er.get_email_group_data(@email_group_data) %>
<% end %>
</p> </p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -32,6 +32,11 @@
<% if current_or_guest_user.admin? || (!email_er.is_rejected? && !email_er.is_checked?) %> <% if current_or_guest_user.admin? || (!email_er.is_rejected? && !email_er.is_checked?) %>
<li><%= link_to t(:edit), edit_panel_er_email_back_end_email_er_path(email_er, :page => params[:page], :filter => @filter) %></li> <li><%= link_to t(:edit), edit_panel_er_email_back_end_email_er_path(email_er, :page => params[:page], :filter => @filter) %></li>
<% if email_er.is_pending %>
<li><%= link_to t('er_email.test_send_email'), test_send_email_panel_er_email_back_end_email_ers_path(:id=>email_er.id), :confirm => t('sure?'), :controller => "email_er", :action => "test_send_email" %></li>
<% end %>
<% end %> <% end %>
<li><%= link_to t(:delete_), panel_er_email_back_end_email_er_path(email_er), :confirm => t('sure?'), :method => :delete, :remote => true %></li> <li><%= link_to t(:delete_), panel_er_email_back_end_email_er_path(email_er), :confirm => t('sure?'), :method => :delete, :remote => true %></li>
@ -53,7 +58,4 @@
<td class="span2"> <td class="span2">
<%= email_er.get_email_group_data(@email_group_data) %> <%= email_er.get_email_group_data(@email_group_data) %>
</td> </td>
<td class="span2">
<%= display_date_time(email_er.mail_sentdate) %>
</td>
</tr> </tr>

View File

@ -6,23 +6,6 @@
<%= f.error_messages %> <%= f.error_messages %>
<!--Widget start-->
<div id="sub-wiget">
<div id="widget-date" class="widget-box widget-size-300">
<h3 class="widget-title"><i class="icons-calendar"></i><%= t("er_email.mail_sentdate") %></h3>
<div class="widget-content clear">
<div class="control-group">
<%= f.datetime_picker :mail_sentdate, :picker_type => 'separated', :label => t(:start) %>
</div>
</div>
</div>
</div>
<!--Wiget End-->
<!--Post Start--> <!--Post Start-->
<div id="post-body"> <div id="post-body">
@ -48,8 +31,8 @@
</div> </div>
<%= f.label :other_mailaddress ,"#{t("er_email.other_mailaddress")}(#{t("er_email.other_mailaddress_note")})"%> <%= f.label :other_mailaddress ,"#{t("er_email.other_mailaddress")}(#{t("er_email.other_mailaddress_note")})(#{t("er_email.other_mailaddress_note_limit")})"%>
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %> <%= f.text_area :other_mailaddress, :class=>"span12", :rows=>"5" %>
<br /> <br />

View File

@ -2,5 +2,4 @@
['status', ['is_pending', 'is_checked', 'is_rejected'], 'span1', :status], ['status', ['is_pending', 'is_checked', 'is_rejected'], 'span1', :status],
['category', 'email_er_category', 'span1', :category], ['category', 'email_er_category', 'span1', :category],
['subject', 'mail_subject','span2', 'er_email.mail_subject'] , ['subject', 'mail_subject','span2', 'er_email.mail_subject'] ,
['email_group', 'email_group','span2', 'er_email.email_group'] , ['email_group', 'email_group','span2', 'er_email.email_group']).html_safe %>
['sentdate', 'mail_sentdate','span2', 'er_email.mail_sentdate'] ).html_safe %>

View File

@ -8,7 +8,6 @@
<th class="span1"></th> <th class="span1"></th>
<th class="span2"></th> <th class="span2"></th>
<th class="span2"></th> <th class="span2"></th>
<th class="span2"></th>
</tr> </tr>
</thead> </thead>
<tbody id="tbody_email_ers"> <tbody id="tbody_email_ers">

View File

@ -10,6 +10,8 @@ en:
approve_email_er_fail: Approval Fail approve_email_er_fail: Approval Fail
approve_email_er_success: Approve Successfully approve_email_er_success: Approve Successfully
create_email_er_success: Create Successfully create_email_er_success: Create Successfully
email_resend: Resend
test_send_email: Test Send Email
mail_subject: Mail Subject mail_subject: Mail Subject
mail_content: Mail Content mail_content: Mail Content
mail_sentdate: Email Time mail_sentdate: Email Time
@ -21,4 +23,5 @@ en:
email_group_data_4: Other email_group_data_4: Other
other_mailaddress: Other Email other_mailaddress: Other Email
other_mailaddress_note: Divide different email accounts with "," other_mailaddress_note: Divide different email accounts with ","
other_mailaddress_note_limit: maximum 1000 characters
email_file_limit: File upload size is limited to 1MB email_file_limit: File upload size is limited to 1MB

View File

@ -10,12 +10,15 @@ zh_tw:
approve_email_er_fail: 審核失敗 approve_email_er_fail: 審核失敗
approve_email_er_success: 審核成功 approve_email_er_success: 審核成功
create_email_er_success: 建立資料成功 create_email_er_success: 建立資料成功
email_resend: 重新寄送
test_send_email: 測試寄信
mail_subject: 主旨 mail_subject: 主旨
mail_content: 信件內容 mail_content: 信件內容
mail_sentdate: 寄送時間 mail_sentdate: 寄送時間
email_group: 寄送群組 email_group: 寄送群組
other_mailaddress: 其他Mail other_mailaddress: 其他Mail
other_mailaddress_note: 輸入多組mail時,請用","逗號隔開 other_mailaddress_note: 輸入多組mail時,請用","逗號隔開
other_mailaddress_note_limit: 限制1000字元以內
email_group_data_0: 全校教職員 email_group_data_0: 全校教職員
email_group_data_1: 大學部學生 email_group_data_1: 大學部學生
email_group_data_2: 日間部研究生 email_group_data_2: 日間部研究生

View File

@ -16,6 +16,7 @@ Rails.application.routes.draw do
put "preview" put "preview"
get 'delete' get 'delete'
get 'email_resend' get 'email_resend'
get 'test_send_email'
end end
end end