消息已阅!

This commit is contained in:
lizanle 2015-10-21 15:03:46 +08:00
parent e44d95cca5
commit 75ee45b2d1
1 changed files with 4 additions and 3 deletions

View File

@ -243,6 +243,7 @@ class UsersController < ApplicationController
#status 1 同意 2 拒绝
def dealwith_apply_request
@msg = CourseMessage.find(params[:msg_id])
case params[:agree]
when 'Y'
apply_user = User.find(@msg.course_message_id)
@ -260,18 +261,18 @@ class UsersController < ApplicationController
member.course_group_id = 0
member.save
CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1)
@msg.update_attributes(:status=>1)
@msg.update_attributes(:status=>1,:viewed=>1)
else
members = []
members << Member.new(:role_ids => [@msg.content.to_i], :user_id => @msg.course_message_id)
Course.find(@msg.course_id).members << members
CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1)
@msg.update_attributes(:status=>1)
@msg.update_attributes(:status=>1,:viewed=>1)
end
when 'N'
CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>2)
@msg.update_attributes(:status=>2)
@msg.update_attributes(:status=>2,:viewed=>1)
end
respond_to do |format|
format.js