mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-03 22:06:07 +00:00
Merge pull request #7720 from luisramos0/rubocop_auto_correct
Executed rubocop autocorrect (-a for safe corrections plus adding frozen_string_literal comment to all files)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
0
.simplecov
Normal file → Executable file
0
.simplecov
Normal file → Executable file
10
Gemfile
10
Gemfile
@@ -74,14 +74,14 @@ gem 'figaro'
|
||||
gem 'geocoder'
|
||||
gem 'gmaps4rails'
|
||||
gem 'mimemagic', '> 0.3.5'
|
||||
gem 'paper_trail', '~> 10.3.1'
|
||||
gem 'paperclip', '~> 3.4.1'
|
||||
gem 'paper_trail', '~> 10.3.1'
|
||||
gem 'rack-rewrite'
|
||||
gem 'rack-ssl', require: 'rack/ssl'
|
||||
gem 'roadie-rails'
|
||||
|
||||
gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
|
||||
gem 'hiredis'
|
||||
gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
|
||||
gem 'sidekiq'
|
||||
gem 'sidekiq-scheduler'
|
||||
|
||||
@@ -152,17 +152,16 @@ end
|
||||
group :test do
|
||||
gem 'byebug'
|
||||
gem 'codecov', require: false
|
||||
gem 'pdf-reader'
|
||||
gem 'rails-controller-testing'
|
||||
gem 'simplecov', require: false
|
||||
gem 'test-prof'
|
||||
gem 'webmock'
|
||||
gem 'rails-controller-testing'
|
||||
gem 'pdf-reader'
|
||||
# See spec/spec_helper.rb for instructions
|
||||
# gem 'perftools.rb'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'web-console'
|
||||
gem 'debugger-linecache'
|
||||
gem 'pry'
|
||||
gem 'pry-byebug'
|
||||
@@ -170,6 +169,7 @@ group :development do
|
||||
gem 'rubocop-rails'
|
||||
gem 'spring'
|
||||
gem 'spring-commands-rspec'
|
||||
gem 'web-console'
|
||||
|
||||
gem "view_component_storybook", require: "view_component/storybook/engine"
|
||||
|
||||
|
||||
4
Rakefile
4
Rakefile
@@ -8,6 +8,6 @@ require_relative 'config/application'
|
||||
|
||||
Openfoodnetwork::Application.load_tasks
|
||||
|
||||
unless ENV['DISABLE_KNAPSACK']
|
||||
Knapsack.load_tasks if defined?(Knapsack)
|
||||
if !ENV['DISABLE_KNAPSACK'] && defined?(Knapsack)
|
||||
Knapsack.load_tasks
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class BulkLineItemsController < Spree::Admin::BaseController
|
||||
include PaginationData
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ColumnPreferencesController < Admin::ResourceController
|
||||
before_action :load_collection, only: [:bulk_update]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ContentsController < Spree::Admin::BaseController
|
||||
def edit
|
||||
@@ -16,7 +18,8 @@ module Admin
|
||||
# Save any uploaded images
|
||||
ContentConfig.save
|
||||
|
||||
flash[:success] = t(:successfully_updated, resource: I18n.t('admin.contents.edit.your_content'))
|
||||
flash[:success] =
|
||||
t(:successfully_updated, resource: I18n.t('admin.contents.edit.your_content'))
|
||||
|
||||
redirect_to main_app.edit_admin_contents_path
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/address_finder'
|
||||
|
||||
module Admin
|
||||
@@ -10,7 +12,10 @@ module Admin
|
||||
tag_rule_mapping = TagRule.mapping_for(Enterprise.where(id: @customer.enterprise))
|
||||
render_as_json @customer, tag_rule_mapping: tag_rule_mapping
|
||||
},
|
||||
failure: lambda { render json: { errors: @customer.errors.full_messages }, status: :unprocessable_entity }
|
||||
failure: lambda {
|
||||
render json: { errors: @customer.errors.full_messages },
|
||||
status: :unprocessable_entity
|
||||
}
|
||||
} }
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class EnterpriseFeesController < Admin::ResourceController
|
||||
before_action :load_enterprise_fee_set, only: :index
|
||||
@@ -16,7 +18,9 @@ module Admin
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render_as_json @collection, controller: self, include_calculators: @include_calculators }
|
||||
format.json {
|
||||
render_as_json @collection, controller: self, include_calculators: @include_calculators
|
||||
}
|
||||
# format.json { @presented_collection = @collection.each_with_index.map { |ef, i| EnterpriseFeePresenter.new(self, ef, i) } }
|
||||
end
|
||||
end
|
||||
@@ -56,10 +60,12 @@ module Admin
|
||||
order_cycle = OrderCycle.find_by(id: params[:order_cycle_id]) if params[:order_cycle_id]
|
||||
coordinator = Enterprise.find_by(id: params[:coordinator_id]) if params[:coordinator_id]
|
||||
order_cycle = OrderCycle.new(coordinator: coordinator) if order_cycle.nil? && coordinator.present?
|
||||
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user, order_cycle).visible_enterprises
|
||||
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user,
|
||||
order_cycle).visible_enterprises
|
||||
EnterpriseFee.for_enterprises(enterprises).order('enterprise_id', 'fee_type', 'name')
|
||||
else
|
||||
collection = EnterpriseFee.managed_by(spree_current_user).order('enterprise_id', 'fee_type', 'name')
|
||||
collection = EnterpriseFee.managed_by(spree_current_user).order('enterprise_id',
|
||||
'fee_type', 'name')
|
||||
collection = collection.for_enterprise(current_enterprise) if current_enterprise
|
||||
collection
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class EnterpriseGroupsController < Admin::ResourceController
|
||||
before_action :load_data, except: :index
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class EnterpriseRelationshipsController < Admin::ResourceController
|
||||
def index
|
||||
@@ -16,7 +18,8 @@ module Admin
|
||||
if @enterprise_relationship.save
|
||||
render plain: Api::Admin::EnterpriseRelationshipSerializer.new(@enterprise_relationship).to_json
|
||||
else
|
||||
render status: :bad_request, json: { errors: @enterprise_relationship.errors.full_messages.join(', ') }
|
||||
render status: :bad_request,
|
||||
json: { errors: @enterprise_relationship.errors.full_messages.join(', ') }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class EnterpriseRolesController < Admin::ResourceController
|
||||
def index
|
||||
@@ -13,7 +15,8 @@ module Admin
|
||||
render plain: Api::Admin::EnterpriseRoleSerializer.new(@enterprise_role).to_json
|
||||
|
||||
else
|
||||
render status: :bad_request, json: { errors: @enterprise_role.errors.full_messages.join(', ') }
|
||||
render status: :bad_request,
|
||||
json: { errors: @enterprise_role.errors.full_messages.join(', ') }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/referer_parser'
|
||||
require 'open_food_network/permissions'
|
||||
require 'open_food_network/order_cycle_permissions'
|
||||
@@ -32,7 +34,10 @@ module Admin
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render_as_json @collection, ams_prefix: params[:ams_prefix], spree_current_user: spree_current_user }
|
||||
format.json {
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix],
|
||||
spree_current_user: spree_current_user
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,11 +61,15 @@ module Admin
|
||||
respond_with(@object) do |format|
|
||||
format.html { redirect_to location_after_save }
|
||||
format.js { render layout: false }
|
||||
format.json { render_as_json @object, ams_prefix: 'index', spree_current_user: spree_current_user }
|
||||
format.json {
|
||||
render_as_json @object, ams_prefix: 'index', spree_current_user: spree_current_user
|
||||
}
|
||||
end
|
||||
else
|
||||
respond_with(@object) do |format|
|
||||
format.json { render json: { errors: @object.errors.messages }, status: :unprocessable_entity }
|
||||
format.json {
|
||||
render json: { errors: @object.errors.messages }, status: :unprocessable_entity
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -101,7 +110,8 @@ module Admin
|
||||
def for_order_cycle
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: @collection, each_serializer: Api::Admin::ForOrderCycle::EnterpriseSerializer, order_cycle: @order_cycle, spree_current_user: spree_current_user
|
||||
render json: @collection,
|
||||
each_serializer: Api::Admin::ForOrderCycle::EnterpriseSerializer, order_cycle: @order_cycle, spree_current_user: spree_current_user
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -109,7 +119,8 @@ module Admin
|
||||
def visible
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix] || 'basic', spree_current_user: spree_current_user
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix] || 'basic',
|
||||
spree_current_user: spree_current_user
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -152,7 +163,7 @@ module Admin
|
||||
if enterprises.present?
|
||||
enterprises.includes(
|
||||
supplied_products:
|
||||
[:supplier, master: [:images], variants: { option_values: :option_type }]
|
||||
[:supplier, { master: [:images], variants: { option_values: :option_type } }]
|
||||
)
|
||||
end
|
||||
when :index
|
||||
@@ -284,7 +295,8 @@ module Admin
|
||||
end
|
||||
|
||||
def strip_new_properties
|
||||
unless spree_current_user.admin? || params.dig(:enterprise, :producer_properties_attributes).nil?
|
||||
unless spree_current_user.admin? || params.dig(:enterprise,
|
||||
:producer_properties_attributes).nil?
|
||||
names = Spree::Property.pluck(:name)
|
||||
enterprise_params[:producer_properties_attributes].each do |key, property|
|
||||
enterprise_params[:producer_properties_attributes].delete key unless names.include? property[:property_name]
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class InventoryItemsController < Admin::ResourceController
|
||||
respond_to :json
|
||||
|
||||
respond_override update: { json: {
|
||||
success: lambda { render_as_json @inventory_item },
|
||||
failure: lambda { render json: { errors: @inventory_item.errors.full_messages }, status: :unprocessable_entity }
|
||||
failure: lambda {
|
||||
render json: { errors: @inventory_item.errors.full_messages },
|
||||
status: :unprocessable_entity
|
||||
}
|
||||
} }
|
||||
|
||||
respond_override create: { json: {
|
||||
success: lambda { render_as_json @inventory_item },
|
||||
failure: lambda { render json: { errors: @inventory_item.errors.full_messages }, status: :unprocessable_entity }
|
||||
failure: lambda {
|
||||
render json: { errors: @inventory_item.errors.full_messages },
|
||||
status: :unprocessable_entity
|
||||
}
|
||||
} }
|
||||
|
||||
private
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class InvoiceSettingsController < Spree::Admin::BaseController
|
||||
def update
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ManagerInvitationsController < Spree::Admin::BaseController
|
||||
authorize_resource class: false
|
||||
@@ -11,7 +13,8 @@ module Admin
|
||||
existing_user = Spree::User.find_by(email: @email)
|
||||
|
||||
if existing_user
|
||||
render json: { errors: t('admin.enterprises.invite_manager.user_already_exists') }, status: :unprocessable_entity
|
||||
render json: { errors: t('admin.enterprises.invite_manager.user_already_exists') },
|
||||
status: :unprocessable_entity
|
||||
return
|
||||
end
|
||||
|
||||
@@ -20,7 +23,8 @@ module Admin
|
||||
if new_user
|
||||
render json: { user: new_user.id }, status: :ok
|
||||
else
|
||||
render json: { errors: t('admin.enterprises.invite_manager.error') }, status: :internal_server_error
|
||||
render json: { errors: t('admin.enterprises.invite_manager.error') },
|
||||
status: :internal_server_error
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class MatomoSettingsController < Spree::Admin::BaseController
|
||||
def update
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class OrderCyclesController < Admin::ResourceController
|
||||
include OrderCyclesHelper
|
||||
@@ -156,8 +158,8 @@ module Admin
|
||||
orders_close_at_gt = raw_params[:q].andand.delete(:orders_close_at_gt) || 31.days.ago
|
||||
raw_params[:q] = {
|
||||
g: [raw_params.delete(:q) || {}, { m: 'or',
|
||||
orders_close_at_gt: orders_close_at_gt,
|
||||
orders_close_at_null: true }]
|
||||
orders_close_at_gt: orders_close_at_gt,
|
||||
orders_close_at_null: true }]
|
||||
}
|
||||
@collection = collection
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ProducerPropertiesController < Admin::ResourceController
|
||||
before_action :load_enterprise
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'roo'
|
||||
|
||||
module Admin
|
||||
@@ -12,7 +14,8 @@ module Admin
|
||||
|
||||
def import
|
||||
@filepath = save_uploaded_file(params[:file])
|
||||
@importer = ProductImport::ProductImporter.new(File.new(@filepath), spree_current_user, params[:settings])
|
||||
@importer = ProductImport::ProductImporter.new(File.new(@filepath), spree_current_user,
|
||||
params[:settings])
|
||||
@original_filename = params[:file].try(:original_filename)
|
||||
@non_updatable_fields = ProductImport::EntryValidator.non_updatable_fields
|
||||
|
||||
@@ -34,7 +37,8 @@ module Admin
|
||||
end
|
||||
|
||||
def reset_absent_products
|
||||
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]), spree_current_user, import_into: params[:import_into], enterprises_to_reset: params[:enterprises_to_reset], updated_ids: params[:updated_ids], settings: params[:settings])
|
||||
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]),
|
||||
spree_current_user, import_into: params[:import_into], enterprises_to_reset: params[:enterprises_to_reset], updated_ids: params[:updated_ids], settings: params[:settings])
|
||||
|
||||
if params.key?(:enterprises_to_reset) && params.key?(:updated_ids)
|
||||
@importer.reset_absent(params[:updated_ids])
|
||||
@@ -52,7 +56,8 @@ module Admin
|
||||
end
|
||||
|
||||
def process_data(method)
|
||||
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]), spree_current_user, start: params[:start], end: params[:end], settings: params[:settings])
|
||||
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]),
|
||||
spree_current_user, start: params[:start], end: params[:end], settings: params[:settings])
|
||||
|
||||
begin
|
||||
@importer.public_send("#{method}_entries")
|
||||
@@ -75,7 +80,8 @@ module Admin
|
||||
|
||||
def check_spreadsheet_has_data(importer)
|
||||
unless importer.item_count
|
||||
redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
|
||||
redirect_to '/admin/product_import',
|
||||
notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ProxyOrdersController < Admin::ResourceController
|
||||
respond_to :json
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ResourceController < Spree::Admin::BaseController
|
||||
helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/permissions'
|
||||
require 'order_management/subscriptions/proxy_order_syncer'
|
||||
|
||||
@@ -15,18 +17,31 @@ module Admin
|
||||
respond_to :json
|
||||
|
||||
respond_override create: { json: {
|
||||
success: lambda { render_as_json @schedule, editable_schedule_ids: permissions.editable_schedules.pluck(:id) },
|
||||
failure: lambda { render json: { errors: @schedule.errors.full_messages }, status: :unprocessable_entity }
|
||||
success: lambda {
|
||||
render_as_json @schedule,
|
||||
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
|
||||
},
|
||||
failure: lambda {
|
||||
render json: { errors: @schedule.errors.full_messages },
|
||||
status: :unprocessable_entity
|
||||
}
|
||||
} }
|
||||
respond_override update: { json: {
|
||||
success: lambda { render_as_json @schedule, editable_schedule_ids: permissions.editable_schedules.pluck(:id) },
|
||||
failure: lambda { render json: { errors: @schedule.errors.full_messages }, status: :unprocessable_entity }
|
||||
success: lambda {
|
||||
render_as_json @schedule,
|
||||
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
|
||||
},
|
||||
failure: lambda {
|
||||
render json: { errors: @schedule.errors.full_messages },
|
||||
status: :unprocessable_entity
|
||||
}
|
||||
} }
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix], editable_schedule_ids: permissions.editable_schedules.pluck(:id)
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix],
|
||||
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -111,7 +126,8 @@ module Admin
|
||||
def check_dependent_subscriptions
|
||||
return if Subscription.where(schedule_id: @schedule).empty?
|
||||
|
||||
render json: { errors: [t('admin.schedules.destroy.associated_subscriptions_error')] }, status: :conflict
|
||||
render json: { errors: [t('admin.schedules.destroy.associated_subscriptions_error')] },
|
||||
status: :conflict
|
||||
end
|
||||
|
||||
def permissions
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'stripe/account_connector'
|
||||
|
||||
module Admin
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# This controller is used by super admin users to update the settings the app is using
|
||||
|
||||
module Admin
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/permissions'
|
||||
require 'open_food_network/order_cycle_permissions'
|
||||
require 'open_food_network/scope_variant_to_hub'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/permissions'
|
||||
|
||||
module Admin
|
||||
@@ -85,7 +87,8 @@ module Admin
|
||||
def collection
|
||||
if request.format.json?
|
||||
permissions.editable_subscriptions.ransack(params[:q]).result
|
||||
.preload([:shop, :customer, :schedule, :subscription_line_items, :ship_address, :bill_address, proxy_orders: { order: :order_cycle }])
|
||||
.preload([:shop, :customer, :schedule, :subscription_line_items, :ship_address,
|
||||
:bill_address, { proxy_orders: { order: :order_cycle } }])
|
||||
else
|
||||
Subscription.where("1=0")
|
||||
end
|
||||
@@ -116,11 +119,13 @@ module Admin
|
||||
end
|
||||
|
||||
def wrap_bill_address_attrs
|
||||
subscription_params[:bill_address_attributes] = raw_params[:bill_address].slice(*Spree::Address.attribute_names)
|
||||
subscription_params[:bill_address_attributes] =
|
||||
raw_params[:bill_address].slice(*Spree::Address.attribute_names)
|
||||
end
|
||||
|
||||
def wrap_ship_address_attrs
|
||||
subscription_params[:ship_address_attributes] = raw_params[:ship_address].slice(*Spree::Address.attribute_names)
|
||||
subscription_params[:ship_address_attributes] =
|
||||
raw_params[:ship_address].slice(*Spree::Address.attribute_names)
|
||||
end
|
||||
|
||||
def check_for_open_orders
|
||||
@@ -129,14 +134,16 @@ module Admin
|
||||
@open_orders_to_keep = @subscription.proxy_orders.placed_and_open.pluck(:id)
|
||||
return if @open_orders_to_keep.empty? || params[:open_orders] == 'keep'
|
||||
|
||||
render json: { errors: { open_orders: t('admin.subscriptions.confirm_cancel_open_orders_msg') } }, status: :conflict
|
||||
render json: { errors: { open_orders: t('admin.subscriptions.confirm_cancel_open_orders_msg') } },
|
||||
status: :conflict
|
||||
end
|
||||
|
||||
def check_for_canceled_orders
|
||||
return if params[:canceled_orders] == 'notified'
|
||||
return if @subscription.proxy_orders.active.canceled.empty?
|
||||
|
||||
render json: { errors: { canceled_orders: t('admin.subscriptions.resume_canceled_orders_msg') } }, status: :conflict
|
||||
render json: { errors: { canceled_orders: t('admin.subscriptions.resume_canceled_orders_msg') } },
|
||||
status: :conflict
|
||||
end
|
||||
|
||||
def strip_banned_attrs
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class TagRulesController < Admin::ResourceController
|
||||
respond_to :json
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/spree_api_key_loader'
|
||||
|
||||
module Admin
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V0
|
||||
class TaxonsController < Api::V0::BaseController
|
||||
|
||||
@@ -52,10 +52,10 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def redirect_to(options = {}, response_status = {})
|
||||
::Rails.logger.error("Redirected by #{begin
|
||||
caller(1).first
|
||||
rescue StandardError
|
||||
'unknown'
|
||||
end}")
|
||||
caller(1).first
|
||||
rescue StandardError
|
||||
'unknown'
|
||||
end}")
|
||||
super(options, response_status)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CartController < BaseController
|
||||
before_action :check_authorization
|
||||
|
||||
|
||||
@@ -152,8 +152,8 @@ class CheckoutController < ::BaseController
|
||||
|
||||
def checkout_workflow(shipping_method_id)
|
||||
while @order.state != "complete"
|
||||
if @order.state == "payment"
|
||||
return if redirect_to_payment_gateway
|
||||
if @order.state == "payment" && redirect_to_payment_gateway
|
||||
return
|
||||
end
|
||||
|
||||
next if OrderWorkflow.new(@order).next({ shipping_method_id: shipping_method_id })
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'discourse/single_sign_on'
|
||||
|
||||
class DiscourseSsoController < ApplicationController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/enterprise_injection_data'
|
||||
|
||||
class EnterprisesController < BaseController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GroupsController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class HomeController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class LineItemsController < BaseController
|
||||
respond_to :json
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MapController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# For the API
|
||||
ActionController::Metal.class_eval do
|
||||
def spree_current_user
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ProducersController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/spree_api_key_loader'
|
||||
|
||||
class RegistrationController < BaseController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ShopController < BaseController
|
||||
layout "darkswarm"
|
||||
before_action :require_distributor_chosen, :set_order_cycles, except: :changeable_orders_alert
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ShopsController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SitemapController < ApplicationController
|
||||
layout nil
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class AdjustmentsController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class BaseController < ApplicationController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class CountriesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class GeneralSettingsController < Spree::Admin::BaseController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class ImagesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class InvoicesController < Spree::Admin::BaseController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class MailMethodsController < Spree::Admin::BaseController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
module Orders
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/spree_api_key_loader'
|
||||
|
||||
module Spree
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# this clas was inspired (heavily) from the mephisto admin architecture
|
||||
module Spree
|
||||
module Admin
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class PaymentMethodsController < ::Admin::ResourceController
|
||||
|
||||
@@ -11,7 +11,7 @@ module Spree
|
||||
before_action :can_transition_to_payment
|
||||
# We ensure that items are in stock before all screens if the order is in the Payment state.
|
||||
# This way, we don't allow someone to enter credit card details for an order only to be told
|
||||
# that it can't be processed.
|
||||
# that it can't be processed.
|
||||
before_action :ensure_sufficient_stock_lines
|
||||
|
||||
respond_to :html
|
||||
@@ -150,7 +150,7 @@ module Spree
|
||||
return if !@order.payment? || @order.insufficient_stock_lines.blank?
|
||||
|
||||
flash[:error] = I18n.t("spree.orders.line_item.insufficient_stock",
|
||||
on_hand: "0 #{out_of_stock_item_names}")
|
||||
on_hand: "0 #{out_of_stock_item_names}")
|
||||
redirect_to spree.edit_admin_order_url(@order)
|
||||
end
|
||||
|
||||
@@ -171,7 +171,7 @@ module Spree
|
||||
end
|
||||
|
||||
def authorize_stripe_sca_payment
|
||||
return unless @payment.payment_method.class == Spree::Gateway::StripeSCA
|
||||
return unless @payment.payment_method.instance_of?(Spree::Gateway::StripeSCA)
|
||||
|
||||
@payment.authorize!(full_order_path(@payment.order))
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class ProductPropertiesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/spree_api_key_loader'
|
||||
require 'open_food_network/referer_parser'
|
||||
require 'open_food_network/permissions'
|
||||
@@ -161,7 +163,9 @@ module Spree
|
||||
private
|
||||
|
||||
def product_set_from_params
|
||||
collection_hash = Hash[products_bulk_params[:products].each_with_index.map { |p, i| [i, p] }]
|
||||
collection_hash = Hash[products_bulk_params[:products].each_with_index.map { |p, i|
|
||||
[i, p]
|
||||
} ]
|
||||
Sets::ProductSet.new(collection_attributes: collection_hash)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class PropertiesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'csv'
|
||||
|
||||
require 'open_food_network/reports/list'
|
||||
@@ -46,7 +48,8 @@ module Spree
|
||||
def customers
|
||||
@report_types = report_types[:customers]
|
||||
@report_type = params[:report_type]
|
||||
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, raw_params, render_content?
|
||||
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, raw_params,
|
||||
render_content?
|
||||
render_report(@report.header, @report.table, params[:csv], "customers_#{timestamp}.csv")
|
||||
end
|
||||
|
||||
@@ -91,7 +94,8 @@ module Spree
|
||||
def sales_tax
|
||||
@distributors = my_distributors
|
||||
@report_type = params[:report_type]
|
||||
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, raw_params, render_content?
|
||||
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, raw_params,
|
||||
render_content?
|
||||
render_report(@report.header, @report.table, params[:csv], "sales_tax.csv")
|
||||
end
|
||||
|
||||
@@ -101,7 +105,8 @@ module Spree
|
||||
@report_type = params[:report_type]
|
||||
|
||||
# -- Build Report with Order Grouper
|
||||
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, raw_params, render_content?
|
||||
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, raw_params,
|
||||
render_content?
|
||||
@table = order_grouper_table
|
||||
csv_file_name = "payments_#{timestamp}.csv"
|
||||
|
||||
@@ -279,14 +284,14 @@ module Spree
|
||||
def describe_report(report)
|
||||
name = I18n.t(:name, scope: [:admin, :reports, report])
|
||||
description = begin
|
||||
I18n.t!(:description, scope: [:admin, :reports, report])
|
||||
rescue I18n::MissingTranslationData
|
||||
render_to_string(
|
||||
partial: "#{report}_description",
|
||||
layout: false,
|
||||
locals: { report_types: report_types[report] }
|
||||
).html_safe
|
||||
end
|
||||
I18n.t!(:description, scope: [:admin, :reports, report])
|
||||
rescue I18n::MissingTranslationData
|
||||
render_to_string(
|
||||
partial: "#{report}_description",
|
||||
layout: false,
|
||||
locals: { report_types: report_types[report] }
|
||||
).html_safe
|
||||
end
|
||||
{ name: name, url: url_for_report(report), description: description }
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class ReturnAuthorizationsController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class SearchController < Spree::Admin::BaseController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class ShippingCategoriesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class ShippingMethodsController < ::Admin::ResourceController
|
||||
@@ -87,7 +89,7 @@ module Spree
|
||||
params.require(:shipping_method).permit(
|
||||
:name, :description, :display_on, :require_ship_address, :tag_list, :calculator_type,
|
||||
:tax_category_id, distributor_ids: [],
|
||||
calculator_attributes: PermittedAttributes::Calculator.attributes
|
||||
calculator_attributes: PermittedAttributes::Calculator.attributes
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class StatesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxCategoriesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxRatesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxSettingsController < Spree::Admin::BaseController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxonomiesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxonsController < Spree::Admin::BaseController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class UsersController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/scope_variants_for_search'
|
||||
|
||||
module Spree
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class ZonesController < ::Admin::ResourceController
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class OrdersController < ::BaseController
|
||||
include OrderCyclesHelper
|
||||
@@ -131,7 +133,7 @@ module Spree
|
||||
result = ProcessPaymentIntent.new(params["payment_intent"], @order).call!
|
||||
|
||||
unless result.ok?
|
||||
flash.now[:error] = "#{I18n.t("payment_could_not_process")}. #{result.error}"
|
||||
flash.now[:error] = "#{I18n.t('payment_could_not_process')}. #{result.error}"
|
||||
end
|
||||
@order.reload
|
||||
end
|
||||
|
||||
@@ -26,7 +26,9 @@ module Spree
|
||||
# sent back and the response is handled in the #confirm action in this controller.
|
||||
redirect_to provider.express_checkout_url(pp_response, useraction: 'commit')
|
||||
else
|
||||
flash[:error] = Spree.t('flash.generic_error', scope: 'paypal', reasons: pp_response.errors.map(&:long_message).join(" "))
|
||||
flash[:error] =
|
||||
Spree.t('flash.generic_error', scope: 'paypal',
|
||||
reasons: pp_response.errors.map(&:long_message).join(" "))
|
||||
redirect_to main_app.checkout_state_path(:payment)
|
||||
end
|
||||
rescue SocketError
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class UsersController < ::BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'stripe/account_connector'
|
||||
|
||||
module Stripe
|
||||
@@ -13,7 +15,8 @@ module Stripe
|
||||
else
|
||||
flash[:error] = t('admin.controllers.enterprises.stripe_connect_fail')
|
||||
end
|
||||
redirect_to main_app.edit_admin_enterprise_path(connector.enterprise, anchor: 'payment_methods')
|
||||
redirect_to main_app.edit_admin_enterprise_path(connector.enterprise,
|
||||
anchor: 'payment_methods')
|
||||
rescue Stripe::StripeError => e
|
||||
render plain: e.message, status: :internal_server_error
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'stripe/webhook_handler'
|
||||
|
||||
module Stripe
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserConfirmationsController < DeviseController
|
||||
# Needed for access to current_ability, so we can authorize! actions
|
||||
include Spree::Core::ControllerHelpers::Auth
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserPasswordsController < Spree::UserPasswordsController
|
||||
layout 'darkswarm'
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/error_logger'
|
||||
|
||||
class UserRegistrationsController < Spree::UserRegistrationsController
|
||||
I18N_SCOPE = 'devise.user_registrations.spree_user'.freeze
|
||||
I18N_SCOPE = 'devise.user_registrations.spree_user'
|
||||
|
||||
before_action :set_checkout_redirect, only: :create
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
module EnterprisesHelper
|
||||
def add_check_if_single(count)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
module InjectionHelper
|
||||
def admin_inject_enterprise
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
module OrdersHelper
|
||||
# Adjustments to display under "Order adjustments".
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
module SubscriptionsHelper
|
||||
def subscriptions_setup_complete?(shops)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AngularFormBuilder < ActionView::Helpers::FormBuilder
|
||||
def ng_fields_for(record_name, *_args)
|
||||
raise "Nested ng_fields_for is not yet supported" if @fields_for_record_name.present?
|
||||
@@ -23,13 +25,15 @@ class AngularFormBuilder < ActionView::Helpers::FormBuilder
|
||||
def ng_select(method, choices, angular_field, options = {})
|
||||
options.reverse_merge!('id' => angular_id(method), 'ng-model' => angular_model(method).to_s)
|
||||
|
||||
@template.select_tag angular_name(method), @template.ng_options_for_select(choices, angular_field), options
|
||||
@template.select_tag angular_name(method),
|
||||
@template.ng_options_for_select(choices, angular_field), options
|
||||
end
|
||||
|
||||
def ng_collection_select(method, collection, value_method, text_method, angular_field, options = {})
|
||||
options.reverse_merge!('id' => angular_id(method), 'ng-model' => angular_model(method).to_s)
|
||||
|
||||
@template.select_tag angular_name(method), @template.ng_options_from_collection_for_select(collection, value_method, text_method, angular_field), options
|
||||
@template.select_tag angular_name(method),
|
||||
@template.ng_options_from_collection_for_select(collection, value_method, text_method, angular_field), options
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module AngularFormHelper
|
||||
def ng_options_for_select(container, _angular_field = nil)
|
||||
return container if String === container
|
||||
return container if container.is_a?(String)
|
||||
|
||||
container.map do |element|
|
||||
html_attributes = option_html_attributes(element)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ApplicationHelper
|
||||
include RawParams
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module CheckoutHelper
|
||||
def guest_checkout_allowed?
|
||||
current_order.distributor.allow_guest_orders?
|
||||
@@ -10,12 +12,28 @@ module CheckoutHelper
|
||||
|
||||
# Remove empty tax adjustments and (optionally) shipping fees
|
||||
adjustments.reject! { |a| a.originator_type == 'Spree::TaxRate' && a.amount == 0 }
|
||||
adjustments.reject! { |a| a.originator_type == 'Spree::ShippingMethod' } if exclude.include? :shipping
|
||||
adjustments.reject! { |a| a.originator_type == 'Spree::PaymentMethod' } if exclude.include? :payment
|
||||
adjustments.reject! { |a| a.adjustable_type == 'Spree::LineItem' } if exclude.include? :line_item
|
||||
if exclude.include? :shipping
|
||||
adjustments.reject! { |a|
|
||||
a.originator_type == 'Spree::ShippingMethod'
|
||||
}
|
||||
end
|
||||
if exclude.include? :payment
|
||||
adjustments.reject! { |a|
|
||||
a.originator_type == 'Spree::PaymentMethod'
|
||||
}
|
||||
end
|
||||
if exclude.include? :line_item
|
||||
adjustments.reject! { |a|
|
||||
a.adjustable_type == 'Spree::LineItem'
|
||||
}
|
||||
end
|
||||
|
||||
enterprise_fee_adjustments = adjustments.select { |a| a.originator_type == 'EnterpriseFee' && a.adjustable_type != 'Spree::LineItem' }
|
||||
adjustments.reject! { |a| a.originator_type == 'EnterpriseFee' && a.adjustable_type != 'Spree::LineItem' }
|
||||
enterprise_fee_adjustments = adjustments.select { |a|
|
||||
a.originator_type == 'EnterpriseFee' && a.adjustable_type != 'Spree::LineItem'
|
||||
}
|
||||
adjustments.reject! { |a|
|
||||
a.originator_type == 'EnterpriseFee' && a.adjustable_type != 'Spree::LineItem'
|
||||
}
|
||||
unless exclude.include? :admin_and_handling
|
||||
adjustments << Spree::Adjustment.new(
|
||||
label: I18n.t(:orders_form_admin), amount: enterprise_fee_adjustments.sum(&:amount)
|
||||
@@ -92,7 +110,8 @@ module CheckoutHelper
|
||||
"ng-class" => "{error: !fieldValid('#{path}')}"
|
||||
}.merge args
|
||||
|
||||
render "shared/validated_select", name: name, path: path, options: options, attributes: attributes
|
||||
render "shared/validated_select", name: name, path: path, options: options,
|
||||
attributes: attributes
|
||||
end
|
||||
|
||||
def payment_method_price(method, order)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module DiscourseHelper
|
||||
def discourse_configured?
|
||||
discourse_url.present?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EnterpriseFeesHelper
|
||||
def angular_name(method)
|
||||
"sets_enterprise_fee_set[collection_attributes][{{ $index }}][#{method}]"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/available_payment_method_filter'
|
||||
|
||||
module EnterprisesHelper
|
||||
@@ -16,7 +18,8 @@ module EnterprisesHelper
|
||||
|
||||
shipping_methods = current_distributor.shipping_methods.display_on_checkout.to_a
|
||||
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor, "FilterShippingMethods", current_customer.andand.tag_list)
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor,
|
||||
"FilterShippingMethods", current_customer.andand.tag_list)
|
||||
applicator.filter!(shipping_methods)
|
||||
|
||||
shipping_methods.uniq
|
||||
@@ -30,7 +33,8 @@ module EnterprisesHelper
|
||||
filter = OpenFoodNetwork::AvailablePaymentMethodFilter.new
|
||||
filter.filter!(payment_methods)
|
||||
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor, "FilterPaymentMethods", current_customer.andand.tag_list)
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor,
|
||||
"FilterPaymentMethods", current_customer.andand.tag_list)
|
||||
applicator.filter!(payment_methods)
|
||||
|
||||
payment_methods
|
||||
@@ -47,7 +51,10 @@ module EnterprisesHelper
|
||||
end
|
||||
|
||||
def enterprises_options(enterprises)
|
||||
enterprises.map { |enterprise| [enterprise.name + ": " + enterprise.address.address1 + ", " + enterprise.address.city, enterprise.id.to_i] }
|
||||
enterprises.map { |enterprise|
|
||||
[enterprise.name + ": " + enterprise.address.address1 + ", " + enterprise.address.city,
|
||||
enterprise.id.to_i]
|
||||
}
|
||||
end
|
||||
|
||||
def enterprises_to_names(enterprises)
|
||||
@@ -64,7 +71,8 @@ module EnterprisesHelper
|
||||
|
||||
def enterprise_confirm_delete_message(enterprise)
|
||||
if enterprise.supplied_products.present?
|
||||
I18n.t(:enterprise_confirm_delete_message, product: pluralize(enterprise.supplied_products.count, 'product'))
|
||||
I18n.t(:enterprise_confirm_delete_message,
|
||||
product: pluralize(enterprise.supplied_products.count, 'product'))
|
||||
else
|
||||
t(:are_you_sure)
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'web/cookies_consent'
|
||||
|
||||
module FooterLinksHelper
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module GroupsHelper
|
||||
def link_to_service(baseurl, name, html_options = {})
|
||||
def link_to_service(baseurl, name, html_options = {}, &block)
|
||||
return if name.blank?
|
||||
|
||||
html_options = html_options.merge target: '_blank'
|
||||
link_to ext_url(baseurl, name), html_options do
|
||||
yield
|
||||
end
|
||||
link_to ext_url(baseurl, name), html_options, &block
|
||||
end
|
||||
|
||||
def ext_url(prefix, url)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module I18nHelper
|
||||
def set_locale
|
||||
UserLocaleSetter.new(spree_current_user, params[:locale], cookies).set_locale
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/enterprise_injection_data'
|
||||
|
||||
module InjectionHelper
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module MapHelper
|
||||
def using_google_maps?
|
||||
ENV["GOOGLE_MAPS_API_KEY"].present? || google_maps_configured_with_geocoder_api_key?
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module MarkdownHelper
|
||||
def render_markdown(markdown)
|
||||
md ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, no_intra_emphasis: true, tables: true, autolink: true, superscript: true)
|
||||
md ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, no_intra_emphasis: true, tables: true,
|
||||
autolink: true, superscript: true)
|
||||
md.render markdown
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +32,8 @@ module OrderCyclesHelper
|
||||
end
|
||||
|
||||
def permitted_hub_enterprise_options_for(order_cycle)
|
||||
validated_enterprise_options permitted_hub_enterprises_for(order_cycle), shipping_and_payment_methods: true
|
||||
validated_enterprise_options permitted_hub_enterprises_for(order_cycle),
|
||||
shipping_and_payment_methods: true
|
||||
end
|
||||
|
||||
def order_cycle_status_class(order_cycle)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user