Sha256: 51f66bd7bddd288057b149f329b6d8b531537d559eafcef82a715b737edd9b41

Contents?: true

Size: 1.62 KB

Versions: 16

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

class Tramway::Event::Events::Show::EventDecorator < ::Tramway::Core::ApplicationDecorator
  class << self
    def collections
      [:all]
    end
  end

  delegate :title, to: :object
  delegate :description, to: :object
  delegate :participant_form_fields, to: :object
  delegate :sections, to: :object
  delegate :partakings, to: :object
  delegate :request_collecting_state, to: :object

  if defined?(::Tramway::Partner)
    ::Tramway::Partner::Partnership.partnership_type.values.each do |partnership_type|
      decorate_association partnership_type.to_s.pluralize
    end
  end

  def background
    object.photo
  end

  def duration
    return unless object.begin_date.present? || object.end_date.present?

    if object.begin_date.to_date == object.end_date.to_date
      I18n.l(object.begin_date, format: '%d %B %Y').to_s
    elsif object.begin_date.month == object.end_date.month
      "#{I18n.t('date.from')} #{I18n.l(object.begin_date, format: '%d')} #{I18n.t('date.to')} #{I18n.l(object.end_date, format: '%d %B %Y')}"
    else
      "#{I18n.t('date.from')} #{I18n.l(object.begin_date, format: '%d %B %Y')} #{I18n.t('date.to')} #{I18n.l(object.end_date, format: '%d %B %Y')}"
    end
  end

  def partners
    if defined?(::Tramway::Partner)
      @partners ||= ::Tramway::Partner::Partnership.partnership_type.values.reduce({}) do |hash, partnership_type|
        hash.merge! partnership_type => (object.send(partnership_type.to_s.pluralize).active.map do |partner|
          Tramway::Partner::OrganizationFeatureDecorator.decorate partner
        end)
      end
    end
  end

  alias tagline duration
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
tramway-event-1.9.30 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.29 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.28.4 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.28.3 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.28.2 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.28.1 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.28 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.27.6 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.27.5 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.27.4 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.27.3 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.27.2 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.27.1 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.27 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.26 app/decorators/tramway/event/events/show/event_decorator.rb
tramway-event-1.9.25.1 app/decorators/tramway/event/events/show/event_decorator.rb