Sha256: a231326f951c39430ef79021377137c906c604754106786e3d507dd075557f10

Contents?: true

Size: 966 Bytes

Versions: 6

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    class VotingPresenter < SimpleDelegator
      include Rails.application.routes.mounted_helpers
      include ActionView::Helpers::UrlHelper
      include Decidim::SanitizeHelper
      include Decidim::TranslatableAttributes

      delegate :url, to: :introductory_image, prefix: true
      delegate :url, to: :banner_image, prefix: true

      def title
        content = translated_attribute(voting.title)
        decidim_html_escape(content)
      end

      def introductory_image_url
        return if voting.introductory_image.blank?

        URI.join(decidim.root_url(host: voting.organization.host), voting.introductory_image_url).to_s
      end

      def banner_image_url
        return if voting.banner_image.blank?

        URI.join(decidim.root_url(host: voting.organization.host), voting.banner_image_url).to_s
      end

      def voting
        __getobj__
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-elections-0.24.3 app/presenters/decidim/votings/voting_presenter.rb
decidim-elections-0.24.2 app/presenters/decidim/votings/voting_presenter.rb
decidim-elections-0.24.1 app/presenters/decidim/votings/voting_presenter.rb
decidim-elections-0.24.0 app/presenters/decidim/votings/voting_presenter.rb
decidim-elections-0.24.0.rc2 app/presenters/decidim/votings/voting_presenter.rb
decidim-elections-0.24.0.rc1 app/presenters/decidim/votings/voting_presenter.rb