diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 07a3ba393..53afa50aa 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -228,18 +228,18 @@ class NewsController < ApplicationController @news.safe_attributes = params[:news] @news.save_attachments(params[:attachments]) if @news.save - @course.members.each do |m| - if m.user_id != User.current.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=#{@news.course_id}").count - if count == 0 - ws = WechatService.new - content = @news.title - name = @news.course.syllabus.nil? ? @news.course.name : @news.course.syllabus.title+" • "+@news.course.name - ws.class_notice m.user_id, "course_notice", @news.id, "#{l(:label_new_notice_template)}", name, @news.author.show_name, format_time(@news.created_on), content, "点击查看通知详情" - end - end - end + # @course.members.each do |m| + # if m.user_id != User.current.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=#{@news.course_id}").count + # if count == 0 + # ws = WechatService.new + # content = @news.title + # name = @news.course.syllabus.nil? ? @news.course.name : @news.course.syllabus.title+" • "+@news.course.name + # ws.class_notice m.user_id, "course_notice", @news.id, "#{l(:label_new_notice_template)}", name, @news.author.show_name, format_time(@news.created_on), content, "点击查看通知详情" + # end + # end + # end if params[:asset_id] ids = params[:asset_id].split(',') diff --git a/app/helpers/avatar_helper.rb b/app/helpers/avatar_helper.rb index 5c3ffd950..243207fc7 100644 --- a/app/helpers/avatar_helper.rb +++ b/app/helpers/avatar_helper.rb @@ -8,14 +8,17 @@ module AvatarHelper FileUtils.cp(src_file, des_file) if File.exist?(src_file) end - + def avatar_image(source, copyed=false) source_type = source.class source_id = source.id - course = Course.find(source_id) rescue nil - if course && copyed - source_id = course.is_copy + # course = Course.find(source_id) rescue nil + # if course && copyed + # source_id = course.is_copy + # end + if source_type.to_s == 'Course' && copyed + source_id = source.is_copy end File.join(relative_path, avatar_directory(source_type), source_id.to_s) diff --git a/app/models/news.rb b/app/models/news.rb index 0a893e34e..dc47f66ac 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -65,7 +65,7 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :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_create :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_wechat_send,:delay_news_send after_update :update_activity after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score @@ -186,6 +186,26 @@ class News < ActiveRecord::Base end end + def delay_news_wechat_send + if self.course + self.delay.news_wechat_message + end + end + + def news_wechat_message + self.course.members.each do |m| + if m.user_id != self.author_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 + content = self.title + ws.class_notice m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.course.name, self.author.show_name, format_time(self.created_on), content, "点击查看通知详情" + end + end + end + end + def delay_news_send if self.course self.delay.contain_news_message diff --git a/app/views/courses/code_repeat.html.erb b/app/views/courses/code_repeat.html.erb index b980ac28f..0ccc4c8fb 100644 --- a/app/views/courses/code_repeat.html.erb +++ b/app/views/courses/code_repeat.html.erb @@ -1,5 +1,6 @@
-

查重结果

+

查重结果

+

代码量少的作品,误报率高,因此不参与查重