Sha256: 4a0db4c6bd838d1bcd916b50ef970daf6a72cd4e16a6c475bf09adaab31917b3

Contents?: true

Size: 1.37 KB

Versions: 22

Compression:

Stored size: 1.37 KB

Contents

class OrangeEvent < Orange::Carton
  id
  admin do
    title :name
    text :location_name
    text :location_address
    text :location_address2
    text :location_city
    text :location_state
    text :location_zip
    boolean :link_to_eventbrite, :default => false
    text :eventbrite_id
    fulltext :blurb
    fulltext :description
  end
  orange do
    time :starts
    time :ends
  end
  
  def starts_time
    self.starts.strftime("%I:%M %p")
  end
  def starts_date
    self.starts.strftime("%m/%d/%Y")
  end
  def ends_time
    self.ends.strftime("%I:%M %p")
  end
  def ends_date
    self.ends.strftime("%m/%d/%Y")
  end
  def date_attr(attribute, datestr = false)
    time_attr(attribute, false, datestr)
  end
  
  def attribute_time_get(attribute)
    attribute_get(attribute) || Time.now
  end
  def time_attr(attribute, timestr = false, datestr = false)
    date = datestr || attribute_time_get(attribute).strftime("%m/%d/%Y")
    time = timestr || attribute_time_get(attribute).strftime("%I:%M %p")
    attribute_set(attribute, Time.parse(date + " " + time))
  end
  
  def starts_time=(time)
    time_attr(:starts, time)
  end
  def starts_date=(date)
    date_attr(:starts, date)
  end
  def ends_time=(time)
    time_attr(:ends, time)
  end
  def ends_date=(date)
    date_attr(:ends, date)
  end
  
  belongs_to :calendar, "OrangeCalendar", :child_key => [:orange_calendar_id]
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
orange-more-0.5.8 lib/orange-more/events/cartons/orange_event.rb
orange-more-0.5.7 lib/orange-more/events/cartons/orange_event.rb
orange-0.5.5 lib/orange-more/events/cartons/orange_event.rb
orange-0.5.4 lib/orange-more/events/cartons/orange_event.rb
orange-0.5.3 lib/orange-more/events/cartons/orange_event.rb
orange-0.5.2 lib/orange-more/events/cartons/orange_event.rb
orange-0.5.1 lib/orange-more/events/cartons/orange_event.rb
orange-0.4.0 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.9 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.8 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.7 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.6 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.5 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.4 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.3 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.2 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.1 lib/orange-more/events/cartons/orange_event.rb
orange-0.3.0 lib/orange-more/events/cartons/orange_event.rb
orange-0.2.11 lib/orange-more/events/cartons/orange_event.rb
orange-0.2.9 lib/orange-more/events/cartons/orange_event.rb