Sha256: b8e41b2c7a3da8bb82e8fb848dd3b7cc44cb7f2e0f1673286375422a44846b2a

Contents?: true

Size: 1.03 KB

Versions: 12

Compression:

Stored size: 1.03 KB

Contents

module EventPresenter
  module ClassMethods
    # Presents events for a select tag in the views
    def options_for_select_by_organization(organization)
      where(organization_id: organization.id).collect do |event|
        [event.name, event.id]
      end.sort{|a, b| a[0] <=> b[0]} #.unshift([Event::ANY_EVENT_TEXT, Event::ANY_EVENT_ID])
    end
  end

  module InstanceMethods
    def to_s
      self.name || ""
    end

    ### JSON Methods
    def as_widget_json(options = {})
      as_json(options.merge(:methods => ['shows', 'charts', 'venue'])).merge('performances' => upcoming_public_shows.as_json)
    end

    def as_full_calendar_json
      shows.collect do |p|
        { :title  => '',
          :start  => p.datetime_local_to_event,
          :allDay => false,
          :color  => '#077083',
          :id     => p.id
        }
      end
    end

    def as_json(options = {})
      super(options)
    end
  end

  def self.included(receiver)
    receiver.extend         ClassMethods
    receiver.send :include, InstanceMethods
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
artfully_ose-1.3.0.pre4 app/presenters/event_presenter.rb
artfully_ose-1.3.0.pre3 app/presenters/event_presenter.rb
artfully_ose-1.3.0.pre2 app/presenters/event_presenter.rb
artfully_ose-1.3.0.pre1 app/presenters/event_presenter.rb
artfully_ose-1.2.0 app/presenters/event_presenter.rb
artfully_ose-1.2.0.beta.1 app/presenters/event_presenter.rb
artfully_ose-1.2.0.alpha.2 app/presenters/event_presenter.rb
artfully_ose-1.2.0.alpha.1 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.27 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.26 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.24 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.23 app/presenters/event_presenter.rb