|
|
|
@ -20,7 +20,7 @@ class Course < ActiveRecord::Base
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name
|
|
|
|
|
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name, :is_delete
|
|
|
|
|
#belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier
|
|
|
|
|
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
|
|
|
|
|
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表
|
|
|
|
@ -86,7 +86,8 @@ class Course < ActiveRecord::Base
|
|
|
|
|
'is_public',
|
|
|
|
|
'description',
|
|
|
|
|
'class_period',
|
|
|
|
|
'open_student'
|
|
|
|
|
'open_student',
|
|
|
|
|
'is_delete'
|
|
|
|
|
|
|
|
|
|
acts_as_customizable
|
|
|
|
|
|
|
|
|
@ -94,7 +95,7 @@ class Course < ActiveRecord::Base
|
|
|
|
|
scope :active, lambda { where(:status => STATUS_ACTIVE) }
|
|
|
|
|
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
|
|
|
|
scope :all_public, lambda { where(:is_public => true) }
|
|
|
|
|
scope :visible, lambda {|*args| where(Course.visible_condition(args.shift || User.current, *args)) }
|
|
|
|
|
scope :visible, lambda {|*args| where(Course.where("is_delete =?", 0).visible_condition(args.shift || User.current, *args)) }
|
|
|
|
|
scope :allowed_to, lambda {|*args|
|
|
|
|
|
user = User.current
|
|
|
|
|
permission = nil
|
|
|
|
|