app/models/venue.rb in artfully_ose-1.3.0.pre3 vs app/models/venue.rb in artfully_ose-1.3.0.pre4
- old
+ new
@@ -1,18 +1,41 @@
require 'geocoder'
class Venue < ActiveRecord::Base
belongs_to :organization
has_one :event
+ has_many :charts
validates_presence_of :name
attr_accessible :name, :address1, :address2, :city, :state, :zip, :time_zone, :lat, :long
geocoded_by :full_street_address, :latitude => :lat, :longitude => :long
after_save :run_geocode, :if => :address1_changed?
after_save :refresh_show_stats, :if => :time_zone_changed?
+
+ def default_chart
+ self.charts.first
+ end
+
+ def self.most_recently_named(organization, venue_name)
+ organization.venues
+ .where(:name => venue_name)
+ .order('id desc')
+ .first
+ end
+
+ #
+ # MigrateChartsBackToVenues depends on this method
+ #
+ def update_default_chart_from(chart)
+ new_chart = chart.dup!({:save => true})
+ new_chart.event = nil
+ self.default_chart.destroy if default_chart
+ new_chart.venue = self
+ new_chart.save
+ end
def name_and_address_as_string
string = ''
string = self.name
string += " -- " if (self.name? && self.address_as_string.present?)