Compare commits

..

1 Commits
ntue ... master

Author SHA1 Message Date
spen 83d680b547 orbit er_email module 2014-03-07 10:44:24 +08:00
8 changed files with 69 additions and 150 deletions

View File

@ -7,7 +7,6 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
def preview_and_approve
email_group_data
@email_er = EmailEr.find params[:email_er_id]
end
@ -73,39 +72,23 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
@user = User.find(email_er.create_user_id)
email_group_data
@group_mail = Array.new
email_er.email_group.each do |egroup|
if @email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
@group_mail << @email_group_data[egroup]["email"]
elsif @email_group_data.include?(egroup) and egroup == 'e_4'
@group_mail << email_er.other_mailaddress
end
end
@group_mail = MailCron.get_send_group_mail( email_er.email_user_ids , email_er.other_mailaddress )
if !@group_mail.join.blank?
@mail_content = {
"lang" => I18n.locale,
"text" => email_er.mail_content
}
@mail_cron = {
:mail_from_app => 'er_email',
:mail_from => @user.email,
:mail_reply_to => @user.email,
# :mail_from => @user.email,
# :mail_reply_to => @user.email,
:mail_subject => email_er.mail_subject,
:mail_to => @group_mail.join(','),
:mail_content => @mail_content ,
# :mail_sentdate => email_er.mail_sentdate,
:mail_sentdate => DateTime.now,
:mail_sentdate => email_er.mail_sentdate,
:create_user_id => email_er.create_user_id,
:update_user_id => email_er.create_user_id
}
@ -131,16 +114,8 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
@mail_cron.save
MailCron.send_mail_now(@mail_cron.id)
end
end
def email_group_data
@email_group_data = EmailEr.email_group_data
end
end

View File

@ -17,7 +17,6 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
end
def index
email_group_data
@categories = get_categories_for_index
@statuses = get_statuses
@ -42,8 +41,6 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
def show
email_group_data
@item = Page.find(params[:page_id]) rescue nil
if params[:preview] == "true"
preview_content
@ -73,8 +70,6 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
# GET /email_ers/new.xml
def new
email_group_data
@email_er = EmailEr.new(:mail_sentdate => DateTime.now)
respond_to do |format|
@ -86,13 +81,13 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
# GET /email_ers/1/edit
def edit
email_group_data
@email_er = EmailEr.find(params[:id])
@email_users = @email_er.get_email_users
is_authorized_sub_manager = @email_er.category.auth_sub_manager.authorized_user_ids rescue nil
if !(is_manager? || is_admin? || (is_authorized_sub_manager.include?(current_user.id) and @email_er.create_user_id == current_user.id))
if !(is_manager? || is_admin? || is_authorized_sub_manager.include?(current_user.id))
redirect_to :action => :index
else
# @summary_variable = @bulletin.summary_variable
@ -108,7 +103,8 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
# POST /email_ers.xml
def create
email_group_data
params[:email_er][:email_user_ids] = params[:email_er][:email_user_ids].uniq
params[:email_er][:email_user_ids].delete('')
@email_er = EmailEr.new(params[:email_er])
@email_er.create_user_id = current_user.id
@ -151,10 +147,11 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
# PUT /email_ers/1.xml
def update
email_group_data
@email_er = EmailEr.find(params[:id])
params[:email_er][:email_user_ids] = params[:email_er][:email_user_ids].uniq
params[:email_er][:email_user_ids].delete('')
@email_er.update_user_id = current_user.id
respond_to do |format|
@ -235,45 +232,33 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
if !test_send
email_group_data
@group_mail = MailCron.get_send_group_mail( email_er.email_user_ids , email_er.other_mailaddress )
@group_mail = Array.new
email_er.email_group.each do |egroup|
if @email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
@group_mail << @email_group_data[egroup]["email"]
elsif @email_group_data.include?(egroup) and egroup == 'e_4'
@group_mail << email_er.other_mailaddress
end
end
@mail_sentdate = email_er.mail_sentdate
else
@group_mail = [@user.email]
@mail_sentdate = DateTime.now
end
if !@group_mail.join.blank?
@mail_content = {
"lang" => I18n.locale,
"text" => email_er.mail_content
}
@mail_cron = {
:mail_from_app => 'er_email',
:mail_from => @user.email,
:mail_reply_to => @user.email,
# :mail_from => @user.email,
# :mail_reply_to => @user.email,
:mail_subject => email_er.mail_subject,
:mail_to => @group_mail.join(','),
:mail_content => @mail_content ,
# :mail_sentdate => email_er.mail_sentdate,
:mail_sentdate => DateTime.now,
:mail_sentdate => @mail_sentdate,
:create_user_id => email_er.create_user_id,
:update_user_id => email_er.create_user_id
}
@ -299,7 +284,7 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
@mail_cron.save
MailCron.send_mail_now(@mail_cron.id)
MailCron.send_mail_now(@mail_cron.id) if test_send
end

