From 0eeb4ed4397e1d83fb1087082483658c845e8b32 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 26 Sep 2016 13:52:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E4=B8=BB=E9=A1=B5=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 2 ++ app/models/attachment.rb | 9 ++++++++- app/models/course.rb | 4 ++++ app/models/homework_common.rb | 10 ++++++++-- app/models/news.rb | 11 +++++++++-- app/views/files/_resource_detail.html.erb | 4 ++-- app/views/layouts/base_courses.html.erb | 8 ++++---- 7 files changed, 37 insertions(+), 11 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 7318a4dc2..3e85c3230 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -598,6 +598,8 @@ class FilesController < ApplicationController attachment.description = params[:description] attachment.save end + #更新course的时间 + @course.update_course end if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array) params[:course_attachment_type].each do |type| diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 88fadd644..6e215e128 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -96,7 +96,7 @@ class Attachment < ActiveRecord::Base after_save :act_as_course_activity after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index - after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score + after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score, :update_others # add by nwb # 获取所有可公开的资源文件列表 @@ -682,6 +682,13 @@ class Attachment < ActiveRecord::Base down_course_score_num(self.container_id, self.author_id, "Attachment") end end + + #更新时间 + def update_others + if self.course + self.course.update_course + end + end end # Delete the previous articles index in Elasticsearch diff --git a/app/models/course.rb b/app/models/course.rb index cc80a1b4b..e07375023 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -506,6 +506,10 @@ class Course < ActiveRecord::Base ticket end + def update_course + self.update_attribute(:updated_at,Time.now) + end + def log_infor Rails.logger.info "##########################################################course's syllabus_id is #{self.syllabus_id}." end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 7a082cecf..ee89d73be 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -29,10 +29,10 @@ class HomeworkCommon < ActiveRecord::Base :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail,:act_as_course_message + after_create :act_as_activity, :send_mail,:act_as_course_message,:update_others after_update :update_activity after_save :act_as_course_activity - after_destroy :delete_kindeditor_assets + after_destroy :delete_kindeditor_assets,:update_others #作业类型 def homework_type_ch @@ -122,6 +122,12 @@ class HomeworkCommon < ActiveRecord::Base jfm end + #更新时间 + def update_others + self.course.update_course + + end + #修改作业后发送微信模板消息 # def wechat_message # self.course.members.each do |member| diff --git a/app/models/news.rb b/app/models/news.rb index 58bbc40ac..ebd211930 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -62,9 +62,9 @@ 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_send, :update_others 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, :update_others scope :visible, lambda {|*args| includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args)) @@ -226,4 +226,11 @@ class News < ActiveRecord::Base end end + #更新时间 + def update_others + if self.course + self.course.update_course + end + end + end \ No newline at end of file diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index 00ac20b87..32883ac66 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -27,7 +27,7 @@ <%=file.publish_time %> 0点发布 <% end %> - <% cache [:resource_detail,file.id.to_s] do%> + <%# cache [:resource_detail,file.id.to_s] do%>
文件大小:<%= number_to_human_size(file.filesize) %>
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>