From af4523815c6d53a95f8ff3ed0838698532c5bb4a Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 11:03:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BB=8E=E5=85=AC=E5=BC=80?= =?UTF-8?q?=E6=94=B9=E6=88=90=E7=A7=81=E6=9C=89=20=E5=88=99=E8=AF=A5?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=AD=E6=89=80=E6=9C=89=E7=9A=84=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E9=83=BD=E5=8F=98=E6=88=90=E7=A7=81=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/course.rb b/app/models/course.rb index 46599dbfc..a583990c1 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -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