diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 67d4de0ff..b8d78562c 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -444,6 +444,8 @@ class NewsController < ApplicationController def destroy if @news.org_subfield_id @org_subfield = OrgSubfield.find(@news.org_subfield_id) + elsif @news.contest_id + @contest = Contest.find(@news.contest_id) end @news.destroy # modify by nwb @@ -451,6 +453,8 @@ class NewsController < ApplicationController redirect_to project_news_index_url(@project) elsif @course redirect_to course_news_index_url(@course) + elsif @contest + redirect_to contest_news_index_url(@contest) elsif @org_subfield redirect_to organization_path(@org_subfield.organization, :org_subfield_id => @org_subfield.id) end diff --git a/app/models/news.rb b/app/models/news.rb index f79768b88..0fa995ce1 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -236,6 +236,23 @@ class News < ActiveRecord::Base self.delay.contain_news_message(vs) end + elsif self.contest_id + vs = [] + self.contest.contest_members.each do | m| + if m.user_id != self.author_id + vs << {course_message_type:'Contest',course_message_id:self.id, :user_id => m.user_id, + :contest_id => self.contest_id, :viewed => false} + + if vs.size >= 30 + self.delay.contain_contst_news_message(vs) + vs.clear + end + end + end + + unless vs.empty? + self.delay.contain_contst_news_message(vs) + end end end @@ -243,6 +260,10 @@ class News < ActiveRecord::Base CourseMessage.create(vs) end + def contain_contst_news_message(vs) + ContestMessage.create(vs) + end + # Time 2015-03-31 13:50:54 # Author lizanle # Description 删除news后删除对应的资源