项目、课程讨论区邮件提醒查询修改

This commit is contained in:
huang 2015-06-03 16:59:27 +08:00
parent 0354e65497
commit 9e0a986fe9
2 changed files with 7 additions and 9 deletions

View File

@ -83,13 +83,10 @@ class Mailer < ActionMailer::Base
# 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言
def send_for_user_activities(user, date_to, days)
date_from = date_to - days.days
subject = "[ #{user.show_name}#{l(:label_day_mail)}]"
@subject = " #{user.show_name}#{l(:label_day_mail)}"
date_from = "#{date_from} 17:59:59"
date_to = "#{date_to} 17:59:59"
# 生成token用于直接点击登录
@user = user
@token = Token.get_token_from_user(user, 'autologin')
@ -102,7 +99,7 @@ class Mailer < ActionMailer::Base
# 查询user的缺陷包括发布的跟踪的以及被指派的缺陷
sql = "select * from members m, issues i where i.project_id = m.project_id and m.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"
@issues = Issue.find_by_sql(sql)
# @bids 查询课程作业包括老师发布的作业以及user提交作业
@ -125,7 +122,9 @@ class Mailer < ActionMailer::Base
@homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc")
# 查询user在课程。项目中发布的讨论帖子
messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
messages = Message.find_by_sql("select me.* from messages me, boards b, members m where
b.id = me.board_id and b.project_id = m.project_id and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
# messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
@course_messages ||= []
@project_messages ||= []
unless messages.first.nil?

View File

@ -193,6 +193,7 @@
<% end %>
</div><!--课程动态 end-->
<% end %>
<!--项目相关-->
<% if @issues.first || @project_messages.first %>
<div class="wmail_main" style="padding:20px 10px 0px;">
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_project_overview_new)%></h2>
@ -260,11 +261,9 @@
<div class="cl"></div>
</ul><!--项目论坛 end-->
<% end %>
</div><!--项目动态 end-->
<% end %>
<% unless @user_journal_messages.first.nil? %>
<div class="wmail_main" style="padding:20px 10px 0px;">
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_activities) %></h2>
@ -293,7 +292,7 @@
<% end %>
<div class="cl"></div>
</ul><!--课程动态 end-->
</ul><!--用户留言 end-->
</div><!--个人动态 end-->
<% end %>