1.用户请求加入课程成为老师或者教师时,给课程创建者发送邮件;

2.更新相应消息的状态
This commit is contained in:
ouyangxuhua 2015-10-26 17:24:32 +08:00
parent 5fb1291bf8
commit b0b1a27908
6 changed files with 26 additions and 4 deletions

View File

@ -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')

View File

@ -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(",") + ")"

View File

@ -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

View File

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

View File

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

View File

@ -27,7 +27,7 @@ zh:
# 资源库 (课程、项目按类型分)
label_course_file: 资源库
label_upload_files: 上传资源
label_apply_join_course: 申请加入课程
#
# 课程托管平台主页
#