decidim-comments/app/models/decidim/comments/comment.rb in decidim-0.0.5 vs decidim-comments/app/models/decidim/comments/comment.rb in decidim-0.0.6
- old
+ new
@@ -3,10 +3,11 @@
module Comments
# Some resources will be configured as commentable objects so users can
# comment on them. The will be able to create conversations between users
# to discuss or share their thoughts about the resource.
class Comment < ApplicationRecord
+ include Reportable
include Decidim::Authorable
include Decidim::Comments::Commentable
# Limit the max depth of a comment tree. If C is a comment and R is a reply:
# C (depth 0)
@@ -26,11 +27,11 @@
validate :commentable_can_have_comments
before_save :compute_depth
- delegate :organization, to: :commentable
+ delegate :organization, :feature, to: :commentable
# Public: Override Commentable concern method `accepts_new_comments?`
def accepts_new_comments?
depth < MAX_DEPTH
end
@@ -51,9 +52,14 @@
# Public: Returns the commentable object of the parent comment
def root_commentable
return commentable if depth == 0
commentable.root_commentable
+ end
+
+ # Public: Overrides the `reported_content` Reportable concern method.
+ def reported_content
+ "<p>#{body}</p>"
end
private
# Private: Check if commentable can have comments and if not adds