View File

@ -18,6 +18,9 @@ class EmailEr
field :mail_sentdate , :type => DateTime
field :mail_content
field :email_user_ids
field :other_mailaddress
field :create_user_id
field :update_user_id
@ -27,9 +30,6 @@ class EmailEr
field :not_checked_reason
field :email_group, :type => Array, default: []
field :other_mailaddress
scope :can_display,where(is_hidden: false)
has_many :email_er_files, :autosave => true, :dependent => :destroy
@ -71,33 +71,6 @@ class EmailEr
!self.is_pending && self.is_rejected && (self.is_rejected == true)
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 == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
#group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})"
group_mail << "#{email_group_data[egroup]["name"]}"
elsif email_group_data.include?(egroup) and egroup == 'e_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
def to_preview
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_er_email_back_end_email_er_path",:object_class_type=>"EmailEr")
@ -109,18 +82,8 @@ class EmailEr
preview_object
end
protected
def self.email_group_data
@email_group_data = {
'e_0'=> {"name"=>I18n.t('er_email.email_group_data_0'), "email"=>"alluser@tea.ntue.edu.tw"},
'e_1'=> {"name"=>I18n.t('er_email.email_group_data_1'), "email"=>"allstu@tea.ntue.edu.tw"},
'e_2'=> {"name"=>I18n.t('er_email.email_group_data_2'), "email"=>"allgrad@tea.ntue.edu.tw"},
'e_3'=> {"name"=>I18n.t('er_email.email_group_data_3'), "email"=>"allad@tea.ntue.edu.tw"},
'e_4'=> {"name"=>I18n.t('er_email.email_group_data_4')}
}
def get_email_users
User.find(self.email_user_ids) rescue []
end
end

View File

@ -15,9 +15,9 @@
<br />
<% end %>
<% if !@email_er.email_group.blank? %>
<%= label_tag 'group_mail' %>
<%= @email_er.get_email_group_data(@email_group_data) %>
<% if !@email_er.email_user_ids.blank? || !@email_er.other_mailaddress.blank? %>
<%= label_tag t('er_email.mail_to') %>
<%= MailCron.get_send_group_mail(@email_er.email_user_ids , @email_er.other_mailaddress).join("<br />").html_safe %>
<% end %>
</div>
<div class="modal-right">

View File

@ -5,10 +5,13 @@
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/modal-preview" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<%= javascript_include_tag "member-selection" %>
<% end %>
<%= f.error_messages %>
@ -23,9 +26,6 @@
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<li>
<a href="#mail-group" data-toggle="tab"><%= t('er_email.email_group')%></a>
</li>
</ul>
<!-- Module -->
@ -42,25 +42,19 @@
</div>
</div>
<!-- Mail Sentdate -->
<div class="control-group">
<label class="control-label muted"><%= t("er_email.mail_sentdate") %></label>
<div class="controls">
<%= f.datetime_picker :mail_sentdate, :no_label => true %>
</div>
</div>
<!-- Mail Group Module -->
<div class="tab-pane fade" id="mail-group">
<!-- Mail Group -->
<div class="control-group">
<label class="control-label muted"><%= t("er_email.email_group") %></label>
<label class="control-label muted"><%= t("er_email.mail_to") %></label>
<div class="controls">
<% @email_group_data.collect do |k,v| %>
<label class="checkbox inline">
<%= check_box_tag 'email_er[email_group][]', k, (@email_er.email_group.nil? ? false : @email_er.email_group.include?(k)), :id => "field-#{k}" %> <%= v["name"] %>
<%= hidden_field_tag 'email_er[email_group][]', '' %>
</label>
<% end if !@email_group_data.blank? %>
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'email_er[email_user_ids][]', users: @email_users} %>
</div>
</div>
<div class="control-group">

