|
|
|
@ -81,7 +81,7 @@ class Course < ApplicationRecord
|
|
|
|
|
# 老版的members弃用 现用course_members
|
|
|
|
|
has_many :members
|
|
|
|
|
|
|
|
|
|
validate_harmonious_of [:name, :subject]
|
|
|
|
|
validate :validate_sensitive_string
|
|
|
|
|
|
|
|
|
|
scope :hidden, ->(is_hidden = true) { where(is_hidden: is_hidden) }
|
|
|
|
|
scope :ended, ->(is_end = true) { where(is_end: is_end) }
|
|
|
|
@ -437,4 +437,8 @@ class Course < ApplicationRecord
|
|
|
|
|
|
|
|
|
|
self.laboratory = Laboratory.current if laboratory_id.blank?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def validate_sensitive_string
|
|
|
|
|
raise("课堂名称包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(name)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|