Sha256: 1996f7bb4d68c5d519bedc21dfeee94e8d8dfdd46a6537e861d08f4d68efab83

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    class AssemblyPresenter < SimpleDelegator
      include Decidim::TranslationsHelper

      def hero_image_url
        assembly.attached_uploader(:hero_image).url(host: assembly.organization.host)
      end

      def banner_image_url
        assembly.attached_uploader(:banner_image).url(host: assembly.organization.host)
      end

      def area_name
        return if assembly.area.blank?

        Decidim::AreaPresenter.new(assembly.area).translated_name_with_type
      end

      def creation_date
        formatted_date(assembly.creation_date)
      end

      def included_at
        formatted_date(assembly.included_at)
      end

      def closing_date
        formatted_date(assembly.closing_date)
      end

      def duration
        return I18n.t("indefinite_duration", scope: "decidim.assemblies.assemblies.description") if (date = assembly.duration).blank?

        formatted_date(date)
      end

      def assembly_type
        return if assembly.assembly_type.blank?

        translated_attribute(assembly.assembly_type.title)
      end

      def formatted_date(date)
        return if date.blank?

        I18n.l(date, format: :decidim_short)
      end

      def assembly
        __getobj__
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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