新建竞赛通知发送消息, 及竞赛通知删除

This commit is contained in:
huang 2016-12-23 20:19:17 +08:00
parent 2c97f12538
commit 854de1fae6
2 changed files with 25 additions and 0 deletions

View File

@ -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

View File

@ -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后删除对应的资源