发布帖子不能删除

This commit is contained in:
huang 2015-05-08 15:02:04 +08:00
parent 89ea9ddc7b
commit f7ad600dde
1 changed files with 14 additions and 41 deletions

View File

@ -93,15 +93,7 @@ class MessagesController < ApplicationController
end end
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
render_attachment_warning_if_needed(@message) render_attachment_warning_if_needed(@message)
if params[:is_board]
if @project
redirect_to project_boards_path(@project)
elsif @course
redirect_to course_boards_path(@course)
end
else
redirect_to board_message_url(@board, @message) redirect_to board_message_url(@board, @message)
end
else else
layout_file = @project ? 'base_projects' : 'base_courses' layout_file = @project ? 'base_projects' : 'base_courses'
render :action => 'new', :layout => layout_file render :action => 'new', :layout => layout_file
@ -140,15 +132,8 @@ class MessagesController < ApplicationController
else else
#render file: 'messages#show', layout: 'base_courses' #render file: 'messages#show', layout: 'base_courses'
end end
if params[:is_board]
if @project
redirect_to project_boards_path(@project)
elsif @course
redirect_to course_boards_path(@course)
end
else
redirect_to board_message_url(@board, @topic, :r => @reply) redirect_to board_message_url(@board, @topic, :r => @reply)
end
end end
# Edit a message # Edit a message
@ -165,15 +150,7 @@ class MessagesController < ApplicationController
render_attachment_warning_if_needed(@message) render_attachment_warning_if_needed(@message)
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
@message.reload @message.reload
if params[:is_board]
if @project
redirect_to project_boards_path(@project)
elsif @course
redirect_to course_boards_path(@course)
end
else
redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)) redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id))
end
elsif request.get? elsif request.get?
respond_to do |format| respond_to do |format|
format.html { format.html {
@ -195,15 +172,12 @@ class MessagesController < ApplicationController
@message.destroy @message.destroy
# modify by nwb # modify by nwb
if @project if @project
if params[:is_board] if @message.parent
redirect_to project_boards_url(@project) redirect_to board_message_url(@board, @message.parent, :r => r)
else else
redirect_to board_message_url(@board, @topic, :r => @reply) redirect_to project_boards_url(@project)
end end
elsif @course elsif @course
if params[:is_board]
redirect_to course_boards_url(@course)
else
if @message.parent if @message.parent
redirect_to board_message_url(@board, @message.parent, :r => r) redirect_to board_message_url(@board, @message.parent, :r => r)
else else
@ -211,7 +185,6 @@ class MessagesController < ApplicationController
end end
end end
end end
end
def quote def quote
@subject = @message.subject @subject = @message.subject
@ -229,7 +202,7 @@ class MessagesController < ApplicationController
render :partial => 'common/preview' render :partial => 'common/preview'
end end
private private
def find_message def find_message
return unless find_board return unless find_board
@message = @board.messages.find(params[:id], :include => :parent) @message = @board.messages.find(params[:id], :include => :parent)