Merge branch 'guange_dev' into szzh

This commit is contained in:
sw 2015-06-19 15:04:49 +08:00
commit 2f07d629c0
2 changed files with 6 additions and 7 deletions

View File

@ -695,13 +695,11 @@ class CoursesController < ApplicationController
# 显示老师和助教的活动
# @authors = searchTeacherAndAssistant(@course)
@authors = course_all_member(@course)
#TODO 貌似删除操作不会更新缓存 还是先不用缓存吧
# Dir.glob("#{Rails.root}/app/models/*.rb").sort.each { |file| require file }
events = []
# key = "course_events_#{@course.id}".to_sym
# if Rails.env.production? && Setting.course_cahce_enabled?
# events = Rails.cache.read(key) || []
# end
key = "course_events_#{@course.id}".to_sym
if Rails.env.production? && Setting.course_cahce_enabled?
events = Rails.cache.read(key) || []
end
if events.empty?
@authors.each do |author|
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
@ -717,7 +715,7 @@ class CoursesController < ApplicationController
events += @activity.events(@days, @course.created_at, :is_public => 1)
end
end
# Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled?
Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled?
end
else
# @author = @course.teacher

View File

@ -6,6 +6,7 @@ module Trustie
def self.included(base)
base.class_eval{
after_create :clear_course_events
after_destroy :clear_course_events
}
end