解决课程导语时间和课程创建动态时间一致的问题
This commit is contained in:
parent
c5d935108e
commit
0db69e1ebf
|
@ -37,7 +37,7 @@ module CoursesHelper
|
|||
a_courses = []
|
||||
courses = Course.search(keywords)
|
||||
courses.each do |c|
|
||||
a_courses << c.id unless current_course.id != c.id
|
||||
a_courses << c.id
|
||||
end
|
||||
a_courses << a_tags unless a_tags.length == 0
|
||||
# 过滤条件:精品课程、本身不在搜索范围
|
||||
|
|
|
@ -72,7 +72,7 @@ class Course < ActiveRecord::Base
|
|||
before_save :self_validate
|
||||
# 公开课程变成私有课程,所有资源都变成私有
|
||||
after_update :update_files_public,:update_course_ealasticsearch_index,:update_activity
|
||||
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index, :add_course_ead
|
||||
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index
|
||||
before_destroy :delete_all_members,:delete_course_ealasticsearch_index
|
||||
|
||||
safe_attributes 'extra',
|
||||
|
@ -405,14 +405,6 @@ class Course < ActiveRecord::Base
|
|||
self.course_messages << CourseMessage.new(:user_id => self.tea_id, :course_id => self.id, :viewed => false)
|
||||
end
|
||||
|
||||
# 发布新课导语
|
||||
def add_course_ead
|
||||
name = Redmine::Configuration['course_message_lead_subject']
|
||||
content = Redmine::Configuration['course_message_lead_content']
|
||||
# message的status状态为0为正常,为1表示创建课程时发送的message
|
||||
Message.create(:subject => name, :content => content, :board_id => self.boards.first.id, :author_id => self.tea_id , :sticky => true, :status => true )
|
||||
end
|
||||
|
||||
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
|
||||
#def name
|
||||
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
|
|
|
@ -70,7 +70,9 @@ class CourseActivity < ActiveRecord::Base
|
|||
name = Redmine::Configuration['course_message_lead_subject']
|
||||
content = Redmine::Configuration['course_message_lead_content']
|
||||
# message的status状态为0为正常,为1表示创建课程时发送的message
|
||||
Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => self.course.tea_id , :sticky => true, :status => true )
|
||||
message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => self.course.tea_id , :sticky => true, :status => true )
|
||||
# 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一直
|
||||
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue