diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb index e5fdfb187..093002a2c 100644 --- a/app/models/journals_for_message_observer.rb +++ b/app/models/journals_for_message_observer.rb @@ -1,9 +1,7 @@ # Added by young class JournalsForMessageObserver < ActiveRecord::Observer def after_create(journals_for_message) - Thread.new do Mailer.journals_for_message_add(User.current, journals_for_message).deliver - end end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a303d92bf..e0ad54296 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -44,16 +44,7 @@ class Mailer < ActionMailer::Base when :Bid respond_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") when :Project - if journals_for_message.jour.project_type == 1 - project = journals_for_message.jour - @teachers = searchTeacherAndAssistant journals_for_message.jour - @recipients ||= [] - @teachers.each do |teacher| - @recipients << teacher - end - mail :to => @recipients, - :subject => "您的课程#{journals_for_message.jour.name}中有了新的留言" - end + return -1 if journals_for_message.jour.project_type == Project::ProjectType_project project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") when :Contest show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") @@ -63,7 +54,23 @@ class Mailer < ActionMailer::Base logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}" return -1 end - mail :to => @mail.mail, :subject => @title + #如果是直接留言并且留言对象是Project并且Project类型是课程 + if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Project && journals_for_message.jour.project_type == 1 + project = journals_for_message.jour + #课程的教师 + @teachers = searchTeacherAndAssistant journals_for_message.jour + #收件人邮箱 + @recipients ||= [] + @teachers.each do |teacher| + @recipients << teacher.user.mail + end + mail :to => @recipients, + :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} " + else + mail :to => @mail.mail, :subject => @title + end + + end # Builds a Mail::Message object used to email recipients of the added issue. @@ -433,7 +440,10 @@ class Mailer < ActionMailer::Base headers[:to].delete(@author.mail) if headers[:to].is_a?(Array) headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array) end - + if !User.current.nil? + #不给本人发邮件 + headers[:to].delete(User.current.mail) if headers[:to].is_a?(Array) + end if @author && @author.logged? redmine_headers 'Sender' => @author.login end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 48cc16c6e..aa4140f95 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -57,7 +57,7 @@   - 发布人:  <%= link_to (display_id ? homework.user.realname : homework.user ), user_path(homework.user)%> + 发布人:  <%= link_to ( is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%> 作业评分: diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index dfe8a10b9..173fc26a4 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -18,7 +18,7 @@ <%= h(e.project) if @project.nil? || @project.id != e.project.id %> - <%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %> + <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>(<%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %>) <%= l(:label_new_activity) %> <%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %> @@ -86,7 +86,7 @@ #判断是否显示真名 if @canShowRealName %> - <%= link_to (h @user.try(:realname)), user_path(@user) if @user %> + <%= link_to (h @user.try(:name)), user_path(@user) if @user %>(<%= link_to (h @user.try(:realname)), user_path(@user) if @user %>) <% else %> <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 20fc758c0..f19e076c0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1617,6 +1617,8 @@ en: label_class_hour: period label_activity_time: publish date + label_your_course: your course + label_have_message : have a new message label_login_prompt: Email/NickName # ajax异步验证 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 739edff85..a0d90f8a2 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1499,6 +1499,8 @@ zh: label_tags_numbers: Tag统计: label_max_number: 昵称是在网站中显示的您的公开标识,至多25个字符。 label_mail_attention: qq邮箱可能收不到此邮件,其他邮箱如果没有收到可能在垃圾邮件中,其中gmail与教育网邮箱的激活邮件有时比较慢,请耐心等待。 + label_your_course: 您的课程《 + label_have_message : 》有新的留言 label_all_revisions: 所有版本: label_upassword_info: 该密码在项目组内可共享 label_how_commit_code: 查看如何提交代码: