课程动态增加课程创建信息的动态
This commit is contained in:
parent
ce76308864
commit
053587bd53
|
@ -33,6 +33,8 @@ class Course < ActiveRecord::Base
|
|||
has_many :student_works, :through => :homework_commons, :dependent => :destroy
|
||||
|
||||
has_many :course_groups, :dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
|
||||
acts_as_taggable
|
||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||
|
@ -44,7 +46,7 @@ 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_create :create_board_sync
|
||||
after_create :create_board_sync, :act_as_course_activity
|
||||
before_destroy :delete_all_members
|
||||
|
||||
safe_attributes 'extra',
|
||||
|
@ -310,6 +312,11 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)
|
||||
end
|
||||
|
||||
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
|
||||
#def name
|
||||
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
|
|
|
@ -3,6 +3,7 @@ class CourseActivities < ActiveRecord::Migration
|
|||
def up
|
||||
Course.all.each do |course|
|
||||
transaction do
|
||||
course.course_acts << CourseActivity.new(:user_id => course.tea_id,:course_id => course.id)
|
||||
#作业
|
||||
course.homework_commons.each do |homework_common|
|
||||
homework_common.course_acts << CourseActivity.new(:user_id => homework_common.user_id,:course_id => course.id)
|
||||
|
|
Loading…
Reference in New Issue