From 586cde6f87c1d89fac58681b2449c7aa07ec73d9 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 26 Oct 2015 09:04:09 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=88=90=E4=B8=BA=E8=AF=BE=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E8=80=81=E5=B8=88=E6=88=96=E6=95=99=E8=BE=85=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7425692c0..2ffc7338e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -918,6 +918,9 @@ class UsersController < ApplicationController end def show + #更新用户申请成为课程老师或教辅消息的状态 + join_course_messages = CourseMessage.where("course_message_type =? and course_message_id =? and viewed =?", 'JoinCourseRequest', @user.id, false) + join_course_messages.update_all(:viewed => true) @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" From d509ef01e83ed4fe03cf53f18556853751ed8007 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 26 Oct 2015 13:26:49 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=8F=8D=E9=A6=88=E7=9A=84=E6=B6=88=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 5 +++++ app/controllers/courses_controller.rb | 4 ++++ app/controllers/users_controller.rb | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 86c220bd2..7632cf591 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -381,6 +381,11 @@ class ApplicationController < ActionController::Base if allowed true else + if params[:action] == 'show' + #更新申请结果反馈消息的状态 + messages = CourseMessage.where("course_message_type =? and course_id =? and user_id =? and viewed =?", 'CourseRequestDealResult', @course.id, User.current.id, false) + messages.update_all(:viewed => true) + end if @course && @course.archived? render_403 :message => :notice_not_authorized_archived_project else diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 56252253a..042311961 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -617,6 +617,10 @@ class CoursesController < ApplicationController create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) create_course_messages.update_all(:viewed => true) + #更新申请结果反馈消息的状态 + course_request_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @course.id, 'CourseRequestDealResult', false) + course_request_messages.update_all(:viewed => true) + course_activities = @course.course_activities @canShowRealName = User.current.member_of_course? @course @page = params[:page] ? params[:page].to_i + 1 : 0 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2ffc7338e..e2edcb44a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -919,7 +919,8 @@ class UsersController < ApplicationController def show #更新用户申请成为课程老师或教辅消息的状态 - join_course_messages = CourseMessage.where("course_message_type =? and course_message_id =? and viewed =?", 'JoinCourseRequest', @user.id, false) + join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", + params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) join_course_messages.update_all(:viewed => true) @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" From 5fb1291bf8b15c84e7fb5ee6a4c96d6039dc3721 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 26 Oct 2015 14:15:23 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/users/_user_message_course.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e2edcb44a..2a646f5ce 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -919,7 +919,7 @@ class UsersController < ApplicationController def show #更新用户申请成为课程老师或教辅消息的状态 - join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", + join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and u ser_id =? and course_message_id =? and viewed =?", params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) join_course_messages.update_all(:viewed => true) @page = params[:page] ? params[:page].to_i + 1 : 0 diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index d7042b6c2..2398fd8c5 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -442,7 +442,7 @@ ">您有了新的课程成员申请:
  • - <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id)), + <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> From b0b1a2790818c8c32086b5117cba771021ccd72e Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 26 Oct 2015 17:24:32 +0800 Subject: [PATCH 4/5] =?UTF-8?q?1.=E7=94=A8=E6=88=B7=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E6=88=90=E4=B8=BA=E8=80=81?= =?UTF-8?q?=E5=B8=88=E6=88=96=E8=80=85=E6=95=99=E5=B8=88=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E7=BB=99=E8=AF=BE=E7=A8=8B=E5=88=9B=E5=BB=BA=E8=80=85=E5=8F=91?= =?UTF-8?q?=E9=80=81=E9=82=AE=E4=BB=B6=EF=BC=9B=202.=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=BA=94=E6=B6=88=E6=81=AF=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/controllers/users_controller.rb | 8 +++++--- app/models/mailer.rb | 11 +++++++++++ app/views/mailer/join_course_request.html.erb | 4 ++++ app/views/mailer/join_course_request.text.erb | 4 ++++ config/locales/courses/zh.yml | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 app/views/mailer/join_course_request.html.erb create mode 100644 app/views/mailer/join_course_request.text.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 042311961..a49126a6c 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -37,6 +37,7 @@ class CoursesController < ApplicationController join = cs.join_course params,@user @state = join[:state] @course = join[:course] + Mailer.run.join_course_request(@course, User.current, params[:role]) # else # @course = Course.find_by_id params[:object_id] # CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2a646f5ce..6d049783e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -919,9 +919,11 @@ class UsersController < ApplicationController def show #更新用户申请成为课程老师或教辅消息的状态 - join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and u ser_id =? and course_message_id =? and viewed =?", - params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) - join_course_messages.update_all(:viewed => true) + if params[:course_id] != nil + join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", + params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) + join_course_messages.update_all(:viewed => true) + end @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" diff --git a/app/models/mailer.rb b/app/models/mailer.rb index d797f1ce1..8891e6552 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -1009,6 +1009,16 @@ class Mailer < ActionMailer::Base end end + def join_course_request(course, user, role) + @receive = User.find(course.tea_id) + @course = course + @user = user + @role = role + @subject = "#{@user.show_name} #{l(:label_apply_join_course)} #{@course.name} " + mail :to => @receive.mail, + :subject => @subject + end + private @@ -1066,4 +1076,5 @@ class Mailer < ActionMailer::Base 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } return newpass end + end diff --git a/app/views/mailer/join_course_request.html.erb b/app/views/mailer/join_course_request.html.erb new file mode 100644 index 000000000..680b9c9df --- /dev/null +++ b/app/views/mailer/join_course_request.html.erb @@ -0,0 +1,4 @@ +

    + <%= @user.show_name %>申请成为课程<%= @course.name %>的<%= @role.eql?('9') ? '老师': '教辅' %> + <%=link_to user_message_url(@receive),user_message_url(@receive)%> +

    diff --git a/app/views/mailer/join_course_request.text.erb b/app/views/mailer/join_course_request.text.erb new file mode 100644 index 000000000..62e2315c5 --- /dev/null +++ b/app/views/mailer/join_course_request.text.erb @@ -0,0 +1,4 @@ +<%= @user.show_name %>申请成为课程<%= @course.name %>的<%= @role.eql?('9') ? '老师': '教辅' %> +<%=link_to user_message_url(@receive),user_message_url(@receive)%> + + diff --git a/config/locales/courses/zh.yml b/config/locales/courses/zh.yml index 498388cfc..585ef7bec 100644 --- a/config/locales/courses/zh.yml +++ b/config/locales/courses/zh.yml @@ -27,7 +27,7 @@ zh: # 资源库 (课程、项目按类型分) label_course_file: 资源库 label_upload_files: 上传资源 - + label_apply_join_course: 申请加入课程 # # 课程托管平台主页 # From f5a498a5950d64d7fb0d61ef711d3b7357174391 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 27 Oct 2015 09:29:54 +0800 Subject: [PATCH 5/5] =?UTF-8?q?1.=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6=EF=BC=9B?= =?UTF-8?q?=202.=E8=A7=A3=E5=86=B3360=E6=B5=8F=E8=A7=88=E5=99=A8=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=AD=A3=E7=A1=AE=E6=98=BE=E7=A4=BA=E2=80=9C=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E8=AF=84=E9=98=85=E4=BA=86=E4=BD=9C=E5=93=81=E2=80=9D?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 2 ++ app/views/users/_user_message_course.html.erb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index fb01e0398..b388b660c 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -317,6 +317,7 @@ class CoursesService elsif current_user.allowed_to?(:as_teacher,course) @state = 3 else + Mailer.run.join_course_request(course, User.current, params[:role]) #如果加入角色为教师或者教辅 CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) @state = 6 @@ -337,6 +338,7 @@ class CoursesService if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0 @state = 7 else + Mailer.run.join_course_request(course, User.current, params[:role]) CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) @state = 6 end diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 2398fd8c5..afbeb5ed5 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -309,7 +309,7 @@ <% content = ma.content.gsub("作业评分:","").split("    评语:")%>
  • 作品评分:<%= content[0] %>分
  • <% if content.size > 1 %> -
  • 作品评语:
  • +
  • 作品评语:
  • <%= content[1] %>
    <% end %>