diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 2e51d6a03..82c827b48 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -616,9 +616,14 @@ class AdminController < ApplicationController # 未审批tab页 # status: 0 未审批; 1 已批阅; 2已更改; 3拒绝; def applied_schools + # 更新消息状态 + if params[:flag] + applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first + applied_message.update_attribute(:viewed, true) + end + @name = params[:name] || "" condition = "#{@name.strip}".gsub(" ","") - @apply_status = ApplyAddSchools.where("status = 0 and name like '%#{condition}%'").order('created_at desc') @apply_count = @apply_status.count @apply_pages = Paginator.new @apply_count, 30, params['page'] || 1 @@ -655,7 +660,7 @@ class AdminController < ApplicationController applied_school.update_column('status', 1) unless applied_school.nil? school = applied_school.school school.update_attribute("province", applied_school.province) - AppliedMessage.create(:user_id => applied_school.user_id, :status => 1, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name ) + AppliedMessage.create(:user_id => applied_school.user_id, :status => 1, :viewed => 0, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name ) # School.create(:user_id => applied_school.user_id, :status => 1, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name ) respond_to do |format| format.html{ redirect_to unapplied_schools_url } @@ -663,8 +668,8 @@ class AdminController < ApplicationController end # 单位审核:更改 - # REDO: 修改该字段 - # REDO: 同步修改使用了改名称的用户单位 + # 修改该字段 + # 同步修改使用了改名称的用户单位 def edit_applied_schools aas = ApplyAddSchools.find(params[:applied_id]) # aas.update_attribute(:name, params[:name]) @@ -672,7 +677,7 @@ class AdminController < ApplicationController school = School.find params[:school_id] begin aas.update_attribute(:status, 2) - AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => true, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name ) + 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}") users.update_all(:school_id => school[0].id) if aas.school_id != school[0].id.to_i @@ -707,15 +712,12 @@ class AdminController < ApplicationController end # 单位审核:删除 - # REDO: destroy关联删除 - # REDO: 删除确认提示,是否删除 - # REDO: 给申请人发送消息 def delete_applied_schools applied_school = ApplyAddSchools.find(params[:id]) applied_school.update_attribute(:status, 3) # 未审批删除 if params[:tip] == "unapplied" - AppliedMessage.create(:user_id => applied_school.user_id, :status => 3, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name ) + AppliedMessage.create(:user_id => applied_school.user_id, :status => 3, :viewed => 0, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name ) # 删除学校的用户 users = UserExtensions.where("school_id = #{applied_school.school_id}") users.update_all(:school_id => nil) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 32c605516..05b93d302 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -108,6 +108,12 @@ class MyController < ApplicationController # Edit user's account def account + # 更新消息状态 + if params[:flag] + applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first + applied_message.update_attribute(:viewed, true) + end + @user = User.current lg=@user.login diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 98d814137..b6e34a185 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -188,11 +188,12 @@ class SchoolController < ApplicationController user_extention.school_id = school.id user_extention.save! - # status=4 向管理员发送信息 + # 向管理员发送信息 users = User.where(:admin => 1) users.each do |user| - AppliedMessage.create(:user_id => user.id, :status => 0, :applied_user_id => User.current.id, :viewed => true, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name ) + AppliedMessage.create(:user_id => user.id, :status => 0, :applied_user_id => User.current.id, :viewed => 0, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name ) end + else data[:result] = 3 end diff --git a/app/views/admin/_all_schools.html.erb b/app/views/admin/_all_schools.html.erb index ce5bc6dc7..d4cf916f5 100644 --- a/app/views/admin/_all_schools.html.erb +++ b/app/views/admin/_all_schools.html.erb @@ -8,9 +8,7 @@