Sha256: d2d3ea86f83457e65e18226871cfe89a985748b3fa2208738d1765c325161079

Contents?: true

Size: 909 Bytes

Versions: 20

Compression:

Stored size: 909 Bytes

Contents

class FestivityPerformance < ActiveRecord::Base
  validates_presence_of :event_page_id
  belongs_to :festivity_event_page, foreign_key: :event_page_id
  belongs_to :festivity_location_page, foreign_key: :location_page_id
  default_scope {order :start_date}

  attr_accessible :start_date, :end_date, :festivity_location_page, :notes

  def start_date=(date)
    super(parse_date(date))
  end

  def end_date=(date)
    super(parse_date(date))
  end

  def festivity_location_page=(location)
    super(FestivityLocationPage.find(location[:id])) unless location[:id].blank?
  end

  def location
    FestivityLocationPage.find_by_id(self.location_page_id).title
  end

  def area
    location = FestivityLocationPage.find_by_id(self.location_page_id).parent_id
    FestivityLocationAreaPage.find_by_id(location).title
  end


  private

  def parse_date(date)
    Chronic.parse(date)
  rescue
    nil
  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

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