Merge branch 'hjq_mail' into develop
Conflicts: app/models/news.rb
This commit is contained in:
commit
a207f48b94
|
@ -1,5 +1,6 @@
|
|||
class OrgDocumentCommentsController < ApplicationController
|
||||
before_filter :find_organization, :only => [:new, :create, :show, :index]
|
||||
before_filter :authorize_allowed, :only => [:create, :add_reply]
|
||||
helper :attachments,:organizations
|
||||
layout 'base_org'
|
||||
|
||||
|
@ -101,6 +102,13 @@ class OrgDocumentCommentsController < ApplicationController
|
|||
@organization = Organization.find(params[:organization_id])
|
||||
end
|
||||
|
||||
def authorize_allowed
|
||||
unless User.current.logged?
|
||||
redirect_to signin_url
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@org_document_comment = OrgDocumentComment.find(params[:id])
|
||||
@org_sub_id = @org_document_comment.org_subfield_id
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class SubDocumentCommentsController < ApplicationController
|
||||
before_filter :find_subdomain_and_subfield, :only => [:new, :create, :show, :index, :destroy, :edit]
|
||||
before_filter :find_subfield_content, :only => [:show, :index]
|
||||
before_filter :authorize_allowed, :only => [:create, :add_reply]
|
||||
helper :attachments,:organizations
|
||||
layout 'base_sub_domain'
|
||||
|
||||
|
@ -207,4 +208,11 @@ class SubDocumentCommentsController < ApplicationController
|
|||
def find_subfield_content
|
||||
@subfield_content = @organization.org_subfields.order("priority")
|
||||
end
|
||||
|
||||
def authorize_allowed
|
||||
unless User.current.logged?
|
||||
redirect_to signin_url
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,7 +83,7 @@ class Message < ActiveRecord::Base
|
|||
# after_create :add_author_as_watcher, :reset_counters!, :add_boards_count
|
||||
after_update :update_messages_board, :update_activity
|
||||
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
|
||||
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message
|
||||
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message, :delay_message_send
|
||||
#before_save :be_user_score
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -308,6 +308,22 @@ class Message < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def delay_message_send
|
||||
if self.course
|
||||
if self.parent_id.nil? # 发帖
|
||||
self.delay.contain_messages_message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def contain_messages_message
|
||||
self.course.members.includes(:user).each do |m|
|
||||
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建message且无parent的为发帖
|
||||
|
|
|
@ -62,7 +62,7 @@ class News < ActiveRecord::Base
|
|||
:author_key => :author_id
|
||||
acts_as_watchable
|
||||
|
||||
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score, :act_as_system_message
|
||||
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score, :act_as_system_message, :delay_news_send
|
||||
after_update :update_activity
|
||||
after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score
|
||||
|
||||
|
@ -169,7 +169,7 @@ class News < ActiveRecord::Base
|
|||
if self.course
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
# self.delay.send_message(m.user_id, self.course_id)
|
||||
#self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
||||
if count == 0
|
||||
ws = WechatService.new
|
||||
|
@ -189,9 +189,19 @@ class News < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# def send_message user_id, course_id
|
||||
# self.course_messages << CourseMessage.new(:user_id => user_id, :course_id => course_id, :viewed => false)
|
||||
# end
|
||||
def delay_news_send
|
||||
if self.course
|
||||
self.delay.contain_news_message
|
||||
end
|
||||
end
|
||||
|
||||
def contain_news_message
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => user_id, :course_id => container_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Time 2015-03-31 13:50:54
|
||||
# Author lizanle
|
||||
|
|
Loading…
Reference in New Issue