From 6cddb59a4a92c2281c2c089d0f2ec27f5b30e58b Mon Sep 17 00:00:00 2001
From: huang
Date: Tue, 2 Jun 2015 11:02:12 +0800
Subject: [PATCH 01/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6?=
=?UTF-8?q?=E6=8F=90=E9=86=92=EF=BC=9A=E9=A1=B9=E7=9B=AE=E7=BC=BA=E9=99=B7?=
=?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=8D=E8=83=BD=E6=94=B6=E5=88=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/mailer.rb | 42 +-
.../mailer/send_for_user_activities.html.erb | 566 +++++++++---------
2 files changed, 299 insertions(+), 309 deletions(-)
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index dbc5d3cff..44139fb03 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -45,7 +45,6 @@ class Mailer < ActionMailer::Base
MailerProxy.new(self)
end
- # author: alan
# 发送邀请未注册用户加入项目邮件
# 功能: 在加入项目的同时自动注册用户
def send_invite_in_project(email, project, invitor)
@@ -101,16 +100,16 @@ class Mailer < ActionMailer::Base
course_ids = courses.map {|course| course.id}.join(",")
# 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷
- sql = "select DISTINCT i.* from issues i, watchers w
- 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}))
- and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
+ # sql = "select DISTINCT i.* from issues i, watchers w
+ # 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}))
+ # 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)
# @bids 查询课程作业,包括老师发布的作业,以及user提交作业
# @attachments查询课程课件更新
@attachments ||= []
-
@bids ||= [] # 老师发布的作业
unless courses.first.nil?
@@ -142,9 +141,9 @@ class Mailer < ActionMailer::Base
# 查询user在课程中发布的通知,项目中发的新闻
@course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n
where n.course_id in (#{course_ids})
- and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
+ and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
@project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids})
- and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
+ and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
# 查询user在课程及个人中留言
@course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT * from journals_for_messages where
@@ -165,7 +164,7 @@ class Mailer < ActionMailer::Base
}
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
# 公共讨论区发帖、回帖添加邮件发送信息
@@ -188,8 +187,8 @@ class Mailer < ActionMailer::Base
:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]",
:filter => true
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
# 直接留言后 reply_id,m_parent_id 为空,相对应的at_user取值为nil
@@ -511,7 +510,7 @@ class Mailer < ActionMailer::Base
end
# Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
- #
+ # 新增新闻评论时邮件通知
# Example:
# news_comment_added(comment) => Mail::Message object
# Mailer.news_comment_added(comment) => sends an email to the news' project recipients
@@ -526,9 +525,9 @@ class Mailer < ActionMailer::Base
@comment = comment
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => news.recipients,
- :cc => news.watcher_recipients,
- :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
- :filter => true
+ :cc => news.watcher_recipients,
+ :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
+ :filter => true
elsif news.course
redmine_headers 'Course' => news.course.id
@author = comment.author
@@ -563,9 +562,9 @@ class Mailer < ActionMailer::Base
@message = message
@message_url = url_for(message.event_url)
mail :to => recipients,
- :cc => cc,
- :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
- :filter => true
+ :cc => cc,
+ :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
+ :filter => true
elsif message.course
redmine_headers 'Course' => message.course.id,
'Topic-Id' => (message.parent_id || message.id)
@@ -909,10 +908,11 @@ class Mailer < ActionMailer::Base
if email.attachments && email.attachments.any?
email.attachments.each do |attachment|
obj.attachments << Attachment.create(:container => obj,
- :file => attachment.decoded,
- :filename => attachment.filename,
- :author => user,
- :content_type => attachment.mime_type)
+ :file => attachment.decoded,
+ :filename => attachment.filename,
+ :author => user,
+
+ :content_type => attachment.mime_type)
end
end
end
diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb
index 73a561ca3..2cf070960 100644
--- a/app/views/mailer/send_for_user_activities.html.erb
+++ b/app/views/mailer/send_for_user_activities.html.erb
@@ -1,341 +1,331 @@
-
-
-
-
-
-
-
-<%= @subject %>
+ <%= @subject %>
<% if @attachments.first || @course_news.first || @bids.first ||
- @homeworks.first || @course_journal_messages.first|| @course_messages.first %>
-
-
<%= l(:label_course_overview)%>
- <% unless @course_news.first.nil? %>
-
+ @homeworks.first || @course_journal_messages.first|| @course_messages.first %>
+
+
<%= l(:label_course_overview)%>
+ <% unless @course_news.first.nil? %>
+
+
+ <%= l(:label_course_news) %>
+ (<%= @course_news.count %>)
+
+ <% @course_news.each do |course_new|%>
+ -
+ ▪
+ [
-
- <%= l(:label_course_news) %>
- (<%= @course_news.count %>)
-
+ <%= link_to truncate(course_new.course.name,length: 30,omission: '...'), course_url(course_new.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
- <% @course_news.each do |course_new|%>
- -
- ▪
- [
-
- <%= link_to truncate(course_new.course.name,length: 30,omission: '...'), course_url(course_new.course, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
+ <%= link_to course_new.author, user_activities_url(course_new.author,: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;"%>
+ <%= l(:label_project_notice) %>
- <%= link_to course_new.author, user_activities_url(course_new.author,: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;"%>
- <%= l(:label_project_notice) %>
+ <%= link_to truncate(course_new.title,length: 30,omission: '...'), news_url(course_new,: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;"
+ %>
+ <%= format_time(course_new.created_on) %>
+
+ <% end %>
- <%= link_to truncate(course_new.title,length: 30,omission: '...'), news_url(course_new,: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;"
- %>
- <%= format_time(course_new.created_on) %>
-
+
+
+ <% end %>
+ <% if !@bids.first.nil? || !@homeworks.first.nil? %>
+
+
+ <%= l(:label_homework_overview) %>(<%= @bids.count %>)
+ <% unless @bids.first.nil?%>
+ <% @bids.each do |bid| %>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(bid.courses.first.name,length: 30,omission: '...'), course_url(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;" %>
+ ]
+
+ <%= link_to bid.author, user_activities_url(bid.author,: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;"%>
+ <%= l(:label_course_homework) %>
+
+ <%= link_to truncate(bid.name,length: 30,omission: '...'), course_for_bid_url(:id => 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;"
+ %>
+ <%= format_time(bid.created_on) %>
+
+ <% 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),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= 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;"%>
+ <%= l(:label_course_submit_homework) %>
+
+ <%= 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;"
+ %>
+ <%= format_time(homework.created_at) %>
+
+ <% end %>
+ <% end %>
+
+
+
<% end %>
-
-
- <% end %>
- <% if !@bids.first.nil? || !@homeworks.first.nil? %>
-
+ <% unless @course_journal_messages.first.nil? %>
+
- <%= l(:label_homework_overview) %>(<%= @bids.count %>)
- <% unless @bids.first.nil?%>
- <% @bids.each do |bid| %>
- -
- ▪
- [
+
+ <%= l(:view_course_journals_for_messages) %>
+ (<%= @course_journal_messages.count %>)
+
- <%= link_to truncate(bid.courses.first.name,length: 30,omission: '...'), course_url(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;" %>
- ]
+ <% @course_journal_messages.each do |course_journal_message|%>
+ -
+ ▪
+ [
- <%= link_to bid.author, user_activities_url(bid.author,: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;"%>
- <%= l(:label_course_homework) %>
+ <%= link_to truncate(course_journal_message.course.name,length: 30,omission: '...'), course_url(course_journal_message.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
- <%= link_to truncate(bid.name,length: 30,omission: '...'), course_for_bid_url(:id => 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;"
- %>
- <%= format_time(bid.created_on) %>
-
- <% end %>
- <% end %>
- <% unless @homeworks.first.nil? %>
- <% @homeworks.each do |homework| %>
- -
- ▪
- [
+ <%= link_to course_journal_message.user, user_activities_url(course_journal_message.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;"%>
+ <%= l(:label_send_course_journals_for_messages) %>
- <%= 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;" %>
- ]
+ <%= link_to truncate(course_journal_message.notes,length: 30,omission: '...'), course_feedback_url(course_journal_message.course,: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;"
+ %>
+ <%= format_time(course_journal_message.created_on) %>
+
+ <% end %>
- <%= 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;"%>
- <%= l(:label_course_submit_homework) %>
-
- <%= 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;"
- %>
- <%= format_time(homework.created_at) %>
-
- <% end %>
+
+
<% end %>
-
-
- <% end %>
+ <% unless @course_messages.first.nil? %>
+
- <% unless @course_journal_messages.first.nil? %>
-
+
+ <%= l(:view_borad_course) %>
+ (<%= @course_journal_messages.count %>)
+
-
- <%= l(:view_course_journals_for_messages) %>
- (<%= @course_journal_messages.count %>)
-
+ <% @course_messages.each do |course_message|%>
+ -
+ ▪
+ [
- <% @course_journal_messages.each do |course_journal_message|%>
-
-
- ▪
- [
+ <%= link_to truncate(course_message.course.name,length: 30,omission: '...'), course_url(course_message.course.id, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
- <%= link_to truncate(course_journal_message.course.name,length: 30,omission: '...'), course_url(course_journal_message.course, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
+ <%= link_to course_message.author, user_activities_url(course_message.author,: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;"%>
+ <%= l(:label_send_course_messages) %>
- <%= link_to course_journal_message.user, user_activities_url(course_journal_message.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;"%>
- <%= l(:label_send_course_journals_for_messages) %>
+ <%= link_to truncate(course_message.subject,length: 30,omission: '...'),board_message_url(course_message, :board_id => course_message.board_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;"
+ %>
+ <%= format_time(course_message.created_on) %>
+
+ <% end %>
- <%= link_to truncate(course_journal_message.notes,length: 30,omission: '...'), course_feedback_url(course_journal_message.course,: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;"
- %>
- <%= format_time(course_journal_message.created_on) %>
-
- <% end %>
+
+
+ <% end %>
-
-
- <% end %>
+ <% unless @attachments.first.nil? %>
+
+
+ <%= l(:label_course_attendingcontestwork_download) %>
+ (<%= @attachments.count %>)
+
- <% unless @course_messages.first.nil? %>
-
+ <% @attachments.each do |attachment|%>
+ -
+ ▪
+ [
-
- <%= l(:view_borad_course) %>
- (<%= @course_journal_messages.count %>)
-
+ <%= link_to truncate(attachment.course.name,length: 30,omission: '...'), course_url(attachment.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
- <% @course_messages.each do |course_message|%>
- -
- ▪
- [
+ <%= link_to attachment.author, user_activities_url(attachment.author,: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;"%>
+ <%= l(:label_course_file_upload) %>
- <%= link_to truncate(course_message.course.name,length: 30,omission: '...'), course_url(course_message.course.id, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
+ <%= link_to truncate(attachment.filename,length: 30,omission: '...'),course_files_url(attachment.course,: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;"
+ %>
+ <%= format_time(attachment.created_on) %>
+
+ <% end %>
+
+
+ <% end %>
+
+<% end %>
+<% if @issues.first || @project_messages.first %>
+
+
<%= l(:label_project_overview_new)%>
+ <% unless @issues.first.nil? %>
+
+
+ <%= l(:label_issue_tracking) %>
+ (<%= @issues.count %>)
+
+ <% @issues.each do |issue|%>
+ -
+ ▪
+ [
- <%= link_to course_message.author, user_activities_url(course_message.author,: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;"%>
- <%= l(:label_send_course_messages) %>
+ <%= link_to truncate(issue.project.name,length: 30,omission: '...'), project_url(issue.project, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
- <%= link_to truncate(course_message.subject,length: 30,omission: '...'),board_message_url(course_message, :board_id => course_message.board_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;"
- %>
- <%= format_time(course_message.created_on) %>
-
- <% end %>
+ <%= link_to issue.author, user_activities_url(issue.author,: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;"%>
+ <%= l(:label_project_issue) %>
-
-
- <% end %>
+ <%= link_to truncate(issue.subject,length: 30,omission: '...'),issue_url(issue, :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;"
+ %>
+
<%= format_time(issue.created_on) %>
+
+ <% end %>
- <% unless @attachments.first.nil? %>
-
-
- <%= l(:label_course_attendingcontestwork_download) %>
- (<%= @attachments.count %>)
-
+
+
+ <% end %>
- <% @attachments.each do |attachment|%>
-
-
- ▪
- [
+ <% unless @project_messages.first.nil? %>
+
+
+ <%= l(:project_moule_boards_show) %>
+ (<%= @project_messages.count %>)
+
- <%= link_to truncate(attachment.course.name,length: 30,omission: '...'), course_url(attachment.course, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
+ <% @project_messages.each do |project_message|%>
+ -
+ ▪
+ [
- <%= link_to attachment.author, user_activities_url(attachment.author,: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;"%>
- <%= l(:label_course_file_upload) %>
+ <%= link_to truncate(project_message.project.name,length: 30,omission: '...'), project_url(project_message.project, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
- <%= link_to truncate(attachment.filename,length: 30,omission: '...'),course_files_url(attachment.course,: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;"
- %>
- <%= format_time(attachment.created_on) %>
-
- <% end %>
-
-
- <% end %>
-
- <% end %>
- <% if @issues.first || @project_messages.first %>
-
-
<%= l(:label_project_overview_new)%>
- <% unless @issues.first.nil? %>
-
-
- <%= l(:label_issue_tracking) %>
- (<%= @issues.count %>)
-
+ <%= link_to project_message.author, user_activities_url(project_message.author,: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;"%>
+ <%= l(:label_send_course_messages) %>
- <% @issues.each do |issue|%>
- -
- ▪
- [
+ <%= link_to truncate(project_message.subject,length: 30,omission: '...'),board_message_url(project_message, :board_id => project_message.board_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;"
+ %>
+ <%= format_time(project_message.created_on) %>
+
+ <% end %>
- <%= link_to truncate(issue.project.name,length: 30,omission: '...'), project_url(issue.project, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to issue.author, user_activities_url(issue.author,: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;"%>
- <%= l(:label_project_issue) %>
-
- <%= link_to truncate(issue.subject,length: 30,omission: '...'),issue_url(issue, :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;"
- %>
- <%= format_time(issue.created_on) %>
-
- <% end %>
-
-
-
- <% end %>
-
- <% unless @project_messages.first.nil? %>
-
-
- <%= l(:project_moule_boards_show) %>
- (<%= @project_messages.count %>)
-
-
- <% @project_messages.each do |project_message|%>
- -
- ▪
- [
-
- <%= link_to truncate(project_message.project.name,length: 30,omission: '...'), project_url(project_message.project, :token => @token.value),
- :class=> "wmail_column",
- :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
- ]
-
- <%= link_to project_message.author, user_activities_url(project_message.author,: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;"%>
- <%= l(:label_send_course_messages) %>
-
- <%= link_to truncate(project_message.subject,length: 30,omission: '...'),board_message_url(project_message, :board_id => project_message.board_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;"
- %>
- <%= format_time(project_message.created_on) %>
-
- <% end %>
-
-
-
- <% end %>
+
+
+ <% end %>
-
- <% end %>
- <% unless @user_journal_messages.first.nil? %>
-
-
<%= l(:label_activities) %>
+
+<% end %>
+<% unless @user_journal_messages.first.nil? %>
+
+
<%= l(:label_activities) %>
-
-
- <%= l(:label_user_message) %>
- (<%= @user_journal_messages.count %>)
-
+
+
+ <%= l(:label_user_message) %>
+ (<%= @user_journal_messages.count %>)
+
- <% @user_journal_messages.each do |user_journal_message|%>
- -
- ▪
+ <% @user_journal_messages.each do |user_journal_message|%>
+
-
+ ▪
- <%= link_to user_journal_message.user, user_activities_url(user_journal_message.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;" %>
- <%= l(:label_show_your_message) %>
+ <%= link_to user_journal_message.user, user_activities_url(user_journal_message.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;" %>
+ <%= l(:label_show_your_message) %>
- <%= link_to truncate(user_journal_message.notes,length: 30,omission: '...'),feedback_url(@user,: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;"
- %>
+ <%= link_to truncate(user_journal_message.notes,length: 30,omission: '...'),feedback_url(@user,: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;"
+ %>
<%= format_time(user_journal_message.created_on) %>
<% end %>
-
-
+
+
-
- <% end %>
- <% if @forums.first || @memos.first %>
+
+<% end %>
+<% if @forums.first || @memos.first %>
<%= l(:lable_bar_active) %>
<% unless @forums.first.nil? %>
-
-
- <%= l(:label_user_forum) %>
- (<%= @forums.count %>)
-
+
+
+ <%= l(:label_user_forum) %>
+ (<%= @forums.count %>)
+
- <% @forums.each do |forum|%>
- -
- ▪
+ <% @forums.each do |forum|%>
+
-
+ ▪
- <%= link_to forum.creator, user_activities_url(forum.creator,: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;" %>
- <%= l(:label_forum_new) %>
+ <%= link_to forum.creator, user_activities_url(forum.creator,: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;" %>
+ <%= l(:label_forum_new) %>
- <%= link_to truncate(forum.name,length: 30,omission: '...'),forum_url(forum,: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;"
- %>
- <%= format_time(forum.created_at) %>
+ <%= link_to truncate(forum.name,length: 30,omission: '...'),forum_url(forum,: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;"
+ %>
+ <%= format_time(forum.created_at) %>
- <% end %>
+ <% end %>
-
-
+
+
<% end %>
<% unless @memos.first.nil? %>
@@ -366,14 +356,14 @@
<% end %>
<% end %>
-
+
From 64e56eca8e98d902505a5c8eb7c66eae5f9d4d53 Mon Sep 17 00:00:00 2001
From: huang
Date: Tue, 2 Jun 2015 11:14:13 +0800
Subject: [PATCH 02/12] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=8F=90=E9=86=92?=
=?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE=E8=AE=BA=E5=9D=9B?=
=?UTF-8?q?=E6=8F=90=E9=86=92=E4=B8=8D=E5=85=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/mailer.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 44139fb03..7be526f41 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -126,7 +126,7 @@ 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 DISTINCT * from messages where (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
@course_messages ||= []
@project_messages ||= []
unless messages.first.nil?
From 0354e65497a0f779f08a9cac70c154c594323a9e Mon Sep 17 00:00:00 2001
From: huang
Date: Wed, 3 Jun 2015 14:25:22 +0800
Subject: [PATCH 03/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9issues=E9=82=AE?=
=?UTF-8?q?=E4=BB=B6=E9=80=9A=E7=9F=A5=E6=9F=A5=E8=AF=A2=E8=AF=AD=E5=8F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/mailer.rb | 138 +++++++++++++++++++++----------------------
1 file changed, 68 insertions(+), 70 deletions(-)
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 7be526f41..e0726599b 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -45,6 +45,7 @@ class Mailer < ActionMailer::Base
MailerProxy.new(self)
end
+ # author: alan
# 发送邀请未注册用户加入项目邮件
# 功能: 在加入项目的同时自动注册用户
def send_invite_in_project(email, project, invitor)
@@ -88,7 +89,7 @@ class Mailer < ActionMailer::Base
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')
@@ -100,16 +101,14 @@ class Mailer < ActionMailer::Base
course_ids = courses.map {|course| course.id}.join(",")
# 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷
- # sql = "select DISTINCT i.* from issues i, watchers w
- # 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}))
- # 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"
+ 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"
@issues = Issue.find_by_sql(sql)
# @bids 查询课程作业,包括老师发布的作业,以及user提交作业
# @attachments查询课程课件更新
@attachments ||= []
+
@bids ||= [] # 老师发布的作业
unless courses.first.nil?
@@ -118,15 +117,15 @@ class Mailer < ActionMailer::Base
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")
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
+ @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")
# 查询user在课程。项目中发布的讨论帖子
- messages = Message.find_by_sql("select DISTINCT * from messages where (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?
@@ -141,9 +140,9 @@ class Mailer < ActionMailer::Base
# 查询user在课程中发布的通知,项目中发的新闻
@course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n
where n.course_id in (#{course_ids})
- and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
+ and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
@project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids})
- and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
+ and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
# 查询user在课程及个人中留言
@course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT * from journals_for_messages where
@@ -160,11 +159,11 @@ class Mailer < ActionMailer::Base
has_content = [@issues,@homeworks,@course_messages,@project_messages,@course_news,@project_news,
@course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o|
- !o.empty?
- }
+ !o.empty?
+ }
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
# 公共讨论区发帖、回帖添加邮件发送信息
@@ -187,8 +186,8 @@ class Mailer < ActionMailer::Base
:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]",
:filter => true
end
-
# Builds a Mail::Message object used to email recipients of the added journals for message.
+
# 留言分为直接留言,和对留言人留言的回复
# 字段说明在JournalsForMessage.rb
# 直接留言后 reply_id,m_parent_id 为空,相对应的at_user取值为nil
@@ -276,11 +275,11 @@ class Mailer < ActionMailer::Base
@token = Token.get_token_from_user(user, 'autologin')
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value)
- # edit
- @issue_author_url = url_for(user_activities_url(@author,:token => @token.value))
- @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
+ # edit
+ @issue_author_url = url_for(user_activities_url(@author,:token => @token.value))
+ @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
- @user_url = url_for(my_account_url(user,:token => @token.value))
+ @user_url = url_for(my_account_url(user,:token => @token.value))
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
@@ -288,13 +287,13 @@ class Mailer < ActionMailer::Base
:subject => subject,
:filter => true
end
- # issue.attachments.each do |attach|
- # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}")
- # end
- # cc = issue.watcher_recipients - recipients
- #mail.attachments['test'] = File.read("#{RAILS.root}/files/2015/01/150114094010_libegl.dll")
+ # issue.attachments.each do |attach|
+ # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}")
+ # end
+ # cc = issue.watcher_recipients - recipients
+ #mail.attachments['test'] = File.read("#{RAILS.root}/files/2015/01/150114094010_libegl.dll")
+
-
# Builds a Mail::Message object used to email recipients of the edited issue.
@@ -323,13 +322,13 @@ class Mailer < ActionMailer::Base
@project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
@user_url = url_for(my_account_url(user,:token => @token.value))
- @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value)
+ @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value)
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] "
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
s << issue.subject
@issue = issue
@journal = journal
- # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
+ # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
mail :to => recipients,
:subject => s,
:filter => true
@@ -359,10 +358,10 @@ class Mailer < ActionMailer::Base
@issues = issues
@days = days
@issues_url = url_for(:controller => 'issues', :action => 'index',
- :set_filter => 1, :assigned_to_id => user.id,
- :sort => 'due_date:asc')
+ :set_filter => 1, :assigned_to_id => user.id,
+ :sort => 'due_date:asc')
mail :to => user.mail,
- :subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
+ :subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
end
#缺陷到期邮件通知
@@ -493,8 +492,8 @@ class Mailer < ActionMailer::Base
@news = news
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => news.recipients,
- :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
- :filter => true
+ :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
+ :filter => true
elsif news.course
redmine_headers 'Course' => news.course.id
@author = news.author
@@ -510,7 +509,7 @@ class Mailer < ActionMailer::Base
end
# Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
- # 新增新闻评论时邮件通知
+ #
# Example:
# news_comment_added(comment) => Mail::Message object
# Mailer.news_comment_added(comment) => sends an email to the news' project recipients
@@ -597,12 +596,12 @@ class Mailer < ActionMailer::Base
cc = wiki_content.page.wiki.watcher_recipients - recipients
@wiki_content = wiki_content
@wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
- :project_id => wiki_content.project,
- :id => wiki_content.page.title)
+ :project_id => wiki_content.project,
+ :id => wiki_content.page.title)
mail :to => recipients,
- :cc => cc,
- :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}",
- :filter => true
+ :cc => cc,
+ :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}",
+ :filter => true
end
# Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated.
@@ -619,15 +618,15 @@ class Mailer < ActionMailer::Base
cc = wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients
@wiki_content = wiki_content
@wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
- :project_id => wiki_content.project,
- :id => wiki_content.page.title)
+ :project_id => wiki_content.project,
+ :id => wiki_content.page.title)
@wiki_diff_url = url_for(:controller => 'wiki', :action => 'diff',
- :project_id => wiki_content.project, :id => wiki_content.page.title,
- :version => wiki_content.version)
+ :project_id => wiki_content.project, :id => wiki_content.page.title,
+ :version => wiki_content.version)
mail :to => recipients,
- :cc => cc,
- :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}",
- :filter => true
+ :cc => cc,
+ :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}",
+ :filter => true
end
# Builds a Mail::Message object used to email the specified user their account information.
@@ -641,7 +640,7 @@ class Mailer < ActionMailer::Base
@password = password
@login_url = url_for(:controller => 'account', :action => 'login')
mail :to => user.mail,
- :subject => l(:mail_subject_register, Setting.app_title)
+ :subject => l(:mail_subject_register, Setting.app_title)
end
# Builds a Mail::Message object used to email all active administrators of an account activation request.
@@ -654,10 +653,10 @@ class Mailer < ActionMailer::Base
recipients = User.active.where(:admin => true).all.collect { |u| u.mail }.compact
@user = user
@url = url_for(:controller => 'users', :action => 'index',
- :status => User::STATUS_REGISTERED,
- :sort_key => 'created_on', :sort_order => 'desc')
+ :status => User::STATUS_REGISTERED,
+ :sort_key => 'created_on', :sort_order => 'desc')
mail :to => recipients,
- :subject => l(:mail_subject_account_activation_request, Setting.app_title)
+ :subject => l(:mail_subject_account_activation_request, Setting.app_title)
end
# Builds a Mail::Message object used to email the specified user that their account was activated by an administrator.
@@ -670,7 +669,7 @@ class Mailer < ActionMailer::Base
@user = user
@login_url = url_for(:controller => 'account', :action => 'login')
mail :to => user.mail,
- :subject => l(:mail_subject_register, Setting.app_title)
+ :subject => l(:mail_subject_register, Setting.app_title)
end
def lost_password(token)
@@ -678,7 +677,7 @@ class Mailer < ActionMailer::Base
@token = token
@url = url_for(:controller => 'account', :action => 'lost_password', :token => token.value)
mail :to => token.user.mail,
- :subject => l(:mail_subject_lost_password, Setting.app_title)
+ :subject => l(:mail_subject_lost_password, Setting.app_title)
end
def register(token)
@@ -686,14 +685,14 @@ class Mailer < ActionMailer::Base
@token = token
@url = url_for(:controller => 'account', :action => 'activate', :token => token.value)
mail :to => token.user.mail,
- :subject => l(:mail_subject_register, Setting.app_title)
+ :subject => l(:mail_subject_register, Setting.app_title)
end
def test_email(user)
set_language_if_valid(user.language)
@url = url_for(:controller => 'welcome')
mail :to => user.mail,
- :subject => 'forge test'
+ :subject => 'forge test'
end
# Overrides default deliver! method to prevent from sending an email
@@ -701,8 +700,8 @@ class Mailer < ActionMailer::Base
def deliver!(mail = @mail)
set_language_if_valid @initial_language
return false if (recipients.nil? || recipients.empty?) &&
- (cc.nil? || cc.empty?) &&
- (bcc.nil? || bcc.empty?)
+ (cc.nil? || cc.empty?) &&
+ (bcc.nil? || bcc.empty?)
# Log errors when raise_delivery_errors is set to false, Rails does not
@@ -734,8 +733,8 @@ class Mailer < ActionMailer::Base
user_ids = options[:users]
scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
- " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
- " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
+ " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
+ " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
)
scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
scope = scope.where(:project_id => project.id) if project
@@ -799,12 +798,12 @@ class Mailer < ActionMailer::Base
def mail(headers={})
headers.merge! 'X-Mailer' => 'Redmine',
- 'X-Redmine-Host' => Setting.host_name,
- 'X-Redmine-Site' => Setting.app_title,
- 'X-Auto-Response-Suppress' => 'OOF',
- 'Auto-Submitted' => 'auto-generated',
- 'From' => Setting.mail_from,
- 'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
+ 'X-Redmine-Host' => Setting.host_name,
+ 'X-Redmine-Site' => Setting.app_title,
+ 'X-Auto-Response-Suppress' => 'OOF',
+ 'Auto-Submitted' => 'auto-generated',
+ 'From' => Setting.mail_from,
+ 'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
# Removes the author from the recipients and cc
# if he doesn't want to receive notifications about what he does
@@ -850,7 +849,7 @@ class Mailer < ActionMailer::Base
set_language_if_valid Setting.default_language
super
end
-
+
def self.deliver_mail(mail)
return false if mail.to.blank? && mail.cc.blank? && mail.bcc.blank?
Thread.new do
@@ -897,7 +896,7 @@ class Mailer < ActionMailer::Base
end
def mylogger
- if Setting.delayjob_enabled?
+ if Setting.delayjob_enabled?
Delayed::Worker.logger
else
Rails.logger
@@ -908,11 +907,10 @@ class Mailer < ActionMailer::Base
if email.attachments && email.attachments.any?
email.attachments.each do |attachment|
obj.attachments << Attachment.create(:container => obj,
- :file => attachment.decoded,
- :filename => attachment.filename,
- :author => user,
-
- :content_type => attachment.mime_type)
+ :file => attachment.decoded,
+ :filename => attachment.filename,
+ :author => user,
+ :content_type => attachment.mime_type)
end
end
end
From 9e0a986fe92477d499531200825564b9f5f3c9af Mon Sep 17 00:00:00 2001
From: huang
Date: Wed, 3 Jun 2015 16:59:27 +0800
Subject: [PATCH 04/12] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E3=80=81=E8=AF=BE?=
=?UTF-8?q?=E7=A8=8B=E8=AE=A8=E8=AE=BA=E5=8C=BA=E9=82=AE=E4=BB=B6=E6=8F=90?=
=?UTF-8?q?=E9=86=92=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/mailer.rb | 9 ++++-----
app/views/mailer/send_for_user_activities.html.erb | 7 +++----
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index e0726599b..c13334b08 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -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?
diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb
index 2cf070960..1ea977e89 100644
--- a/app/views/mailer/send_for_user_activities.html.erb
+++ b/app/views/mailer/send_for_user_activities.html.erb
@@ -193,6 +193,7 @@
<% end %>
<% end %>
+
<% if @issues.first || @project_messages.first %>
<%= l(:label_project_overview_new)%>
@@ -260,11 +261,9 @@
<% end %>
-
-
-
<% end %>
+
<% unless @user_journal_messages.first.nil? %>
<%= l(:label_activities) %>
@@ -293,7 +292,7 @@
<% end %>
-
+
<% end %>
From e40f1a570e9993b0d3000a03572950b75a414ea7 Mon Sep 17 00:00:00 2001
From: huang
Date: Wed, 3 Jun 2015 18:11:52 +0800
Subject: [PATCH 05/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=82=AE=E4=BB=B6?=
=?UTF-8?q?=E9=82=80=E8=AF=B7=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/projects_controller.rb | 3 ++-
app/models/invite_list.rb | 12 ++++++++++--
app/models/mailer.rb | 1 +
app/models/project.rb | 2 +-
app/views/projects/invite_members_by_mail.html.erb | 7 ++++++-
5 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index fbafd16e9..3c34aa549 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -363,7 +363,8 @@ class ProjectsController < ApplicationController
#发送邮件邀请新用户
def invite_members_by_mail
- if User.current.member_of?(@project) || User.current.admin?
+ if User.current.member_of?(@project) || User.current.admin?
+ @inviter_lists = InviteList.where(project_id:@project.id).all
@is_zhuce = false
respond_to do |format|
format.html
diff --git a/app/models/invite_list.rb b/app/models/invite_list.rb
index f1ba8546f..4868fc3d7 100644
--- a/app/models/invite_list.rb
+++ b/app/models/invite_list.rb
@@ -1,5 +1,13 @@
class InviteList < ActiveRecord::Base
attr_accessible :project_id, :user_id
- # belongs_to :user
- # belongs_to :project
+ belongs_to :user
+ belongs_to :project
+
+ # 用户拒绝邀请后,删除记录
+ def self.delete_inviter(userid, projectid)
+ @inviters = AppliedProject.where("user_id = ? and project_id = ?", userid, projectid)
+ @inviters.each do |inviter|
+ inviter.destroy
+ end
+ end
end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index c13334b08..001d1b1f6 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -58,6 +58,7 @@ class Mailer < ActionMailer::Base
us = UsersService.new
# 自动激活用户
user = us.register_auto(login, @email, @password)
+ InviteList.create(:user_id => user.id, :project_id => project.id)
User.current = user unless User.current.nil?
@user = user
diff --git a/app/models/project.rb b/app/models/project.rb
index bf94df248..249df8640 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -67,7 +67,7 @@ class Project < ActiveRecord::Base
has_many :student, :through => :students_for_courses, :source => :user
has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy
has_many :applied_projects
- # has_many :invite_lists
+ has_many :invite_lists
# end
#ADDED BY NIE
diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb
index 7f952cb3c..7cad9bff3 100644
--- a/app/views/projects/invite_members_by_mail.html.erb
+++ b/app/views/projects/invite_members_by_mail.html.erb
@@ -80,4 +80,9 @@
<% end %>
-
\ No newline at end of file
+
+
+<% @inviter_lists.each do |inviter_list| %>
+ <%= inviter_list.user.name %>
+ <% end
+ %>
\ No newline at end of file
From c39e0bf3db834e109d7a1dac292cccc8ac030875 Mon Sep 17 00:00:00 2001
From: huang
Date: Thu, 4 Jun 2015 10:34:39 +0800
Subject: [PATCH 06/12] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=88=90=E5=91=98?=
=?UTF-8?q?=E9=82=80=E8=AF=B7=E6=B7=BB=E5=8A=A0=EF=BC=9A=20=E9=82=80?=
=?UTF-8?q?=E8=AF=B7=E7=AD=89=E5=BE=85=20=E5=B7=B2=E9=82=80=E8=AF=B7?=
=?UTF-8?q?=E7=9A=84=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/mailer.rb | 4 +
.../projects/invite_members_by_mail.html.erb | 79 +++++++++++--------
public/stylesheets/project.css | 1 +
3 files changed, 50 insertions(+), 34 deletions(-)
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 001d1b1f6..56fe1e6a9 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -74,6 +74,10 @@ class Mailer < ActionMailer::Base
@project_name = "#{project.name}"
@user = user
@project = project
+ inviter_lists = InviteList.where(project_id:@project.id, user_id:@user.id).all
+ if inviter_lists.blank?
+ InviteList.create(:user_id => user.id, :project_id => project.id)
+ end
@token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
mail :to => email, :subject => @subject
diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb
index 7cad9bff3..ce7ea2aa1 100644
--- a/app/views/projects/invite_members_by_mail.html.erb
+++ b/app/views/projects/invite_members_by_mail.html.erb
@@ -45,44 +45,55 @@
}
-// if (filter.test(email)&& !(email.value == null)) return true;
-// else
-// {
-// document.getElementById('valid_email').innerHTML = "您所填写的电子邮件格式不正确";
-// document.getElementById('valid_email').style.color = "#FF0000";
-// return false;
-// }
-//
-// }
+ // if (filter.test(email)&& !(email.value == null)) return true;
+ // else
+ // {
+ // document.getElementById('valid_email').innerHTML = "您所填写的电子邮件格式不正确";
+ // document.getElementById('valid_email').style.color = "#FF0000";
+ // return false;
+ // }
+ //
+ // }
<%= l(:label_invite_join)%>
-
- <%= l(:label_invite_email_tips)%>
-
-
- <%= render :partial => 'regested', locals: { :isregisted => false} %>
-
- <%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get') do %>
-
-
- -
- <%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email), :onkeyup => "this.value=this.value.replace(' ','')", :style => "ime-mode:disabled;", :onblur => "verifyAddress(this);" %>
-
-
-
-
- <%= l(:label_send_email)%>
-
-
- <% end %>
-
-
+
+ <%= l(:label_invite_email_tips)%>
+
+
+ <%= render :partial => 'regested', locals: { :isregisted => false} %>
+
+ <%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get') do %>
+
+
+ -
+ <%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email), :onkeyup => "this.value=this.value.replace(' ','')", :style => "ime-mode:disabled;", :onblur => "verifyAddress(this);" %>
+
+
+
+
+ <%= l(:label_send_email)%>
+
+ <% end %>
+ <%# 邀请用户的状态 %>
+ <% unless @inviter_lists.blank? %>
+
+ 已邀请的用户
+ <% @inviter_lists.each do |inviter_list| %>
+ <%= inviter_list.user.name %>
+ <% end %>
+
+ 等待加入项目的用户
+ <% @inviter_lists.each do |inviter_list| %>
+ <% unless inviter_list.user.member_of?(@project) %>
+ <%= inviter_list.user.name %>
+ <% end %>
+ <% end %>
+
+ <% end %>
-<% @inviter_lists.each do |inviter_list| %>
- <%= inviter_list.user.name %>
- <% end
- %>
\ No newline at end of file
+
+
diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css
index 5a6d98fbe..6cba7011f 100644
--- a/public/stylesheets/project.css
+++ b/public/stylesheets/project.css
@@ -49,6 +49,7 @@ a.icon_removem{ background:url(../images/img_floatbox.png) -22px -33px no-repea
a:hover.icon_removem{background:url(../images/img_floatbox.png) -22px -61px no-repeat;}
a.btn_free{ background:#ff5722; display:block; text-align:center; color:#fff; padding:3px 0; width:80px; margin-bottom:10px;}
a:hover.btn_free{ background:#d63502;}
+.status_inviter{color: #3CA5C6;font-weight: bold; font-size: 14px }
/*成员邀请*/
.invi_search{ }
.invi_search_input{ border:1px solid #15bccf; width:180px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;}
From 52bbb92c9fa590fb94da0ed9f84e05c2465f9fdc Mon Sep 17 00:00:00 2001
From: huang
Date: Thu, 4 Jun 2015 14:42:56 +0800
Subject: [PATCH 07/12] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5?=
=?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=86=85=E5=AE=B9=E6=98=BE=E7=A4=BA=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=EF=BC=88=E6=96=B0=E7=BC=96=E8=BE=91=E5=99=A8=E4=B8=8B?=
=?UTF-8?q?=E4=B8=8D=E8=83=BD=E4=BD=BF=E7=94=A8=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/mailer.rb | 4 +---
app/views/mailer/news_added.html.erb | 20 +++++++++-----------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 56fe1e6a9..6df73225f 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -102,7 +102,7 @@ class Mailer < ActionMailer::Base
project_ids = projects.map{|project| project.id}.join(",")
course_ids = courses.map {|course| course.id}.join(",")
- # 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷
+ # 查询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"
@issues = Issue.find_by_sql(sql)
@@ -110,9 +110,7 @@ class Mailer < ActionMailer::Base
# @bids 查询课程作业,包括老师发布的作业,以及user提交作业
# @attachments查询课程课件更新
@attachments ||= []
-
@bids ||= [] # 老师发布的作业
-
unless courses.first.nil?
count = courses.count
count = count - 1
diff --git a/app/views/mailer/news_added.html.erb b/app/views/mailer/news_added.html.erb
index ca8f3c1b0..f214b8293 100644
--- a/app/views/mailer/news_added.html.erb
+++ b/app/views/mailer/news_added.html.erb
@@ -1,17 +1,15 @@
-
-
-
- <%= link_to(h("#{@news.author.login}(#{@news.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %>
-
- <%= l(:mail_issue_title_userin)%>
+
+ <%= link_to(h("#{@news.author.login}(#{@news.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %>
+ <%= l(:mail_issue_title_userin)%>
<% if @news.project %>
- <%=h @news.project.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
+ <%=h @news.project.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
<% elsif @news.course %>
- <%=h @news.course.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
- <% end %>
- <%= l(:mail_issue_title_active)%>
+ <%=h @news.course.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
+ <% end %>
+ <%= l(:mail_issue_title_active)%>
+
- <%= l(:mail_issue_subject)%>
@@ -25,7 +23,7 @@
- <%= l(:mail_issue_content)%>
- <%= @news.description %>
+ <%= @news.description.html_safe %>
From cd0752f5daa171c6c46fdab1fc622c8e8fd55204 Mon Sep 17 00:00:00 2001
From: yutao <283765470@qq.com>
Date: Thu, 4 Jun 2015 15:55:41 +0800
Subject: [PATCH 08/12] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?=
=?UTF-8?q?=E5=8C=BA=E5=8A=A8=E6=80=81=E4=B8=8E=E6=88=91=E7=9B=B8=E5=85=B3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../activity_notifys_controller.rb | 54 +++++++++++++++
app/controllers/boards_controller.rb | 43 +++++++++---
app/controllers/messages_controller.rb | 54 +++++++++++++++
app/models/activity_notify.rb | 3 +
app/models/message.rb | 16 +++++
.../activity_notifys/chang_read_flag.html.erb | 1 +
app/views/boards/_course_show.html.erb | 19 +++++-
app/views/boards/show.html.erb | 2 +
app/views/courses/show.html.erb | 64 ++++++++++++++++--
config/routes.rb | 6 ++
...20150604153000_create_activity_notifies.rb | 17 +++++
public/images/new.png | Bin 0 -> 4196 bytes
public/stylesheets/courses.css | 9 ++-
13 files changed, 270 insertions(+), 18 deletions(-)
create mode 100644 app/controllers/activity_notifys_controller.rb
create mode 100644 app/models/activity_notify.rb
create mode 100644 app/views/activity_notifys/chang_read_flag.html.erb
create mode 100644 db/migrate/20150604153000_create_activity_notifies.rb
create mode 100644 public/images/new.png
diff --git a/app/controllers/activity_notifys_controller.rb b/app/controllers/activity_notifys_controller.rb
new file mode 100644
index 000000000..c696836b2
--- /dev/null
+++ b/app/controllers/activity_notifys_controller.rb
@@ -0,0 +1,54 @@
+class ActivityNotifysController < ApplicationController
+# layout 'base_projects'#by young
+# default_search_scope :messages
+ before_filter :find_project_by_project_id#, :find_board_if_available
+# before_filter :authorize, :except => [:new, :show, :create, :index]
+# accept_rss_auth :index, :show
+
+ helper :activities
+ def index
+ query = nil
+ if @course
+ query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=?',@course.id,'Course',User.current.id);
+ else
+ @events_by_day = []
+ end
+
+ if( query != nil )
+ logger.info('xxoo')
+ limit = 10;
+ @obj_count = query.count();
+ @obj_pages = Paginator.new @obj_count,limit,params['page']
+ list = query.order('id desc').limit(limit).offset(@obj_pages.offset).all();
+ events=[];
+ for item in list
+ event = item.activity;
+ event.set_notify_id(item.id)
+ event.set_notify_is_read(item.is_read)
+ events << event
+ end
+ @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
+ @controller_name = 'ActivityNotifys'
+ logger.info('aavv')
+ end
+ respond_to do |format|
+ format.html {render :template => 'courses/show', :layout => 'base_courses'}
+ end
+ end
+
+ def chang_read_flag
+ if @course
+ if(params[:an_id] != nil )
+ query = ActivityNotify.where('id=? and notify_to=?',params[:an_id],User.current.id)
+ else
+ query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=? and is_read=0',@course.id,'Course',User.current.id)
+ end
+ @result = query.update_all('is_read=1');
+ else
+ @result = false;
+ end
+ respond_to do |format|
+ format.html{render :layout => nil}
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index db5bded55..6ff4d2f97 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -88,14 +88,40 @@ class BoardsController < ApplicationController
preload(:author, {:last_reply => :author}).
all
elsif @course
- board_topics = @board ? @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc").
- includes(:last_reply).
- # limit(@topic_pages.per_page).
- # offset(@topic_pages.offset).
-
- preload(:author, {:last_reply => :author}).
- all : []
- @topics = paginateHelper board_topics,10
+ #
+ # board_topics = @board ? @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc").
+ # includes(:last_reply).
+ # # limit(@topic_pages.per_page).
+ # # offset(@topic_pages.offset).
+ #
+ # preload(:author, {:last_reply => :author}).
+ # all : []
+ # @topics = paginateHelper board_topics,10
+ if( @board )
+ limit = 10;
+ pageno = params[:page];
+ if(pageno == nil || pageno=='')
+ dw_topic = nil;
+ if( params[:parent_id]!=nil && params[:parent_id]!='' )
+ dw_topic = @board.topics.where(id:params[:parent_id]).first();
+ end
+ if( dw_topic != nil )
+ dw_count = @board.topics.where('(sticky>?) or (sticky=? and created_on>?)',dw_topic.sticky,dw_topic.sticky,dw_topic.created_on).count();
+ dw_count = dw_count+1;
+ pageno = dw_count%10==0 ? (dw_count/limit) : (dw_count/limit+1)
+ end
+ end
+ if(pageno == nil || pageno=='')
+ pageno=1;
+ end
+ @topic_count = @board.topics.count();
+ @topic_pages = Paginator.new @topic_count, limit, pageno
+ @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc").
+ limit(limit).offset(@topic_pages.offset).includes(:last_reply).
+ preload(:author, {:last_reply => :author}).all();
+ else
+ @topics = [];
+ end
end
@message = Message.new(:board => @board)
@@ -103,6 +129,7 @@ class BoardsController < ApplicationController
if @project
render :action => 'show', :layout => 'base_projects'
elsif @course
+ @params=params
render :action => 'show', :layout => 'base_courses'
end
}
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index e33eb8d75..9e36d15f4 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -31,6 +31,8 @@ class MessagesController < ApplicationController
include AttachmentsHelper
helper :project_score
+ include CoursesHelper
+
REPLIES_PER_PAGE = 25 unless const_defined?(:REPLIES_PER_PAGE)
# Show a topic and its replies
@@ -91,6 +93,29 @@ class MessagesController < ApplicationController
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
end
+ # 与我相关动态的记录add start
+ if(@board.course_id>0) #项目的先不管
+ teachers = searchTeacherAndAssistant(@board.course);
+ for teacher in teachers
+ if(teacher.user_id != User.current.id)
+ notify = ActivityNotify.new()
+ if(@board.course_id>0)
+ notify.activity_container_id = @board.course_id
+ notify.activity_container_type = 'Course'
+ else
+ notify.activity_container_id = @board.project_id
+ notify.activity_container_type = 'Project'
+ end
+ notify.activity_id = @message.id
+ notify.activity_type = 'Message'
+ notify.notify_to = teacher.user_id
+ notify.is_read = 0
+ notify.save()
+ end
+ end
+ end
+ # 与我相关动态的记录add end
+
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
render_attachment_warning_if_needed(@message)
if params[:is_board]
@@ -151,6 +176,35 @@ class MessagesController < ApplicationController
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE
end
+
+ # 与我相关动态的记录add start
+ if(@board.course_id>0) #项目的先不管
+ notifyto_arr = {}
+ notifyto_arr[@topic.author_id] = @topic.author_id
+ if( params[:parent_topic] != nil && params[:parent_topic] != '')
+ parent_topic = Message.find(params[:parent_topic])
+ notifyto_arr[parent_topic.author_id] = parent_topic.author_id
+ end
+ notifyto_arr.each do |k,user_id|
+ if(user_id != User.current.id)
+ notify = ActivityNotify.new()
+ if(@board.course_id>0)
+ notify.activity_container_id = @board.course_id
+ notify.activity_container_type = 'Course'
+ else
+ notify.activity_container_id = @board.project_id
+ notify.activity_container_type = 'Project'
+ end
+ notify.activity_id = @reply.id
+ notify.activity_type = 'Message'
+ notify.notify_to = user_id
+ notify.is_read = 0
+ notify.save()
+ end
+ end
+ end
+ # 与我相关动态的记录add end
+
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply)
diff --git a/app/models/activity_notify.rb b/app/models/activity_notify.rb
new file mode 100644
index 000000000..0fbe1f6f1
--- /dev/null
+++ b/app/models/activity_notify.rb
@@ -0,0 +1,3 @@
+class ActivityNotify < ActiveRecord::Base
+ belongs_to :activity, polymorphic: true
+end
\ No newline at end of file
diff --git a/app/models/message.rb b/app/models/message.rb
index bbf62b5dc..15d358789 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -34,6 +34,8 @@ class Message < ActiveRecord::Base
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# end
+ has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
+
acts_as_searchable :columns => ['subject', 'content'],
:include => {:board => :project},
:project_key => "#{Board.table_name}.project_id",
@@ -148,6 +150,19 @@ class Message < ActiveRecord::Base
usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project)))
end
+ def set_notify_id(notify_id)
+ @notify_id= notify_id
+ end
+ def get_notify_id()
+ return @notify_id
+ end
+ def set_notify_is_read(notify_is_read)
+ @notify_is_read = notify_is_read
+ end
+ def get_notify_is_read()
+ return @notify_is_read
+ end
+
private
def add_author_as_watcher
@@ -218,4 +233,5 @@ class Message < ActiveRecord::Base
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
end
+
end
diff --git a/app/views/activity_notifys/chang_read_flag.html.erb b/app/views/activity_notifys/chang_read_flag.html.erb
new file mode 100644
index 000000000..ca89a7e3f
--- /dev/null
+++ b/app/views/activity_notifys/chang_read_flag.html.erb
@@ -0,0 +1 @@
+<%= @result == false ? 'false' : 'true' %>
\ No newline at end of file
diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb
index 0d9d6a780..48e5a870d 100644
--- a/app/views/boards/_course_show.html.erb
+++ b/app/views/boards/_course_show.html.erb
@@ -109,6 +109,7 @@
:html => {:nhname=>"form",:multipart => true, :id => 'message_form' + topic.id.to_s, :name=>'message-form'} do |f| %>
<%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
+
<%= l(:button_cancel)%>
@@ -127,7 +128,7 @@
<% replies_all.each do |message| %>
<% replies_all_i=replies_all_i+1 %>
- -
+
-
<%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %>
<%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
@@ -151,6 +152,7 @@
:nhname =>'showbtn_child_reply',
:class => ' c_dblue fr',
:style => 'margin-right: 10px;',
+ 'data-topic-id' =>message.id,
:title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %>
@@ -172,7 +174,8 @@
<%= l(:label_no_data) %>
<% end %>
- <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
+ <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
+ <%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => false, :flag => true %>
<%# other_formats_links do |f| %>
<%#= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
@@ -255,6 +258,18 @@
}
nh_init_board(params);
});
+
+ <% if( @params[:topic_id]!=nil && @params[:topic_id]!='' && @params[:page]==nil ) %>
+ var nh_dw_html = $("#topic<%=@params[:topic_id]%>");
+ if(nh_dw_html!=undefined && nh_dw_html.length!=0){
+ if(nh_dw_html.is(':hidden')){
+ $("a[nhname='reply_ex_btn']",nh_dw_html.parent('ul').parent('div').parent('div')).click();
+ }
+ $("#nhjump").attr('href','#'+nh_dw_html.attr('id'));
+ $("#nhjump")[0].click();
+
+ }
+ <% end %>
<% if(!@flag.nil? && @flag=='true') %>
if($("#new_topic_btn")!=undefined)$("#new_topic_btn").click();
<% end %>
diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb
index 863d524ec..a86cee5bf 100644
--- a/app/views/boards/show.html.erb
+++ b/app/views/boards/show.html.erb
@@ -201,6 +201,8 @@ function nh_init_board(params){
params.cancelbtn.click();
}
}
+ var parent_topic_id = $(this).data('topic-id');
+ if(parent_topic_id!=undefined)$("input[name='parent_topic']",params.form).val(parent_topic_id);
var ref_str = params.get_ref_str_call($(this));
params.quote_show.html(ref_str);
params.quote_input.html(ref_str);
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb
index cc3bb33f1..0feca0d1b 100644
--- a/app/views/courses/show.html.erb
+++ b/app/views/courses/show.html.erb
@@ -1,11 +1,22 @@
-
<%= l(:label_activity)%>
+<% if @controller_name=='ActivityNotifys' %>
+
<%= l(:label_activity)%>
+
与我相关
+
+
+
+<% else %>
+
<%= l(:label_activity)%>
+ <% if User.current.logged? %>
+
与我相关
+ <% end %>
+<% end %>
<% if @events_by_day != nil && @events_by_day.size >0 %>
<% @events_by_day.keys.sort.reverse.each do |day| %>
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
-
+
<%= image_tag(url_to_avatar(e.event_author), :width => "42", :height => "42") %>
@@ -14,8 +25,19 @@
<%= link_to_user_header("(#{e.event_author})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName && e.respond_to?(:event_author) %>
<%= l(:label_new_activity) %>:
- <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) :
- (e.event_type.eql?("bid") ? homework_course_path(@course) : (e.event_type.eql?("message") || e.event_type.eql?("reply") ? course_boards_path(@course,:topic_id => e.id) : e.event_url)),:class => "problem_tit c_dblue fl fb"%>
+ <%
+ link = (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) :
+ (e.event_type.eql?("bid") ? homework_course_path(@course) :
+ (e.event_type.eql?("message") || e.event_type.eql?("reply") ?
+ course_boards_path(@course,:topic_id => e.id,:parent_id=>(e.parent_id ? e.parent_id : e.id)) : e.event_url))
+ %>
+ <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link,
+ :class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
+ 'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
+ 'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
+ <%if @controller_name=='ActivityNotifys' && !e.get_notify_is_read%>
+
+ <%end%>
<%= e.event_description.html_safe %>
@@ -28,7 +50,7 @@
<% end%>
<% end%>
<% end%>
-<% if @obj_pages.next_page.nil? %>
+<% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %>
<%= image_tag(url_to_avatar(@user), :width => "42", :height => "42") %>
@@ -51,3 +73,35 @@
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index bd4464458..e166e37e5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -710,6 +710,12 @@ RedmineApp::Application.routes.draw do
resources :news, :except => [:show, :edit, :update, :destroy]
resources :boards
match '/homework', :to => 'courses#homework', :as => 'homework', :via => :get
+ resources :activity_notifys do
+ collection do
+ match 'chang_read_flag', :via => :get
+ end
+ end
+
end # end of resources :courses
match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback'
match '/courses/search', :via => [:get, :post]
diff --git a/db/migrate/20150604153000_create_activity_notifies.rb b/db/migrate/20150604153000_create_activity_notifies.rb
new file mode 100644
index 000000000..ff9b78389
--- /dev/null
+++ b/db/migrate/20150604153000_create_activity_notifies.rb
@@ -0,0 +1,17 @@
+class CreateActivityNotifies < ActiveRecord::Migration
+ def change
+ create_table :activity_notifies do |t|
+ t.integer :activity_container_id
+ t.string :activity_container_type
+ t.integer :activity_id
+ t.string :activity_type
+ t.integer :notify_to
+ t.datetime :created_on
+ t.integer :is_read
+
+ end
+ add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to"
+ add_index "activity_notifies", ["created_on"], :name => "index_an_created_on"
+ add_index "activity_notifies", ["activity_container_id","activity_container_type"], :name => "index_an_activity_container_id"
+ end
+end
\ No newline at end of file
diff --git a/public/images/new.png b/public/images/new.png
new file mode 100644
index 0000000000000000000000000000000000000000..91d15f3b1f008db25735bfeedb425d1eb38b6c33
GIT binary patch
literal 4196
zcmV-q5S#CbP)KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA
z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e
zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5
z07D)V%>y7z1E4U{zu>7~aD})?0RX_umCct+(lZpemCzb@^6=o|A>zVpu|i=NDG+7}
zl4`aK{0#b-!z=TL9Wt0BGO&T{GJWpjryhdijfaIQ&2!o}p04JRKYg3k&Tf
zVxhe-O!X
z{f;To;xw^bEES6JSc$k$B2CA6xl)ltA<32E66t?3@gJ7`36pmX0IY^jz)rRYwaaY4
ze(nJRiw;=Qb^t(r^DT@T3y}a2XEZW-_W%Hszxj_qD**t_m!#tW0KDiJT&R>6OvVTR
z07RgHDzHHZ48atvzz&?j9lXF70$~P3Knx_nJP<+#`N
z#-MZ2bTkiLfR>_b(HgWKJ%F~Nr_oF3b#wrIijHG|(J>BYjM-sajE6;FiC7vY#};Gd
zST$CUHDeuEH+B^pz@B062qXfFfD`NpUW5?BY=V%GM_5c)L#QR}BeW8_2v-S%gfYS=
zB9o|3v?Y2H`NVi)In3rTB8+ej^>
zQ=~r95NVuDChL%G$=>7$vVg20myx%S50Foi`^m%Pw-h?Xh~i8Mq9jtJloCocWk2Nv
zrJpiFnV_ms&8eQ$2WpIS+6pmtC%Q-`S&GF4Q#^mhymh7E(qNMa}%YZ-ePrx>>xFPTiH1=E+A$W$=bG8>s^
zm=Bn5Rah$aDtr}@$`X}2l~$F0mFKEdRdZE8)p@E5RI61Ft6o-prbbn>P~)iy)E2AN
zsU20jsWz_8Qg>31P|s0cqrPALg8E|(vWA65poU1JRAaZs8I2(p#xiB`SVGovRs-uS
zYnV-9TeA7=Om+qP8+I>yOjAR1s%ETak!GFdam@h^#
z)@rS0t$wXH+Irf)+G6c;?H29p+V6F6oj{!|o%K3xI`?%6x;DB|x`n#ibhIR?(H}Q3Gzd138Ei2)WAMz7W9Vy`X}HnwgyEn!VS)>mv$8&{hQn>w4zwy3R}t;BYlZQm5)6pty=DfLrs+A-|>>;~;Q
z_F?uV_HFjh9n2gO9o9Q^JA86v({H5aB!kjoO6
zc9$1ZZKsN-Zl8L~mE{`ly3)1N^`o1+o7}D0ZPeY&J;i;i`%NyJ8_8Y6J?}yE@b_5a
zam?eLr<8@mESk|3$_SkmS{wQ>%qC18))9_|&j{ZT
zes8AvOzF(F2#DZEY>2oYX&IRp`F#{ADl)1r>QS^)ba8a|EY_^#S^HO&t^Rgqwv=MZThqqEWH8
zxJo>d=ABlR_Bh=;eM9Tw|Ih34~oTE|=
zX_mAr*D$vzw@+p(E0Yc6dFE}(8oqt`+R{gE3x4zjX+Sb3_cYE^=
zgB=w+-tUy`ytONMS8KgRef4hA?t0j
zufM;t32jm~jUGrkaOInTZ`zyfns>EuS}G30LFK_G-==(f<51|K&cocp&EJ`SxAh3?
zNO>#LI=^+SEu(FqJ)ynt=!~PC9bO$rzPJB=?=j6w@a-(u02P7
zaQ)#(uUl{HW%tYNS3ItC^iAtK(eKlL`f9+{bJzISE?u8_z3;~C8@FyI-5j_jy7l;W
z_U#vU3hqqYU3!mrul&B+{ptt$59)uk{;_4iZQ%G|z+lhASr6|H35TBkl>gI*;nGLU
zN7W-nBaM%pA0HbH8olyl&XeJ%vZoWz%6?Y=dFykl=imL}`%BMQ{Mhgd`HRoLu6e2R
za__6DuR6yg#~-}Tc|Gx_{H@O0eebyMy5GmWADJlpK>kqk(fVV@r_fLLKIeS?{4e)}
z^ZO;zpECde03c&XQcVB=dL;k=fP(-4`Tqa_faw4Lbua(`>RI+y?e7jKeZ#YO-C
z1(8WaK~#9!l$L#L)zultzrWx4z1`ovx3|1?=8g@NPLWk9w51I$L*vXc{9~gbVbjII
zia21JbXoS6WrLVyTQ&r^ri7ZF_4A1EwMpsL*05_x1OFe&79J
zMi4`kCwY?doIE*s&N=x!-v=adGd@geSL43JwIl66{t;j6th+uh?Cq@MhG!Sw%-IS_
ze3Au!c;+Fe^S}euU!AuFJw}mZq~;2?Gd&02%}$(?&6lA*4jL9wP5cSf&AM=kJ%uX){hMr_N7Ri%x3%?8wyo0}KBB
z`NsM|ttK1axR{>4>8JO++**6^UklvWRMmz%22C~8@>_TPBoj+SiV8ip;h+r77Jw%q
zbOS|6q+j);Zj}N3b4}3hy&a{)XOKMB53%BLVEb=?7?5r4kf8@di{ZSHgLSeW%6FfD(*Ft&
zRRaxk;qTlGDHIrO%b?|Q;Oh3TDPCw56d*JE?m;TIM3N;kQtZ^uw+4VQo%e
zEMs9p#~SFnZ$&<+LiM+oz)U+R(15aWJtD0JV#U&z;#3uqx7_)<*WR|?Uh(KZ001Q6
z|M_oU;nLN=4y+o60EslIfh99Z51@Cvmm$fxdx*u{t7O+9dJ0&$XCZlcl>V-rl=TZJ
z)g)OrkE0|jo3@Z8@*GKj(JGP-E8G4~35!w%soLb9I=*o&O;;Cg?!e6Q6K$lKCXwV=
z5_Hoka^?ckaT)ZVV$luBkn}fhVkeqA22l)r6c8bis=|aB)6dl0ar@h`skxA$26lJd=Iz+NFu!W`&$)d0ldNlE
zMW_st)eHeT@AT3Q$LOXt(!0Qzl0{XJB0=`{@B@yt9Q;TFH3N8VFER;<{N9&g41a*~rE!!mkH9+A1^q8C
z!pqt)w(Wz_eGmcyYEu&``HL{KpM~tkqpJ2tgyn|8MeQP31=NAL@F
z^ww~#7THtB#3f9QC&E?7kx&3c8XR3kzz`C|Bq1h;yBJPM=Cq3m4Su_r`y?_6PpVFCXB#
ujUT<~mJN&FU%B!ZmB)U$_GTx7{|x{wyZId*o|ohR0000
Date: Thu, 4 Jun 2015 16:12:49 +0800
Subject: [PATCH 09/12] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?=
=?UTF-8?q?=E5=8C=BA=E7=BC=96=E8=BE=91=E6=A1=86=E8=A1=A8=E6=83=85=20?=
=?UTF-8?q?=E8=A7=A3=E5=86=B3ie=E6=B5=8F=E8=A7=88=E5=99=A8=E6=A0=B7?=
=?UTF-8?q?=E5=BC=8F=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/boards/show.html.erb | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb
index a86cee5bf..f25e690d0 100644
--- a/app/views/boards/show.html.erb
+++ b/app/views/boards/show.html.erb
@@ -1,11 +1,11 @@
-