Sha256: c8d115d17cd43956e9c4ae5666910a23e6f6765de1d9115ddf28730c06a96947

Contents?: true

Size: 1.21 KB

Versions: 35

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Decidim
  # A moderation belongs to a reportable and includes many reports
  class Moderation < ApplicationRecord
    include Traceable
    include Loggable

    belongs_to :reportable, foreign_key: "decidim_reportable_id", foreign_type: "decidim_reportable_type", polymorphic: true, touch: true
    belongs_to :participatory_space, foreign_key: "decidim_participatory_space_id", foreign_type: "decidim_participatory_space_type", polymorphic: true
    has_many :reports, foreign_key: "decidim_moderation_id", class_name: "Decidim::Report", dependent: :destroy

    delegate :component, :organization, to: :reportable

    scope :hidden, -> { where.not(hidden_at: nil) }
    scope :not_hidden, -> { where(hidden_at: nil) }

    def self.log_presenter_class_for(_log)
      Decidim::AdminLog::ModerationPresenter
    end

    ransacker :reported_id_string do
      Arel.sql(%{cast("decidim_moderations"."decidim_reportable_id" as text)})
    end

    ransacker :reported_content do
      Arel.sql(%{cast("decidim_moderations"."reported_content" as text)})
    end

    ransacker :reportable_type_string do
      Arel.sql(%{cast("decidim_moderations"."decidim_reportable_type" as text)})
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/models/decidim/moderation.rb
decidim-core-0.28.4 app/models/decidim/moderation.rb
decidim-core-0.27.9 app/models/decidim/moderation.rb
decidim-core-0.29.0 app/models/decidim/moderation.rb
decidim-core-0.28.3 app/models/decidim/moderation.rb
decidim-core-0.27.8 app/models/decidim/moderation.rb
decidim-core-0.29.0.rc4 app/models/decidim/moderation.rb
decidim-core-0.29.0.rc3 app/models/decidim/moderation.rb
decidim-core-0.29.0.rc2 app/models/decidim/moderation.rb
decidim-core-0.29.0.rc1 app/models/decidim/moderation.rb
decidim-core-0.28.2 app/models/decidim/moderation.rb
decidim-core-0.27.7 app/models/decidim/moderation.rb
decidim-core-0.28.1 app/models/decidim/moderation.rb
decidim-core-0.27.6 app/models/decidim/moderation.rb
decidim-core-0.26.10 app/models/decidim/moderation.rb
decidim-core-0.26.9 app/models/decidim/moderation.rb
decidim-core-0.28.0 app/models/decidim/moderation.rb
decidim-core-0.27.5 app/models/decidim/moderation.rb
decidim-core-0.28.0.rc5 app/models/decidim/moderation.rb
decidim-core-0.28.0.rc4 app/models/decidim/moderation.rb