修改邮件提醒:项目缺陷动态不能收到

This commit is contained in:
huang 2015-06-02 11:02:12 +08:00
parent 7197c33be4
commit 6cddb59a4a
2 changed files with 299 additions and 309 deletions

View File

@ -45,7 +45,6 @@ class Mailer < ActionMailer::Base
MailerProxy.new(self) MailerProxy.new(self)
end end
# author: alan
# 发送邀请未注册用户加入项目邮件 # 发送邀请未注册用户加入项目邮件
# 功能: 在加入项目的同时自动注册用户 # 功能: 在加入项目的同时自动注册用户
def send_invite_in_project(email, project, invitor) def send_invite_in_project(email, project, invitor)
@ -101,16 +100,16 @@ class Mailer < ActionMailer::Base
course_ids = courses.map {|course| course.id}.join(",") course_ids = courses.map {|course| course.id}.join(",")
# 查询user的缺陷包括发布的跟踪的以及被指派的缺陷 # 查询user的缺陷包括发布的跟踪的以及被指派的缺陷
sql = "select DISTINCT i.* from issues i, watchers w # sql = "select DISTINCT i.* from issues i, watchers w
where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id} # where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id}
or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id})) # or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id}))
and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" # and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
sql = "select DISTINCT i.* from issues i where (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
@issues = Issue.find_by_sql(sql) @issues = Issue.find_by_sql(sql)
# @bids 查询课程作业包括老师发布的作业以及user提交作业 # @bids 查询课程作业包括老师发布的作业以及user提交作业
# @attachments查询课程课件更新 # @attachments查询课程课件更新
@attachments ||= [] @attachments ||= []
@bids ||= [] # 老师发布的作业 @bids ||= [] # 老师发布的作业
unless courses.first.nil? unless courses.first.nil?
@ -165,7 +164,7 @@ class Mailer < ActionMailer::Base
} }
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
#有内容才发,没有不发 #有内容才发,没有不发
mail :to => user.mail,:subject => subject if has_content mail :to => user.mail, :subject => subject if has_content
end end
# 公共讨论区发帖、回帖添加邮件发送信息 # 公共讨论区发帖、回帖添加邮件发送信息
@ -188,8 +187,8 @@ class Mailer < ActionMailer::Base
:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]", :subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]",
:filter => true :filter => true
end end
# Builds a Mail::Message object used to email recipients of the added journals for message.
# Builds a Mail::Message object used to email recipients of the added journals for message.
# 留言分为直接留言,和对留言人留言的回复 # 留言分为直接留言,和对留言人留言的回复
# 字段说明在JournalsForMessage.rb # 字段说明在JournalsForMessage.rb
# 直接留言后 reply_id,m_parent_id 为空相对应的at_user取值为nil # 直接留言后 reply_id,m_parent_id 为空相对应的at_user取值为nil
@ -511,7 +510,7 @@ class Mailer < ActionMailer::Base
end end
# Builds a Mail::Message object used to email recipients of a news' project when a news comment is added. # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
# # 新增新闻评论时邮件通知
# Example: # Example:
# news_comment_added(comment) => Mail::Message object # news_comment_added(comment) => Mail::Message object
# Mailer.news_comment_added(comment) => sends an email to the news' project recipients # Mailer.news_comment_added(comment) => sends an email to the news' project recipients
@ -912,6 +911,7 @@ class Mailer < ActionMailer::Base
:file => attachment.decoded, :file => attachment.decoded,
:filename => attachment.filename, :filename => attachment.filename,
:author => user, :author => user,
:content_type => attachment.mime_type) :content_type => attachment.mime_type)
end end
end end

View File

