parent
62c657a827
commit
88397d58d0
|
@ -89,72 +89,54 @@ class MessagesController < ApplicationController
|
|||
|
||||
# Create a new topic
|
||||
def new
|
||||
@message = Message.new
|
||||
@message.author = User.current
|
||||
@message.board = @board
|
||||
@message.safe_attributes = params[:message]
|
||||
if request.post?
|
||||
@message.save_attachments(params[:attachments])
|
||||
if @message.save
|
||||
# 更新kindeditor上传的图片资源所有者
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
# # 与我相关动态的记录add start
|
||||
# if(@board && @board.course) #项目的先不管
|
||||
# teachers = searchTeacherAndAssistant(@board.course)
|
||||
# for teacher in teachers
|
||||
# if(teacher.user_id != User.current.id)
|
||||
# notify = ActivityNotify.new()
|
||||
# if(@board.course)
|
||||
# notify.activity_container_id = @board.course_id
|
||||
# notify.activity_container_type = 'Course'
|
||||
# else
|
||||
# notify.activity_container_id = @board.project_id
|
||||
# notify.activity_container_type = 'Project'
|
||||
# end
|
||||
# notify.activity_id = @message.id
|
||||
# notify.activity_type = 'Message'
|
||||
# notify.notify_to = teacher.user_id
|
||||
# notify.is_read = 0
|
||||
# notify.save()
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# 与我相关动态的记录add end
|
||||
if User.current.logged?
|
||||
@message = Message.new
|
||||
@message.author = User.current
|
||||
@message.board = @board
|
||||
@message.safe_attributes = params[:message]
|
||||
if request.post?
|
||||
@message.save_attachments(params[:attachments])
|
||||
if @message.save
|
||||
# 更新kindeditor上传的图片资源所有者
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
|
||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @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)
|
||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @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)
|
||||
end
|
||||
else
|
||||
redirect_to board_message_url(@board, @message)
|
||||
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
|
||||
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
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :layout => layout_file
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :layout => layout_file
|
||||
}
|
||||
end
|
||||
redirect_to signin_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
class DeleteAnonymousFeedback < ActiveRecord::Migration
|
||||
def up
|
||||
jour_count = JournalsForMessage.all.count / 30 + 2
|
||||
puts jour_count
|
||||
transaction do
|
||||
for i in 1 ... jour_count do i
|
||||
JournalsForMessage.page(i).per(30).each do |jour|
|
||||
jour.destroy if jour.user_id == 2
|
||||
jour.destroy if jour.user_id.to_s == "2"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class DeleteAnonymousMessage < ActiveRecord::Migration
|
||||
def up
|
||||
message_count = Message.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... message_count do i
|
||||
Message.page(i).per(30).each do |message|
|
||||
message.destroy if jour.author_id.to_s == "2"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue