处理新作业模块的冲突

This commit is contained in:
huang 2015-06-05 17:17:35 +08:00
parent c62d468ed3
commit c85fd9f7b8
3 changed files with 8 additions and 50 deletions

View File

@ -115,14 +115,15 @@ class Mailer < ActionMailer::Base
count = courses.count
count = count - 1
for i in 0..count do
bids = courses[i].homeworks.where("bids.created_on between '#{date_from}' and '#{date_to}'").order("bids.created_on desc")
bids = courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc")
attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order('attachments.created_on DESC')
@bids += bids if bids.count > 0
@attachments += attachments if attachments.count > 0
end
end
# user 提交的作业
@homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc")
# @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 me.* from messages me, boards b, members m where
@ -157,7 +158,7 @@ class Mailer < ActionMailer::Base
@memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id}))
and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc")
has_content = [@issues,@homeworks,@course_messages,@project_messages,@course_news,@project_news,
has_content = [@issues,@course_messages,@project_messages,@course_news,@project_news,
@course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty?}
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
#有内容才发,没有不发

View File

@ -3,7 +3,7 @@
<%= @subject %>
</h4>
<% if @attachments.first || @course_news.first || @bids.first ||
@homeworks.first || @course_journal_messages.first|| @course_messages.first %>
@course_journal_messages.first|| @course_messages.first %>
<div class="wmail_main" style="padding:20px 10px 0px;">
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_course_overview)%></h2>
<% unless @course_news.first.nil? %>
@ -39,7 +39,7 @@
<% end %>
<!--课程作业-->
<% if !@bids.first.nil? || !@homeworks.first.nil? %>
<% if !@bids.first.nil? %>
<ul class="wmail_ul" style="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;"><%= l(:label_homework_overview) %><span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @bids.count %>)</span></h4>
<% unless @bids.first.nil?%>
@ -65,29 +65,6 @@
</li>
<% end %>
<% end %>
<% unless @homeworks.first.nil? %>
<% @homeworks.each do |homework| %>
<li style="clear: both; list-style: none;">
<span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span>
<span class="wmail_b" style="color:#1b55a7; font-weight:bold; float:left;">[</span>
<%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value),
:class=> "wmail_column",
:style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
<span class="wmail_b" style="color:#1b55a7; font-weight:bold; float:left;">]</span>
<%= link_to homework.user, user_activities_url(homework.user,:token => @token.value), :class => "wmail_name",
:style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
<span class="wmail_txt" style="float:left; margin-right:5px;color:#6e6e6e;"><%= l(:label_course_submit_homework) %></span>
<%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(:id => homework.bid.id,:token => @token.value),
:class => 'wmail_info',
:style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
%>
<span class="wmail_date" style="color:#6e6e6e; float:right;display:block; margin-left:10px;"><%= format_time(homework.created_at) %></span>
</li>
<% end %>
<% end %>
<div class="cl"></div>
</ul><!--作业动态 end-->

View File

@ -1,6 +1,6 @@
<%= @subject %>
<% if @attachments.first || @course_news.first || @bids.first ||
@homeworks.first || @course_journal_messages.first|| @course_messages.first %>
@course_journal_messages.first|| @course_messages.first %>
<%= l(:label_course_overview)%>
<% unless @course_news.first.nil? %>
<%= l(:label_course_news) %>
@ -27,7 +27,7 @@
<% end %>
<% end %>
<% if !@bids.first.nil? || !@homeworks.first.nil? %>
<% if !@bids.first.nil? %>
<%= l(:label_homework_overview) %><%= @bids.count %>
<% unless @bids.first.nil?%>
<% @bids.each do |bid| %>
@ -51,26 +51,6 @@
<% end %>
<% end %>
<% unless @homeworks.first.nil? %>
<% @homeworks.each do |homework| %>
▪[
<%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value)
%>
]
<%= link_to homework.user, user_activities_url(homework.user,:token => @token.value)
%>
<%= l(:label_course_submit_homework) %>
<%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(homework.bid,:token => @token.value)
%>
<%= format_time(homework.created_at) %>
<% end %>
<% end %>
<!--作业动态 end-->