View File

@ -7,6 +7,7 @@
objects @email_ers
quick_edit_link type: 'edit',
link: 'edit_panel_er_email_back_end_email_er_path'
quick_edit_link type: 'detail'
quick_edit_link type: 'test_send_email',
define_link: 'test_send_email_panel_er_email_back_end_email_ers_path(:id=>object.id)',
condition_option: 'object.is_pending',
@ -17,7 +18,7 @@
quick_edit_link type: 'email_resend',
define_link: 'email_resend_panel_er_email_back_end_email_ers_path(:id=>object.id)',
condition_option: 'object.is_checked and !object.is_rejected',
translation: 'er_email.email_resend'
translation: 'er_email.mail_resend'
quick_edit_link type: 'approval',
link: 'panel_er_email_back_end_email_er_approval_preview_path'
quick_edit_link type: 'reject_reason'
@ -25,23 +26,32 @@
db_field: @statuses,
translation: 'status',
hide: 'phone',
sort: 'status'
sort: 'status',
header_class: 'span2'
field type: 'associated',
db_field: 'category',
model_field: 'title',
translation: 'category',
hide: 'phone',
sort: 'category'
sort: 'category',
header_class: 'span2'
field db_field: 'mail_subject',
translation: 'er_email.mail_subject',
sort: 'mail_subject',
quick_edit: true,
header_class: 'span5'
field db_field: 'email_group',
translation: 'er_email.email_group',
display_option: 'object.get_email_group_data(@email_group_data)',
header_class: 'span8'
field db_field: 'email_user_ids',
hide: 'all',
translation: 'er_email.mail_to',
display_option: '"<br />#{MailCron.get_send_group_mail(object.email_user_ids , object.other_mailaddress).join(" ").html_safe}"',
sort: 'email_user_ids'
field type: 'id',
db_field: 'create_user_id',
model: User,
model_field: 'name',
translation: 'er_email.created_user',
hide: 'phone',
sort: 'email_group'
sort: 'create_user_id'
footer link: 'new_panel_er_email_back_end_email_er_path'
end %>

View File

@ -10,18 +10,14 @@ en:
approve_email_er_fail: Approval Fail
approve_email_er_success: Approve Successfully
create_email_er_success: Create Successfully
email_resend: Resend
mail_resend: Resend
test_send_email: Test Send Email
mail_subject: Mail Subject
mail_content: Mail Content
mail_sentdate: Email Time
email_group: Email Group
email_group_data_0: All Faculty
email_group_data_1: Undergraduates
email_group_data_2: Postgraduates
email_group_data_3: Continuing Ed. Postgraduates
email_group_data_4: Other
mail_to: Email To
other_mailaddress: Other Email
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
created_user: Creator

View File

@ -10,18 +10,14 @@ zh_tw:
approve_email_er_fail: 審核失敗
approve_email_er_success: 審核成功
create_email_er_success: 建立資料成功
email_resend: 重新寄送
mail_resend: 重新寄送
test_send_email: 測試寄信
mail_subject: 主旨
mail_content: 信件內容
mail_sentdate: 寄送時間
email_group: 寄送群組
mail_to: 寄送對象
other_mailaddress: 其他Mail
other_mailaddress_note: 輸入多組mail時,請用","逗號隔開
other_mailaddress_note_limit: 限制1000字元以內
email_group_data_0: 全校教職員
email_group_data_1: 大學部學生
email_group_data_2: 日間部研究生
email_group_data_3: 進修部研究生
email_group_data_4: 其他
email_file_limit: 檔案上傳容量限制為10MB
created_user: 建立者