微信模板消息的还原

This commit is contained in:
cxt 2016-05-18 14:49:49 +08:00
parent 617649129e
commit 3b3cafbc81
5 changed files with 16 additions and 16 deletions

View File

@ -291,9 +291,9 @@ class HomeworkCommonController < ApplicationController
def open_student_works def open_student_works
if @homework.is_open == 0 if @homework.is_open == 0
@homework.update_attribute(:is_open, 1) @homework.update_column('is_open', 1)
else else
@homework.update_attribute(:is_open, 0) @homework.update_column('is_open', 0)
end end
@user_activity_id = params[:user_activity_id] @user_activity_id = params[:user_activity_id]
@is_in_course = params[:is_in_course] if params[:is_in_course] @is_in_course = params[:is_in_course] if params[:is_in_course]
@ -440,7 +440,7 @@ class HomeworkCommonController < ApplicationController
puts time puts time
s_time = time s_time = time
if format_time(time) > format_time(h.updated_at) if format_time(time) > format_time(h.updated_at)
h.update_attribute(:updated_at, s_time) h.update_column('updated_at', s_time)
end end
end end
end end

View File

@ -814,7 +814,7 @@ class StudentWorkController < ApplicationController
stu_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") stu_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.student_score = stu_score.first.score.try(:round, 2).to_f @work.student_score = stu_score.first.score.try(:round, 2).to_f
end end
@homework.update_attributes(:updated_at => Time.now) @homework.update_column('updated_at', Time.now)
update_course_activity(@homework.class,@homework.id) update_course_activity(@homework.class,@homework.id)
update_user_activity(@homework.class,@homework.id) update_user_activity(@homework.class,@homework.id)
update_org_activity(@homework.class,@homework.id) update_org_activity(@homework.class,@homework.id)

View File

@ -29,8 +29,8 @@ class HomeworkCommon < ActiveRecord::Base
:description => :description, :description => :description,
:author => :author, :author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
after_create :act_as_activity, :send_mail after_create :act_as_activity, :send_mail,:act_as_course_message
after_update :update_activity after_update :update_activity, :wechat_message
after_save :act_as_course_activity after_save :act_as_course_activity
after_destroy :delete_kindeditor_assets after_destroy :delete_kindeditor_assets
@ -59,12 +59,12 @@ class HomeworkCommon < ActiveRecord::Base
else else
self.course.members.each do |m| self.course.members.each do |m|
# if m.user_id != self.user_id # if m.user_id != self.user_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) #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 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 if count == 0
# ws = WechatService.new ws = WechatService.new
# ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
#end end
# end # end
end end
end end

View File

@ -274,7 +274,7 @@ class Message < ActiveRecord::Base
else # 回帖 else # 回帖
parent_author_id = Message.find(self.parent_id).author_id parent_author_id = Message.find(self.parent_id).author_id
if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
#self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false) self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false)
count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count
if count == 0 if count == 0
content = strip_html self.content.html_safe, 200 content = strip_html self.content.html_safe, 200
@ -297,7 +297,7 @@ class Message < ActiveRecord::Base
else # 回帖 else # 回帖
parent_author_id = Message.find(self.parent_id).author_id parent_author_id = Message.find(self.parent_id).author_id
if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
#self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false) self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false)
count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count
if count == 0 if count == 0
content = strip_html self.content.html_safe, 200 content = strip_html self.content.html_safe, 200

View File

@ -62,7 +62,7 @@ class News < ActiveRecord::Base
:author_key => :author_id :author_key => :author_id
acts_as_watchable 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 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_update :update_activity after_update :update_activity
after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score 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 if self.course
self.course.members.each do |m| self.course.members.each do |m|
if m.user_id != self.author_id if m.user_id != self.author_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) #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 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 if count == 0
ws = WechatService.new ws = WechatService.new