课程从公开改成私有

则该课程中所有的资源都变成私有
This commit is contained in:
huang 2015-10-20 11:03:47 +08:00
parent c9eb7b4b90
commit af4523815c
1 changed files with 10 additions and 0 deletions

View File

@ -50,6 +50,8 @@ class Course < ActiveRecord::Base
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
validates_length_of :description, :maximum => 10000
before_save :self_validate
# 公开课程变成私有课程,所有资源都变成私有
after_update :update_files_public
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message
before_destroy :delete_all_members
@ -213,6 +215,14 @@ class Course < ActiveRecord::Base
end
def update_files_public
unless self.is_public?
self.attachments.each do |a|
a.update_attributes(:is_public => false)
end
end
end
# 创建课程讨论区
def create_board_sync
@board = self.boards.build