课程动态 加入 与我相关
This commit is contained in:
parent
d3d656f3b8
commit
0a0f5d98db
|
@ -6,6 +6,7 @@ class ActivityNotifysController < ApplicationController
|
|||
# accept_rss_auth :index, :show
|
||||
|
||||
helper :activities
|
||||
helper :attachments
|
||||
def index
|
||||
query = nil
|
||||
if @course
|
||||
|
|
|
@ -34,6 +34,20 @@ class CommentsController < ApplicationController
|
|||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
|
||||
end
|
||||
# 与我相关动态的记录add start
|
||||
if( @comment.id && @news.course )
|
||||
if(@news.author_id != User.current.id)
|
||||
notify = ActivityNotify.new()
|
||||
notify.activity_container_id = @news.course.id
|
||||
notify.activity_container_type = 'Course'
|
||||
notify.activity_id = @comment.id
|
||||
notify.activity_type = 'Comment'
|
||||
notify.notify_to = @news.author_id
|
||||
notify.is_read = 0
|
||||
notify.save()
|
||||
end
|
||||
end
|
||||
# 与我相关动态的记录add end
|
||||
flash[:notice] = l(:label_comment_added)
|
||||
end
|
||||
|
||||
|
|
|
@ -141,6 +141,21 @@ class NewsController < ApplicationController
|
|||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
|
||||
end
|
||||
# 与我相关动态的记录add start
|
||||
teachers = searchTeacherAndAssistant(@course)
|
||||
for teacher in teachers
|
||||
if(teacher.user_id != User.current.id)
|
||||
notify = ActivityNotify.new()
|
||||
notify.activity_container_id = @course.id
|
||||
notify.activity_container_type = 'Course'
|
||||
notify.activity_id = @news.id
|
||||
notify.activity_type = 'News'
|
||||
notify.notify_to = teacher.user_id
|
||||
notify.is_read = 0
|
||||
notify.save()
|
||||
end
|
||||
end
|
||||
# 与我相关动态的记录add end
|
||||
render_attachment_warning_if_needed(@news)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to course_news_index_url(@course)
|
||||
|
|
|
@ -19,6 +19,14 @@ class Comment < ActiveRecord::Base
|
|||
include Redmine::SafeAttributes
|
||||
include ApplicationHelper
|
||||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
acts_as_event :datetime => :updated_on,
|
||||
:description => :comments,
|
||||
:type => 'news',
|
||||
:title=>Proc.new {|o| "RE: #{o.commented.title}" },
|
||||
:url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.commented.id} }
|
||||
|
||||
belongs_to :commented, :polymorphic => true, :counter_cache => true
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
validates_presence_of :commented, :author, :comments
|
||||
|
@ -38,4 +46,17 @@ class Comment < ActiveRecord::Base
|
|||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::COMMENT
|
||||
end
|
||||
|
||||
def set_notify_id(notify_id)
|
||||
@notify_id= notify_id
|
||||
end
|
||||
def get_notify_id()
|
||||
return @notify_id
|
||||
end
|
||||
def set_notify_is_read(notify_is_read)
|
||||
@notify_is_read = notify_is_read
|
||||
end
|
||||
def get_notify_is_read()
|
||||
return @notify_is_read
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,6 +30,8 @@ class News < ActiveRecord::Base
|
|||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
||||
validates_presence_of :title, :description
|
||||
validates_length_of :title, :maximum => 60
|
||||
validates_length_of :summary, :maximum => 255
|
||||
|
@ -85,6 +87,19 @@ class News < ActiveRecord::Base
|
|||
#description
|
||||
end
|
||||
|
||||
def set_notify_id(notify_id)
|
||||
@notify_id= notify_id
|
||||
end
|
||||
def get_notify_id()
|
||||
return @notify_id
|
||||
end
|
||||
def set_notify_is_read(notify_is_read)
|
||||
@notify_is_read = notify_is_read
|
||||
end
|
||||
def get_notify_is_read()
|
||||
return @notify_is_read
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_author_as_watcher
|
||||
|
|
Loading…
Reference in New Issue