2019-05-08 13:59:02 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-08 13:18:20 +01:00
|
|
|
class StepComment < Comment
|
2020-11-30 15:55:20 +01:00
|
|
|
before_create :fill_unseen_by
|
|
|
|
|
2019-05-08 13:59:02 +02:00
|
|
|
belongs_to :step, foreign_key: :associated_id, inverse_of: :step_comments, touch: true
|
2016-02-12 16:52:43 +01:00
|
|
|
|
2017-03-08 13:18:20 +01:00
|
|
|
validates :step, presence: true
|
2020-11-20 12:29:40 +01:00
|
|
|
|
|
|
|
def commentable
|
|
|
|
step
|
|
|
|
end
|
2020-11-30 15:55:20 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fill_unseen_by
|
|
|
|
self.unseen_by += step.protocol.my_module.experiment.project.users.where.not(id: user.id).pluck(:id)
|
|
|
|
end
|
2016-02-12 16:52:43 +01:00
|
|
|
end
|