mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Adding addresses to existing groups and make them changable
This commit is contained in:
@@ -12,6 +12,7 @@ class EnterpriseGroup < ActiveRecord::Base
|
||||
|
||||
attr_accessible :name, :description, :long_description, :on_front_page, :enterprise_ids
|
||||
attr_accessible :logo, :promo_image
|
||||
attr_accessible :address_attributes
|
||||
attr_accessible :email, :website, :facebook, :instagram, :linkedin, :twitter
|
||||
|
||||
delegate :phone, :to => :address
|
||||
@@ -37,7 +38,7 @@ class EnterpriseGroup < ActiveRecord::Base
|
||||
scope :on_front_page, where(on_front_page: true)
|
||||
|
||||
def set_unused_address_fields
|
||||
address.firstname = address.lastname = address.phone = 'unused' if address.present?
|
||||
address.firstname = address.lastname = 'unused' if address.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -52,9 +52,10 @@
|
||||
%legend Contact
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :phone
|
||||
= af.label :phone
|
||||
%span.required *
|
||||
.omega.eight.columns
|
||||
= f.text_field :phone, { placeholder: "eg. 98 7654 3210"}
|
||||
= af.text_field :phone, { placeholder: "eg. 98 7654 3210"}
|
||||
.row
|
||||
.three.columns.alpha
|
||||
= af.label :address1
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class AddAddressInstancesToExistingEnterpriseGroups < ActiveRecord::Migration
|
||||
def change
|
||||
country = Spree::Country.find_by_name(ENV['DEFAULT_COUNTRY'])
|
||||
state = country.states.first
|
||||
EnterpriseGroup.all.each do |g|
|
||||
if g.address.present? then
|
||||
next
|
||||
end
|
||||
address = Spree::Address.new(firstname: 'unused', lastname: 'unused', address1: 'undefined', city: 'undefined', zipcode: 'undefined', state: state, country: country, phone: 'undefined')
|
||||
g.address = address
|
||||
g.save
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user