@ -1,13 +1,6 @@
<div class="content"> <div class="content">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" > <h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
<%= @subject %> <%= @subject %>
</h4> </h4>
<% if @attachments.first || @course_news.first || @bids.first || <% if @attachments.first || @course_news.first || @bids.first ||
@homeworks.first || @course_journal_messages.first|| @course_messages.first %> @homeworks.first || @course_journal_messages.first|| @course_messages.first %>
@ -15,12 +8,10 @@
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_course_overview)%></h2> <h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_course_overview)%></h2>
<% unless @course_news.first.nil? %> <% unless @course_news.first.nil? %>
<ul class="wmail_ul" style=" list-style-type:none;clear: both;margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;"> <ul class="wmail_ul" style=" list-style-type:none;clear: both;margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" > <h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
<%= l(:label_course_news) %> <%= l(:label_course_news) %>
<span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @course_news.count %>)</span> <span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @course_news.count %>)</span>
</h4> </h4>
<% @course_news.each do |course_new|%> <% @course_news.each do |course_new|%>
<li style="clear: both; list-style: none;"> <li style="clear: both; list-style: none;">
<span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span> <span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span>
@ -201,8 +192,8 @@
</ul><!--课件下载 end--> </ul><!--课件下载 end-->
<% end %> <% end %>
</div><!--课程动态 end--> </div><!--课程动态 end-->
<% end %> <% end %>
<% if @issues.first || @project_messages.first %> <% if @issues.first || @project_messages.first %>
<div class="wmail_main" style="padding:20px 10px 0px;"> <div class="wmail_main" style="padding:20px 10px 0px;">
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_project_overview_new)%></h2> <h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_project_overview_new)%></h2>
<% unless @issues.first.nil? %> <% unless @issues.first.nil? %>
@ -211,7 +202,6 @@
<%= l(:label_issue_tracking) %> <%= l(:label_issue_tracking) %>
<span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @issues.count %>)</span> <span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @issues.count %>)</span>
</h4> </h4>
<% @issues.each do |issue|%> <% @issues.each do |issue|%>
<li style="clear: both; list-style: none;"> <li style="clear: both; list-style: none;">
<span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span> <span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span>
@ -274,8 +264,8 @@
</div><!--项目动态 end--> </div><!--项目动态 end-->
<% end %> <% end %>
<% unless @user_journal_messages.first.nil? %> <% unless @user_journal_messages.first.nil? %>
<div class="wmail_main" style="padding:20px 10px 0px;"> <div class="wmail_main" style="padding:20px 10px 0px;">
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_activities) %></h2> <h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_activities) %></h2>
@ -306,8 +296,8 @@
</ul><!--课程动态 end--> </ul><!--课程动态 end-->
</div><!--个人动态 end--> </div><!--个人动态 end-->
<% end %> <% end %>
<% if @forums.first || @memos.first %> <% if @forums.first || @memos.first %>
<div class="wmail_main" style="padding:20px 10px 0px;"> <div class="wmail_main" style="padding:20px 10px 0px;">
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:lable_bar_active) %></h2> <h2 class="wmail_h2" style="color:#15bccf; "><%= l(:lable_bar_active) %></h2>
<% unless @forums.first.nil? %> <% unless @forums.first.nil? %>
@ -366,7 +356,7 @@
<% end %> <% end %>
</div><!--贴吧动态 end--> </div><!--贴吧动态 end-->
<% end %> <% end %>
<div class="wmail_foot" style="margin-top:20px;color:#2775d2; margin-left:10px;"> <div class="wmail_foot" style="margin-top:20px;color:#2775d2; margin-left:10px;">
<% [:label_user_mail_option_all, :label_user_mail_option_day, :label_user_mail_option_none].each do |mail_option| %> <% [:label_user_mail_option_all, :label_user_mail_option_day, :label_user_mail_option_none].each do |mail_option| %>
<% if Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten][@user.mail_notification] == mail_option %> <% if Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten][@user.mail_notification] == mail_option %>
<label style="margin-top:20px;color:gray; margin-left:10px;"><%= l(mail_option) %></label> <label style="margin-top:20px;color:gray; margin-left:10px;"><%= l(mail_option) %></label>
@ -374,6 +364,6 @@
<%= link_to l(mail_option), my_change_mail_notification_url(token: @token.value,mail_notification: Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten].invert[mail_option]), :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %> <%= link_to l(mail_option), my_change_mail_notification_url(token: @token.value,mail_notification: Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten].invert[mail_option]), :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
</div> </div>