mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
This for new changes to the enterprise registration/signup flow where a map will be displayed when people are filling in their address. On this map people can check the geocoder has geocoded their address correctly and if not they can manually adjust their latitude/longitude on the map. But currently every time someone changes their address in the Admin > Enterprise > Address section the address would automatically be geocoded so this could overwrite the latitude/longitude that was set during sign up. To prevent the latitude/longitude from being overwritten this add's a checkbox which people need to explicity click if they want their address to be automatically geocoded, otherwise it will just use the manually configured latitude/longitude. Note this new feature which allows people to select their location on a map during registration only works with Google maps so far. So if an instance is using Open Street Map this change also adds support for passing a :use_geocoder parameter to the Api::EnterprisesController during registration so that the address will be geocoded on the backend without the use of a map.
10 lines
229 B
Ruby
10 lines
229 B
Ruby
# frozen_string_literal: true
|
|
|
|
module GeocodeEnterpriseAddress
|
|
extend ActiveSupport::Concern
|
|
|
|
def geocode_address_if_use_geocoder
|
|
AddressGeocoder.new(@enterprise.address).geocode if params[:use_geocoder] == "1"
|
|
end
|
|
end
|