Signed-off-by: alan <547533434@qq.com>

This commit is contained in:
alan 2015-05-11 17:35:36 +08:00
parent 8e61136d7f
commit 8773842801
1 changed files with 32 additions and 6 deletions

View File

@ -103,8 +103,17 @@ class MessagesController < ApplicationController
redirect_to board_message_url(@board, @message) redirect_to board_message_url(@board, @message)
end end
else else
layout_file = @project ? 'base_projects' : 'base_courses' if params[:is_board]
render :action => 'new', :layout => layout_file if @project
redirect_to project_boards_path(@project, :flag => true)
elsif @course
redirect_to course_boards_path(@course, :flag => true)
end
else
layout_file = @project ? 'base_projects' : 'base_courses'
render :action => 'new', :layout => layout_file
end
end end
else else
respond_to do |format| respond_to do |format|
@ -119,7 +128,15 @@ class MessagesController < ApplicationController
# Reply to a topic # Reply to a topic
def reply def reply
if params[:reply][:content] == "" if params[:reply][:content] == ""
(redirect_to board_message_url(@board, @topic, :r => @reply), :notice => l(:label_reply_empty);return) if params[:is_board]
if @project
(redirect_to project_boards_path(@project), :notice => l(:label_reply_empty);return)
elsif @course
(redirect_to course_boards_path(@course), :notice => l(:label_reply_empty);return)
end
else
(redirect_to board_message_url(@board, @topic, :r => @reply), :notice => l(:label_reply_empty);return)
end
end end
@quote = params[:quote][:quote] @quote = params[:quote][:quote]
@reply = Message.new @reply = Message.new
@ -155,11 +172,20 @@ class MessagesController < ApplicationController
# Edit a message # Edit a message
def edit def edit
@isReply = false @isReply = false
if @project if params[:is_board]
(render_403; return false) unless @message.editable_by?(User.current) if @project
(redirect_to project_boards_path(@project); return false)
elsif @course
(redirect_to course_boards_path(@course); return false)
end
else else
(render_403; return false) unless @message.course_editable_by?(User.current) if @project
(render_403; return false) unless @message.editable_by?(User.current)
else
(render_403; return false) unless @message.course_editable_by?(User.current)
end
end end
@message.safe_attributes = params[:message] @message.safe_attributes = params[:message]
if request.post? && @message.save if request.post? && @message.save
attachments = Attachment.attach_files(@message, params[:attachments]) attachments = Attachment.attach_files(@message, params[:attachments])