mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Rename OpenFoodWeb namespace to OpenFoodNetwork
This commit is contained in:
@@ -23,7 +23,7 @@ module Admin
|
||||
|
||||
respond_to do |format|
|
||||
if @order_cycle.save
|
||||
OpenFoodWeb::OrderCycleFormApplicator.new(@order_cycle).go!
|
||||
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle).go!
|
||||
|
||||
flash[:notice] = 'Your order cycle has been created.'
|
||||
format.html { redirect_to admin_order_cycles_path }
|
||||
@@ -40,7 +40,7 @@ module Admin
|
||||
|
||||
respond_to do |format|
|
||||
if @order_cycle.update_attributes(params[:order_cycle])
|
||||
OpenFoodWeb::OrderCycleFormApplicator.new(@order_cycle).go!
|
||||
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle).go!
|
||||
|
||||
flash[:notice] = 'Your order cycle has been updated.'
|
||||
format.html { redirect_to admin_order_cycles_path }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
class CartController < ApplicationController
|
||||
respond_to :json
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ require 'open_food_web/order_grouper'
|
||||
require 'open_food_web/model_class_from_controller_name'
|
||||
|
||||
Spree::Admin::ReportsController.class_eval do
|
||||
include OpenFoodWeb::ModelClassFromControllerName
|
||||
include OpenFoodNetwork::ModelClassFromControllerName
|
||||
|
||||
# Render a partial for orders and fulfillment description
|
||||
respond_override :index => { :html => { :success => lambda {
|
||||
@@ -45,7 +45,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
@search = Spree::Order.complete.not_state(:canceled).managed_by(spree_current_user).search(params[:q])
|
||||
orders = @search.result
|
||||
|
||||
@report = OpenFoodWeb::OrderAndDistributorReport.new orders
|
||||
@report = OpenFoodNetwork::OrderAndDistributorReport.new orders
|
||||
unless params[:csv]
|
||||
render :html => @report
|
||||
else
|
||||
@@ -77,7 +77,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
@distributors = Enterprise.is_distributor.managed_by(spree_current_user)
|
||||
|
||||
@report = OpenFoodWeb::GroupBuyReport.new orders
|
||||
@report = OpenFoodNetwork::GroupBuyReport.new orders
|
||||
unless params[:csv]
|
||||
render :html => @report
|
||||
else
|
||||
@@ -233,7 +233,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
end
|
||||
|
||||
order_grouper = OpenFoodWeb::OrderGrouper.new rules, columns
|
||||
order_grouper = OpenFoodNetwork::OrderGrouper.new rules, columns
|
||||
|
||||
@header = header
|
||||
@table = order_grouper.table(@line_items)
|
||||
@@ -337,7 +337,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
end
|
||||
|
||||
order_grouper = OpenFoodWeb::OrderGrouper.new rules, columns
|
||||
order_grouper = OpenFoodNetwork::OrderGrouper.new rules, columns
|
||||
|
||||
@header = header
|
||||
@table = order_grouper.table(table_items)
|
||||
@@ -549,7 +549,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
end
|
||||
|
||||
order_grouper = OpenFoodWeb::OrderGrouper.new rules, columns
|
||||
order_grouper = OpenFoodNetwork::OrderGrouper.new rules, columns
|
||||
|
||||
@header = header
|
||||
@table = order_grouper.table(table_items)
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'open_food_web/split_products_by_distribution'
|
||||
Spree::HomeController.class_eval do
|
||||
include EnterprisesHelper
|
||||
include OrderCyclesHelper
|
||||
include OpenFoodWeb::SplitProductsByDistribution
|
||||
include OpenFoodNetwork::SplitProductsByDistribution
|
||||
|
||||
respond_override :index => { :html => { :success => lambda {
|
||||
@products, @products_local, @products_remote = split_products_by_distribution @products, current_distributor, current_order_cycle
|
||||
|
||||
@@ -6,7 +6,7 @@ Spree::OrdersController.class_eval do
|
||||
|
||||
# Patch Orders#populate to provide distributor_id and order_cycle_id to OrderPopulator
|
||||
def populate
|
||||
if OpenFoodWeb::FeatureToggle.enabled? :multi_cart
|
||||
if OpenFoodNetwork::FeatureToggle.enabled? :multi_cart
|
||||
populate_cart params.slice(:products, :variants, :quantity, :distributor_id, :order_cycle_id)
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'open_food_web/split_products_by_distribution'
|
||||
Spree::ProductsController.class_eval do
|
||||
include EnterprisesHelper
|
||||
include OrderCyclesHelper
|
||||
include OpenFoodWeb::SplitProductsByDistribution
|
||||
include OpenFoodNetwork::SplitProductsByDistribution
|
||||
|
||||
before_filter :require_distributor_chosen, only: :index
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'open_food_web/split_products_by_distribution'
|
||||
Spree::TaxonsController.class_eval do
|
||||
include EnterprisesHelper
|
||||
include OrderCyclesHelper
|
||||
include OpenFoodWeb::SplitProductsByDistribution
|
||||
include OpenFoodNetwork::SplitProductsByDistribution
|
||||
|
||||
before_filter :require_distributor_chosen, only: :show
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ module OrderCyclesHelper
|
||||
|
||||
|
||||
def order_cycles_enabled?
|
||||
OpenFoodWeb::FeatureToggle.enabled? :order_cycles
|
||||
OpenFoodNetwork::FeatureToggle.enabled? :order_cycles
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,8 +7,8 @@ module Spree
|
||||
css_class = (current_taxon && current_taxon.self_and_ancestors.include?(taxon)) ? 'current' : nil
|
||||
|
||||
# The concern of separating products by distributor and order cycle is dealt with in
|
||||
# a few other places: OpenFoodWeb::Searcher (for searching over products) and in
|
||||
# OpenFoodWeb::SplitProductsByDistribution (for splitting the main product display).
|
||||
# a few other places: OpenFoodNetwork::Searcher (for searching over products) and in
|
||||
# OpenFoodNetwork::SplitProductsByDistribution (for splitting the main product display).
|
||||
|
||||
products = Product.in_taxon(taxon)
|
||||
products = products.in_distributor(current_distributor) if current_distributor
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
class Calculator::Weight < Spree::Calculator
|
||||
preference :per_kg, :decimal, :default => 0.0
|
||||
attr_accessible :preferred_per_kg
|
||||
|
||||
@@ -50,7 +50,7 @@ Spree::Order.class_eval do
|
||||
# -- Methods
|
||||
def products_available_from_new_distribution
|
||||
# Check that the line_items in the current order are available from a newly selected distribution
|
||||
if OpenFoodWeb::FeatureToggle.enabled? :order_cycles
|
||||
if OpenFoodNetwork::FeatureToggle.enabled? :order_cycles
|
||||
errors.add(:base, "Distributor or order cycle cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distribution?(distributor, order_cycle)
|
||||
else
|
||||
errors.add(:distributor_id, "cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distributor?(distributor)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
|
||||
- if OpenFoodWeb::FeatureToggle.enabled? :multi_cart
|
||||
- if OpenFoodNetwork::FeatureToggle.enabled? :multi_cart
|
||||
= render :partial => 'open_food_web/cart/show'
|
||||
@@ -26,14 +26,14 @@ module Openfoodweb
|
||||
|
||||
# Register Spree calculators
|
||||
initializer "spree.register.calculators" do |app|
|
||||
app.config.spree.calculators.shipping_methods << OpenFoodWeb::Calculator::Weight
|
||||
app.config.spree.calculators.shipping_methods << OpenFoodNetwork::Calculator::Weight
|
||||
|
||||
app.config.spree.calculators.enterprise_fees = [Spree::Calculator::FlatPercentItemTotal,
|
||||
Spree::Calculator::FlatRate,
|
||||
Spree::Calculator::FlexiRate,
|
||||
Spree::Calculator::PerItem,
|
||||
Spree::Calculator::PriceSack,
|
||||
OpenFoodWeb::Calculator::Weight]
|
||||
OpenFoodNetwork::Calculator::Weight]
|
||||
end
|
||||
|
||||
# Register Spree payment methods
|
||||
|
||||
@@ -14,7 +14,7 @@ Spree.config do |config|
|
||||
config.shipping_instructions = true
|
||||
config.checkout_zone = 'Australia'
|
||||
config.address_requires_state = true
|
||||
config.searcher_class = OpenFoodWeb::Searcher
|
||||
config.searcher_class = OpenFoodNetwork::Searcher
|
||||
|
||||
# 109 should be Australia. Hardcoded for CI (Jenkins), where countries are not pre-loaded.
|
||||
config.default_country_id = Spree::Country.find_by_name('Australia').andand.id || 109
|
||||
|
||||
@@ -3,5 +3,5 @@ require "eaterprises_feature/engine"
|
||||
|
||||
module EaterprisesFeature
|
||||
extend Chili::Base
|
||||
active_if { OpenFoodWeb::FeatureToggle.enabled? :eaterprises }
|
||||
active_if { OpenFoodNetwork::FeatureToggle.enabled? :eaterprises }
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ module EaterprisesFeature
|
||||
class Engine < ::Rails::Engine
|
||||
isolate_namespace EaterprisesFeature
|
||||
|
||||
if OpenFoodWeb::FeatureToggle.enabled? :eaterprises
|
||||
if OpenFoodNetwork::FeatureToggle.enabled? :eaterprises
|
||||
initializer 'eaterprises_feature.sass', :after => :load_config_initializers do |app|
|
||||
app.config.sass.load_paths += [self.root.join('app', 'assets', 'stylesheets', 'eaterprises_feature')] if Rails.application.config.respond_to? :sass
|
||||
end
|
||||
|
||||
@@ -3,5 +3,5 @@ require "enterprises_distributor_info_rich_text_feature/engine"
|
||||
|
||||
module EnterprisesDistributorInfoRichTextFeature
|
||||
extend Chili::Base
|
||||
active_if { OpenFoodWeb::FeatureToggle.enabled? :enterprises_distributor_info_rich_text }
|
||||
active_if { OpenFoodNetwork::FeatureToggle.enabled? :enterprises_distributor_info_rich_text }
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ module EnterprisesDistributorInfoRichTextFeature
|
||||
isolate_namespace EnterprisesDistributorInfoRichTextFeature
|
||||
|
||||
initializer 'enterprises_distributor_info_rich_text_feature.mailer', :after => :load_config_initializers do |app|
|
||||
if OpenFoodWeb::FeatureToggle.enabled? :enterprises_distributor_info_rich_text
|
||||
if OpenFoodNetwork::FeatureToggle.enabled? :enterprises_distributor_info_rich_text
|
||||
::Spree::OrderMailer.class_eval do
|
||||
helper CheckoutHelper
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ require "local_organics_feature/engine"
|
||||
|
||||
module LocalOrganicsFeature
|
||||
extend Chili::Base
|
||||
active_if { OpenFoodWeb::FeatureToggle.enabled? :local_organics }
|
||||
active_if { OpenFoodNetwork::FeatureToggle.enabled? :local_organics }
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ module LocalOrganicsFeature
|
||||
class Engine < ::Rails::Engine
|
||||
isolate_namespace LocalOrganicsFeature
|
||||
|
||||
if OpenFoodWeb::FeatureToggle.enabled? :local_organics
|
||||
if OpenFoodNetwork::FeatureToggle.enabled? :local_organics
|
||||
initializer 'local_organics_feature.sass', :after => :load_config_initializers do |app|
|
||||
app.config.sass.load_paths += [self.root.join('app', 'assets', 'stylesheets', 'local_organics_feature')] if Rails.application.config.respond_to? :sass
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
class FeatureToggle
|
||||
def self.enabled? feature
|
||||
features[feature]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
|
||||
GroupBuyVariantRow = Struct.new(:variant, :sum_quantities, :sum_max_quantities) do
|
||||
def to_row
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
module ModelClassFromControllerName
|
||||
# Equivalent to CanCan's "authorize_resource :class => false" (see https://github.com/ryanb/cancan/blob/master/lib/cancan/controller_resource.rb#L146)
|
||||
def model_class
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
class OrderAndDistributorReport
|
||||
|
||||
def initialize orders
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
|
||||
# There are two translator classes on the boundary between Angular and Rails: On the Angular side,
|
||||
# there is the OrderCycle#dataForSubmit method, and on the Rails side is this class. I think data
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
|
||||
class OrderGrouper
|
||||
def initialize(rules, column_constructors)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'spree/core/search/base'
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
class Searcher < Spree::Core::Search::Base
|
||||
|
||||
# Do not perform pagination
|
||||
@@ -15,7 +15,7 @@ module OpenFoodWeb
|
||||
base_scope = super
|
||||
|
||||
# The concern of separating products by distributor and order cycle is dealt with in
|
||||
# a few other places: OpenFoodWeb::SplitProductsByDistribution (for splitting the main
|
||||
# a few other places: OpenFoodNetwork::SplitProductsByDistribution (for splitting the main
|
||||
# product display) and Spree::BaseHelper decorator (for taxon counts).
|
||||
|
||||
base_scope = base_scope.in_supplier_or_distributor(enterprise_id) if enterprise_id
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
|
||||
# The concern of separating products by distributor and order cycle is dealt with in a few
|
||||
# other places: OpenFoodWeb::Searcher (for searching over products) and in
|
||||
# other places: OpenFoodNetwork::Searcher (for searching over products) and in
|
||||
# Spree::BaseHelper decorator (for taxon counts).
|
||||
|
||||
module SplitProductsByDistribution
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'spec_helper'
|
||||
require 'spree/api/testing_support/helpers'
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
describe CartController do
|
||||
render_views
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ FactoryGirl.define do
|
||||
enterprise_role 'distributor'
|
||||
end
|
||||
|
||||
factory :weight_calculator, :class => OpenFoodWeb::Calculator::Weight do
|
||||
factory :weight_calculator, :class => OpenFoodNetwork::Calculator::Weight do
|
||||
after(:build) { |c| c.set_preference(:per_kg, 0.5) }
|
||||
after(:create) { |c| c.set_preference(:per_kg, 0.5); c.save! }
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ feature "enterprises distributor info as rich text" do
|
||||
include WebHelper
|
||||
|
||||
before(:each) do
|
||||
OpenFoodWeb::FeatureToggle.stub(:features).and_return({eaterprises: false,
|
||||
OpenFoodNetwork::FeatureToggle.stub(:features).and_return({eaterprises: false,
|
||||
local_organics: true,
|
||||
enterprises_distributor_info_rich_text: true})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'open_food_web/feature_toggle'
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
describe FeatureToggle do
|
||||
it "returns true when feature is on" do
|
||||
FeatureToggle.stub(:features).and_return({foo: true})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
describe GroupBuyReport do
|
||||
|
||||
before(:each) do
|
||||
@@ -81,8 +81,8 @@ module OpenFoodWeb
|
||||
|
||||
table_row_objects = subject.variants_and_quantities
|
||||
|
||||
variant_rows = table_row_objects.select { |r| r.class == OpenFoodWeb::GroupBuyVariantRow }
|
||||
product_rows = table_row_objects.select { |r| r.class == OpenFoodWeb::GroupBuyProductRow }
|
||||
variant_rows = table_row_objects.select { |r| r.class == OpenFoodNetwork::GroupBuyVariantRow }
|
||||
product_rows = table_row_objects.select { |r| r.class == OpenFoodNetwork::GroupBuyProductRow }
|
||||
|
||||
supplier_groups = variant_rows.group_by { |r| r.variant.product.supplier }
|
||||
variant_groups = variant_rows.group_by { |r| r.variant }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
describe OrderAndDistributorReport do
|
||||
|
||||
describe "orders and distributors report" do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'open_food_web/order_cycle_form_applicator'
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
describe OrderCycleFormApplicator do
|
||||
context "unit specs" do
|
||||
it "creates new exchanges for incoming_exchanges" do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
describe OrderGrouper do
|
||||
|
||||
before(:each) do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'spec_helper'
|
||||
require 'open_food_web/searcher'
|
||||
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
describe Searcher do
|
||||
it "searches by supplier" do
|
||||
# Given products under two suppliers
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'open_food_web/split_products_by_distribution'
|
||||
|
||||
describe OpenFoodWeb::SplitProductsByDistribution do
|
||||
let(:products_splitter) { Class.new { include OpenFoodWeb::SplitProductsByDistribution } }
|
||||
describe OpenFoodNetwork::SplitProductsByDistribution do
|
||||
let(:products_splitter) { Class.new { include OpenFoodNetwork::SplitProductsByDistribution } }
|
||||
let(:subject) { products_splitter.new }
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe OpenFoodWeb::Calculator::Weight do
|
||||
describe OpenFoodNetwork::Calculator::Weight do
|
||||
it "computes shipping cost for an order by total weight" do
|
||||
variant_1 = double(:variant, :weight => 10)
|
||||
variant_2 = double(:variant, :weight => 20)
|
||||
|
||||
@@ -87,7 +87,7 @@ RSpec.configure do |config|
|
||||
config.include Spree::CheckoutHelpers
|
||||
config.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.include OpenFoodWeb::FeatureToggleHelper
|
||||
config.include OpenFoodNetwork::FeatureToggleHelper
|
||||
config.include ActionView::Helpers::DateHelper
|
||||
|
||||
# Factory girl
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module OpenFoodWeb
|
||||
module OpenFoodNetwork
|
||||
module FeatureToggleHelper
|
||||
def set_feature_toggle(feature, status)
|
||||
features = OpenFoodWeb::FeatureToggle.features
|
||||
features = OpenFoodNetwork::FeatureToggle.features
|
||||
features[feature] = status
|
||||
OpenFoodWeb::FeatureToggle.stub(:features) { features }
|
||||
OpenFoodNetwork::FeatureToggle.stub(:features) { features }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user