mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
This was actually shown in one place and represents a user-facing change. But you weren't able to edit the field which means that only very old enterprises would have had this field set and were not able to change it anymore. I searched au-prod and found the following values in the database: - "Friday 31st January" - "From 4pm, Monday 30 September" - "From 5pm-7pm Monday" - "Saturday 27 April 12noon" - "January 31st/February 1st" - "Saturday 1st February" They seem specific to a certain order cycle and have no value as fallback any more. Seems safe to remove.
51 lines
1.7 KiB
Ruby
51 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'csv'
|
|
|
|
namespace :ofn do
|
|
# Note this task is still rather naive and only covers the simple case where
|
|
# an enterprise was created but never used and thus, does not have any
|
|
# associated entities like orders.
|
|
desc 'remove the specified enterprise'
|
|
task :remove_enterprise, [:enterprise_id] => :environment do |_task, args|
|
|
enterprise = Enterprise.find(args.enterprise_id)
|
|
enterprise.destroy
|
|
end
|
|
|
|
namespace :dev do
|
|
desc 'export enterprises to CSV'
|
|
task export_enterprises: :environment do
|
|
CSV.open('db/enterprises.csv', 'wb') do |csv|
|
|
csv << enterprise_header
|
|
enterprises.each do |enterprise|
|
|
csv << enterprise_row(enterprise)
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def enterprises
|
|
Enterprise.by_name
|
|
end
|
|
|
|
def enterprise_header
|
|
['name', 'description', 'long_description', 'is_primary_producer', 'is_distributor',
|
|
'contact_name', 'phone', 'email', 'website', 'twitter', 'abn', 'acn',
|
|
'visible', 'facebook', 'instagram', 'linkedin',
|
|
'address1', 'address2', 'city', 'zipcode', 'state', 'country']
|
|
end
|
|
|
|
def enterprise_row(enterprise)
|
|
[enterprise.name, enterprise.description, enterprise.long_description,
|
|
enterprise.is_primary_producer, enterprise.is_distributor, enterprise.contact_name,
|
|
enterprise.phone, enterprise.email, enterprise.website, enterprise.twitter, enterprise.abn,
|
|
enterprise.acn,
|
|
enterprise.visible, enterprise.facebook, enterprise.instagram,
|
|
enterprise.linkedin, enterprise.address.address1, enterprise.address.address2,
|
|
enterprise.address.city, enterprise.address.zipcode, enterprise.address.state_name,
|
|
enterprise.address.country&.name]
|
|
end
|
|
end
|
|
end
|