Sha256: 7b9d32f4e773e49e3545f441949452051be107937a245d95f9d66602b661ed97

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

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

        def action_string
          case action
          when "create", "delete", "update"
            "decidim.meetings.admin_log.invite.#{action}"
          else
            super
          end
        end

        # Tries to use the attendee name from the invitation (resource).
        # If invitation does not exist anymore use the one in extras.
        def i18n_params
          attendee_name = action_log.resource ? action_log.resource.user.name : action_log.extra["attendee_name"]
          super.merge(
            # before Decidim v0.23.0 attendee_name was not being copied into the extras so it may be nil
            attendee_name: attendee_name || "????"
          )
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-meetings-0.29.1 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.28.4 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.29.0 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.28.3 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.29.0.rc4 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.29.0.rc3 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.29.0.rc2 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.29.0.rc1 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.28.2 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.28.1 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.28.0 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.28.0.rc5 app/presenters/decidim/meetings/admin_log/invite_presenter.rb
decidim-meetings-0.28.0.rc4 app/presenters/decidim/meetings/admin_log/invite_presenter.rb