问卷发布后才能提交
This commit is contained in:
parent
580735ef79
commit
953817800a
|
@ -13,7 +13,8 @@ class Poll < ActiveRecord::Base
|
|||
after_create :act_as_activity, :act_as_course_activity
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message
|
||||
after_create :act_as_activity, :act_as_course_activity
|
||||
after_save :act_as_course_message
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
|
||||
:description => :polls_description,
|
||||
|
@ -46,10 +47,14 @@ class Poll < ActiveRecord::Base
|
|||
# 发布问卷,出了发布者外,其他人都能收到消息通知
|
||||
def act_as_course_message
|
||||
if self.polls_type == "Course"
|
||||
Course.find(self.polls_group_id).members.each do |m|
|
||||
if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.polls_group_id, :viewed => false)
|
||||
if self.polls_status == 2 #问卷是发布状态
|
||||
Course.find(self.polls_group_id).members.each do |m|
|
||||
if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.polls_group_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
elsif self.polls_status == 1 #问卷是新建状态
|
||||
self.course_messages.destroy_all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue