diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 41f698be2..ece68733b 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -759,6 +759,9 @@ class AdminController < ApplicationController # status: 0表示未批准; status:1表示已批准; status: 2表示已更改; status: 3表示已拒绝; def approve_applied_schools applied_school = ApplyAddSchools.find params[:id] + applied_message_id = applied_school.school_id + applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools") + applied_message.update_all(:status => 1) applied_school.update_column('status', 1) unless applied_school.nil? school = applied_school.school school.update_attribute("province", applied_school.province) @@ -778,6 +781,10 @@ class AdminController < ApplicationController #applied_add_school = ApplyAddSchools.where(:name => aas.name) school = School.find params[:school_id] begin + #更新消息表的status + applied_message_id = aas.school_id + applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools") + applied_message.update_all(:status => 2) aas.update_attribute(:status, 2) AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name ) users = UserExtensions.where("school_id = #{aas.school_id}") @@ -816,6 +823,9 @@ class AdminController < ApplicationController # 单位审核:删除 def delete_applied_schools applied_school = ApplyAddSchools.find(params[:id]) + applied_message_id = applied_school.school_id + applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools") + applied_message.update_all(:status => 3) applied_school.update_attribute(:status, 3) # 未审批删除 if params[:tip] == "unapplied" diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 73c7b15bd..b139510fe 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2049,10 +2049,18 @@ class UsersController < ApplicationController # @unreview_homework = 1 # 待审批的申请 - applied_message_count = AppliedMessage.where(:applied_type => ["Organization", "AppliedContest", "StudentWorksScoresAppeal", "AppliedProject", "ApplyAddSchools"], :user_id => User.current.id, :status => 0).count - applied_course_message_count = CourseMessage.where(:user_id => User.current.id, :course_message_type => "JoinCourseRequest", :status => 0).count - applied_pull_request_message_count = ForgeMessage.where(:user_id => User.current.id, :forge_message_type => "PullRequest", :status => [1,3]).count - @applied_message_alls_count = applied_message_count + applied_course_message_count + applied_pull_request_message_count + #applied_message_count = AppliedMessage.where(:applied_type => ["Organization", "AppliedContest", "StudentWorksScoresAppeal", "AppliedProject", "ApplyAddSchools"], :user_id => User.current.id, :status => 0).count + #applied_course_message_count = CourseMessage.where(:user_id => User.current.id, :course_message_type => "JoinCourseRequest", :status => 0).count + # applied_pull_request_message_count = ForgeMessage.where(:user_id => User.current.id, :forge_message_type => "PullRequest", :status => [1,3]).count + # @applied_message_alls_count = applied_message_count + applied_course_message_count + applied_pull_request_message_count + user_id = User.current.id + sql = "SELECT * FROM `message_alls` ma left join `forge_messages` fm on ma.message_id=fm.id + left join `course_messages` cm on ma.message_id=cm.id left join `applied_messages` apm on ma.message_id=apm.id + where (ma.user_id =#{user_id} and ma.message_type = 'ForgeMessage' and fm.forge_message_type='PullRequest' and fm.status=0 and fm.user_id=#{user_id} ) or + (ma.user_id=#{user_id} and ma.message_type='AppliedMessage' and apm.applied_type in ('Organization', 'AppliedContest', 'StudentWorksScoresAppeal', 'AppliedProject', 'ApplyAddSchools') and apm.user_id =#{user_id} and apm.status =0 ) or + (ma.user_id=#{user_id} and ma.message_type='CourseMessage' and cm.course_message_type='JoinCourseRequest' and cm.status=0 and cm.user_id=#{user_id} );" + message_alls = MessageAll.find_by_sql(sql) + @applied_message_alls_count = message_alls.count else # 看别人的主页显示动态 #更新用户申请成为课程老师或教辅消息的状态