mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-22 20:16:50 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05ac1a9861 |
@@ -2,9 +2,9 @@ version: "2"
|
||||
plugins:
|
||||
rubocop:
|
||||
enabled: true
|
||||
channel: "rubocop-1-12"
|
||||
channel: "rubocop-0-76"
|
||||
config:
|
||||
file: ".rubocop.yml"
|
||||
file: ".rubocop_styleguide.yml"
|
||||
scss-lint:
|
||||
enabled: true
|
||||
checks:
|
||||
|
||||
5
.github/codecov.yml
vendored
5
.github/codecov.yml
vendored
@@ -1,5 +0,0 @@
|
||||
coverage:
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
informational: true
|
||||
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
@@ -272,13 +272,8 @@ jobs:
|
||||
- name: Run JS tests
|
||||
run: RAILS_ENV=test bundle exec rake karma:run
|
||||
|
||||
# Migration tests need to be run in a separate task.
|
||||
# See: https://github.com/openfoodfoundation/openfoodnetwork/pull/6924#issuecomment-813056525
|
||||
- name: Run migration tests
|
||||
run: bundle exec rspec --pattern "spec/{migrations}/**/*_spec.rb"
|
||||
|
||||
- name: Run all other tests
|
||||
run: bundle exec rake ofn:specs:run:excluding_folders["models,controllers,serializers,features,lib,migrations"]
|
||||
run: bundle exec rake ofn:specs:run:excluding_folders["models,controllers,serializers,features,lib"]
|
||||
|
||||
test-the-rest:
|
||||
runs-on: ubuntu-18.04
|
||||
@@ -322,4 +317,4 @@ jobs:
|
||||
run: bundle exec rspec --profile --pattern "engines/*/spec/{,/*/**}/*_spec.rb,spec/features/admin/*/*_spec.rb,spec/lib/{,/*/**}/*_spec.rb"
|
||||
|
||||
- name: Codecov
|
||||
uses: codecov/codecov-action@v1.5.0
|
||||
uses: codecov/codecov-action@v1.3.1
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,4 +47,3 @@ coverage
|
||||
/reports/
|
||||
!/reports/README.md
|
||||
bin/
|
||||
/spec/components/stories/**/*.stories.json
|
||||
|
||||
@@ -1 +1 @@
|
||||
14.16.1
|
||||
5.12.0
|
||||
|
||||
@@ -10,8 +10,8 @@ inherit_from:
|
||||
# The automatically generated todo list to ignore all current violations.
|
||||
- .rubocop_todo.yml
|
||||
|
||||
# Our Open Food Network style guide. If you want to see all violations,
|
||||
# then use only that configuration:
|
||||
# Our Open Food Network style guide. It's used by Code Climate. If you want to see all violations,
|
||||
# then use only that configuration (like Code Climate):
|
||||
#
|
||||
# bundle exec rubocop -c .rubocop_styleguide.yml
|
||||
#
|
||||
|
||||
@@ -249,6 +249,7 @@ Layout/LineLength:
|
||||
- spec/lib/open_food_network/products_and_inventory_report_spec.rb
|
||||
- spec/lib/open_food_network/scope_variant_to_hub_spec.rb
|
||||
- spec/lib/open_food_network/tag_rule_applicator_spec.rb
|
||||
- spec/lib/open_food_network/user_balance_calculator_spec.rb
|
||||
- spec/lib/open_food_network/users_and_enterprises_report_spec.rb
|
||||
- spec/lib/open_food_network/xero_invoices_report_spec.rb
|
||||
- spec/lib/spree/core/calculated_adjustments_spec.rb
|
||||
@@ -848,7 +849,6 @@ Metrics/ModuleLength:
|
||||
- app/models/spree/payment/processing.rb
|
||||
- engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb
|
||||
- engines/order_management/spec/services/order_management/subscriptions/validator_spec.rb
|
||||
- engines/order_management/spec/services/order_management/subscriptions/summary_spec.rb
|
||||
- lib/open_food_network/column_preference_defaults.rb
|
||||
- spec/controllers/admin/order_cycles_controller_spec.rb
|
||||
- spec/controllers/api/orders_controller_spec.rb
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# Our Open Food Network style guide.
|
||||
#
|
||||
# These are the rules we agreed upon and we work towards.
|
||||
# These are the rules we agreed upon and we work towards. Code Climate uses
|
||||
# these rules to rate our code and detect new violations. But when you run
|
||||
# rubocop locally, the default configuration file `.rubocop.yml` loads
|
||||
# our "todo lists" to ignore all current violations.
|
||||
AllCops:
|
||||
NewCops: disable
|
||||
SuggestExtensions: false
|
||||
|
||||
@@ -368,6 +368,84 @@ Rails/ApplicationMailer:
|
||||
Exclude:
|
||||
- 'app/mailers/spree/base_mailer.rb'
|
||||
|
||||
# Offense count: 73
|
||||
# Cop supports --auto-correct.
|
||||
Rails/ApplicationRecord:
|
||||
Exclude:
|
||||
- 'app/models/adjustment_metadata.rb'
|
||||
- 'app/models/column_preference.rb'
|
||||
- 'app/models/coordinator_fee.rb'
|
||||
- 'app/models/customer.rb'
|
||||
- 'app/models/distributor_shipping_method.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_fee.rb'
|
||||
- 'app/models/enterprise_group.rb'
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/enterprise_relationship_permission.rb'
|
||||
- 'app/models/enterprise_role.rb'
|
||||
- 'app/models/exchange.rb'
|
||||
- 'app/models/exchange_fee.rb'
|
||||
- 'app/models/exchange_variant.rb'
|
||||
- 'app/models/inventory_item.rb'
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/order_cycle_schedule.rb'
|
||||
- 'app/models/producer_property.rb'
|
||||
- 'app/models/proxy_order.rb'
|
||||
- 'app/models/schedule.rb'
|
||||
- 'app/models/spree/address.rb'
|
||||
- 'app/models/spree/adjustment.rb'
|
||||
- 'app/models/spree/asset.rb'
|
||||
- 'app/models/spree/calculator.rb'
|
||||
- 'app/models/spree/classification.rb'
|
||||
- 'app/models/spree/country.rb'
|
||||
- 'app/models/spree/credit_card.rb'
|
||||
- 'app/models/spree/inventory_unit.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/log_entry.rb'
|
||||
- 'app/models/spree/option_type.rb'
|
||||
- 'app/models/spree/option_value.rb'
|
||||
- 'app/models/spree/option_values_line_item.rb'
|
||||
- 'app/models/spree/order.rb'
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
- 'app/models/spree/payment.rb'
|
||||
- 'app/models/spree/payment/processing.rb'
|
||||
- 'app/models/spree/payment_method.rb'
|
||||
- 'app/models/spree/paypal_express_checkout.rb'
|
||||
- 'app/models/spree/preference.rb'
|
||||
- 'app/models/spree/price.rb'
|
||||
- 'app/models/spree/product.rb'
|
||||
- 'app/models/spree/product_option_type.rb'
|
||||
- 'app/models/spree/product_property.rb'
|
||||
- 'app/models/spree/property.rb'
|
||||
- 'app/models/spree/return_authorization.rb'
|
||||
- 'app/models/spree/role.rb'
|
||||
- 'app/models/spree/shipment.rb'
|
||||
- 'app/models/spree/shipping_category.rb'
|
||||
- 'app/models/spree/shipping_method.rb'
|
||||
- 'app/models/spree/shipping_method_category.rb'
|
||||
- 'app/models/spree/shipping_rate.rb'
|
||||
- 'app/models/spree/state.rb'
|
||||
- 'app/models/spree/state_change.rb'
|
||||
- 'app/models/spree/stock_item.rb'
|
||||
- 'app/models/spree/stock_location.rb'
|
||||
- 'app/models/spree/stock_movement.rb'
|
||||
- 'app/models/spree/tax_category.rb'
|
||||
- 'app/models/spree/tax_rate.rb'
|
||||
- 'app/models/spree/taxon.rb'
|
||||
- 'app/models/spree/taxonomy.rb'
|
||||
- 'app/models/spree/tokenized_permission.rb'
|
||||
- 'app/models/spree/user.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
- 'app/models/spree/zone.rb'
|
||||
- 'app/models/spree/zone_member.rb'
|
||||
- 'app/models/stripe_account.rb'
|
||||
- 'app/models/subscription.rb'
|
||||
- 'app/models/subscription_line_item.rb'
|
||||
- 'app/models/tag_rule.rb'
|
||||
- 'app/models/variant_override.rb'
|
||||
- 'lib/tasks/data/remove_transient_data.rb'
|
||||
- 'spec/models/spree/preferences/preferable_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
|
||||
@@ -931,8 +1009,10 @@ Style/FrozenStringLiteralComment:
|
||||
- 'app/helpers/spree/admin/base_helper.rb'
|
||||
- 'app/helpers/spree/admin/general_settings_helper.rb'
|
||||
- 'app/helpers/spree/admin/orders_helper.rb'
|
||||
- 'app/helpers/spree/admin/payments_helper.rb'
|
||||
- 'app/helpers/spree/admin/taxons_helper.rb'
|
||||
- 'app/helpers/spree/admin/zones_helper.rb'
|
||||
- 'app/helpers/spree/api/api_helpers.rb'
|
||||
- 'app/helpers/spree/orders_helper.rb'
|
||||
- 'app/helpers/spree/reports_helper.rb'
|
||||
- 'app/helpers/spree_currency_helper.rb'
|
||||
@@ -1134,6 +1214,7 @@ Style/FrozenStringLiteralComment:
|
||||
- 'lib/open_food_network/scope_variants_for_search.rb'
|
||||
- 'lib/open_food_network/spree_api_key_loader.rb'
|
||||
- 'lib/open_food_network/tag_rule_applicator.rb'
|
||||
- 'lib/open_food_network/user_balance_calculator.rb'
|
||||
- 'lib/open_food_network/users_and_enterprises_report.rb'
|
||||
- 'lib/open_food_network/xero_invoices_report.rb'
|
||||
- 'lib/spree/authentication_helpers.rb'
|
||||
|
||||
@@ -13,7 +13,6 @@ SimpleCov.start 'rails' do
|
||||
add_filter '/script'
|
||||
add_filter '/log'
|
||||
add_filter '/db'
|
||||
add_filter '/lib/tasks/sample_data/'
|
||||
end
|
||||
|
||||
require 'codecov'
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
module.exports = {
|
||||
stories: ['../spec/components/stories/**/*.stories.json'],
|
||||
addons: [
|
||||
'@storybook/addon-docs',
|
||||
'@storybook/addon-controls',
|
||||
],
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" media="screen" href="http://localhost:3000/assets/darkswarm/all.css" />
|
||||
@@ -1,5 +0,0 @@
|
||||
export const parameters = {
|
||||
server: {
|
||||
url: `http://localhost:3000/rails/stories`,
|
||||
},
|
||||
};
|
||||
@@ -6,7 +6,7 @@ This is a general guide to setting up an Open Food Network **development environ
|
||||
|
||||
The fastest way to make it work locally is to use Docker, you only need to setup git, see the [Docker setup guide](docker/README.md).
|
||||
Otherwise, for a local setup you will need:
|
||||
* Ruby and bundler (check current Ruby version in [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file)
|
||||
* Ruby 2.4.4 and bundler (check current Ruby version in [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file)
|
||||
* PostgreSQL database
|
||||
* Chrome (for testing)
|
||||
|
||||
@@ -78,6 +78,8 @@ Note: If your OS is not explicitly supported in the setup guides then not all te
|
||||
|
||||
Note: The time zone on your machine should match the one defined in `config/application.yml`.
|
||||
|
||||
The project is configured to use [Zeus][zeus] to reduce the pre-test startup time while Rails loads. See the [Zeus GitHub page][zeus] for usage instructions.
|
||||
|
||||
Once [npm dependencies are installed][karma], AngularJS tests can be run with:
|
||||
|
||||
./script/karma run
|
||||
@@ -117,6 +119,7 @@ If these commands succeed, you should be able to [continue the setup process](#g
|
||||
[ubuntu]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-Ubuntu
|
||||
[debian]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-Debian
|
||||
[wiki]: https://github.com/openfoodfoundation/openfoodnetwork/wiki
|
||||
[zeus]: https://github.com/burke/zeus
|
||||
[rubocop]: https://rubocop.readthedocs.io/en/latest/
|
||||
[karma]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Karma
|
||||
[slack-dev]: https://openfoodnetwork.slack.com/messages/C2GQ45KNU
|
||||
|
||||
33
Gemfile
33
Gemfile
@@ -4,18 +4,18 @@ source 'https://rubygems.org'
|
||||
ruby "2.5.8"
|
||||
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
|
||||
|
||||
gem 'rails', '~> 5.2'
|
||||
gem 'rails', '~> 5.0.0'
|
||||
|
||||
gem 'activemerchant', '>= 1.78.0'
|
||||
gem 'angular-rails-templates', '>= 0.3.0'
|
||||
gem 'awesome_nested_set'
|
||||
gem 'ransack', '2.4.1'
|
||||
gem 'ransack', '2.3.0'
|
||||
gem 'responders'
|
||||
gem 'sass', '<= 4.7.1'
|
||||
gem 'sass-rails', '< 6.0.0'
|
||||
|
||||
gem 'i18n'
|
||||
gem 'i18n-js', '~> 3.8.3'
|
||||
gem 'i18n-js', '~> 3.8.2'
|
||||
gem 'rails-i18n'
|
||||
gem 'rails_safe_tasks', '~> 1.0'
|
||||
|
||||
@@ -29,9 +29,9 @@ gem "order_management", path: "./engines/order_management"
|
||||
gem 'web', path: './engines/web'
|
||||
|
||||
gem 'activerecord-postgresql-adapter'
|
||||
gem 'pg', '~> 1.2.3'
|
||||
gem 'pg', '~> 0.21.0'
|
||||
|
||||
gem 'acts_as_list', '1.0.4'
|
||||
gem 'acts_as_list', '1.0.3'
|
||||
gem 'cancancan', '~> 1.15.0'
|
||||
gem 'ffaker'
|
||||
gem 'highline', '2.0.3' # Necessary for the install generator
|
||||
@@ -75,19 +75,15 @@ gem 'dalli'
|
||||
gem 'figaro'
|
||||
gem 'geocoder'
|
||||
gem 'gmaps4rails'
|
||||
gem 'mimemagic', '> 0.3.5'
|
||||
gem 'paper_trail', '~> 10.3.1'
|
||||
gem 'paperclip', '~> 3.4.1'
|
||||
gem 'rack-rewrite'
|
||||
gem 'rack-ssl', require: 'rack/ssl'
|
||||
gem 'roadie-rails', '~> 2.2.0'
|
||||
|
||||
gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
|
||||
gem 'hiredis'
|
||||
gem 'roadie-rails', '~> 1.3.0'
|
||||
|
||||
gem 'combine_pdf'
|
||||
gem 'wicked_pdf'
|
||||
gem 'wkhtmltopdf-binary'
|
||||
gem 'wkhtmltopdf-binary', '0.12.5' # We need to upgrade our CI before we can bump this :/
|
||||
|
||||
gem 'immigrant'
|
||||
gem 'roo', '~> 2.8.3'
|
||||
@@ -96,10 +92,10 @@ gem 'whenever', require: false
|
||||
|
||||
gem 'test-unit', '~> 3.4'
|
||||
|
||||
gem 'coffee-rails', '~> 5.0.0'
|
||||
gem 'coffee-rails', '~> 4.2.2'
|
||||
gem 'compass-rails'
|
||||
|
||||
gem 'mini_racer', '0.4.0'
|
||||
gem 'mini_racer', '0.3.1'
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
|
||||
@@ -117,12 +113,6 @@ gem 'ofn-qz', github: 'openfoodfoundation/ofn-qz', branch: 'ofn-rails-4'
|
||||
|
||||
gem 'good_migrations'
|
||||
|
||||
gem 'flipper'
|
||||
gem 'flipper-active_record'
|
||||
gem 'flipper-ui'
|
||||
|
||||
gem "view_component", require: "view_component/engine"
|
||||
|
||||
group :production, :staging do
|
||||
gem 'ddtrace'
|
||||
gem 'unicorn-worker-killer'
|
||||
@@ -130,11 +120,12 @@ end
|
||||
|
||||
group :test, :development do
|
||||
# Pretty printed test output
|
||||
gem 'atomic'
|
||||
gem 'awesome_print'
|
||||
gem 'bullet'
|
||||
gem 'capybara'
|
||||
gem 'database_cleaner', require: false
|
||||
gem "factory_bot_rails", '6.2.0', require: false
|
||||
gem "factory_bot_rails", '6.1.0', require: false
|
||||
gem 'fuubar', '~> 2.5.1'
|
||||
gem 'json_spec', '~> 1.1.4'
|
||||
gem 'knapsack'
|
||||
@@ -169,8 +160,6 @@ group :development do
|
||||
gem 'spring'
|
||||
gem 'spring-commands-rspec'
|
||||
|
||||
gem "view_component_storybook", require: "view_component/storybook/engine"
|
||||
|
||||
# 1.0.9 fixed openssl issues on macOS https://github.com/eventmachine/eventmachine/issues/602
|
||||
# While we don't require this gem directly, no dependents forced the upgrade to a version
|
||||
# greater than 1.0.9, so we just required the latest available version here.
|
||||
|
||||
273
Gemfile.lock
273
Gemfile.lock
@@ -47,69 +47,65 @@ PATH
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
actionview (= 5.2.6)
|
||||
activejob (= 5.2.6)
|
||||
actioncable (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
nio4r (>= 1.2, < 3.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activejob (= 5.0.7.2)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.6)
|
||||
actionview (= 5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
rack-test (>= 0.6.3)
|
||||
actionpack (5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionpack-action_caching (1.2.2)
|
||||
actionpack-action_caching (1.2.1)
|
||||
actionpack (>= 4.0.0)
|
||||
actionview (5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
actionview (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
active_model_serializers (0.8.4)
|
||||
activemodel (>= 3.0)
|
||||
activejob (5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
activejob (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
globalid (>= 0.3.6)
|
||||
activemerchant (1.119.0)
|
||||
activesupport (>= 4.2)
|
||||
builder (>= 2.1.2, < 4.0.0)
|
||||
i18n (>= 0.6.9)
|
||||
nokogiri (~> 1.4)
|
||||
activemodel (5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
activerecord (5.2.6)
|
||||
activemodel (= 5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
arel (>= 9.0)
|
||||
activerecord-import (1.1.0)
|
||||
activemodel (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
activerecord (5.0.7.2)
|
||||
activemodel (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
arel (~> 7.0)
|
||||
activerecord-import (1.0.8)
|
||||
activerecord (>= 3.2)
|
||||
activerecord-postgresql-adapter (0.0.1)
|
||||
pg
|
||||
activerecord-session_store (2.0.0)
|
||||
actionpack (>= 5.2.4.1)
|
||||
activerecord (>= 5.2.4.1)
|
||||
activerecord-session_store (1.1.3)
|
||||
actionpack (>= 4.0)
|
||||
activerecord (>= 4.0)
|
||||
multi_json (~> 1.11, >= 1.11.2)
|
||||
rack (>= 2.0.8, < 3)
|
||||
railties (>= 5.2.4.1)
|
||||
activestorage (5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
activerecord (= 5.2.6)
|
||||
marcel (~> 1.0.0)
|
||||
activesupport (5.2.6)
|
||||
rack (>= 1.5.2, < 3)
|
||||
railties (>= 4.0)
|
||||
activesupport (5.0.7.2)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
acts-as-taggable-on (7.0.0)
|
||||
activerecord (>= 5.0, < 6.2)
|
||||
acts_as_list (1.0.4)
|
||||
acts_as_list (1.0.3)
|
||||
activerecord (>= 4.2)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
@@ -122,8 +118,9 @@ GEM
|
||||
railties (>= 3, < 7)
|
||||
angularjs-file-upload-rails (2.4.1)
|
||||
angularjs-rails (1.5.5)
|
||||
arel (9.0.0)
|
||||
arel (7.1.4)
|
||||
ast (2.4.2)
|
||||
atomic (1.1.101)
|
||||
awesome_nested_set (3.4.0)
|
||||
activerecord (>= 4.0.0, < 7.0)
|
||||
awesome_print (1.9.2)
|
||||
@@ -155,12 +152,12 @@ GEM
|
||||
climate_control (0.2.0)
|
||||
cocaine (0.5.8)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
codecov (0.5.2)
|
||||
codecov (0.5.1)
|
||||
simplecov (>= 0.15, < 0.22)
|
||||
coderay (1.1.3)
|
||||
coffee-rails (5.0.0)
|
||||
coffee-rails (4.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 5.2.0)
|
||||
railties (>= 4.0.0)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
@@ -187,13 +184,12 @@ GEM
|
||||
crack (0.4.5)
|
||||
rexml
|
||||
crass (1.0.6)
|
||||
css_parser (1.9.0)
|
||||
css_parser (1.7.1)
|
||||
addressable
|
||||
daemons (1.4.0)
|
||||
daemons (1.3.1)
|
||||
dalli (2.7.11)
|
||||
database_cleaner (1.99.0)
|
||||
ddtrace (0.49.0)
|
||||
ffi (~> 1.0)
|
||||
ddtrace (0.47.0)
|
||||
msgpack
|
||||
debugger-linecache (1.2.0)
|
||||
delayed_job (4.1.9)
|
||||
@@ -206,7 +202,7 @@ GEM
|
||||
delayed_job (> 2.0.3)
|
||||
rack-protection (>= 1.5.5)
|
||||
sinatra (>= 1.4.4)
|
||||
devise (4.8.0)
|
||||
devise (4.7.3)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
@@ -218,14 +214,14 @@ GEM
|
||||
devise (>= 4.0.0, < 5.0.0)
|
||||
diff-lcs (1.4.4)
|
||||
docile (1.3.5)
|
||||
erubi (1.10.0)
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.2.7)
|
||||
excon (0.79.0)
|
||||
execjs (2.7.0)
|
||||
factory_bot (6.2.0)
|
||||
factory_bot (6.1.0)
|
||||
activesupport (>= 5.0.0)
|
||||
factory_bot_rails (6.2.0)
|
||||
factory_bot (~> 6.2.0)
|
||||
factory_bot_rails (6.1.0)
|
||||
factory_bot (~> 6.1.0)
|
||||
railties (>= 5.0.0)
|
||||
faraday (1.3.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
@@ -236,15 +232,6 @@ GEM
|
||||
ffi (1.15.0)
|
||||
figaro (1.2.0)
|
||||
thor (>= 0.14.0, < 2)
|
||||
flipper (0.20.4)
|
||||
flipper-active_record (0.20.4)
|
||||
activerecord (>= 5.0, < 7)
|
||||
flipper (~> 0.20.4)
|
||||
flipper-ui (0.20.4)
|
||||
erubi (>= 1.0.0, < 2.0.0)
|
||||
flipper (~> 0.20.4)
|
||||
rack (>= 1.4, < 3)
|
||||
rack-protection (>= 1.5.3, < 2.2.0)
|
||||
fog-aws (2.0.1)
|
||||
fog-core (~> 1.38)
|
||||
fog-json (~> 1.0)
|
||||
@@ -270,7 +257,7 @@ GEM
|
||||
fuubar (2.5.1)
|
||||
rspec-core (~> 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
geocoder (1.6.7)
|
||||
geocoder (1.6.6)
|
||||
get_process_mem (0.2.7)
|
||||
ffi (~> 1.0)
|
||||
globalid (0.4.2)
|
||||
@@ -284,10 +271,9 @@ GEM
|
||||
tilt
|
||||
hashdiff (1.0.1)
|
||||
highline (2.0.3)
|
||||
hiredis (0.6.3)
|
||||
i18n (1.8.10)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n-js (3.8.3)
|
||||
i18n-js (3.8.2)
|
||||
i18n (>= 0.6.6)
|
||||
immigrant (0.3.6)
|
||||
activerecord (>= 3.0)
|
||||
@@ -305,7 +291,7 @@ GEM
|
||||
json_spec (1.1.5)
|
||||
multi_json (~> 1.0)
|
||||
rspec (>= 2.0, < 4.0)
|
||||
jwt (2.2.3)
|
||||
jwt (2.2.2)
|
||||
kaminari (1.2.1)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.2.1)
|
||||
@@ -319,30 +305,26 @@ GEM
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-core (1.2.1)
|
||||
kgio (2.11.3)
|
||||
knapsack (1.22.0)
|
||||
knapsack (1.20.0)
|
||||
rake
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
letter_opener (1.7.0)
|
||||
launchy (~> 2.2)
|
||||
libv8-node (15.14.0.0)
|
||||
loofah (2.9.1)
|
||||
libv8 (8.4.255.0)
|
||||
loofah (2.9.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (1.0.1)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2020.1104)
|
||||
mimemagic (0.4.3)
|
||||
nokogiri (~> 1)
|
||||
rake
|
||||
mini_mime (1.1.0)
|
||||
mini_portile2 (2.5.1)
|
||||
mini_racer (0.4.0)
|
||||
libv8-node (~> 15.14.0.0)
|
||||
mini_mime (1.0.3)
|
||||
mini_portile2 (2.5.0)
|
||||
mini_racer (0.3.1)
|
||||
libv8 (~> 8.4.255)
|
||||
minitest (5.14.4)
|
||||
monetize (1.11.0)
|
||||
money (~> 6.12)
|
||||
@@ -354,8 +336,8 @@ GEM
|
||||
multipart-post (2.1.1)
|
||||
mustermann (1.1.1)
|
||||
ruby2_keywords (~> 0.0.1)
|
||||
nio4r (2.5.7)
|
||||
nokogiri (1.11.4)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.11.2)
|
||||
mini_portile2 (~> 2.5.0)
|
||||
racc (~> 1.4)
|
||||
oauth2 (1.4.7)
|
||||
@@ -377,14 +359,16 @@ GEM
|
||||
parallel (1.20.1)
|
||||
paranoia (2.4.3)
|
||||
activerecord (>= 4.0, < 6.2)
|
||||
parser (3.0.1.1)
|
||||
parser (3.0.0.0)
|
||||
ast (~> 2.4.1)
|
||||
paypal-sdk-core (0.3.4)
|
||||
multi_json (~> 1.0)
|
||||
xml-simple
|
||||
paypal-sdk-merchant (1.117.2)
|
||||
paypal-sdk-core (~> 0.3.0)
|
||||
pg (1.2.3)
|
||||
pg (0.21.0)
|
||||
polyamorous (2.3.0)
|
||||
activerecord (>= 5.0)
|
||||
power_assert (2.0.0)
|
||||
pry (0.13.1)
|
||||
coderay (~> 1.1)
|
||||
@@ -395,27 +379,26 @@ GEM
|
||||
public_suffix (4.0.6)
|
||||
racc (1.5.2)
|
||||
rack (2.2.3)
|
||||
rack-mini-profiler (2.3.2)
|
||||
rack-mini-profiler (2.3.1)
|
||||
rack (>= 1.2.0)
|
||||
rack-protection (2.1.0)
|
||||
rack
|
||||
rack-rewrite (1.5.1)
|
||||
rack-ssl (1.4.1)
|
||||
rack
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.6)
|
||||
actioncable (= 5.2.6)
|
||||
actionmailer (= 5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
actionview (= 5.2.6)
|
||||
activejob (= 5.2.6)
|
||||
activemodel (= 5.2.6)
|
||||
activerecord (= 5.2.6)
|
||||
activestorage (= 5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.0.7.2)
|
||||
actioncable (= 5.0.7.2)
|
||||
actionmailer (= 5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activejob (= 5.0.7.2)
|
||||
activemodel (= 5.0.7.2)
|
||||
activerecord (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.6)
|
||||
railties (= 5.0.7.2)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.5)
|
||||
actionpack (>= 5.0.1.rc1)
|
||||
@@ -430,37 +413,38 @@ GEM
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 5.0, < 6)
|
||||
rails_safe_tasks (1.0.0)
|
||||
railties (5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
railties (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
raindrops (0.19.1)
|
||||
rake (13.0.3)
|
||||
ransack (2.4.1)
|
||||
activerecord (>= 5.2.4)
|
||||
activesupport (>= 5.2.4)
|
||||
ransack (2.3.0)
|
||||
actionpack (>= 5.0)
|
||||
activerecord (>= 5.0)
|
||||
activesupport (>= 5.0)
|
||||
i18n
|
||||
polyamorous (= 2.3.0)
|
||||
rb-fsevent (0.10.4)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
redcarpet (3.5.1)
|
||||
redis (4.2.5)
|
||||
regexp_parser (2.1.1)
|
||||
request_store (1.5.0)
|
||||
rack (>= 1.4)
|
||||
responders (3.0.1)
|
||||
actionpack (>= 5.0)
|
||||
railties (>= 5.0)
|
||||
rexml (3.2.5)
|
||||
roadie (4.0.0)
|
||||
rexml (3.2.4)
|
||||
roadie (3.5.1)
|
||||
css_parser (~> 1.4)
|
||||
nokogiri (~> 1.8)
|
||||
roadie-rails (2.2.0)
|
||||
railties (>= 5.1, < 6.2)
|
||||
roadie (>= 3.1, < 5.0)
|
||||
roadie-rails (1.3.0)
|
||||
railties (>= 3.0, < 5.3)
|
||||
roadie (~> 3.1)
|
||||
roo (2.8.3)
|
||||
nokogiri (~> 1)
|
||||
rubyzip (>= 1.3.0, < 3.0.0)
|
||||
@@ -476,10 +460,10 @@ GEM
|
||||
rspec-mocks (3.10.2)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-rails (5.0.1)
|
||||
actionpack (>= 5.2)
|
||||
activesupport (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
rspec-rails (4.1.2)
|
||||
actionpack (>= 4.2)
|
||||
activesupport (>= 4.2)
|
||||
railties (>= 4.2)
|
||||
rspec-core (~> 3.10)
|
||||
rspec-expectations (~> 3.10)
|
||||
rspec-mocks (~> 3.10)
|
||||
@@ -500,21 +484,21 @@ GEM
|
||||
rswag-ui (2.4.0)
|
||||
actionpack (>= 3.1, < 7.0)
|
||||
railties (>= 3.1, < 7.0)
|
||||
rubocop (1.15.0)
|
||||
rubocop (1.12.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml
|
||||
rubocop-ast (>= 1.5.0, < 2.0)
|
||||
rubocop-ast (>= 1.2.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.5.0)
|
||||
parser (>= 3.0.1.1)
|
||||
rubocop-rails (2.10.1)
|
||||
rubocop-ast (1.4.1)
|
||||
parser (>= 2.7.1.5)
|
||||
rubocop-rails (2.9.1)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby-rc4 (0.1.5)
|
||||
ruby2_keywords (0.0.2)
|
||||
@@ -556,17 +540,17 @@ GEM
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
state_machines (0.5.0)
|
||||
state_machines-activemodel (0.8.0)
|
||||
activemodel (>= 5.1)
|
||||
state_machines-activemodel (0.7.1)
|
||||
activemodel (>= 4.1)
|
||||
state_machines (>= 0.5.0)
|
||||
state_machines-activerecord (0.8.0)
|
||||
activerecord (>= 5.1)
|
||||
state_machines-activemodel (>= 0.8.0)
|
||||
state_machines-activerecord (0.6.0)
|
||||
activerecord (>= 4.1)
|
||||
state_machines-activemodel (>= 0.5.0)
|
||||
stringex (2.8.5)
|
||||
stripe (5.30.0)
|
||||
temple (0.8.2)
|
||||
test-prof (1.0.5)
|
||||
test-unit (3.4.1)
|
||||
test-prof (1.0.2)
|
||||
test-unit (3.4.0)
|
||||
power_assert
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
@@ -577,38 +561,34 @@ GEM
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode-display_width (2.0.0)
|
||||
unicorn (6.0.0)
|
||||
unicorn (5.8.0)
|
||||
kgio (~> 2.6)
|
||||
raindrops (~> 0.7)
|
||||
unicorn-rails (2.2.1)
|
||||
rack
|
||||
unicorn
|
||||
unicorn-worker-killer (0.4.5)
|
||||
unicorn-worker-killer (0.4.4)
|
||||
get_process_mem (~> 0)
|
||||
unicorn (>= 4, < 7)
|
||||
unicorn (>= 4, < 6)
|
||||
uniform_notifier (1.14.1)
|
||||
view_component (2.31.1)
|
||||
activesupport (>= 5.0.0, < 7.0)
|
||||
view_component_storybook (0.8.0)
|
||||
view_component (>= 2.2)
|
||||
warden (1.2.9)
|
||||
rack (>= 2.0.9)
|
||||
webdrivers (4.6.0)
|
||||
nokogiri (~> 1.6)
|
||||
rubyzip (>= 1.3.0)
|
||||
selenium-webdriver (>= 3.0, < 4.0)
|
||||
webmock (3.13.0)
|
||||
webmock (3.12.2)
|
||||
addressable (>= 2.3.6)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
websocket-driver (0.7.3)
|
||||
websocket-driver (0.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
whenever (1.0.0)
|
||||
chronic (>= 0.6.3)
|
||||
wicked_pdf (2.1.0)
|
||||
activesupport
|
||||
wkhtmltopdf-binary (0.12.6.5)
|
||||
wkhtmltopdf-binary (0.12.5)
|
||||
xml-simple (1.1.8)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
@@ -624,12 +604,13 @@ DEPENDENCIES
|
||||
activerecord-postgresql-adapter
|
||||
activerecord-session_store
|
||||
acts-as-taggable-on (~> 7.0)
|
||||
acts_as_list (= 1.0.4)
|
||||
acts_as_list (= 1.0.3)
|
||||
andand
|
||||
angular-rails-templates (>= 0.3.0)
|
||||
angular_rails_csrf
|
||||
angularjs-file-upload-rails (~> 2.4.1)
|
||||
angularjs-rails (= 1.5.5)
|
||||
atomic
|
||||
awesome_nested_set
|
||||
awesome_print
|
||||
aws-sdk (= 1.67.0)
|
||||
@@ -640,7 +621,7 @@ DEPENDENCIES
|
||||
capybara
|
||||
catalog!
|
||||
codecov
|
||||
coffee-rails (~> 5.0.0)
|
||||
coffee-rails (~> 4.2.2)
|
||||
combine_pdf
|
||||
compass-rails
|
||||
custom_error_message!
|
||||
@@ -657,12 +638,9 @@ DEPENDENCIES
|
||||
devise-token_authenticatable
|
||||
dfc_provider!
|
||||
eventmachine (>= 1.2.3)
|
||||
factory_bot_rails (= 6.2.0)
|
||||
factory_bot_rails (= 6.1.0)
|
||||
ffaker
|
||||
figaro
|
||||
flipper
|
||||
flipper-active_record
|
||||
flipper-ui
|
||||
fog-aws (>= 0.6.0)
|
||||
foundation-icons-sass-rails
|
||||
foundation-rails (= 5.5.2.1)
|
||||
@@ -672,9 +650,8 @@ DEPENDENCIES
|
||||
good_migrations
|
||||
haml
|
||||
highline (= 2.0.3)
|
||||
hiredis
|
||||
i18n
|
||||
i18n-js (~> 3.8.3)
|
||||
i18n-js (~> 3.8.2)
|
||||
immigrant
|
||||
jquery-migrate-rails
|
||||
jquery-rails (= 4.4.0)
|
||||
@@ -685,8 +662,7 @@ DEPENDENCIES
|
||||
kaminari (~> 1.2.1)
|
||||
knapsack
|
||||
letter_opener (>= 1.4.1)
|
||||
mimemagic (> 0.3.5)
|
||||
mini_racer (= 0.4.0)
|
||||
mini_racer (= 0.3.1)
|
||||
monetize (~> 1.11)
|
||||
oauth2 (~> 1.4.7)
|
||||
ofn-qz!
|
||||
@@ -695,21 +671,20 @@ DEPENDENCIES
|
||||
paperclip (~> 3.4.1)
|
||||
paranoia (~> 2.4)
|
||||
paypal-sdk-merchant (= 1.117.2)
|
||||
pg (~> 1.2.3)
|
||||
pg (~> 0.21.0)
|
||||
pry
|
||||
pry-byebug
|
||||
rack-mini-profiler (< 3.0.0)
|
||||
rack-rewrite
|
||||
rack-ssl
|
||||
rails (~> 5.2)
|
||||
rails (~> 5.0.0)
|
||||
rails-controller-testing
|
||||
rails-i18n
|
||||
rails_safe_tasks (~> 1.0)
|
||||
ransack (= 2.4.1)
|
||||
ransack (= 2.3.0)
|
||||
redcarpet
|
||||
redis (>= 4.0)
|
||||
responders
|
||||
roadie-rails (~> 2.2.0)
|
||||
roadie-rails (~> 1.3.0)
|
||||
roo (~> 2.8.3)
|
||||
rspec-rails (>= 3.5.2)
|
||||
rspec-retry
|
||||
@@ -733,14 +708,12 @@ DEPENDENCIES
|
||||
uglifier (>= 1.0.3)
|
||||
unicorn-rails
|
||||
unicorn-worker-killer
|
||||
view_component
|
||||
view_component_storybook
|
||||
web!
|
||||
webdrivers
|
||||
webmock
|
||||
whenever
|
||||
wicked_pdf
|
||||
wkhtmltopdf-binary
|
||||
wkhtmltopdf-binary (= 0.12.5)
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.5.8p224
|
||||
|
||||
@@ -34,7 +34,7 @@ We also have a [Super Admin Guide][super-admin-guide] to help with configuration
|
||||
|
||||
## Testing
|
||||
|
||||
If you'd like to help out with testing, please introduce yourself on the #testing channel on [Slack][slack-invite] and download the [ZenHub browser extension][zenhub] to view the development pipeline. Also, do have a look in our [Welcome New QAs board](https://github.com/openfoodfoundation/openfoodnetwork/projects/31) for some good first issues, both on manual and automated testing (RSpec/Capybara).
|
||||
If you'd like to help out with testing, please introduce yourself on the #testing channel on [Slack][slack-invite] and download the [ZenHub browser extension][zenhub] to view the development pipeline.
|
||||
|
||||
We use [BrowserStack](https://www.browserstack.com/) as a manual testing tool. BrowserStack provides open source projects with unlimited and free of charge accounts. A big thanks to them!
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ angular.module("admin.products").controller "editUnitsCtrl", ($scope, VariantUni
|
||||
if $scope.product.variant_unit == 'items'
|
||||
$scope.variant_unit_with_scale = 'items'
|
||||
else
|
||||
$scope.variant_unit_with_scale = $scope.product.variant_unit + '_' + $scope.product.variant_unit_scale.replace(/\.0$/, '');
|
||||
$scope.variant_unit_with_scale = $scope.product.variant_unit + '_' + $scope.product.variant_unit_scale
|
||||
|
||||
$scope.setFields = ->
|
||||
if $scope.variant_unit_with_scale == 'items'
|
||||
|
||||
@@ -23,6 +23,8 @@ angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, $fil
|
||||
preferred_customer_tags: (tag.text for tag in tagGroup.tags).join(",")
|
||||
type: "TagRule::#{ruleType}"
|
||||
switch ruleType
|
||||
when "DiscountOrder"
|
||||
newRule.calculator = { preferred_flat_percent: 0 }
|
||||
when "FilterShippingMethods"
|
||||
newRule.peferred_shipping_method_tags = []
|
||||
newRule.preferred_matched_shipping_methods_visibility = "visible"
|
||||
|
||||
@@ -8,6 +8,7 @@ angular.module("admin.tagRules").directive 'newTagRuleDialog', ($compile, $templ
|
||||
template = $compile($templateCache.get('admin/new_tag_rule_dialog.html'))(scope)
|
||||
|
||||
scope.ruleTypes = [
|
||||
# { id: "DiscountOrder", name: 'Apply a discount to orders' }
|
||||
{ id: "FilterProducts", name: t('js.tag_rules.show_hide_variants') }
|
||||
{ id: "FilterShippingMethods", name: t('js.tag_rules.show_hide_shipping') }
|
||||
{ id: "FilterPaymentMethods", name: t('js.tag_rules.show_hide_payment') }
|
||||
|
||||
@@ -11,9 +11,8 @@
|
||||
#= require leaflet-1.6.0.js
|
||||
#= require leaflet-providers.js
|
||||
#= require lodash.underscore.js
|
||||
# bluebird.js and angular-simple-logger are dependencies of angular-google-maps.js 2.0.0
|
||||
# bluebird.js is a dependency of angular-google-maps.js 2.0.0
|
||||
#= require bluebird.js
|
||||
#= require angular-simple-logger.min.js
|
||||
#= require angular-scroll.min.js
|
||||
#= require angular-google-maps.min.js
|
||||
#= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
|
||||
|
||||
@@ -3,7 +3,7 @@ Darkswarm.controller "EditBoughtOrderController", ($scope, $resource, $timeout,
|
||||
$scope.removeEnabled = true
|
||||
|
||||
$scope.deleteLineItem = (id) ->
|
||||
if Cart.isOnlyItemInOrder(id)
|
||||
if Cart.has_one_line_item()
|
||||
Messages.error(t 'orders_cannot_remove_the_final_item')
|
||||
$scope.removeEnabled = false
|
||||
$timeout (->
|
||||
|
||||
@@ -11,8 +11,6 @@ Darkswarm.controller "ProductsCtrl", ($scope, $sce, $filter, $rootScope, Product
|
||||
$scope.supplied_taxons = null
|
||||
$scope.supplied_properties = null
|
||||
$scope.showFilterSidebar = false
|
||||
$scope.activeTaxons = []
|
||||
$scope.activeProperties = []
|
||||
|
||||
# Update filters after initial load of shop tab
|
||||
$timeout =>
|
||||
@@ -22,7 +20,6 @@ Darkswarm.controller "ProductsCtrl", ($scope, $sce, $filter, $rootScope, Product
|
||||
$rootScope.$on "orderCycleSelected", ->
|
||||
$scope.update_filters()
|
||||
$scope.clearAll()
|
||||
$scope.page = 1
|
||||
|
||||
$scope.update_filters = ->
|
||||
order_cycle_id = OrderCycle.order_cycle.order_cycle_id
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseRegistrationService, availableCountries, GmapsGeo) ->
|
||||
Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseRegistrationService, availableCountries) ->
|
||||
$scope.currentStep = RegistrationService.currentStep
|
||||
$scope.enterprise = EnterpriseRegistrationService.enterprise
|
||||
$scope.select = RegistrationService.select
|
||||
$scope.geocodedAddress = ''
|
||||
$scope.latLong = null
|
||||
$scope.addressConfirmed = false
|
||||
|
||||
$scope.steps = ['details', 'contact', 'type', 'about', 'images', 'social']
|
||||
|
||||
# Filter countries without states since the form requires a state to be selected.
|
||||
@@ -24,26 +22,3 @@ Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, Enterpris
|
||||
|
||||
$scope.countryHasStates = ->
|
||||
$scope.enterprise.country.states.length > 0
|
||||
|
||||
$scope.map = {center: {latitude: 0.000000, longitude: 0.000000 }, zoom: 1}
|
||||
$scope.options = {scrollwheel: false}
|
||||
$scope.locateAddress = () ->
|
||||
{ address1, address2, city, state_id, zipcode } = $scope.enterprise.address
|
||||
addressQuery = [address1, address2, city, state_id, zipcode].filter((value) => !!value).join(", ")
|
||||
GmapsGeo.geocode addressQuery, (results, status) =>
|
||||
$scope.geocodedAddress = results && results[0]?.formatted_address
|
||||
location = results[0]?.geometry?.location
|
||||
if location
|
||||
$scope.$apply(() =>
|
||||
$scope.latLong = {latitude: location.lat(), longitude: location.lng()}
|
||||
$scope.map = {center: {latitude: location.lat(), longitude: location.lng()}, zoom: 16 }
|
||||
)
|
||||
|
||||
$scope.toggleAddressConfirmed = ->
|
||||
$scope.addressConfirmed = !$scope.addressConfirmed
|
||||
if $scope.addressConfirmed
|
||||
$scope.enterprise.address.latitude = $scope.latLong.latitude
|
||||
$scope.enterprise.address.longitude = $scope.latLong.longitude
|
||||
else
|
||||
$scope.enterprise.address.latitude = null
|
||||
$scope.enterprise.address.longitude = null
|
||||
|
||||
@@ -4,5 +4,4 @@ Darkswarm.directive "shopVariantWithUnitPrice", ->
|
||||
templateUrl: 'shop_variant_with_unit_price.html'
|
||||
scope:
|
||||
variant: '='
|
||||
show_unit_price: '=showunitprice'
|
||||
controller: 'ShopVariantCtrl'
|
||||
|
||||
@@ -115,9 +115,8 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo
|
||||
@line_items = []
|
||||
localStorageService.clearAll() # One day this will have to be moar GRANULAR
|
||||
|
||||
isOnlyItemInOrder: (id) =>
|
||||
deletedItem = @line_items_finalised.find((item) -> item.id == id)
|
||||
@line_items_finalised.filter((item) -> item.order_id == deletedItem.order_id).length == 1
|
||||
has_one_line_item: =>
|
||||
@line_items_finalised.length == 1
|
||||
|
||||
removeFinalisedLineItem: (id) =>
|
||||
@line_items_finalised = @line_items_finalised.filter (item) ->
|
||||
|
||||
@@ -21,7 +21,6 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
|
||||
url: "/api/v0/enterprises"
|
||||
data:
|
||||
enterprise: @prepare()
|
||||
use_geocoder: @useGeocoder()
|
||||
params:
|
||||
token: spreeApiKey
|
||||
).success((data) =>
|
||||
@@ -46,7 +45,6 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
|
||||
url: "/api/v0/enterprises/#{@enterprise.id}"
|
||||
data:
|
||||
enterprise: @prepare()
|
||||
use_geocoder: @useGeocoder()
|
||||
params:
|
||||
token: spreeApiKey
|
||||
).success((data) ->
|
||||
@@ -65,7 +63,3 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
|
||||
enterprise.address_attributes = @enterprise.address if @enterprise.address?
|
||||
enterprise.address_attributes.country_id = @enterprise.country.id if @enterprise.country?
|
||||
enterprise
|
||||
|
||||
useGeocoder: =>
|
||||
if @enterprise.address? && !@enterprise.address.latitude? && !@enterprise.address.longitude?
|
||||
return "1"
|
||||
|
||||
@@ -10,7 +10,7 @@ Darkswarm.service "GmapsGeo", ->
|
||||
# console.log "Error: #{status}"
|
||||
geocode: (address, callback) ->
|
||||
geocoder = new google.maps.Geocoder()
|
||||
geocoder.geocode {'address': address, 'region': "<%= DefaultCountry.code %>"}, callback
|
||||
geocoder.geocode {'address': address, 'region': "<%= Spree::Country.find_by(id: Spree::Config[:default_country_id]).iso %>"}, callback
|
||||
|
||||
distanceBetween: (src, dst) ->
|
||||
google.maps.geometry.spherical.computeDistanceBetween @toLatLng(src), @toLatLng(dst)
|
||||
@@ -20,4 +20,4 @@ Darkswarm.service "GmapsGeo", ->
|
||||
if locatable.lat?
|
||||
locatable
|
||||
else
|
||||
new google.maps.LatLng locatable.latitude, locatable.longitude
|
||||
new google.maps.LatLng locatable.latitude, locatable.longitude
|
||||
@@ -2,21 +2,12 @@
|
||||
.columns.small-12
|
||||
%h3{"ng-bind" => "::variant.extended_name"}
|
||||
|
||||
.flex.variant-bulk-buy-price-summary{style: "justify-content: space-around;"}
|
||||
.variant-unit
|
||||
{{ ::variant.unit_to_display }}
|
||||
.div
|
||||
.row.variant-bulk-buy-price-summary
|
||||
.columns.small-6
|
||||
.variant-unit {{ ::variant.unit_to_display }}
|
||||
.columns.small-6
|
||||
{{ variant.line_item.total_price | localizeCurrency }}
|
||||
|
||||
.unit-price{"ng-if": "show_unit_price"}
|
||||
%question-mark-with-tooltip{"question-mark-with-tooltip": "_",
|
||||
"question-mark-with-tooltip-append-to-body": "true",
|
||||
"question-mark-with-tooltip-placement": "top",
|
||||
"question-mark-with-tooltip-animation": true,
|
||||
style: "margin-right: 5px",
|
||||
key: "'js.shopfront.unit_price_tooltip'"}
|
||||
{{ variant.unit_price_price | localizeCurrency }} / {{ variant.unit_price_unit }}
|
||||
|
||||
.row
|
||||
.columns.small-12.medium-6
|
||||
.variant-bulk-buy-quantity-label
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"question-mark-with-tooltip-placement" => "top",
|
||||
"question-mark-with-tooltip-animation" => true,
|
||||
key: "'js.shopfront.unit_price_tooltip'"}
|
||||
{{ variant.unit_price_price | localizeCurrency }} / {{ variant.unit_price_unit }}
|
||||
{{ variant.unit_price_price | localizeCurrency }} / {{ variant.unit_price_unit }}
|
||||
|
||||
.medium-2.large-2.columns.total-price
|
||||
%span{"ng-class" => "{filled: variant.line_item.total_price}"}
|
||||
|
||||
@@ -117,13 +117,6 @@ button.bulk-buy-add.variant-quantity {
|
||||
}
|
||||
}
|
||||
|
||||
// Hide number arrows on Chrome, Safari, Edge, Opera
|
||||
.variant-quantity::-webkit-outer-spin-button,
|
||||
.variant-quantity::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.variant-bulk-buy-price-summary {
|
||||
color: $disabled-med;
|
||||
margin-bottom: 1em;
|
||||
|
||||
@@ -181,10 +181,11 @@ shop ordercycle {
|
||||
}
|
||||
}
|
||||
|
||||
shop .tab-buttons ordercycle {
|
||||
shop navigation ordercycle {
|
||||
margin-top: 3.4em;
|
||||
padding: 1em;
|
||||
height: 7.6em;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 1em;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
@import "mixins";
|
||||
@import 'typography';
|
||||
|
||||
$shop-navigation-zindex: 20;
|
||||
|
||||
section {
|
||||
:not(shop) navigation {
|
||||
box-shadow: $distributor-header-shadow;
|
||||
@@ -13,7 +11,7 @@ section {
|
||||
display: block;
|
||||
background: $white;
|
||||
position: relative;
|
||||
z-index: $shop-navigation-zindex;
|
||||
z-index: 20;
|
||||
|
||||
.details {
|
||||
box-sizing: border-box;
|
||||
|
||||
@@ -167,26 +167,6 @@
|
||||
height: 166px;
|
||||
}
|
||||
}
|
||||
|
||||
.map-container--registration {
|
||||
width: 100%;
|
||||
height: 244px;
|
||||
margin-bottom: 1em;
|
||||
|
||||
map, .angular-google-map-container, google-map, .angular-google-map {
|
||||
display: block;
|
||||
height: 220px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.button.primary {
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
#registration-type {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
color: $dark-grey;
|
||||
box-shadow: $distributor-header-shadow;
|
||||
position: relative;
|
||||
z-index: $shop-navigation-zindex + 1;
|
||||
z-index: 10;
|
||||
|
||||
.columns {
|
||||
display: flex;
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
content: "";
|
||||
color: $white;
|
||||
vertical-align: super;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +58,6 @@
|
||||
margin-left: -7.4rem;
|
||||
margin-top: -0.1rem;
|
||||
background-color: transparent;
|
||||
z-index: $modal-zIndex + 1;
|
||||
|
||||
.background {
|
||||
position: fixed;
|
||||
|
||||
@@ -4,9 +4,6 @@ $white: #fff;
|
||||
$dynamic-blue: #3d8dd1;
|
||||
$teal-500: #0096ad;
|
||||
|
||||
/* Defined in foundation-rails components/_reveal.scss */
|
||||
$modal-zIndex: 1005;
|
||||
|
||||
@font-face {
|
||||
font-family: 'OFN';
|
||||
src: font-url('OFN-v2.eot');
|
||||
@@ -25,4 +22,4 @@ $modal-zIndex: 1005;
|
||||
font-style: normal;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DistributorTitleComponent < ViewComponent::Base
|
||||
def initialize(name:)
|
||||
@name = name
|
||||
end
|
||||
end
|
||||
@@ -1 +0,0 @@
|
||||
%h3= @name
|
||||
@@ -1,7 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ExampleComponent < ViewComponent::Base
|
||||
def initialize(title:)
|
||||
@title = title
|
||||
end
|
||||
end
|
||||
@@ -1 +0,0 @@
|
||||
%h1 #{@title}
|
||||
@@ -35,7 +35,7 @@ module Admin
|
||||
if @line_item.update(line_item_params)
|
||||
order.update_line_item_fees! @line_item
|
||||
order.update_order_fees!
|
||||
order.update_order!
|
||||
order.update!
|
||||
render body: nil, status: :no_content # No Content, does not trigger ng resource auto-update
|
||||
else
|
||||
render json: { errors: @line_item.errors }, status: :precondition_failed
|
||||
|
||||
@@ -18,13 +18,21 @@ module Admin
|
||||
format.html
|
||||
format.json do
|
||||
render json: @collection,
|
||||
each_serializer: ::Api::Admin::CustomerWithBalanceSerializer,
|
||||
each_serializer: index_each_serializer,
|
||||
tag_rule_mapping: tag_rule_mapping,
|
||||
customer_tags: customer_tags_by_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def index_each_serializer
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, spree_current_user)
|
||||
::Api::Admin::CustomerWithBalanceSerializer
|
||||
else
|
||||
::Api::Admin::CustomerWithCalculatedBalanceSerializer
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
render_as_json @customer, ams_prefix: params[:ams_prefix]
|
||||
end
|
||||
@@ -62,7 +70,7 @@ module Admin
|
||||
|
||||
def collection
|
||||
if json_request? && params[:enterprise_id].present?
|
||||
CustomersWithBalance.new(managed_enterprise_id).query.
|
||||
customers_relation.
|
||||
includes(
|
||||
:enterprise,
|
||||
{ bill_address: [:state, :country] },
|
||||
@@ -74,6 +82,14 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
def customers_relation
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, spree_current_user)
|
||||
CustomersWithBalance.new(managed_enterprise_id).query
|
||||
else
|
||||
Customer.of(managed_enterprise_id)
|
||||
end
|
||||
end
|
||||
|
||||
def managed_enterprise_id
|
||||
@managed_enterprise_id ||= Enterprise.managed_by(spree_current_user).
|
||||
select('enterprises.id').find_by(id: params[:enterprise_id])
|
||||
|
||||
@@ -28,7 +28,9 @@ module Admin
|
||||
def build_resource
|
||||
enterprise_group = super
|
||||
enterprise_group.address = Spree::Address.new
|
||||
enterprise_group.address.country = DefaultCountry.country
|
||||
enterprise_group.address.country = Spree::Country.find_by(
|
||||
id: Spree::Config[:default_country_id]
|
||||
)
|
||||
enterprise_group
|
||||
end
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ require 'open_food_network/order_cycle_permissions'
|
||||
|
||||
module Admin
|
||||
class EnterprisesController < Admin::ResourceController
|
||||
include GeocodeEnterpriseAddress
|
||||
|
||||
# These need to run before #load_resource so that @object is initialised with sanitised values
|
||||
prepend_before_action :override_owner, only: :create
|
||||
prepend_before_action :override_sells, only: :create
|
||||
@@ -24,8 +22,6 @@ module Admin
|
||||
before_action :load_properties, only: [:edit, :update]
|
||||
before_action :setup_property, only: [:edit]
|
||||
|
||||
after_action :geocode_address_if_use_geocoder, only: [:create, :update]
|
||||
|
||||
helper 'spree/products'
|
||||
include OrderCyclesHelper
|
||||
|
||||
@@ -119,7 +115,7 @@ module Admin
|
||||
def build_resource
|
||||
enterprise = super
|
||||
enterprise.address ||= Spree::Address.new
|
||||
enterprise.address.country ||= DefaultCountry.country
|
||||
enterprise.address.country ||= Spree::Country.find_by(id: Spree::Config[:default_country_id])
|
||||
enterprise
|
||||
end
|
||||
|
||||
@@ -216,6 +212,7 @@ module Admin
|
||||
tag_rules_attributes.select{ |_i, attrs| attrs[:type].present? }.each do |_i, attrs|
|
||||
rule = @object.tag_rules.find_by(id: attrs.delete(:id)) ||
|
||||
attrs[:type].constantize.new(enterprise: @object)
|
||||
create_calculator_for(rule, attrs) if rule.type == "TagRule::DiscountOrder" && rule.calculator.nil?
|
||||
|
||||
rule.update(attrs.permit(PermittedAttributes::TagRules.attributes))
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Base controller for OFN's API
|
||||
require "spree/api/controller_setup"
|
||||
require_dependency 'spree/api/controller_setup'
|
||||
require "spree/core/controller_helpers/ssl"
|
||||
|
||||
module Api
|
||||
@@ -27,6 +27,8 @@ module Api
|
||||
rescue_from CanCan::AccessDenied, with: :unauthorized
|
||||
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
||||
|
||||
helper Spree::Api::ApiHelpers
|
||||
|
||||
ssl_allowed
|
||||
|
||||
# Include these because we inherit from ActionController::Metal
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
module Api
|
||||
module V0
|
||||
class EnterprisesController < Api::V0::BaseController
|
||||
include GeocodeEnterpriseAddress
|
||||
|
||||
before_action :override_owner, only: [:create, :update]
|
||||
before_action :check_type, only: :update
|
||||
before_action :override_sells, only: [:create, :update]
|
||||
@@ -19,7 +17,6 @@ module Api
|
||||
user_ids = enterprise_params.delete(:user_ids)
|
||||
@enterprise = Enterprise.new(enterprise_params)
|
||||
if @enterprise.save
|
||||
geocode_address_if_use_geocoder
|
||||
@enterprise.user_ids = user_ids
|
||||
render json: @enterprise.id, status: :created
|
||||
else
|
||||
@@ -32,7 +29,6 @@ module Api
|
||||
authorize! :update, @enterprise
|
||||
|
||||
if @enterprise.update(enterprise_params)
|
||||
geocode_address_if_use_geocoder
|
||||
render json: @enterprise.id, status: :ok
|
||||
else
|
||||
invalid_resource!(@enterprise)
|
||||
|
||||
@@ -8,7 +8,6 @@ module Api
|
||||
respond_to :json
|
||||
|
||||
before_action :find_order
|
||||
before_action :refuse_changing_cancelled_orders, only: [:add, :remove]
|
||||
before_action :find_and_update_shipment, only: [:ship, :ready, :add, :remove]
|
||||
|
||||
def create
|
||||
@@ -16,7 +15,7 @@ module Api
|
||||
quantity = params[:quantity].to_i
|
||||
@shipment = get_or_create_shipment(params[:stock_location_id])
|
||||
|
||||
@order.contents.add(variant, quantity, @shipment)
|
||||
@order.contents.add(variant, quantity, nil, @shipment)
|
||||
|
||||
@shipment.refresh_rates
|
||||
@shipment.save!
|
||||
@@ -31,12 +30,10 @@ module Api
|
||||
unlock = params[:shipment].delete(:unlock)
|
||||
|
||||
if unlock == 'yes'
|
||||
@shipment.fee_adjustment.fire_events(:open)
|
||||
@shipment.fee_adjustment.open
|
||||
end
|
||||
|
||||
if @shipment.update(shipment_params)
|
||||
@order.updater.update_totals_and_states
|
||||
end
|
||||
@shipment.update(shipment_params[:shipment])
|
||||
|
||||
if unlock == 'yes'
|
||||
@shipment.fee_adjustment.close
|
||||
@@ -70,8 +67,7 @@ module Api
|
||||
variant = scoped_variant(params[:variant_id])
|
||||
quantity = params[:quantity].to_i
|
||||
|
||||
@order.contents.add(variant, quantity, @shipment)
|
||||
@order.recreate_all_fees!
|
||||
@order.contents.add(variant, quantity, nil, @shipment)
|
||||
|
||||
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
|
||||
end
|
||||
@@ -81,7 +77,6 @@ module Api
|
||||
quantity = params[:quantity].to_i
|
||||
|
||||
@order.contents.remove(variant, quantity, @shipment)
|
||||
@order.recreate_all_fees!
|
||||
@shipment.reload if @shipment.persisted?
|
||||
|
||||
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
|
||||
@@ -96,14 +91,10 @@ module Api
|
||||
|
||||
def find_and_update_shipment
|
||||
@shipment = @order.shipments.find_by!(number: params[:id])
|
||||
@shipment.update(shipment_params)
|
||||
@shipment.update(shipment_params[:shipment]) if shipment_params[:shipment].present?
|
||||
@shipment.reload
|
||||
end
|
||||
|
||||
def refuse_changing_cancelled_orders
|
||||
render status: :unprocessable_entity if @order.canceled?
|
||||
end
|
||||
|
||||
def scoped_variant(variant_id)
|
||||
variant = Spree::Variant.find(variant_id)
|
||||
OpenFoodNetwork::ScopeVariantToHub.new(@order.distributor).scope(variant)
|
||||
@@ -115,9 +106,10 @@ module Api
|
||||
end
|
||||
|
||||
def shipment_params
|
||||
return {} unless params.has_key? :shipment
|
||||
|
||||
params.require(:shipment).permit(:tracking, :selected_shipping_rate_id)
|
||||
params.permit(
|
||||
[:id, :order_id, :variant_id, :quantity,
|
||||
{ shipment: [:tracking, :selected_shipping_rate_id] }]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ module Api
|
||||
taxonomy = Spree::Taxonomy.find_by(id: params[:taxonomy_id])
|
||||
|
||||
if taxonomy.nil?
|
||||
@taxon.errors.add(:taxonomy_id, I18n.t(:invalid_taxonomy_id, scope: 'spree.api'))
|
||||
@taxon.errors[:taxonomy_id] = I18n.t(:invalid_taxonomy_id, scope: 'spree.api')
|
||||
invalid_resource!(@taxon) && return
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "spree/authentication_helpers"
|
||||
require_dependency 'spree/authentication_helpers'
|
||||
require "application_responder"
|
||||
require 'cancan'
|
||||
require 'spree/core/controller_helpers/auth'
|
||||
@@ -13,20 +13,6 @@ class ApplicationController < ActionController::Base
|
||||
self.responder = ApplicationResponder
|
||||
respond_to :html
|
||||
|
||||
helper 'spree/base'
|
||||
helper 'spree/orders'
|
||||
helper 'spree/payment_methods'
|
||||
helper 'shared'
|
||||
helper 'enterprises'
|
||||
helper 'order_cycles'
|
||||
helper 'order'
|
||||
helper 'shop'
|
||||
helper 'injection'
|
||||
helper 'markdown'
|
||||
helper 'footer_links'
|
||||
helper 'discourse'
|
||||
helper 'checkout'
|
||||
|
||||
protect_from_forgery
|
||||
|
||||
include Spree::Core::ControllerHelpers::Auth
|
||||
|
||||
@@ -13,6 +13,8 @@ class BaseController < ApplicationController
|
||||
include I18nHelper
|
||||
include OrderCyclesHelper
|
||||
|
||||
helper 'spree/base'
|
||||
|
||||
before_action :set_locale
|
||||
before_action :check_order_cycle_expiry
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class CheckoutController < ::BaseController
|
||||
flash[:error] = I18n.t("checkout.failed")
|
||||
action_failed(e)
|
||||
ensure
|
||||
@order.update_order!
|
||||
@order.update!
|
||||
end
|
||||
|
||||
# Clears the cached order. Required for #current_order to return a new order
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module GeocodeEnterpriseAddress
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def geocode_address_if_use_geocoder
|
||||
AddressGeocoder.new(@enterprise.address).geocode if params[:use_geocoder] == "1"
|
||||
end
|
||||
end
|
||||
@@ -43,7 +43,7 @@ class LineItemsController < BaseController
|
||||
order.update_shipping_fees!
|
||||
order.update_payment_fees!
|
||||
order.update_order_fees!
|
||||
order.update_order!
|
||||
order.update!
|
||||
order.create_tax_charge!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,12 +2,9 @@ require 'open_food_network/spree_api_key_loader'
|
||||
|
||||
class RegistrationController < BaseController
|
||||
include OpenFoodNetwork::SpreeApiKeyLoader
|
||||
|
||||
layout 'registration'
|
||||
helper 'map'
|
||||
|
||||
before_action :load_spree_api_key, only: [:index]
|
||||
before_action :check_user, except: :authenticate
|
||||
layout 'registration'
|
||||
|
||||
def index
|
||||
@enterprise_attributes = { sells: 'none' }
|
||||
|
||||
@@ -5,7 +5,6 @@ module Spree
|
||||
|
||||
prepend_before_action :set_included_tax, only: [:create, :update]
|
||||
before_action :set_order_id, only: [:create, :update]
|
||||
before_action :skip_changing_canceled_orders, only: [:create, :update]
|
||||
after_action :update_order, only: [:create, :update, :destroy]
|
||||
before_action :set_default_tax_rate, only: :edit
|
||||
before_action :enable_updates, only: :update
|
||||
@@ -14,16 +13,11 @@ module Spree
|
||||
|
||||
def update_order
|
||||
@order.reload
|
||||
@order.update_order!
|
||||
@order.update!
|
||||
end
|
||||
|
||||
def collection
|
||||
order_adjustments = parent.adjustments.where.not(originator_type: 'EnterpriseFee')
|
||||
admin_adjustments = parent.adjustments.admin
|
||||
payment_fees = parent.all_adjustments.payment_fee.eligible
|
||||
shipping_fees = parent.all_adjustments.shipping
|
||||
|
||||
order_adjustments.or(admin_adjustments) | payment_fees.or(shipping_fees)
|
||||
parent.all_adjustments.eligible
|
||||
end
|
||||
|
||||
def find_resource
|
||||
@@ -34,13 +28,6 @@ module Spree
|
||||
@adjustment.order_id = parent.id
|
||||
end
|
||||
|
||||
def skip_changing_canceled_orders
|
||||
return unless @order.canceled?
|
||||
|
||||
flash[:error] = t("admin.adjustments.skipped_changing_canceled_order")
|
||||
redirect_to admin_order_adjustments_path(@order) if @order.canceled?
|
||||
end
|
||||
|
||||
# Choose a default tax rate to show on the edit form. The adjustment stores its included
|
||||
# tax in dollars, but doesn't store the source of the tax (ie. TaxRate that generated it).
|
||||
# We guess which tax rate here, choosing:
|
||||
|
||||
@@ -3,15 +3,7 @@ module Spree
|
||||
class BaseController < ApplicationController
|
||||
ssl_required
|
||||
|
||||
helper 'shared'
|
||||
helper 'spree/admin/navigation'
|
||||
helper 'spree/admin/orders'
|
||||
helper 'admin/injection'
|
||||
helper 'admin/orders'
|
||||
helper 'admin/enterprises'
|
||||
helper 'enterprise_fees'
|
||||
helper 'angular_form'
|
||||
|
||||
layout '/spree/layouts/admin'
|
||||
|
||||
include I18nHelper
|
||||
@@ -29,6 +21,18 @@ module Spree
|
||||
flash[:notice] = warning if warning.present?
|
||||
end
|
||||
|
||||
# This is in Spree::Core::ControllerHelpers::Auth
|
||||
# But you can't easily reopen modules in Ruby
|
||||
def unauthorized
|
||||
if spree_current_user
|
||||
flash[:error] = t(:authorization_failure)
|
||||
redirect_to '/unauthorized'
|
||||
else
|
||||
store_location
|
||||
redirect_to main_app.root_path(anchor: "login?after_login=#{request.env['PATH_INFO']}")
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def model_class
|
||||
|
||||
@@ -3,7 +3,7 @@ module Spree
|
||||
class GeneralSettingsController < Spree::Admin::BaseController
|
||||
def edit
|
||||
@preferences_general = [:site_name, :default_seo_title, :default_meta_keywords,
|
||||
:default_meta_description, :site_url]
|
||||
:default_meta_description, :site_url, :bugherd_api_key]
|
||||
@preferences_security = [:allow_ssl_in_production,
|
||||
:allow_ssl_in_staging, :allow_ssl_in_development_and_test]
|
||||
@preferences_currency = [:display_currency, :hide_cents]
|
||||
|
||||
@@ -38,12 +38,11 @@ module Spree
|
||||
@order.recreate_all_fees!
|
||||
|
||||
unless order_params.present? && @order.update(order_params) && @order.line_items.present?
|
||||
if @order.line_items.empty? && !params[:suppress_error_msg]
|
||||
if @order.line_items.empty?
|
||||
@order.errors.add(:line_items, Spree.t('errors.messages.blank'))
|
||||
end
|
||||
|
||||
flash[:error] = @order.errors.full_messages.join(', ') if @order.errors.present?
|
||||
return redirect_to spree.edit_admin_order_path(@order)
|
||||
return redirect_to(spree.edit_admin_order_path(@order),
|
||||
flash: { error: @order.errors.full_messages.join(', ') })
|
||||
end
|
||||
|
||||
if @order.complete?
|
||||
@@ -68,16 +67,14 @@ module Spree
|
||||
rescue Spree::Core::GatewayError => e
|
||||
flash[:error] = e.message.to_s
|
||||
ensure
|
||||
redirect_back fallback_location: spree.admin_dashboard_path
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
def resend
|
||||
Spree::OrderMailer.confirm_email_for_customer(@order.id, true).deliver_later
|
||||
flash[:success] = t('admin.orders.order_email_resent')
|
||||
|
||||
respond_with(@order) do |format|
|
||||
format.html { redirect_back(fallback_location: spree.admin_dashboard_path) }
|
||||
end
|
||||
respond_with(@order) { |format| format.html { redirect_to :back } }
|
||||
end
|
||||
|
||||
def invoice
|
||||
@@ -92,7 +89,7 @@ module Spree
|
||||
end
|
||||
|
||||
def print
|
||||
render_with_wicked_pdf InvoiceRenderer.new.args(@order)
|
||||
render InvoiceRenderer.new.args(@order)
|
||||
end
|
||||
|
||||
def print_ticket
|
||||
|
||||
@@ -9,10 +9,6 @@ module Spree
|
||||
before_action :load_payment, only: [:fire, :show]
|
||||
before_action :load_data
|
||||
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.
|
||||
before_action :ensure_sufficient_stock_lines
|
||||
|
||||
respond_to :html
|
||||
|
||||
@@ -146,20 +142,6 @@ module Spree
|
||||
redirect_to spree.edit_admin_order_customer_url(@order)
|
||||
end
|
||||
|
||||
def ensure_sufficient_stock_lines
|
||||
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}")
|
||||
redirect_to spree.edit_admin_order_url(@order)
|
||||
end
|
||||
|
||||
def out_of_stock_item_names
|
||||
@order.insufficient_stock_lines.map do |line_item|
|
||||
line_item.variant.name
|
||||
end.join(", ")
|
||||
end
|
||||
|
||||
def load_order
|
||||
@order = Order.find_by!(number: params[:order_id])
|
||||
authorize! action, @order
|
||||
|
||||
@@ -8,7 +8,7 @@ module Spree
|
||||
def fire
|
||||
@return_authorization.public_send("#{params[:e]}!")
|
||||
flash[:success] = Spree.t(:return_authorization_updated)
|
||||
redirect_back fallback_location: spree.admin_dashboard_path
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -79,14 +79,13 @@ module Spree
|
||||
|
||||
def load_data
|
||||
@available_zones = Zone.order(:name)
|
||||
@tax_categories = Spree::TaxCategory.order(:name)
|
||||
@calculators = ShippingMethod.calculators.sort_by(&:name)
|
||||
end
|
||||
|
||||
def permitted_resource_params
|
||||
params.require(:shipping_method).permit(
|
||||
:name, :description, :display_on, :require_ship_address, :tag_list, :calculator_type,
|
||||
:tax_category_id, distributor_ids: [],
|
||||
distributor_ids: [],
|
||||
calculator_attributes: PermittedAttributes::Calculator.attributes
|
||||
)
|
||||
end
|
||||
|
||||
@@ -14,7 +14,11 @@ module Spree
|
||||
private
|
||||
|
||||
def preferences_params
|
||||
params.require(:preferences).permit(:products_require_tax_category)
|
||||
params.require(:preferences).permit(
|
||||
:products_require_tax_category,
|
||||
:shipment_inc_vat,
|
||||
:shipping_tax_rate,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
16
app/controllers/spree/checkout_controller.rb
Normal file
16
app/controllers/spree/checkout_controller.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# This controller (and respective route in the Spree engine)
|
||||
# is only needed for the spree_paypal_express gem that redirects here explicitly.
|
||||
#
|
||||
# According to the rails docs it would be possible to redirect
|
||||
# to CheckoutController directly in the routes
|
||||
# with a slash like "to: '/checkout#edit'", but it does not work in this case.
|
||||
module Spree
|
||||
class CheckoutController < ::BaseController
|
||||
def edit
|
||||
flash.keep
|
||||
redirect_to main_app.checkout_path
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -14,7 +14,7 @@ module Spree
|
||||
respond_to :html
|
||||
respond_to :json
|
||||
|
||||
before_action :set_current_order, only: :update
|
||||
before_action :update_distribution, only: :update
|
||||
before_action :filter_order_params, only: :update
|
||||
before_action :enable_embedded_shopfront
|
||||
|
||||
@@ -26,8 +26,8 @@ module Spree
|
||||
|
||||
def show
|
||||
@order = Spree::Order.find_by!(number: params[:id])
|
||||
|
||||
handle_stripe_response
|
||||
ProcessPaymentIntent.new(params["payment_intent"], @order).call!
|
||||
@order.reload
|
||||
end
|
||||
|
||||
def empty
|
||||
@@ -62,7 +62,7 @@ module Spree
|
||||
associate_user
|
||||
|
||||
if @order.insufficient_stock_lines.present? || @unavailable_order_variants.present?
|
||||
flash.now[:error] = t("spree.orders.error_flash_for_unavailable_items")
|
||||
flash[:error] = t("spree.orders.error_flash_for_unavailable_items")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -86,16 +86,15 @@ module Spree
|
||||
if @order.complete?
|
||||
@order.update_shipping_fees!
|
||||
@order.update_payment_fees!
|
||||
@order.create_tax_charge!
|
||||
end
|
||||
|
||||
respond_with(@order) do |format|
|
||||
format.html do
|
||||
if params.key?(:checkout)
|
||||
@order.next_transition.run_callbacks if @order.cart?
|
||||
redirect_to main_app.checkout_state_path(@order.checkout_steps.first)
|
||||
redirect_to checkout_state_path(@order.checkout_steps.first)
|
||||
elsif @order.complete?
|
||||
redirect_to main_app.order_path(@order)
|
||||
redirect_to order_path(@order)
|
||||
else
|
||||
redirect_to main_app.cart_path
|
||||
end
|
||||
@@ -104,13 +103,29 @@ module Spree
|
||||
else
|
||||
# Show order with original values, not newly entered ones
|
||||
@insufficient_stock_lines = @order.insufficient_stock_lines
|
||||
@order.line_items.reload
|
||||
@order.line_items(true)
|
||||
respond_with(@order)
|
||||
end
|
||||
end
|
||||
|
||||
def set_current_order
|
||||
def update_distribution
|
||||
@order = current_order(true)
|
||||
|
||||
if params[:commit] == 'Choose Hub'
|
||||
distributor = Enterprise.is_distributor.find params[:order][:distributor_id]
|
||||
@order.set_distributor! distributor
|
||||
|
||||
flash[:notice] = I18n.t(:order_choosing_hub_notice)
|
||||
redirect_to request.referer
|
||||
|
||||
elsif params[:commit] == 'Choose Order Cycle'
|
||||
@order.empty! # empty cart
|
||||
order_cycle = OrderCycle.active.find params[:order][:order_cycle_id]
|
||||
@order.set_order_cycle! order_cycle
|
||||
|
||||
flash[:notice] = I18n.t(:order_choosing_hub_notice)
|
||||
redirect_to request.referer
|
||||
end
|
||||
end
|
||||
|
||||
def filter_order_params
|
||||
@@ -135,24 +150,11 @@ module Spree
|
||||
else
|
||||
flash[:error] = I18n.t(:orders_could_not_cancel)
|
||||
end
|
||||
redirect_to request.referer || main_app.order_path(@order)
|
||||
redirect_to request.referer || order_path(@order)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Stripe can redirect here after a payment is processed in the backoffice.
|
||||
# We verify if it was successful here and persist the changes.
|
||||
def handle_stripe_response
|
||||
return unless params.key?("payment_intent")
|
||||
|
||||
result = ProcessPaymentIntent.new(params["payment_intent"], @order).call!
|
||||
|
||||
unless result.ok?
|
||||
flash.now[:error] = "#{I18n.t("payment_could_not_process")}. #{result.error}"
|
||||
end
|
||||
@order.reload
|
||||
end
|
||||
|
||||
def discard_empty_line_items
|
||||
@order.line_items = @order.line_items.select { |li| li.quantity > 0 }
|
||||
end
|
||||
@@ -188,7 +190,7 @@ module Spree
|
||||
|
||||
if items.empty?
|
||||
flash[:error] = I18n.t(:orders_cannot_remove_the_final_item)
|
||||
redirect_to main_app.order_path(order_to_update)
|
||||
redirect_to order_path(order_to_update)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ module Spree
|
||||
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(" "))
|
||||
redirect_to main_app.checkout_state_path(:payment)
|
||||
redirect_to spree.checkout_state_path(:payment)
|
||||
end
|
||||
rescue SocketError
|
||||
flash[:error] = Spree.t('flash.connection_failed', scope: 'paypal')
|
||||
redirect_to main_app.checkout_state_path(:payment)
|
||||
redirect_to spree.checkout_state_path(:payment)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ module Spree
|
||||
session[:order_id] = nil
|
||||
redirect_to completion_route(@order)
|
||||
else
|
||||
redirect_to main_app.checkout_state_path(@order.state)
|
||||
redirect_to checkout_state_path(@order.state)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ module Spree
|
||||
|
||||
def show
|
||||
@payments_requiring_action = PaymentsRequiringAction.new(spree_current_user).query
|
||||
@orders = orders_collection.includes(:line_items)
|
||||
@orders = orders_collection
|
||||
|
||||
customers = spree_current_user.customers
|
||||
@shops = Enterprise
|
||||
@@ -60,7 +60,11 @@ module Spree
|
||||
private
|
||||
|
||||
def orders_collection
|
||||
CompleteOrdersWithBalance.new(@user).query
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, spree_current_user)
|
||||
CompleteOrdersWithBalance.new(@user).query
|
||||
else
|
||||
@user.orders.where(state: 'complete').order('completed_at desc')
|
||||
end
|
||||
end
|
||||
|
||||
def load_object
|
||||
|
||||
@@ -5,7 +5,9 @@ module Admin
|
||||
# We exclude shipping method adjustments because they are displayed in a
|
||||
# separate table together with the order line items.
|
||||
def order_adjustments_for_display(order)
|
||||
order.adjustments + order.all_adjustments.payment_fee.eligible
|
||||
order.all_adjustments.enterprise_fee +
|
||||
order.all_adjustments.payment_fee.eligible +
|
||||
order.adjustments.admin
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,10 +12,10 @@ module CheckoutHelper
|
||||
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
|
||||
adjustments.reject! { |a| a.source_type == 'Spree::LineItem' } if exclude.include? :line_item
|
||||
|
||||
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.source_type != 'Spree::LineItem' }
|
||||
adjustments.reject! { |a| a.originator_type == 'EnterpriseFee' && a.source_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)
|
||||
|
||||
@@ -1,13 +1,2 @@
|
||||
module MapHelper
|
||||
def using_google_maps?
|
||||
ENV["GOOGLE_MAPS_API_KEY"].present? || google_maps_configured_with_geocoder_api_key?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def google_maps_configured_with_geocoder_api_key?
|
||||
ENV["GEOCODER_API_KEY"].present? && (
|
||||
ENV["GEOCODER_SERVICE"].to_s == "google" || ENV["GEOCODER_SERVICE"].blank?
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
module ShopHelper
|
||||
def order_cycles_name_and_pickup_times(order_cycles)
|
||||
order_cycles.map do |oc|
|
||||
[
|
||||
pickup_time(oc),
|
||||
oc.id
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
def oc_select_options
|
||||
@order_cycles.map { |oc| { time: pickup_time(oc), id: oc.id } }
|
||||
end
|
||||
|
||||
@@ -50,13 +50,13 @@ module Spree
|
||||
|
||||
def edit_order_link
|
||||
{ name: t(:edit_order),
|
||||
url: spree.edit_admin_order_path(@order),
|
||||
url: edit_admin_order_path(@order),
|
||||
icon: 'icon-edit' }
|
||||
end
|
||||
|
||||
def resend_confirmation_link
|
||||
{ name: t(:resend_confirmation),
|
||||
url: spree.resend_admin_order_path(@order),
|
||||
url: resend_admin_order_path(@order),
|
||||
icon: 'icon-email',
|
||||
method: 'post',
|
||||
confirm: t(:confirm_resend_order_confirmation) }
|
||||
@@ -78,7 +78,7 @@ module Spree
|
||||
|
||||
def print_invoice_link
|
||||
{ name: t(:print_invoice),
|
||||
url: spree.print_admin_order_path(@order),
|
||||
url: print_admin_order_path(@order),
|
||||
icon: 'icon-print',
|
||||
target: "_blank" }
|
||||
end
|
||||
@@ -99,7 +99,7 @@ module Spree
|
||||
|
||||
def ship_order_link
|
||||
{ name: t(:ship_order),
|
||||
url: spree.fire_admin_order_path(@order, e: 'ship'),
|
||||
url: fire_admin_order_path(@order, e: 'ship'),
|
||||
method: 'put',
|
||||
icon: 'icon-truck',
|
||||
confirm: t(:are_you_sure) }
|
||||
@@ -107,7 +107,7 @@ module Spree
|
||||
|
||||
def cancel_order_link
|
||||
{ name: t(:cancel_order),
|
||||
url: spree.fire_admin_order_path(@order.number, e: 'cancel'),
|
||||
url: fire_admin_order_path(@order.number, e: 'cancel'),
|
||||
icon: 'icon-trash',
|
||||
confirm: t(:are_you_sure) }
|
||||
end
|
||||
@@ -120,14 +120,6 @@ module Spree
|
||||
method: :put, icon: "icon-#{event}",
|
||||
data: { confirm: confirm_message })
|
||||
end
|
||||
|
||||
def quantity_field_tag(manifest_item)
|
||||
html_options = { min: 0, class: "line_item_quantity", size: 5 }
|
||||
unless manifest_item.variant.on_demand
|
||||
html_options.merge!(max: manifest_item.variant.on_hand + manifest_item.quantity)
|
||||
end
|
||||
number_field_tag :quantity, manifest_item.quantity, html_options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
11
app/helpers/spree/admin/payments_helper.rb
Normal file
11
app/helpers/spree/admin/payments_helper.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module Spree
|
||||
module Admin
|
||||
module PaymentsHelper
|
||||
def payment_method_name(payment)
|
||||
# hack to allow us to retrieve the name of a "deleted" payment method
|
||||
id = payment.payment_method_id
|
||||
Spree::PaymentMethod.find_with_destroyed(id).name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
120
app/helpers/spree/api/api_helpers.rb
Normal file
120
app/helpers/spree/api/api_helpers.rb
Normal file
@@ -0,0 +1,120 @@
|
||||
module Spree
|
||||
module Api
|
||||
module ApiHelpers
|
||||
def required_fields_for(model)
|
||||
required_fields = model._validators.select do |_field, validations|
|
||||
validations.any? { |v| v.is_a?(ActiveModel::Validations::PresenceValidator) }
|
||||
end.map(&:first) # get fields that are invalid
|
||||
# Permalinks presence is validated, but are really automatically generated
|
||||
# Therefore we shouldn't tell API clients that they MUST send one through
|
||||
required_fields.map!(&:to_s).delete("permalink")
|
||||
required_fields
|
||||
end
|
||||
|
||||
def product_attributes
|
||||
[:id, :name, :description, :price, :available_on, :permalink, :meta_description,
|
||||
:meta_keywords, :shipping_category_id, :taxon_ids]
|
||||
end
|
||||
|
||||
def product_property_attributes
|
||||
[:id, :product_id, :property_id, :value, :property_name]
|
||||
end
|
||||
|
||||
def variant_attributes
|
||||
[:id, :name, :sku, :price, :weight, :height, :width, :depth,
|
||||
:is_master, :permalink]
|
||||
end
|
||||
|
||||
def image_attributes
|
||||
[:id, :position, :attachment_content_type, :attachment_file_name,
|
||||
:type, :attachment_updated_at, :attachment_width, :attachment_height, :alt]
|
||||
end
|
||||
|
||||
def option_value_attributes
|
||||
[:id, :name, :presentation, :option_type_name, :option_type_id]
|
||||
end
|
||||
|
||||
def order_attributes
|
||||
[:id, :number, :item_total, :total, :state, :adjustment_total, :user_id,
|
||||
:created_at, :updated_at, :completed_at, :payment_total,
|
||||
:shipment_state, :payment_state, :email, :special_instructions, :token]
|
||||
end
|
||||
|
||||
def line_item_attributes
|
||||
[:id, :quantity, :price, :variant_id]
|
||||
end
|
||||
|
||||
def option_type_attributes
|
||||
[:id, :name, :presentation, :position]
|
||||
end
|
||||
|
||||
def payment_attributes
|
||||
[:id, :source_type, :source_id, :amount, :payment_method_id,
|
||||
:response_code, :state, :avs_response, :created_at, :updated_at]
|
||||
end
|
||||
|
||||
def payment_method_attributes
|
||||
[:id, :name, :description]
|
||||
end
|
||||
|
||||
def shipment_attributes
|
||||
[:id, :tracking, :number, :cost, :shipped_at, :state]
|
||||
end
|
||||
|
||||
def taxonomy_attributes
|
||||
[:id, :name]
|
||||
end
|
||||
|
||||
def taxon_attributes
|
||||
[:id, :name, :pretty_name, :permalink, :position, :parent_id, :taxonomy_id]
|
||||
end
|
||||
|
||||
def inventory_unit_attributes
|
||||
[:id, :lock_version, :state, :variant_id, :shipment_id, :return_authorization_id]
|
||||
end
|
||||
|
||||
def return_authorization_attributes
|
||||
[:id, :number, :state, :amount, :order_id, :reason, :created_at, :updated_at]
|
||||
end
|
||||
|
||||
def country_attributes
|
||||
[:id, :iso_name, :iso, :iso3, :name, :numcode]
|
||||
end
|
||||
|
||||
def state_attributes
|
||||
[:id, :name, :abbr, :country_id]
|
||||
end
|
||||
|
||||
def adjustment_attributes
|
||||
[:id, :source_type, :source_id, :adjustable_type, :adjustable_id, :originator_type,
|
||||
:originator_id, :amount, :label, :mandatory, :locked, :eligible, :created_at, :updated_at]
|
||||
end
|
||||
|
||||
def creditcard_attributes
|
||||
[:id, :month, :year, :cc_type, :last_digits, :first_name, :last_name,
|
||||
:gateway_customer_profile_id, :gateway_payment_profile_id]
|
||||
end
|
||||
|
||||
def user_attributes
|
||||
[:id, :email, :created_at, :updated_at]
|
||||
end
|
||||
|
||||
def property_attributes
|
||||
[:id, :name, :presentation]
|
||||
end
|
||||
|
||||
def stock_location_attributes
|
||||
[:id, :name, :address1, :address2, :city,
|
||||
:state_id, :state_name, :country_id, :zipcode, :phone, :active]
|
||||
end
|
||||
|
||||
def stock_movement_attributes
|
||||
[:id, :quantity, :stock_item_id]
|
||||
end
|
||||
|
||||
def stock_item_attributes
|
||||
[:id, :count_on_hand, :backorderable, :lock_version, :stock_location_id, :variant_id]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
module Spree
|
||||
module PaymentMethodsHelper
|
||||
def payment_method_name(payment)
|
||||
# hack to allow us to retrieve the name of a "deleted" payment method
|
||||
id = payment.payment_method_id
|
||||
Spree::PaymentMethod.find_with_destroyed(id).name
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -90,13 +90,13 @@ class SubscriptionConfirmJob < ActiveJob::Base
|
||||
end
|
||||
|
||||
def send_confirmation_email(order)
|
||||
order.update_order!
|
||||
order.update!
|
||||
record_success(order)
|
||||
SubscriptionMailer.confirmation_email(order).deliver_now
|
||||
end
|
||||
|
||||
def send_failed_payment_email(order, error_message = nil)
|
||||
order.update_order!
|
||||
order.update!
|
||||
record_and_log_error(:failed_payment, order, error_message)
|
||||
SubscriptionMailer.failed_payment_email(order).deliver_now
|
||||
rescue StandardError => e
|
||||
|
||||
@@ -3,6 +3,7 @@ require 'order_management/subscriptions/summarizer'
|
||||
class SubscriptionPlacementJob < ActiveJob::Base
|
||||
def perform
|
||||
ids = proxy_orders.pluck(:id)
|
||||
proxy_orders.update_all(placed_at: Time.zone.now)
|
||||
ProxyOrder.where(id: ids).each do |proxy_order|
|
||||
place_order_for(proxy_order)
|
||||
end
|
||||
@@ -12,8 +13,8 @@ class SubscriptionPlacementJob < ActiveJob::Base
|
||||
|
||||
private
|
||||
|
||||
delegate :record_success, :record_issue, :record_subscription_issue, to: :summarizer
|
||||
delegate :record_order, :record_and_log_error, :send_placement_summary_emails, to: :summarizer
|
||||
delegate :record_order, :record_success, :record_issue, to: :summarizer
|
||||
delegate :record_and_log_error, :send_placement_summary_emails, to: :summarizer
|
||||
|
||||
def summarizer
|
||||
@summarizer ||= OrderManagement::Subscriptions::Summarizer.new
|
||||
@@ -29,15 +30,11 @@ class SubscriptionPlacementJob < ActiveJob::Base
|
||||
def place_order_for(proxy_order)
|
||||
JobLogger.logger.info("Placing Order for Proxy Order #{proxy_order.id}")
|
||||
initialise_order(proxy_order)
|
||||
return unless proxy_order.order.present?
|
||||
|
||||
proxy_order.update_column(:placed_at, Time.zone.now)
|
||||
place_order(proxy_order.order)
|
||||
end
|
||||
|
||||
def initialise_order(proxy_order)
|
||||
proxy_order.initialise_order!
|
||||
record_subscription_issue(proxy_order.subscription) if proxy_order.order.nil?
|
||||
rescue StandardError => e
|
||||
Bugsnag.notify(e, subscription: proxy_order.subscription, proxy_order: proxy_order)
|
||||
end
|
||||
@@ -77,7 +74,7 @@ class SubscriptionPlacementJob < ActiveJob::Base
|
||||
|
||||
def handle_empty_order(order, changes)
|
||||
order.reload.all_adjustments.destroy_all
|
||||
order.update_order!
|
||||
order.update!
|
||||
send_empty_email(order, changes)
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ module Spree
|
||||
class OrderMailer < BaseMailer
|
||||
helper 'checkout'
|
||||
helper SpreeCurrencyHelper
|
||||
helper Spree::PaymentMethodsHelper
|
||||
helper Spree::Admin::PaymentsHelper
|
||||
helper OrderHelper
|
||||
helper MailerHelper
|
||||
include I18nHelper
|
||||
|
||||
@@ -3,7 +3,7 @@ class SubscriptionMailer < Spree::BaseMailer
|
||||
helper MailerHelper
|
||||
helper ShopMailHelper
|
||||
helper OrderHelper
|
||||
helper Spree::PaymentMethodsHelper
|
||||
helper Spree::Admin::PaymentsHelper
|
||||
include I18nHelper
|
||||
|
||||
def confirmation_email(order)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class AdjustmentMetadata < ApplicationRecord
|
||||
class AdjustmentMetadata < ActiveRecord::Base
|
||||
belongs_to :adjustment, class_name: 'Spree::Adjustment'
|
||||
belongs_to :enterprise
|
||||
end
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
include DelegateBelongsTo
|
||||
include Spree::Core::Permalinks
|
||||
include Spree::Preferences::Preferable
|
||||
|
||||
self.abstract_class = true
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require_dependency 'spree/calculator'
|
||||
require 'open_food_network/enterprise_fee_calculator'
|
||||
|
||||
module Calculator
|
||||
@@ -12,8 +13,6 @@ module Calculator
|
||||
case computable
|
||||
when Spree::Order
|
||||
compute_order(computable)
|
||||
when Spree::Shipment
|
||||
compute_shipment(computable)
|
||||
when Spree::LineItem
|
||||
compute_line_item(computable)
|
||||
end
|
||||
@@ -32,7 +31,6 @@ module Calculator
|
||||
|
||||
[
|
||||
line_items_total(order),
|
||||
shipments_total(order),
|
||||
per_item_fees_total(order, calculator),
|
||||
per_order_fees_total(order, calculator)
|
||||
].sum do |total|
|
||||
@@ -48,12 +46,6 @@ module Calculator
|
||||
matched_line_items.sum(&:total)
|
||||
end
|
||||
|
||||
def shipments_total(order)
|
||||
order.shipments.select do |shipment|
|
||||
shipment.tax_category == rate.tax_category
|
||||
end.sum(&:cost)
|
||||
end
|
||||
|
||||
# Finds relevant fees for each line_item,
|
||||
# calculates the tax on them, and returns the total tax
|
||||
def per_item_fees_total(order, calculator)
|
||||
@@ -78,19 +70,17 @@ module Calculator
|
||||
.sum { |applicator| applicator.enterprise_fee.compute_amount(order) }
|
||||
end
|
||||
|
||||
def compute_shipment_or_line_item(item)
|
||||
if item.tax_category == rate.tax_category
|
||||
def compute_line_item(line_item)
|
||||
if line_item.tax_category == rate.tax_category
|
||||
if rate.included_in_price
|
||||
deduced_total_by_rate(item.amount, rate)
|
||||
deduced_total_by_rate(line_item.total, rate)
|
||||
else
|
||||
round_to_two_places(item.amount * rate.amount)
|
||||
round_to_two_places(line_item.total * rate.amount)
|
||||
end
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
alias_method :compute_shipment, :compute_shipment_or_line_item
|
||||
alias_method :compute_line_item, :compute_shipment_or_line_item
|
||||
|
||||
def round_to_two_places(amount)
|
||||
BigDecimal(amount.to_s).round(2, BigDecimal::ROUND_HALF_UP)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require_dependency 'spree/calculator'
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
require_dependency 'spree/calculator'
|
||||
require 'spree/localized_number'
|
||||
|
||||
class Calculator::FlatPercentPerItem < Spree::Calculator
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require_dependency 'spree/calculator'
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require_dependency 'spree/calculator'
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require_dependency 'spree/calculator'
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require_dependency 'spree/calculator'
|
||||
# For #to_d method on Ruby 1.8
|
||||
require 'bigdecimal/util'
|
||||
require 'spree/localized_number'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'open_food_network/column_preference_defaults'
|
||||
|
||||
class ColumnPreference < ApplicationRecord
|
||||
class ColumnPreference < ActiveRecord::Base
|
||||
extend OpenFoodNetwork::ColumnPreferenceDefaults
|
||||
|
||||
# Non-persisted attributes that only have one
|
||||
|
||||
@@ -9,7 +9,17 @@ module Balance
|
||||
|
||||
# Branches by the OrderBalance abstraction
|
||||
def outstanding_balance
|
||||
@order_balance ||= OrderBalance.new(self)
|
||||
OrderBalance.new(self)
|
||||
end
|
||||
|
||||
# This method is the one we're gradually replacing with `#new_outstanding_balance`. Having them
|
||||
# separate enables us to choose which implementation we want depending on the context using
|
||||
# a feature toggle. This avoids inconsistent behavior during that incremental refactoring.
|
||||
#
|
||||
# It is meant to be removed as soon as we get product approval that the new implementation has
|
||||
# been working correctly in production.
|
||||
def old_outstanding_balance
|
||||
total - payment_total
|
||||
end
|
||||
|
||||
# Returns the order balance by considering the total as money owed to the order distributor aka.
|
||||
@@ -17,7 +27,7 @@ module Balance
|
||||
# distributor and customer are even.
|
||||
#
|
||||
# Note however, this is meant to be used only in the context of a single order object. When
|
||||
# working with a collection of orders, such as an index controller action, please consider using
|
||||
# working with a collection of orders, such an index controller action, please consider using
|
||||
# `app/queries/outstanding_balance.rb` instead so we avoid potential N+1s.
|
||||
def new_outstanding_balance
|
||||
if state.in?(FINALIZED_NON_SUCCESSFUL_STATES)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class CoordinatorFee < ApplicationRecord
|
||||
class CoordinatorFee < ActiveRecord::Base
|
||||
belongs_to :order_cycle
|
||||
belongs_to :enterprise_fee
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Customer < ApplicationRecord
|
||||
class Customer < ActiveRecord::Base
|
||||
acts_as_taggable
|
||||
|
||||
belongs_to :enterprise
|
||||
@@ -46,6 +46,6 @@ class Customer < ApplicationRecord
|
||||
return true unless orders.any?
|
||||
|
||||
errors[:base] << I18n.t('admin.customers.destroy.has_associated_orders')
|
||||
throw :abort
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class DistributorShippingMethod < ApplicationRecord
|
||||
class DistributorShippingMethod < ActiveRecord::Base
|
||||
self.table_name = "distributors_shipping_methods"
|
||||
belongs_to :shipping_method, class_name: "Spree::ShippingMethod", touch: true
|
||||
belongs_to :distributor, class_name: "Enterprise", touch: true
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'spree/core/s3_support'
|
||||
|
||||
class Enterprise < ApplicationRecord
|
||||
class Enterprise < ActiveRecord::Base
|
||||
SELLS = %w(unspecified none own any).freeze
|
||||
ENTERPRISE_SEARCH_RADIUS = 100
|
||||
|
||||
@@ -100,12 +100,13 @@ class Enterprise < ApplicationRecord
|
||||
|
||||
before_validation :initialize_permalink, if: lambda { permalink.nil? }
|
||||
before_validation :set_unused_address_fields
|
||||
after_validation :geocode_address
|
||||
after_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? && !owner_id.nil? }
|
||||
|
||||
after_touch :touch_distributors
|
||||
after_create :set_default_contact
|
||||
after_create :relate_to_owners_enterprises
|
||||
after_create_commit :send_welcome_email
|
||||
after_create :send_welcome_email
|
||||
|
||||
after_rollback :restore_permalink
|
||||
|
||||
@@ -410,6 +411,10 @@ class Enterprise < ApplicationRecord
|
||||
address.firstname = address.lastname = address.phone = 'unused' if address.present?
|
||||
end
|
||||
|
||||
def geocode_address
|
||||
address.geocode if address.andand.changed?
|
||||
end
|
||||
|
||||
def ensure_owner_is_manager
|
||||
users << owner unless users.include?(owner)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class EnterpriseFee < ApplicationRecord
|
||||
class EnterpriseFee < ActiveRecord::Base
|
||||
include Spree::Core::CalculatedAdjustments
|
||||
|
||||
acts_as_paranoid
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'open_food_network/locking'
|
||||
require 'open_food_network/permalink_generator'
|
||||
require 'spree/core/s3_support'
|
||||
|
||||
class EnterpriseGroup < ApplicationRecord
|
||||
class EnterpriseGroup < ActiveRecord::Base
|
||||
include PermalinkGenerator
|
||||
acts_as_list
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnterpriseRelationship < ApplicationRecord
|
||||
class EnterpriseRelationship < ActiveRecord::Base
|
||||
belongs_to :parent, class_name: 'Enterprise', touch: true
|
||||
belongs_to :child, class_name: 'Enterprise', touch: true
|
||||
has_many :permissions, class_name: 'EnterpriseRelationshipPermission', dependent: :destroy
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class EnterpriseRelationshipPermission < ApplicationRecord
|
||||
class EnterpriseRelationshipPermission < ActiveRecord::Base
|
||||
default_scope { order('name') }
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class EnterpriseRole < ApplicationRecord
|
||||
class EnterpriseRole < ActiveRecord::Base
|
||||
belongs_to :user, class_name: Spree.user_class.to_s
|
||||
belongs_to :enterprise
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
# in its shopfront. Any incoming product can be selected to be shown in the
|
||||
# shopfront (outgoing products). But the set of shown products can be smaller
|
||||
# than all incoming products.
|
||||
class Exchange < ApplicationRecord
|
||||
class Exchange < ActiveRecord::Base
|
||||
acts_as_taggable
|
||||
|
||||
belongs_to :order_cycle
|
||||
belongs_to :sender, class_name: 'Enterprise'
|
||||
belongs_to :receiver, class_name: 'Enterprise'
|
||||
belongs_to :receiver, class_name: 'Enterprise', touch: true
|
||||
|
||||
has_many :exchange_variants, dependent: :destroy
|
||||
has_many :variants, through: :exchange_variants
|
||||
@@ -23,8 +23,6 @@ class Exchange < ApplicationRecord
|
||||
validates :order_cycle, :sender, :receiver, presence: true
|
||||
validates :sender_id, uniqueness: { scope: [:order_cycle_id, :receiver_id, :incoming] }
|
||||
|
||||
after_save :touch_receiver
|
||||
|
||||
accepts_nested_attributes_for :variants
|
||||
|
||||
scope :in_order_cycle, lambda { |order_cycle| where(order_cycle_id: order_cycle) }
|
||||
@@ -97,10 +95,4 @@ class Exchange < ApplicationRecord
|
||||
def participant
|
||||
incoming? ? sender : receiver
|
||||
end
|
||||
|
||||
def touch_receiver
|
||||
return unless receiver&.persisted?
|
||||
|
||||
receiver.touch_later
|
||||
end
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user