Sha256: 79fbfaf6d55b97de6e6930164753e66f0109cb403b004eb29a8879b6840c000a

Contents?: true

Size: 1.02 KB

Versions: 24

Compression:

Stored size: 1.02 KB

Contents

class FestivityEventPage < FestivityBasePage
  has_many :festivity_performances, foreign_key: :event_page_id
  has_many :festivity_page_categories, foreign_key: :page_id
  has_many :festivity_categories, through: :festivity_page_categories

  include Concerns::FestivityArtistMethods

  def festivity_performances=(performances)
    performances.each do |performance|
      performance_id = performance.delete(:performance_id)
      FestivityPerformance.find(performance_id).update_attributes(performance)
    end
  end

  def performances
    self.festivity_performances.select {|perf| perf.festivity_location_page && perf.start_date && perf.end_date }
  end

  def single_location?
    @single_location ||= self.locations.count == 1
  end

  def locations
    @locations ||= event_locations
  end

  def can_buy?
    !self.buy_url.empty?
  end

  def event_locations
    # Return array of unique locations
    self.performances.
        map{ |performance| performance.festivity_location_page }.
        uniq{ |location| location.id }
  end


end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.6.3 app/models/festivity_event_page.rb
trusty-festivity-extension-2.6.2 app/models/festivity_event_page.rb
trusty-festivity-extension-2.6.1 app/models/festivity_event_page.rb
trusty-festivity-extension-2.6 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.19 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.18 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.17 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.16 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.15 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.14 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.13 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.12 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.11 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.10 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.9 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.8 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.7 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.6 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.5 app/models/festivity_event_page.rb
trusty-festivity-extension-2.5.4 app/models/festivity_event_page.rb