Sha256: 560205b5ac2b89528a59d26dbc29b819ceefb185f19e2649b14aed9e586afa38

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

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

        def diff_fields_mapping
          {
            name: :i18n,
            published_at: :date,
            weight: :integer
          }
        end

        def i18n_labels_scope
          "activemodel.attributes.election"
        end

        def action_string
          case action
          when "publish", "unpublish", "setup", "start_key_ceremony", "start_vote", "end_vote", "start_tally", "publish_results"
            "decidim.elections.admin_log.election.#{action}"
          else
            super
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-elections-0.25.2 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.25.1 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.25.0 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.25.0.rc4 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.25.0.rc3 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.25.0.rc2 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.25.0.rc1 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.24.3 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.24.2 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.24.1 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.24.0 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.24.0.rc2 app/presenters/decidim/elections/admin_log/election_presenter.rb
decidim-elections-0.24.0.rc1 app/presenters/decidim/elections/admin_log/election_presenter.rb