|
|
|
@ -292,18 +292,21 @@ class UsersController < ApplicationController
|
|
|
|
|
#status 1 同意 2 拒绝
|
|
|
|
|
def dealwith_apply_homework
|
|
|
|
|
@msg = CourseMessage.find(params[:msg_id])
|
|
|
|
|
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?",@msg.apply_user_id, @msg.course_message_id)
|
|
|
|
|
case params[:agree]
|
|
|
|
|
when 'Y'
|
|
|
|
|
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?",@msg.apply_user_id, @msg.course_message_id)
|
|
|
|
|
unless ah.empty?
|
|
|
|
|
ah.first.update_column('status', 2)
|
|
|
|
|
CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>5,:apply_result=>1)
|
|
|
|
|
CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>1)
|
|
|
|
|
@msg.update_attributes(:apply_result=>1,:viewed=>1)
|
|
|
|
|
end
|
|
|
|
|
when 'N'
|
|
|
|
|
CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>5,:apply_result=>2)
|
|
|
|
|
unless ah.empty?
|
|
|
|
|
ah.first.update_column('status', 3)
|
|
|
|
|
CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>2)
|
|
|
|
|
@msg.update_attributes(:apply_result=>2,:viewed=>1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|