module Decidim::UserReportable

A concern with the components needed when you want a model to be reportable

Public Instance Methods

report_count() click to toggle source
# File lib/decidim/user_reportable.rb, line 14
def report_count
  user_moderation&.report_count.to_i
end
reported?() click to toggle source

Public: Checks if the reportable has been reported or not.

Returns Boolean.

# File lib/decidim/user_reportable.rb, line 28
def reported?
  report_count&.positive?
end
reported_by?(user) click to toggle source

Public: Check if the user has reported the reportable.

Returns Boolean.

# File lib/decidim/user_reportable.rb, line 21
def reported_by?(user)
  user_reports.where(user: user).any?
end