Sha256: c9caa245a84b0250fa6ce73c0ed3c7d5f45c92862ab547e922e41dd348310578

Contents?: true

Size: 1.41 KB

Versions: 42

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    module AdminLog
      # This class holds the logic to present a `Decidim::Debate`
      # 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
      #    DebatePresenter.new(action_log, view_helpers).present
      class DebatePresenter < Decidim::Log::BasePresenter
        private

        def resource_presenter
          @resource_presenter ||= Decidim::Debates::Log::ResourcePresenter.new(action_log.resource, h, action_log.extra["resource"])
        end

        def diff_fields_mapping
          {
            description: "Decidim::Debates::AdminLog::ValueTypes::DebateTitleDescriptionPresenter",
            end_date: :date,
            information_updates: :i18n,
            instructions: :i18n,
            start_date: :date,
            title: "Decidim::Debates::AdminLog::ValueTypes::DebateTitleDescriptionPresenter"
          }
        end

        def i18n_labels_scope
          "activemodel.attributes.debate"
        end

        def action_string
          case action
          when "create", "update"
            "decidim.debates.admin_log.debate.#{action}"
          else
            super
          end
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
decidim-debates-0.27.6 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.10 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.9 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.27.5 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.8 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.27.4 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.27.3 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.7 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.5 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.27.2 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.27.1 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.4 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.27.0 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.3 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.27.0.rc2 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.27.0.rc1 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.2 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.1 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.0 app/presenters/decidim/debates/admin_log/debate_presenter.rb
decidim-debates-0.26.0.rc2 app/presenters/decidim/debates/admin_log/debate_presenter.rb