module Decidim::Reportable
A concern with the components needed when you want a model to be reportable
Public Instance Methods
reported?()
click to toggle source
Public: Checks if the reportable has been reported or not.
Returns Boolean.
# File lib/decidim/reportable.rb, line 35 def reported? moderation&.report_count&.positive? || false end
reported_attributes()
click to toggle source
Public: The collection of attribute names that are considered
to be reportable.
# File lib/decidim/reportable.rb, line 48 def reported_attributes raise NotImplementedError end
reported_by?(user)
click to toggle source
Public: Check if the user has reported the reportable.
Returns Boolean.
# File lib/decidim/reportable.rb, line 21 def reported_by?(user) reports.where(user: user).any? end
reported_content_url()
click to toggle source
Public: The reported content url
Returns String
# File lib/decidim/reportable.rb, line 42 def reported_content_url raise NotImplementedError end
reported_searchable_content_extras()
click to toggle source
Public: An `Array` of `String` that will be concatenated to
the reported searchable content. This content is used in the admin dashboard to filter moderations.
# File lib/decidim/reportable.rb, line 55 def reported_searchable_content_extras [] end
reported_searchable_content_text()
click to toggle source
Public: The reported searchable content in a text format so
moderations can be filtered by content.
# File lib/decidim/reportable.rb, line 61 def reported_searchable_content_text reported_searchable_content_extras.concat( reported_attributes.map do |attribute_name| attribute_value = attributes.with_indifferent_access[attribute_name] next attribute_value.values.join("\n") if attribute_value.is_a? Hash attribute_value end ).join("\n") end