From daecf1a53b83aca4dd59043be4a681d8ebb2c47a Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 28 May 2014 14:17:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=80=81=E5=B8=88=E6=94=B6=E5=88=B0?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=95=99=E8=A8=80=E5=8C=BA=E7=9A=84=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E7=95=99=E8=A8=80=E5=8F=8A=E5=AF=B9=E8=80=81=E5=B8=88?= =?UTF-8?q?=E7=9A=84=E5=9B=9E=E5=A4=8D=E7=9A=84=E9=82=AE=E4=BB=B6=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message_observer.rb | 2 -- app/models/mailer.rb | 34 +++++++++++++-------- config/locales/en.yml | 3 +- config/locales/zh.yml | 2 ++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb index e5fdfb18..093002a2 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 a303d92b..e0ad5429 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/config/locales/en.yml b/config/locales/en.yml index 22422c42..76b820bd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1617,6 +1617,7 @@ en: label_class_hour: period label_activity_time: publish date - + label_your_course: your course + label_have_message : have a new message # ajax异步验证 modal_valid_passing: can be used. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 39749b69..7f20912f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1497,6 +1497,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: 查看如何提交代码: From 1c92007ac675fff9b9c8642fa89e4036daabfb5b Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 28 May 2014 15:31:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E5=8A=A8=E6=80=81=E6=94=B9=E4=B8=BA=20?= =?UTF-8?q?=E6=98=B5=E7=A7=B0=EF=BC=88=E7=9C=9F=E5=90=8D=EF=BC=89=20?= =?UTF-8?q?=E5=BD=A2=E5=BC=8F=E6=98=BE=E7=A4=BA=EF=BC=88=E5=AF=B9=E8=AF=A5?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=9A=84=E8=80=81=E5=B8=88=E5=8A=A9=E6=95=99?= =?UTF-8?q?=EF=BC=89=20=E4=BD=9C=E4=B8=9A=E9=87=8C=E8=80=81=E5=B8=88?= =?UTF-8?q?=E5=8A=A9=E6=95=99=E7=9C=8B=E5=88=B0=E7=9C=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- app/views/bids/_homework_list.html.erb | 4 ++-- app/views/projects/show.html.erb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 45ebaf24..dd83f895 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -140,7 +140,7 @@ module CoursesHelper def is_course_teacher user,project is_teacher = false searchTeacherAndAssistant(project).each do |teacher| - if user == teacher + if user == teacher.user is_teacher = true break end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index f7db8a37..b650f2cb 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -51,7 +51,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)%> 作业评分: @@ -71,7 +71,7 @@   - <% if display_id %> + <% if display_id || is_teacher %> <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> <% end %> diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index dfe8a10b..173fc26a 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 %>