|
|
|
@ -103,11 +103,14 @@ class MessagesController < ApplicationController
|
|
|
|
|
return normal_status(403, "您没有权限进行该操作") if current_user != @message.author && !current_user.teacher_of_course?(@message.board.course)
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
h = {is_md: true}
|
|
|
|
|
email_notify = @message.email_notify ? 1 : @board.course.email_notify && params[:email_notify]
|
|
|
|
|
send_email = !@message.email_notify && email_notify
|
|
|
|
|
h = {is_md: true, email_notify: email_notify}
|
|
|
|
|
m_params = message_params.merge(h)
|
|
|
|
|
@message.update_attributes(m_params)
|
|
|
|
|
Attachment.associate_container(params[:attachment_ids], @message.id, @message.class.name)
|
|
|
|
|
@message.update_content(params[:content])
|
|
|
|
|
notify_course_students(@message, @board.course) if send_email
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
tip_exception("修改失败")
|
|
|
|
@ -123,6 +126,7 @@ class MessagesController < ApplicationController
|
|
|
|
|
@message.author = current_user
|
|
|
|
|
@message.board_id = params[:select_board_id]
|
|
|
|
|
@message.message_detail_attributes = {content: params[:content]}
|
|
|
|
|
@message.email_notify = @board.course.email_notify && params[:email_notify] ? 1 : 0
|
|
|
|
|
@message.save!
|
|
|
|
|
Attachment.associate_container(params[:attachment_ids], @message.id, @message.class.name)
|
|
|
|
|
if @board.course.email_notify && params[:email_notify]
|
|
|
|
|