mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Only geocode addresses associated with enterprises. Makes Checkout#update much faster.
This commit is contained in:
@@ -23,6 +23,7 @@ class Enterprise < ActiveRecord::Base
|
||||
|
||||
after_initialize :initialize_country
|
||||
before_validation :set_unused_address_fields
|
||||
after_validation :geocode_address
|
||||
|
||||
scope :by_name, order('name')
|
||||
scope :is_primary_producer, where(:is_primary_producer => true)
|
||||
@@ -114,4 +115,8 @@ class Enterprise < ActiveRecord::Base
|
||||
def set_unused_address_fields
|
||||
address.firstname = address.lastname = address.phone = 'unused' if address.present?
|
||||
end
|
||||
|
||||
def geocode_address
|
||||
address.geocode if address.changed?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,6 @@ Spree::Address.class_eval do
|
||||
has_one :enterprise
|
||||
|
||||
geocoded_by :full_address
|
||||
after_validation :geocode
|
||||
|
||||
delegate :name, :to => :state, :prefix => true, :allow_nil => true
|
||||
|
||||
@@ -19,7 +18,7 @@ Spree::Address.class_eval do
|
||||
# their way into the database. I don't know what the source of them is, so this patch
|
||||
# is designed to track them down.
|
||||
# This is intended to be a temporary investigative measure, and should be removed from the
|
||||
# code base shortly.
|
||||
# code base shortly. If it's past 17-10-2013, take it out.
|
||||
#
|
||||
#-- Rohan, 17-9-2913
|
||||
def create
|
||||
|
||||
Reference in New Issue
Block a user