Filter internal valuation comments from public api
Why: Internal valuation comments are only for admins and valuators, not for the public view. How: Adding a `not_valuations` scope and use it at the `public_for_api` one
This commit is contained in:
@@ -33,7 +33,8 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :public_for_api, -> do
|
||||
where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or
|
||||
not_valuations
|
||||
.where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or
|
||||
(comments.commentable_type = 'Proposal' and comments.commentable_id in (?)) or
|
||||
(comments.commentable_type = 'Poll' and comments.commentable_id in (?))},
|
||||
Debate.public_for_api.pluck(:id),
|
||||
@@ -50,6 +51,8 @@ class Comment < ActiveRecord::Base
|
||||
scope :sort_by_oldest, -> { order(created_at: :asc) }
|
||||
scope :sort_descendants_by_oldest, -> { order(created_at: :asc) }
|
||||
|
||||
scope :not_valuations, -> { where(valuation: false) }
|
||||
|
||||
after_create :call_after_commented
|
||||
|
||||
def self.build(commentable, user, body, p_id = nil)
|
||||
|
||||
Reference in New Issue
Block a user