Sha256: 559e114440f98be71a14269bd35eb00b61dcf417f8ee803917cda7fd60628528

Contents?: true

Size: 1.13 KB

Versions: 42

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Decidim
  module AdminLog
    # This class holds the logic to present a `Decidim::Moderation`
    # for the `AdminLog` log.
    #
    # Usage should be automatic and you shouldn't need to call this class
    # directly, but here's an example:
    #
    #    action_log = Decidim::ActionLog.last
    #    view_helpers # => this comes from the views
    #    ModerationPresenter.new(action_log, view_helpers).present
    class ModerationPresenter < Decidim::Log::BasePresenter
      private

      def diff_fields_mapping
        {
          hidden_at: :date,
          report_count: :integer
        }
      end

      def action_string
        case action
        when "hide", "unreport"
          "decidim.admin_log.moderation.#{action}"
        else
          super
        end
      end

      def i18n_labels_scope
        "decidim.moderations.models.moderation.fields"
      end

      def i18n_params
        super.merge(
          resource_type: action_log.extra.dig("extra", "reportable_type").try(:demodulize)
        )
      end

      def diff_actions
        super + %w(unreport)
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
decidim-core-0.26.1 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.26.0 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.26.0.rc2 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.26.0.rc1 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.25.2 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.25.1 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.25.0 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.25.0.rc4 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.25.0.rc3 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.25.0.rc2 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.25.0.rc1 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.24.3 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.23.6 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.24.2 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.23.5 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.24.1 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.24.0 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.24.0.rc2 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.23.4 app/presenters/decidim/admin_log/moderation_presenter.rb
decidim-core-0.24.0.rc1 app/presenters/decidim/admin_log/moderation_presenter.rb