Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
parent
8e61136d7f
commit
8773842801
|
@ -103,8 +103,17 @@ class MessagesController < ApplicationController
|
|||
redirect_to board_message_url(@board, @message)
|
||||
end
|
||||
else
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :action => 'new', :layout => layout_file
|
||||
if params[:is_board]
|
||||
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
|
||||
else
|
||||
respond_to do |format|
|
||||
|
@ -119,7 +128,15 @@ class MessagesController < ApplicationController
|
|||
# Reply to a topic
|
||||
def reply
|
||||
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
|
||||
@quote = params[:quote][:quote]
|
||||
@reply = Message.new
|
||||
|
@ -155,11 +172,20 @@ class MessagesController < ApplicationController
|
|||
# Edit a message
|
||||
def edit
|
||||
@isReply = false
|
||||
if @project
|
||||
(render_403; return false) unless @message.editable_by?(User.current)
|
||||
if params[:is_board]
|
||||
if @project
|
||||
(redirect_to project_boards_path(@project); return false)
|
||||
elsif @course
|
||||
(redirect_to course_boards_path(@course); return false)
|
||||
end
|
||||
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
|
||||
|
||||
@message.safe_attributes = params[:message]
|
||||
if request.post? && @message.save
|
||||
attachments = Attachment.attach_files(@message, params[:attachments])
|
||||
|
|
Loading…
Reference in New Issue