mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add Enterprise shop preference to allow customer names in reports
This commit is contained in:
@@ -6,6 +6,7 @@ class Enterprise < ActiveRecord::Base
|
||||
preference :shopfront_closed_message, :text, default: ""
|
||||
preference :shopfront_taxon_order, :string, default: ""
|
||||
preference :shopfront_order_cycle_order, :string, default: "orders_close_at"
|
||||
preference :show_customer_names_to_suppliers, :boolean, default: false
|
||||
|
||||
# This is hopefully a temporary measure, pending the arrival of multiple named inventories
|
||||
# for shops. We need this here to allow hubs to restrict visible variants to only those in
|
||||
|
||||
@@ -4,8 +4,8 @@ class Api::Admin::EnterpriseSerializer < ActiveModel::Serializer
|
||||
:preferred_shopfront_message, :preferred_shopfront_closed_message,
|
||||
:preferred_shopfront_taxon_order, :preferred_shopfront_order_cycle_order,
|
||||
:preferred_product_selection_from_inventory_only,
|
||||
:owner, :contact, :users, :tag_groups, :default_tag_group,
|
||||
:require_login, :allow_guest_orders, :allow_order_changes,
|
||||
:preferred_show_customer_names_to_suppliers, :owner, :contact, :users, :tag_groups,
|
||||
:default_tag_group, :require_login, :allow_guest_orders, :allow_order_changes,
|
||||
:logo, :promo_image
|
||||
|
||||
has_one :owner, serializer: Api::Admin::UserSerializer
|
||||
|
||||
@@ -30,7 +30,7 @@ module PermittedAttributes
|
||||
:abn, :acn, :charges_sales_tax, :display_invoice_logo, :invoice_text,
|
||||
:preferred_product_selection_from_inventory_only, :preferred_shopfront_message,
|
||||
:preferred_shopfront_closed_message, :preferred_shopfront_taxon_order,
|
||||
:preferred_shopfront_order_cycle_order
|
||||
:preferred_shopfront_order_cycle_order, :preferred_show_customer_names_to_suppliers
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,3 +89,16 @@
|
||||
.five.columns.omega
|
||||
= f.radio_button :enable_subscriptions, false
|
||||
= f.label :enable_subscriptions, t('.enable_subscriptions_false'), value: :false
|
||||
|
||||
.row
|
||||
.alpha.eleven.columns
|
||||
.three.columns.alpha
|
||||
%label= t '.customer_names_in_reports'
|
||||
%div{'ofn-with-tip' => t('.customer_names_tip')}
|
||||
%a= t 'admin.whats_this'
|
||||
.three.columns
|
||||
= radio_button :enterprise, :preferred_show_customer_names_to_suppliers, true
|
||||
= label :enterprise_preferred_show_customer_names_to_suppliers, t('.customer_names_true'), value: :true
|
||||
.five.columns.omega
|
||||
= radio_button :enterprise, :preferred_show_customer_names_to_suppliers, false
|
||||
= label :enterprise_preferred_show_customer_names_to_suppliers, t('.customer_names_false'), value: :false
|
||||
|
||||
@@ -772,6 +772,10 @@ en:
|
||||
enable_subscriptions_tip: "Enable subscriptions functionality?"
|
||||
enable_subscriptions_false: "Disabled"
|
||||
enable_subscriptions_true: "Enabled"
|
||||
customer_names_in_reports: "Customer Names in Reports"
|
||||
customer_names_tip: "Enable your suppliers to see your customers names in reports"
|
||||
customer_names_false: "Disabled"
|
||||
customer_names_true: "Enabled"
|
||||
shopfront_message: "Shopfront Message"
|
||||
shopfront_message_placeholder: >
|
||||
An optional message to welcome customers and explain how to shop with you. If text is entered here it will be displayed in a home tab when customers first arrive at your shopfront.
|
||||
|
||||
@@ -133,6 +133,15 @@ describe Admin::EnterprisesController, type: :controller do
|
||||
expect(distributor.users).to_not include user
|
||||
end
|
||||
|
||||
it "updates enterprise preferences" do
|
||||
allow(controller).to receive_messages spree_current_user: distributor_manager
|
||||
update_params = { id: distributor, enterprise: { preferred_show_customer_names_to_suppliers: "1" } }
|
||||
spree_post :update, update_params
|
||||
|
||||
distributor.reload
|
||||
expect(distributor.preferences[:show_customer_names_to_suppliers]).to eq true
|
||||
end
|
||||
|
||||
describe "enterprise properties" do
|
||||
let(:producer) { create(:enterprise) }
|
||||
let!(:property) { create(:property, name: "A nice name") }
|
||||
|
||||
Reference in New Issue
Block a user