Merge branch 'master' into 2-0-stable-oct

This commit is contained in:
luisramos0
2018-10-15 17:09:26 +01:00
275 changed files with 7891 additions and 2490 deletions

View File

@@ -2,7 +2,7 @@ version: "2"
plugins:
rubocop:
enabled: true
channel: "rubocop-0-55"
channel: "rubocop-0-57"
scss-lint:
enabled: true
checks:
@@ -19,23 +19,23 @@ checks:
argument-count:
enabled: false
complex-logic:
enabled: true
enabled: false
file-lines:
enabled: true
enabled: false
method-complexity:
enabled: true
enabled: false
method-count:
enabled: false
method-lines:
enabled: false
nested-control-flow:
enabled: true
enabled: false
return-statements:
enabled: true
enabled: false
similar-code:
enabled: true
enabled: false
identical-code:
enabled: true
enabled: false
exclude_patterns:
- "spec/**/*"
- "vendor/**/*"

1
.gitignore vendored
View File

@@ -40,3 +40,4 @@ libpeerconnection.log
/config/application.yml
node_modules
vendor/bundle/
coverage

View File

@@ -1,4 +0,0 @@
--format Fuubar
--format ParallelTests::RSpec::SummaryLogger --out tmp/spec_summary.log
--format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log
--tag ~performance

View File

@@ -4,18 +4,16 @@ inherit_from:
AllCops:
TargetRubyVersion: 2.1
TargetRailsVersion: 3.2
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'vendor/**/*'
- 'node_modules/**/*'
- !ruby/regexp /old_and_unused\.rb$/
# The parser gem fails to parse this file with out current Ruby version.
- 'spec/factories.rb'
# Excluding: inadequate Naming/FileName rule rejects GemFile name with camelcase
- 'engines/web/Gemfile'
# OFN SETTINGS
# Cop settings that have been agreed upon by the OFN community
@@ -33,6 +31,9 @@ Style/HashSyntax:
Enabled: true
EnforcedStyle: ruby19_no_mixed_keys
Style/Send:
Enabled: true
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
@@ -174,28 +175,28 @@ Lint/AssignmentInCondition:
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
Metrics/AbcSize:
Enabled: false
Max: 15
Metrics/BlockNesting:
Enabled: false
Max: 3
Metrics/ClassLength:
Enabled: false
Max: 100
Metrics/ModuleLength:
Enabled: false
Max: 100
Metrics/CyclomaticComplexity:
Enabled: false
Max: 6
Metrics/LineLength:
Enabled: false
Max: 100
Metrics/MethodLength:
Enabled: false
Max: 10
Metrics/ParameterLists:
Enabled: false
Max: 5
Metrics/PerceivedComplexity:
Enabled: false
Max: 7

View File

@@ -1,12 +1,12 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 1400`
# on 2018-08-06 18:22:59 +0800 using RuboCop version 0.55.0.
# on 2018-09-19 19:24:45 +0200 using RuboCop version 0.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 35
# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
@@ -14,20 +14,20 @@ Bundler/OrderedGems:
Exclude:
- 'Gemfile'
# Offense count: 116
# Offense count: 115
# Cop supports --auto-correct.
Layout/AlignArray:
Exclude:
- 'app/controllers/admin/contents_controller.rb'
- 'lib/open_food_network/bulk_coop_report.rb'
- 'lib/open_food_network/customers_report.rb'
- 'lib/open_food_network/order_and_distributor_report.rb'
- 'lib/open_food_network/orders_and_fulfillments_report.rb'
- 'lib/open_food_network/packing_report.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/services/cart_service_spec.rb'
# Offense count: 127
# Offense count: 121
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
@@ -35,7 +35,6 @@ Layout/AlignArray:
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/AlignHash:
Exclude:
- 'app/overrides/add_capture_order_shortcut.rb'
- 'app/overrides/replace_shipping_address_form_with_distributor_details.rb'
- 'lib/open_food_network/bulk_coop_report.rb'
- 'lib/open_food_network/orders_and_fulfillments_report.rb'
@@ -64,7 +63,6 @@ Layout/AlignHash:
# SupportedStyles: with_first_parameter, with_fixed_indentation
Layout/AlignParameters:
Exclude:
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/helpers/injection_helper.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_group.rb'
@@ -77,9 +75,11 @@ Layout/AlignParameters:
- 'lib/tasks/dev.rake'
- 'spec/controllers/enterprises_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/features/admin/enterprise_fees_spec.rb'
- 'spec/features/admin/enterprise_relationships_spec.rb'
- 'spec/features/admin/order_cycles_spec.rb'
- 'spec/features/consumer/shopping/checkout_spec.rb'
- 'spec/features/consumer/shopping/orders_spec.rb'
- 'spec/helpers/enterprises_helper_spec.rb'
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
- 'spec/serializers/variant_serializer_spec.rb'
@@ -104,9 +104,16 @@ Layout/BlockEndNewline:
# Offense count: 1
# Cop supports --auto-correct.
Layout/ClosingHeredocIndentation:
Exclude:
- 'app/models/content_configuration.rb'
# Offense count: 2
# Cop supports --auto-correct.
Layout/ClosingParenthesisIndentation:
Exclude:
- 'spec/features/admin/order_cycles_spec.rb'
- 'spec/controllers/spree/admin/orders/customer_details_controller_spec.rb'
- 'spec/serializers/variant_serializer_spec.rb'
# Offense count: 8
# Cop supports --auto-correct.
@@ -119,7 +126,7 @@ Layout/ElseAlignment:
- 'app/serializers/api/admin/order_cycle_serializer.rb'
- 'lib/open_food_network/sales_tax_report.rb'
# Offense count: 205
# Offense count: 201
# Cop supports --auto-correct.
Layout/EmptyLines:
Exclude:
@@ -162,7 +169,6 @@ Layout/EmptyLines:
- 'app/models/spree/line_item_decorator.rb'
- 'app/models/spree/option_type_decorator.rb'
- 'app/models/spree/option_value_decorator.rb'
- 'app/models/spree/order_populator_decorator.rb'
- 'app/models/spree/payment_decorator.rb'
- 'app/models/spree/preference_decorator.rb'
- 'app/models/spree/preferences/file_configuration.rb'
@@ -185,7 +191,6 @@ Layout/EmptyLines:
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/open_food_network/products_cache.rb'
- 'lib/open_food_network/products_cache_integrity_checker.rb'
- 'lib/open_food_network/products_cache_refreshment.rb'
- 'lib/open_food_network/products_renderer.rb'
- 'lib/open_food_network/property_merge.rb'
- 'lib/open_food_network/reports/bulk_coop_report.rb'
@@ -216,6 +221,7 @@ Layout/EmptyLines:
- 'spec/features/admin/order_cycles_spec.rb'
- 'spec/features/admin/orders_spec.rb'
- 'spec/features/admin/payment_method_spec.rb'
- 'spec/features/admin/product_import_spec.rb'
- 'spec/features/admin/products_spec.rb'
- 'spec/features/admin/reports_spec.rb'
- 'spec/features/admin/shipping_methods_spec.rb'
@@ -243,7 +249,6 @@ Layout/EmptyLines:
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/spree/adjustment_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/order_populator_spec.rb'
- 'spec/models/spree/order_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/shipping_method_spec.rb'
@@ -253,6 +258,7 @@ Layout/EmptyLines:
- 'spec/serializers/admin/for_order_cycle/enterprise_serializer_spec.rb'
- 'spec/serializers/admin/for_order_cycle/supplied_product_serializer_spec.rb'
- 'spec/serializers/credit_card_serializer_spec.rb'
- 'spec/services/cart_service_spec.rb'
- 'spec/support/delayed_job_helper.rb'
- 'spec/support/matchers/table_matchers.rb'
@@ -262,7 +268,7 @@ Layout/EmptyLinesAroundArguments:
Exclude:
- 'spec/archive/features/consumer/checkout_spec.rb'
# Offense count: 64
# Offense count: 61
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
@@ -282,7 +288,6 @@ Layout/EmptyLinesAroundBlockBody:
- 'lib/tasks/users.rake'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/admin/tag_rules_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/controllers/spree/admin/reports_controller_spec.rb'
- 'spec/controllers/spree/api/orders_controller_spec.rb'
@@ -293,6 +298,7 @@ Layout/EmptyLinesAroundBlockBody:
- 'spec/features/admin/orders_spec.rb'
- 'spec/features/admin/reports_spec.rb'
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/features/consumer/cookies_spec.rb'
- 'spec/features/consumer/shopping/embedded_groups_spec.rb'
- 'spec/features/consumer/shopping/embedded_shopfronts_spec.rb'
- 'spec/features/consumer/shopping/shopping_spec.rb'
@@ -308,8 +314,8 @@ Layout/EmptyLinesAroundBlockBody:
- 'spec/lib/open_food_network/referer_parser_spec.rb'
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
- 'spec/models/billable_period_spec.rb'
- 'spec/models/cart_spec.rb'
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/product_import/product_list_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/tag_rule/filter_payment_methods_spec.rb'
@@ -321,7 +327,7 @@ Layout/EmptyLinesAroundBlockBody:
- 'spec/support/matchers/select2_matchers.rb'
- 'spec/support/matchers/table_matchers.rb'
# Offense count: 26
# Offense count: 24
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
@@ -331,7 +337,6 @@ Layout/EmptyLinesAroundClassBody:
- 'app/controllers/admin/cache_settings_controller.rb'
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/inventory_items_controller.rb'
- 'app/controllers/admin/invoice_settings_controller.rb'
- 'app/controllers/admin/tag_rules_controller.rb'
- 'app/controllers/api/enterprises_controller.rb'
- 'app/controllers/application_controller.rb'
@@ -363,7 +368,7 @@ Layout/EndAlignment:
- 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb'
- 'app/serializers/api/admin/order_cycle_serializer.rb'
# Offense count: 48
# Offense count: 49
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Layout/ExtraSpacing:
@@ -389,6 +394,7 @@ Layout/ExtraSpacing:
- 'spec/features/admin/reports_spec.rb'
- 'spec/features/consumer/groups_spec.rb'
- 'spec/features/consumer/shopping/shopping_spec.rb'
- 'spec/helpers/cookies_policy_helper_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/reports/rule_spec.rb'
- 'spec/models/enterprise_fee_spec.rb'
@@ -406,7 +412,7 @@ Layout/ExtraSpacing:
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstParameterIndentation:
Exclude:
- 'spec/controllers/spree/admin/orders/customer_details_controller_spec.rb'
@@ -418,7 +424,7 @@ Layout/FirstParameterIndentation:
Layout/IndentArray:
EnforcedStyle: consistent
# Offense count: 51
# Offense count: 53
# Cop supports --auto-correct.
# Configuration parameters: IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
@@ -438,12 +444,11 @@ Layout/IndentationConsistency:
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/product_spec.rb'
# Offense count: 21
# Offense count: 20
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'app/controllers/admin/invoice_settings_controller.rb'
- 'app/controllers/admin/order_cycles_controller.rb'
- 'app/controllers/api/order_cycles_controller.rb'
- 'app/models/spree/line_item_decorator.rb'
@@ -461,6 +466,12 @@ Layout/IndentationWidth:
- 'spec/models/enterprise_spec.rb'
- 'spec/models/spree/calculator/flexi_rate_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/LeadingBlankLines:
Exclude:
- 'lib/tasks/dev.rake'
# Offense count: 46
# Cop supports --auto-correct.
Layout/LeadingCommentSpace:
@@ -470,7 +481,6 @@ Layout/LeadingCommentSpace:
- 'app/models/content_configuration.rb'
- 'app/models/spree/inventory_unit_decorator.rb'
- 'app/models/spree/taxon_decorator.rb'
- 'app/overrides/add_capture_order_shortcut.rb'
- 'app/serializers/api/address_serializer.rb'
- 'app/serializers/api/enterprise_serializer.rb'
- 'app/serializers/api/product_serializer.rb'
@@ -522,7 +532,7 @@ Layout/MultilineHashBraceLayout:
- 'lib/spree/product_filters.rb'
- 'spec/support/request/authentication_workflow.rb'
# Offense count: 7
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
@@ -530,9 +540,9 @@ Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'app/helpers/spree/orders_helper.rb'
- 'app/models/spree/variant_decorator.rb'
- 'app/overrides/add_capture_order_shortcut.rb'
- 'lib/open_food_network/products_renderer.rb'
- 'spec/features/admin/order_cycles_spec.rb'
- 'spec/features/consumer/shopping/orders_spec.rb'
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
# Offense count: 4
@@ -544,7 +554,7 @@ Layout/MultilineMethodCallIndentation:
- 'spec/lib/open_food_network/cached_products_renderer_spec.rb'
- 'spec/serializers/variant_serializer_spec.rb'
# Offense count: 30
# Offense count: 28
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
@@ -560,7 +570,6 @@ Layout/MultilineOperationIndentation:
- 'app/models/variant_override_set.rb'
- 'lib/open_food_network/accounts_and_billing_settings_validator.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/open_food_network/products_cache_refreshment.rb'
- 'lib/open_food_network/sales_tax_report.rb'
- 'lib/open_food_network/users_and_enterprises_report.rb'
@@ -613,7 +622,7 @@ Layout/SpaceAfterSemicolon:
Exclude:
- 'spec/controllers/spree/admin/base_controller_spec.rb'
# Offense count: 62
# Offense count: 59
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
@@ -674,11 +683,11 @@ Layout/SpaceAroundOperators:
- 'lib/spree/product_filters.rb'
- 'spec/controllers/admin/enterprises_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/features/admin/bulk_order_management_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'
- 'spec/features/consumer/shopping/checkout_spec.rb'
- 'spec/helpers/checkout_helper_spec.rb'
- 'spec/helpers/cookies_policy_helper_spec.rb'
- 'spec/helpers/order_cycles_helper_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
@@ -715,7 +724,7 @@ Layout/SpaceInLambdaLiteral:
- 'app/models/spree/product_decorator.rb'
- 'app/models/spree/variant_decorator.rb'
# Offense count: 130
# Offense count: 128
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
# SupportedStyles: space, no_space, compact
@@ -730,7 +739,6 @@ Layout/SpaceInsideArrayLiteralBrackets:
- 'lib/open_food_network/payments_report.rb'
- 'lib/open_food_network/users_and_enterprises_report.rb'
- 'spec/controllers/admin/variant_overrides_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/features/admin/reports_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
@@ -791,7 +799,7 @@ Layout/SpaceInsideBlockBraces:
- 'spec/spec_helper.rb'
- 'spec/support/cancan_helper.rb'
# Offense count: 772
# Offense count: 734
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space, compact
@@ -799,7 +807,6 @@ Layout/SpaceInsideBlockBraces:
Layout/SpaceInsideHashLiteralBraces:
Exclude:
- 'app/controllers/admin/cache_settings_controller.rb'
- 'app/controllers/admin/contents_controller.rb'
- 'app/controllers/admin/enterprise_relationships_controller.rb'
- 'app/controllers/admin/enterprise_roles_controller.rb'
- 'app/controllers/api/statuses_controller.rb'
@@ -807,7 +814,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'app/controllers/spree/admin/line_items_controller_decorator.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/controllers/spree/admin/search_controller_decorator.rb'
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/helpers/admin/business_model_configuration_helper.rb'
- 'app/helpers/admin/injection_helper.rb'
- 'app/helpers/angular_form_builder.rb'
@@ -824,11 +830,9 @@ Layout/SpaceInsideHashLiteralBraces:
- 'app/models/enterprise_relationship.rb'
- 'app/models/producer_property.rb'
- 'app/models/spree/gateway/stripe_connect.rb'
- 'app/models/spree/order_populator_decorator.rb'
- 'app/models/spree/product_decorator.rb'
- 'app/models/spree/property_decorator.rb'
- 'app/models/spree/shipping_method_decorator.rb'
- 'app/overrides/add_capture_order_shortcut.rb'
- 'app/serializers/api/admin/enterprise_fee_serializer.rb'
- 'app/serializers/api/admin/order_cycle_serializer.rb'
- 'lib/open_food_network/feature_toggle.rb'
@@ -888,7 +892,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/gateway/stripe_connect_spec.rb'
- 'spec/models/spree/image_spec.rb'
- 'spec/models/spree/order_populator_spec.rb'
- 'spec/models/spree/order_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/shipping_method_spec.rb'
@@ -900,6 +903,7 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/requests/checkout/failed_checkout_spec.rb'
- 'spec/requests/checkout/stripe_connect_spec.rb'
- 'spec/serializers/enterprise_serializer_spec.rb'
- 'spec/services/cart_service_spec.rb'
- 'spec/services/order_syncer_spec.rb'
- 'spec/services/subscription_form_spec.rb'
- 'spec/spec_helper.rb'
@@ -928,17 +932,24 @@ Layout/SpaceInsideStringInterpolation:
- 'lib/open_food_network/users_and_enterprises_report.rb'
- 'spec/support/request/web_helper.rb'
# Offense count: 5
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: IndentationWidth.
Layout/Tab:
Exclude:
- 'app/controllers/admin/invoice_settings_controller.rb'
- 'app/models/spree/line_item_decorator.rb'
- 'spec/lib/spree/product_filters_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
# Offense count: 60
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingBlankLines:
Exclude:
- 'spec/controllers/cart_controller_spec.rb'
# Offense count: 64
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
@@ -954,8 +965,10 @@ Layout/TrailingWhitespace:
- 'app/views/json/_producer.rabl'
- 'app/views/json/partials/_producer.rabl'
- 'spec/controllers/admin/column_preferences_controller_spec.rb'
- 'spec/features/admin/enterprise_user_spec.rb'
- 'spec/features/admin/customers_spec.rb'
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/features/consumer/cookies_spec.rb'
- 'spec/helpers/cookies_policy_helper_spec.rb'
- 'spec/helpers/enterprises_helper_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
@@ -979,14 +992,13 @@ Lint/DuplicateMethods:
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/subscription_summary.rb'
# Offense count: 18
# Offense count: 16
Lint/IneffectiveAccessModifier:
Exclude:
- 'app/models/column_preference.rb'
- 'app/models/variant_override.rb'
- 'lib/open_food_network/feature_toggle.rb'
- 'lib/open_food_network/products_cache.rb'
- 'lib/open_food_network/products_cache_refreshment.rb'
- 'lib/open_food_network/property_merge.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
@@ -1038,7 +1050,7 @@ Lint/UnderscorePrefixedVariableName:
Exclude:
- 'spec/support/cancan_helper.rb'
# Offense count: 123
# Offense count: 121
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
@@ -1050,7 +1062,6 @@ Lint/UnusedBlockArgument:
- 'app/models/column_preference.rb'
- 'app/models/model_set.rb'
- 'app/models/spree/order_decorator.rb'
- 'app/models/spree/order_populator_decorator.rb'
- 'lib/open_food_network/bulk_coop_report.rb'
- 'lib/open_food_network/enterprise_fee_calculator.rb'
- 'lib/open_food_network/group_buy_report.rb'
@@ -1089,26 +1100,24 @@ Lint/UnusedMethodArgument:
- 'lib/open_food_network/paperclippable.rb'
- 'lib/open_food_network/rack_request_blocker.rb'
# Offense count: 7
# Offense count: 6
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'app/models/column_preference.rb'
- 'lib/open_food_network/feature_toggle.rb'
- 'lib/open_food_network/products_cache.rb'
- 'lib/open_food_network/products_cache_refreshment.rb'
- 'lib/open_food_network/property_merge.rb'
- 'lib/open_food_network/reports/bulk_coop_report.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
# Offense count: 288
# Offense count: 246
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'app/serializers/api/enterprise_serializer.rb'
- 'spec/archive/features/consumer/checkout_spec.rb'
- 'spec/controllers/api/order_cycles_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/checkout_controller_spec.rb'
- 'spec/controllers/enterprises_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
@@ -1117,10 +1126,8 @@ Lint/Void:
- 'spec/controllers/spree/admin/variants_controller_spec.rb'
- 'spec/controllers/spree/api/products_controller_spec.rb'
- 'spec/controllers/spree/api/variants_controller_spec.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'
- 'spec/features/admin/enterprise_fees_spec.rb'
- 'spec/features/admin/enterprise_groups_spec.rb'
- 'spec/features/admin/enterprises/index_spec.rb'
- 'spec/features/admin/enterprises_spec.rb'
@@ -1145,14 +1152,12 @@ Lint/Void:
- 'spec/lib/open_food_network/reports/report_spec.rb'
- 'spec/lib/open_food_network/reports/rule_spec.rb'
- 'spec/mailers/order_mailer_spec.rb'
- 'spec/models/cart_spec.rb'
- 'spec/models/enterprise_relationship_spec.rb'
- 'spec/models/enterprise_spec.rb'
- 'spec/models/exchange_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/spree/adjustment_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/order_populator_spec.rb'
- 'spec/models/spree/order_spec.rb'
- 'spec/models/spree/payment_method_spec.rb'
- 'spec/models/spree/payment_spec.rb'
@@ -1162,10 +1167,53 @@ Lint/Void:
- 'spec/serializers/enterprise_serializer_spec.rb'
- 'spec/support/request/web_helper.rb'
# Offense count: 993
# Offense count: 195
Metrics/AbcSize:
Max: 293
# Offense count: 1010
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 776
Max: 787
# Offense count: 1
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 4
# Offense count: 23
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 331
# Offense count: 38
Metrics/CyclomaticComplexity:
Max: 23
# Offense count: 6683
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 623
# Offense count: 163
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 95
# Offense count: 27
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 633
# Offense count: 6
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 8
# Offense count: 30
Metrics/PerceivedComplexity:
Max: 21
# Offense count: 7
Naming/AccessorMethodName:
@@ -1180,14 +1228,6 @@ Naming/BinaryOperatorParameterName:
Exclude:
- 'app/models/exchange.rb'
# Offense count: 2
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'Gemfile'
- 'Guardfile'
# Offense count: 1
# Configuration parameters: Blacklist.
# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
@@ -1228,12 +1268,11 @@ Naming/PredicateName:
- 'lib/open_food_network/packing_report.rb'
- 'lib/tasks/data.rake'
# Offense count: 14
# Offense count: 13
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at
Naming/UncommunicativeMethodParamName:
Exclude:
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/helpers/admin/injection_helper.rb'
- 'app/helpers/spree/admin/base_helper_decorator.rb'
- 'app/helpers/spree/base_helper_decorator.rb'
@@ -1279,6 +1318,15 @@ Performance/DoubleStartEndWith:
Exclude:
- 'app/helpers/application_helper.rb'
# Offense count: 4
# Cop supports --auto-correct.
Performance/InefficientHashSearch:
Exclude:
- 'app/models/spree/payment_method_decorator.rb'
- 'app/models/spree/preferences/file_configuration.rb'
- 'lib/stripe/account_connector.rb'
- 'lib/stripe/webhook_handler.rb'
# Offense count: 3
# Cop supports --auto-correct.
Performance/RedundantBlockCall:
@@ -1350,6 +1398,8 @@ Rails/Delegate:
- 'app/serializers/api/variant_serializer.rb'
# Offense count: 8
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
Exclude:
- 'lib/tasks/karma.rake'
@@ -1381,14 +1431,13 @@ Rails/HasAndBelongsToMany:
- 'app/models/spree/line_item_decorator.rb'
- 'app/models/spree/payment_method_decorator.rb'
# Offense count: 31
# Offense count: 29
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/account_invoice.rb'
- 'app/models/billable_period.rb'
- 'app/models/cart.rb'
- 'app/models/customer.rb'
- 'app/models/enterprise.rb'
- 'app/models/order_cycle.rb'
@@ -1420,6 +1469,7 @@ Rails/HttpStatus:
- 'app/controllers/api/customers_controller.rb'
- 'app/controllers/api/enterprises_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/cart_controller.rb'
- 'app/controllers/checkout_controller.rb'
- 'app/controllers/enterprises_controller.rb'
- 'app/controllers/line_items_controller.rb'
@@ -1427,7 +1477,6 @@ Rails/HttpStatus:
- 'app/controllers/spree/admin/line_items_controller_decorator.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/controllers/spree/credit_cards_controller.rb'
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/controllers/spree/store_controller_decorator.rb'
- 'app/controllers/stripe/callbacks_controller.rb'
- 'app/controllers/stripe/webhooks_controller.rb'
@@ -1474,7 +1523,7 @@ Rails/ReadWriteAttribute:
Exclude:
- 'app/models/enterprise.rb'
# Offense count: 47
# Offense count: 46
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/ScopeArgs:
@@ -1562,7 +1611,7 @@ Style/BarePercentLiterals:
- 'spec/features/admin/variants_spec.rb'
- 'spec/support/request/web_helper.rb'
# Offense count: 210
# Offense count: 207
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: braces, no_braces, context_dependent
@@ -1573,7 +1622,6 @@ Style/BracesAroundHashParameters:
- 'app/controllers/checkout_controller.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/controllers/spree/admin/search_controller_decorator.rb'
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/helpers/admin/account_helper.rb'
- 'app/helpers/admin/business_model_configuration_helper.rb'
- 'app/helpers/angular_form_builder.rb'
@@ -1583,7 +1631,6 @@ Style/BracesAroundHashParameters:
- 'app/jobs/update_account_invoices.rb'
- 'app/jobs/update_billable_periods.rb'
- 'app/models/billable_period.rb'
- 'app/models/cart.rb'
- 'app/models/exchange.rb'
- 'app/models/spree/adjustment_decorator.rb'
- 'app/models/spree/line_item_decorator.rb'
@@ -1627,11 +1674,11 @@ Style/BracesAroundHashParameters:
- 'spec/models/billable_period_spec.rb'
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/order_populator_spec.rb'
- 'spec/models/spree/order_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/taxon_spec.rb'
- 'spec/serializers/admin/customer_serializer_spec.rb'
- 'spec/services/cart_service_spec.rb'
- 'spec/spec_helper.rb'
- 'spec/support/cancan_helper.rb'
- 'spec/support/request/authentication_workflow.rb'
@@ -1643,7 +1690,7 @@ Style/CaseEquality:
- 'app/helpers/angular_form_helper.rb'
- 'spec/models/spree/payment_spec.rb'
# Offense count: 86
# Offense count: 85
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
@@ -1653,7 +1700,6 @@ Style/ClassAndModuleChildren:
- 'app/controllers/admin/accounts_and_billing_settings_controller.rb'
- 'app/controllers/admin/business_model_configuration_controller.rb'
- 'app/controllers/admin/cache_settings_controller.rb'
- 'app/controllers/admin/invoice_settings_controller.rb'
- 'app/controllers/spree/store_controller_decorator.rb'
- 'app/helpers/angular_form_helper.rb'
- 'app/models/calculator/flat_percent_per_item.rb'
@@ -1756,20 +1802,15 @@ Style/CommentedKeyword:
Exclude:
- 'app/controllers/application_controller.rb'
# Offense count: 10
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'app/controllers/checkout_controller.rb'
- 'app/controllers/spree/admin/base_controller_decorator.rb'
- 'app/controllers/spree/admin/payment_methods_controller_decorator.rb'
- 'app/controllers/spree/admin/search_controller_decorator.rb'
- 'app/helpers/spree/admin/orders_helper_decorator.rb'
- 'app/models/spree/calculator/per_item_decorator.rb'
- 'app/models/spree/line_item_decorator.rb'
- 'app/models/spree/payment_decorator.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
# Offense count: 2
@@ -1822,7 +1863,7 @@ Style/FormatStringToken:
- 'lib/open_food_network/sales_tax_report.rb'
- 'spec/models/enterprise_spec.rb'
# Offense count: 83
# Offense count: 79
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
@@ -1853,7 +1894,6 @@ Style/GuardClause:
- 'app/models/producer_property.rb'
- 'app/models/spree/classification_decorator.rb'
- 'app/models/spree/order_decorator.rb'
- 'app/models/spree/order_populator_decorator.rb'
- 'app/models/spree/preference_decorator.rb'
- 'app/models/spree/product_decorator.rb'
- 'app/models/spree/user_decorator.rb'
@@ -1861,7 +1901,6 @@ Style/GuardClause:
- 'lib/open_food_network/accounts_and_billing_settings_validator.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/open_food_network/products_cache.rb'
- 'lib/open_food_network/products_cache_refreshment.rb'
- 'lib/open_food_network/products_renderer.rb'
- 'lib/open_food_network/rack_request_blocker.rb'
- 'lib/open_food_network/variant_and_line_item_naming.rb'
@@ -1872,7 +1911,7 @@ Style/GuardClause:
- 'spec/support/request/distribution_helper.rb'
- 'spec/support/request/shop_workflow.rb'
# Offense count: 968
# Offense count: 930
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
@@ -1887,14 +1926,12 @@ Style/HashSyntax:
- 'app/controllers/admin/tag_rules_controller.rb'
- 'app/controllers/api/enterprises_controller.rb'
- 'app/controllers/checkout_controller.rb'
- 'app/controllers/open_food_network/cart_controller.rb'
- 'app/controllers/spree/admin/line_items_controller_decorator.rb'
- 'app/controllers/spree/admin/orders_controller_decorator.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/controllers/spree/admin/search_controller_decorator.rb'
- 'app/controllers/spree/admin/shipping_methods_controller_decorator.rb'
- 'app/controllers/spree/api/products_controller_decorator.rb'
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/controllers/spree/paypal_controller_decorator.rb'
- 'app/controllers/spree/store_controller_decorator.rb'
- 'app/controllers/user_passwords_controller.rb'
@@ -1910,7 +1947,6 @@ Style/HashSyntax:
- 'app/mailers/spree/user_mailer_decorator.rb'
- 'app/models/billable_period.rb'
- 'app/models/calculator/flat_percent_per_item.rb'
- 'app/models/cart.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_fee.rb'
- 'app/models/enterprise_group.rb'
@@ -1934,12 +1970,10 @@ Style/HashSyntax:
- 'app/models/spree/product_set.rb'
- 'app/models/spree/taxon_decorator.rb'
- 'app/models/spree/user_decorator.rb'
- 'app/overrides/add_capture_order_shortcut.rb'
- 'app/overrides/add_distributor_details_js_to_product.rb'
- 'app/overrides/add_distributor_details_to_product.rb'
- 'app/overrides/add_distributor_to_add_to_cart_form.rb'
- 'app/overrides/add_enterprise_fees_to_admin_configurations_menu.rb'
- 'app/overrides/add_orders_admin_sub_menu.rb'
- 'app/overrides/add_source_to_product.rb'
- 'app/overrides/remove_search_bar.rb'
- 'app/overrides/remove_side_bar.rb'
@@ -1982,13 +2016,11 @@ Style/HashSyntax:
- 'spec/controllers/spree/api/products_controller_spec.rb'
- 'spec/controllers/spree/api/variants_controller_spec.rb'
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/controllers/spree/user_sessions_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/features/admin/bulk_order_management_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'
- 'spec/features/admin/customers_spec.rb'
- 'spec/features/admin/enterprise_fees_spec.rb'
- 'spec/features/admin/enterprise_groups_spec.rb'
- 'spec/features/admin/enterprises_spec.rb'
- 'spec/features/admin/order_cycles_spec.rb'
@@ -2001,6 +2033,8 @@ Style/HashSyntax:
- 'spec/features/admin/subscriptions_spec.rb'
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/features/consumer/account/cards_spec.rb'
- 'spec/features/consumer/cookies_spec.rb'
- 'spec/features/consumer/footer_links_spec.rb'
- 'spec/features/consumer/shopping/products_spec.rb'
- 'spec/features/consumer/shopping/shopping_spec.rb'
- 'spec/jobs/subscription_placement_job_spec.rb'
@@ -2011,7 +2045,6 @@ Style/HashSyntax:
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
- 'spec/mailers/order_mailer_spec.rb'
- 'spec/models/calculator/weight_spec.rb'
- 'spec/models/cart_spec.rb'
- 'spec/models/enterprise_fee_spec.rb'
- 'spec/models/enterprise_spec.rb'
- 'spec/models/exchange_spec.rb'
@@ -2066,20 +2099,18 @@ Style/MethodCallWithoutArgsParentheses:
Exclude:
- 'app/controllers/spree/admin/payment_methods_controller_decorator.rb'
- 'app/views/json/_groups.rabl'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/features/consumer/registration_spec.rb'
- 'spec/models/spree/payment_method_spec.rb'
- 'spec/support/request/ui_component_helper.rb'
# Offense count: 13
# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
Style/MethodDefParentheses:
Exclude:
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/helpers/enterprises_helper.rb'
- 'app/models/cart.rb'
- 'app/models/spree/product_decorator.rb'
- 'lib/open_food_network/distribution_change_validator.rb'
- 'lib/open_food_network/feature_toggle.rb'
@@ -2089,7 +2120,7 @@ Style/MethodDefParentheses:
- 'spec/support/request/web_helper.rb'
# Offense count: 1
Style/MethodMissing:
Style/MissingRespondToMissing:
Exclude:
- 'app/helpers/application_helper.rb'
@@ -2145,13 +2176,12 @@ Style/Next:
Exclude:
- 'lib/tasks/data.rake'
# Offense count: 7
# Offense count: 6
# Cop supports --auto-correct.
Style/NilComparison:
Exclude:
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/order_grouper.rb'
- 'spec/features/admin/enterprise_fees_spec.rb'
- 'spec/features/consumer/shopping/shopping_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/spree/order_spec.rb'
@@ -2202,7 +2232,7 @@ Style/OneLineConditional:
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowSafeAssignment.
# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions.
Style/ParenthesesAroundCondition:
Exclude:
- 'app/controllers/checkout_controller.rb'
@@ -2259,7 +2289,7 @@ Style/RedundantParentheses:
- 'spec/controllers/admin/enterprises_controller_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'
# Offense count: 10
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
@@ -2270,7 +2300,6 @@ Style/RedundantReturn:
- 'app/models/enterprise_fee.rb'
- 'app/models/spree/adjustment_decorator.rb'
- 'app/models/spree/classification_decorator.rb'
- 'app/models/spree/order_populator_decorator.rb'
- 'app/serializers/api/admin/enterprise_serializer.rb'
# Offense count: 98
@@ -2306,7 +2335,7 @@ Style/RedundantSelf:
- 'lib/open_food_network/reports/report.rb'
- 'lib/open_food_network/variant_and_line_item_naming.rb'
# Offense count: 12
# Offense count: 16
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
@@ -2319,6 +2348,7 @@ Style/RegexpLiteral:
- 'app/models/enterprise_group.rb'
- 'app/models/spree/preference_decorator.rb'
- 'lib/discourse/single_sign_on.rb'
- 'spec/mailers/subscription_mailer_spec.rb'
- 'spec/models/content_configuration_spec.rb'
# Offense count: 4
@@ -2412,6 +2442,14 @@ Style/UnlessElse:
- 'app/models/enterprise.rb'
- 'lib/open_food_network/order_grouper.rb'
# Offense count: 5
# Cop supports --auto-correct.
Style/UnneededCondition:
Exclude:
- 'app/controllers/admin/resource_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/serializers/api/order_serializer.rb'
# Offense count: 33
# Cop supports --auto-correct.
Style/UnneededInterpolation:
@@ -2458,7 +2496,7 @@ Style/UnneededPercentQ:
- 'spec/features/consumer/producers_spec.rb'
- 'spec/support/request/web_helper.rb'
# Offense count: 6607
# Offense count: 6683
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:

12
Gemfile
View File

@@ -10,6 +10,8 @@ gem 'i18n-js', '~> 3.0.0'
# Patched version. See http://rubysec.com/advisories/CVE-2015-5312/.
gem 'nokogiri', '>= 1.6.7.1'
gem 'web', path: './engines/web'
gem 'pg'
# OFN-maintained and patched version of Spree v2.0.4. See
@@ -50,7 +52,6 @@ gem 'aws-sdk'
gem 'db2fog'
gem 'andand'
gem 'truncate_html'
gem 'representative_view'
gem 'rabl'
# AMS is pinned to 0.8.4 because 0.9.x is a complete re-write, as is 0.10.x
@@ -91,8 +92,10 @@ group :assets do
gem 'compass-rails'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer'
gem 'mini_racer'
# We found that the following version of libv8 breaks the compilation of mini_racer.
# Nothing else depends on libv8.
gem 'libv8', '!= 6.7.288.46.1'
gem 'uglifier', '>= 1.0.3'
@@ -107,7 +110,6 @@ gem 'foundation_rails_helper', github: 'willrjmarshall/foundation_rails_helper',
gem 'jquery-rails', '3.0.0'
gem 'jquery-migrate-rails'
gem 'css_splitter'
gem 'ofn-qz', github: 'openfoodfoundation/ofn-qz', ref: '60da2ae4c44cbb4c8d602f59fb5fff8d0f21db3c'
@@ -132,6 +134,7 @@ end
group :test do
gem 'webmock'
gem 'simplecov', require: false
# See spec/spec_helper.rb for instructions
#gem 'perftools.rb'
end
@@ -145,7 +148,6 @@ group :development do
gem 'guard-livereload'
gem 'guard-rails'
gem 'guard-rspec', '~> 4.7.3'
gem 'parallel_tests'
gem 'rubocop', '>= 0.49.1'
# 1.0.9 fixed openssl issues on macOS https://github.com/eventmachine/eventmachine/issues/602

View File

@@ -118,10 +118,15 @@ GIT
activemodel (>= 3.0)
railties (>= 3.0)
PATH
remote: engines/web
specs:
web (0.0.1)
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.2)
CFPropertyList (2.3.6)
actionmailer (3.2.22.5)
actionpack (= 3.2.22.5)
mail (~> 2.5.4)
@@ -232,15 +237,13 @@ GEM
safe_yaml (~> 1.0.0)
css_parser (1.3.5)
addressable
css_splitter (0.4.5)
sprockets (>= 2.0.0)
daemons (1.2.6)
dalli (2.7.2)
database_cleaner (0.7.1)
db2fog (0.8.0)
activerecord (~> 3.0)
db2fog (0.9.0)
activerecord (>= 3.2.0, < 5.0)
fog (~> 1.0)
rails (~> 3.0)
rails (>= 3.2.0, < 5.0)
debugger-linecache (1.2.0)
deface (1.0.0)
colorize (>= 0.5.8)
@@ -260,13 +263,15 @@ GEM
devise (>= 2.1.0)
diff-lcs (1.3)
diffy (3.1.0)
docile (1.3.1)
dry-inflector (0.1.2)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
erubis (2.7.0)
eventmachine (1.2.7)
excon (0.45.4)
execjs (2.6.0)
excon (0.62.0)
execjs (2.7.0)
factory_bot (4.10.0)
activesupport (>= 3.0.0)
factory_bot_rails (4.10.0)
@@ -281,19 +286,26 @@ GEM
rails (>= 3, < 5)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.36.0)
fog (1.41.0)
fog-aliyun (>= 0.1.0)
fog-atmos
fog-aws (>= 0.6.0)
fog-brightbox (~> 0.4)
fog-core (~> 1.32)
fog-cloudatcost (~> 0.1.0)
fog-core (~> 1.45)
fog-digitalocean (>= 0.3.0)
fog-dnsimple (~> 1.0)
fog-dynect (~> 0.0.2)
fog-ecloud (~> 0.1)
fog-google (<= 0.1.0)
fog-internet-archive
fog-joyent
fog-json
fog-local
fog-openstack
fog-powerdns (>= 0.1.1)
fog-profitbricks
fog-rackspace
fog-radosgw (>= 0.0.2)
fog-riakcs
fog-sakuracloud (>= 0.0.4)
@@ -303,32 +315,47 @@ GEM
fog-terremark
fog-vmfusion
fog-voxel
fog-vsphere (>= 0.4.0)
fog-xenserver
fog-xml (~> 0.1.1)
ipaddress (~> 0.5)
nokogiri (~> 1.5, >= 1.5.11)
fog-aliyun (0.1.0)
fog-core (~> 1.27)
fog-json (~> 1.0)
json (>= 1.8, < 2.0)
fog-aliyun (0.3.2)
fog-core
fog-json
ipaddress (~> 0.8)
xml-simple (~> 1.1)
fog-atmos (0.1.0)
fog-core
fog-xml
fog-aws (0.7.6)
fog-core (~> 1.27)
fog-aws (2.0.1)
fog-core (~> 1.38)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-brightbox (0.9.0)
fog-core (~> 1.22)
fog-brightbox (0.16.1)
dry-inflector
fog-core
fog-json
inflecto (~> 0.0.2)
fog-core (1.35.0)
mime-types
fog-cloudatcost (0.1.2)
fog-core (~> 1.36)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (1.45.0)
builder
excon (~> 0.45)
excon (~> 0.58)
formatador (~> 0.2)
fog-dynect (0.0.2)
fog-digitalocean (0.4.0)
fog-core
fog-json
fog-xml
ipaddress (>= 0.5)
fog-dnsimple (1.0.0)
fog-core (~> 1.38)
fog-json (~> 1.0)
fog-dynect (0.0.3)
fog-core
fog-json
fog-xml
@@ -339,20 +366,35 @@ GEM
fog-core
fog-json
fog-xml
fog-json (1.0.2)
fog-core (~> 1.0)
multi_json (~> 1.10)
fog-local (0.2.1)
fog-core (~> 1.27)
fog-powerdns (0.1.1)
fog-core (~> 1.27)
fog-json (~> 1.0)
fog-xml (~> 0.1)
fog-profitbricks (0.0.5)
fog-internet-archive (0.0.1)
fog-core
fog-json
fog-xml
nokogiri
fog-radosgw (0.0.4)
fog-joyent (0.0.1)
fog-core (~> 1.42)
fog-json (>= 1.0)
fog-json (1.2.0)
fog-core
multi_json (~> 1.10)
fog-local (0.6.0)
fog-core (>= 1.27, < 3.0)
fog-openstack (0.1.25)
fog-core (~> 1.40)
fog-json (>= 1.0)
ipaddress (>= 0.8)
fog-powerdns (0.2.0)
fog-core
fog-json
fog-xml
fog-profitbricks (4.1.1)
fog-core (~> 1.42)
fog-json (~> 1.0)
fog-rackspace (0.1.6)
fog-core (>= 1.35)
fog-json (>= 1.0)
fog-xml (>= 0.1)
ipaddress (>= 0.8)
fog-radosgw (0.0.5)
fog-core (>= 1.21.0)
fog-json
fog-xml (>= 0.0.1)
@@ -360,13 +402,13 @@ GEM
fog-core
fog-json
fog-xml
fog-sakuracloud (1.4.0)
fog-sakuracloud (1.7.5)
fog-core
fog-json
fog-serverlove (0.1.2)
fog-core
fog-json
fog-softlayer (1.0.2)
fog-softlayer (1.1.4)
fog-core
fog-json
fog-storm_on_demand (0.1.1)
@@ -381,12 +423,15 @@ GEM
fog-voxel (0.1.0)
fog-core
fog-xml
fog-xenserver (0.2.2)
fog-vsphere (2.3.0)
fog-core
rbvmomi (~> 1.9)
fog-xenserver (0.3.0)
fog-core
fog-xml
fog-xml (0.1.2)
fog-xml (0.1.3)
fog-core
nokogiri (~> 1.5, >= 1.5.11)
nokogiri (>= 1.5.11, < 2.0.0)
foreigner (1.7.4)
activerecord (>= 3.0.0)
formatador (0.2.5)
@@ -436,8 +481,8 @@ GEM
i18n (>= 0.6.6, < 2)
immigrant (0.3.6)
activerecord (>= 3.0)
inflecto (0.0.2)
ipaddress (0.8.0)
ipaddress (0.8.3)
jaro_winkler (1.5.1)
journey (1.0.4)
jquery-migrate-rails (1.2.1)
jquery-rails (3.0.0)
@@ -449,7 +494,7 @@ GEM
json_spec (1.1.5)
multi_json (~> 1.0)
rspec (>= 2.0, < 4.0)
jwt (1.5.4)
jwt (1.5.6)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
@@ -460,7 +505,7 @@ GEM
addressable (~> 2.3)
letter_opener (1.6.0)
launchy (~> 2.2)
libv8 (3.16.14.19)
libv8 (6.3.292.48.1)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
@@ -472,6 +517,8 @@ GEM
mime-types (1.25.1)
mini_mime (1.0.1)
mini_portile2 (2.1.0)
mini_racer (0.1.15)
libv8 (~> 6.3)
momentjs-rails (2.5.1)
railties (>= 3.1)
money (5.1.1)
@@ -491,9 +538,9 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (2.1.2)
oj (3.6.10)
orm_adapter (0.5.0)
paper_trail (3.0.8)
paper_trail (3.0.9)
activerecord (>= 3.0, < 5.0)
activesupport (>= 3.0, < 5.0)
paperclip (3.4.2)
@@ -503,12 +550,10 @@ GEM
cocaine (~> 0.5.0)
mime-types
parallel (1.11.2)
parallel_tests (2.14.1)
parallel
paranoia (1.3.4)
activerecord (~> 3.1)
parser (2.4.0.0)
ast (~> 2.2)
parser (2.5.1.0)
ast (~> 2.4.0)
paypal-sdk-core (0.2.10)
multi_json (~> 1.0)
xml-simple
@@ -569,18 +614,14 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rbvmomi (1.13.0)
builder (~> 3.0)
json (>= 1.8)
nokogiri (~> 1.5)
trollop (~> 2.1)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.2.3)
ref (2.0.0)
representative (1.0.5)
activesupport (>= 2.2.2)
builder (>= 2.1.2)
i18n (>= 0.4.1)
nokogiri (>= 1.4.2)
representative_view (1.2.2)
actionpack (> 2.3.0, < 4.0.0)
representative (~> 1.0.2)
roadie (3.0.1)
css_parser (~> 1.3.4)
nokogiri (~> 1.6.0)
@@ -614,10 +655,11 @@ GEM
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-retry (0.5.6)
rspec-core (> 3.3, < 3.8)
rspec-retry (0.6.1)
rspec-core (> 3.3)
rspec-support (3.7.1)
rubocop (0.55.0)
rubocop (0.57.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
@@ -626,7 +668,7 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-ole (1.2.12.1)
ruby-progressbar (1.10.0)
rubyzip (1.2.1)
rubyzip (1.2.2)
safe_yaml (1.0.4)
sass (3.3.14)
sass-rails (3.2.6)
@@ -639,6 +681,11 @@ GEM
shellany (0.0.1)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
skylight (1.6.1)
activesupport (>= 3.0.0)
spinjs-rails (1.3)
@@ -654,24 +701,21 @@ GEM
stringex (1.5.1)
stripe (3.3.2)
faraday (~> 0.9)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (0.20.0)
tilt (1.4.1)
timecop (0.9.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
trollop (2.9.9)
truncate_html (0.9.2)
turbo-sprockets-rails3 (0.3.6)
railties (> 3.2.8, < 4.0.0)
sprockets (>= 2.0.0)
tzinfo (0.3.54)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicode-display_width (1.3.0)
uglifier (4.1.19)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.3.2)
unicorn (4.9.0)
kgio (~> 2.6)
rack
@@ -722,7 +766,7 @@ DEPENDENCIES
capybara (>= 2.15.4)
coffee-rails (~> 3.2.1)
compass-rails
css_splitter
web!
custom_error_message!
daemons
dalli
@@ -756,7 +800,9 @@ DEPENDENCIES
jwt (~> 1.5)
knapsack
letter_opener (>= 1.4.1)
libv8 (!= 6.7.288.46.1)
listen (= 3.0.8)
mini_racer
momentjs-rails
nokogiri (>= 1.6.7.1)
oauth2 (~> 1.2.0)
@@ -764,7 +810,6 @@ DEPENDENCIES
oj
paper_trail (~> 3.0.8)
paperclip (~> 3.4.1)
parallel_tests
pg
poltergeist (>= 1.16.0)
pry-byebug (>= 3.4.3)
@@ -774,7 +819,6 @@ DEPENDENCIES
rails (~> 3.2.22)
rails-i18n (~> 3.0.0)
redcarpet
representative_view
roadie-rails (~> 1.0.3)
roo (~> 2.7.0)
roo-xls (~> 1.1.0)
@@ -785,6 +829,7 @@ DEPENDENCIES
sass-rails (~> 3.2.3)
shoulda-matchers
simple_form!
simplecov
skylight (< 2.0)
spinjs-rails
spree!
@@ -792,7 +837,6 @@ DEPENDENCIES
spree_i18n!
spree_paypal_express!
stripe (~> 3.3.2)
therubyracer
timecop
truncate_html
turbo-sprockets-rails3

View File

@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/openfoodfoundation/openfoodnetwork.svg?branch=master)](https://travis-ci.org/openfoodfoundation/openfoodnetwork)
[![Build Status](https://semaphoreci.com/api/v1/openfoodfoundation/openfoodnetwork-2/branches/master/badge.svg)](https://semaphoreci.com/openfoodfoundation/openfoodnetwork-2)
[![Code Climate](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork.png)](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork)
[![View performance data on Skylight](https://badges.skylight.io/status/EiXQ6sSKij8y.svg)](https://oss.skylight.io/app/applications/EiXQ6sSKij8y)

View File

@@ -61,7 +61,7 @@
//= require moment/nb.js
//= require moment/pt-br.js
//= require moment/sv.js
//= require ../shared/mm-foundation-tpls-0.8.0.min.js
//= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
//= require angularjs-file-upload
//= require_tree .

View File

@@ -8,8 +8,8 @@ angular.module("admin.enterprise_groups")
{ name: 'users', label: t('users'), icon_class: "icon-user" }
{ name: 'about', label: t('about'), icon_class: "icon-pencil" }
{ name: 'images', label: t('images'), icon_class: "icon-picture" }
{ name: 'contact', label: t('admin_entreprise_groups_contact'), icon_class: "icon-phone" }
{ name: 'web', label: t('admin_entreprise_groups_web'), icon_class: "icon-globe" }
{ name: 'contact', label: t('admin_enterprise_groups_contact'), icon_class: "icon-phone" }
{ name: 'web', label: t('admin_enterprise_groups_web'), icon_class: "icon-globe" }
]
$scope.select(0)

View File

@@ -1,5 +1,5 @@
angular.module("admin.enterprises")
.controller "enterpriseCtrl", ($scope, $http, $window, NavigationCheck, enterprise, EnterprisePaymentMethods, EnterpriseShippingMethods, SideMenu, StatusMessage) ->
.controller "enterpriseCtrl", ($scope, $http, $window, NavigationCheck, enterprise, Enterprises, EnterprisePaymentMethods, EnterpriseShippingMethods, SideMenu, StatusMessage) ->
$scope.Enterprise = enterprise
$scope.PaymentMethods = EnterprisePaymentMethods.paymentMethods
$scope.ShippingMethods = EnterpriseShippingMethods.shippingMethods
@@ -67,3 +67,27 @@ angular.module("admin.enterprises")
$scope.resetModal = ->
$scope.newUser = $scope.invite_errors = $scope.invite_success = null
$scope.removeLogo = ->
return unless confirm(t("admin.enterprises.remove_logo.immediate_removal_warning"))
Enterprises.removeLogo($scope.Enterprise).then (data) ->
$scope.Enterprise = angular.copy(data)
$scope.$emit("enterprise:updated", $scope.Enterprise)
StatusMessage.display("success", t("admin.enterprises.remove_logo.removed_successfully"))
, (response) ->
if response.data.error?
StatusMessage.display("failure", response.data.error)
$scope.removePromoImage = ->
return unless confirm(t("admin.enterprises.remove_promo_image.immediate_removal_warning"))
Enterprises.removePromoImage($scope.Enterprise).then (data) ->
$scope.Enterprise = angular.copy(data)
$scope.$emit("enterprise:updated", $scope.Enterprise)
StatusMessage.display("success", t("admin.enterprises.remove_promo_image.removed_successfully"))
, (response) ->
if response.data.error?
StatusMessage.display("failure", response.data.error)

View File

@@ -3,8 +3,12 @@ angular.module("admin.orderCycles").controller "OrderCyclesCtrl", ($scope, $q, C
$scope.columns = Columns.columns
$scope.saveAll = -> OrderCycles.saveChanges($scope.order_cycles_form)
$scope.ordersCloseAtLimit = -31 # days
$scope.involvingFilter = 0
$scope.scheduleFilter = 0
$scope.resetSelectFilters = ->
$scope.scheduleFilter = 0
$scope.involvingFilter = 0
$scope.query = ''
$scope.resetSelectFilters()
compileData = ->
for schedule in $scope.schedules

View File

@@ -156,7 +156,7 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
if response.data.errors?
StatusMessage.display('failure', response.data.errors[0])
else
StatusMessage.display('failure', 'Failed to create order cycle')
StatusMessage.display('failure', t('js.order_cycles.create_failure'))
update: (destination, form) ->
return unless @confirmNoDistributors()
@@ -171,7 +171,7 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
if response.data.errors?
StatusMessage.display('failure', response.data.errors[0])
else
StatusMessage.display('failure', 'Failed to create order cycle')
StatusMessage.display('failure', t('js.order_cycles.update_failure'))
confirmNoDistributors: ->

View File

@@ -0,0 +1,26 @@
angular.module("admin.orders").controller "orderCtrl", ($scope, shops, orderCycles, $compile, $attrs, Orders) ->
$scope.$compile = $compile
$scope.shops = shops
$scope.orderCycles = orderCycles
$scope.distributor_id = parseInt($attrs.ofnDistributorId)
$scope.order_cycle_id = parseInt($attrs.ofnOrderCycleId)
$scope.validOrderCycle = (oc) ->
$scope.orderCycleHasDistributor oc, parseInt($scope.distributor_id)
$scope.distributorHasOrderCycles = (distributor) ->
(oc for oc in $scope.orderCycles when @orderCycleHasDistributor(oc, distributor.id)).length > 0
$scope.orderCycleHasDistributor = (oc, distributor_id) ->
distributor_ids = (d.id for d in oc.distributors)
distributor_ids.indexOf(distributor_id) != -1
$scope.distributionChosen = ->
$scope.distributor_id && $scope.order_cycle_id
for oc in $scope.orderCycles
oc.name_and_status = "#{oc.name} (#{oc.status})"
for shop in $scope.shops
shop.disabled = !$scope.distributorHasOrderCycles(shop)

View File

@@ -1,26 +1,47 @@
angular.module("admin.orders").controller "ordersCtrl", ($scope, $compile, $attrs, shops, orderCycles) ->
$scope.$compile = $compile
$scope.shops = shops
$scope.orderCycles = orderCycles
angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor, Orders, SortOptions) ->
$scope.RequestMonitor = RequestMonitor
$scope.pagination = Orders.pagination
$scope.orders = Orders.all
$scope.sortOptions = SortOptions
$scope.per_page_options = [
{id: 15, name: t('js.admin.orders.index.per_page', results: 15)},
{id: 50, name: t('js.admin.orders.index.per_page', results: 50)},
{id: 100, name: t('js.admin.orders.index.per_page', results: 100)}
]
$scope.distributor_id = parseInt($attrs.ofnDistributorId)
$scope.order_cycle_id = parseInt($attrs.ofnOrderCycleId)
$scope.initialise = ->
$scope.per_page = 15
$scope.q = {
completed_at_not_null: true
}
$scope.fetchResults()
$scope.validOrderCycle = (oc) ->
$scope.orderCycleHasDistributor oc, parseInt($scope.distributor_id)
$scope.fetchResults = (page=1) ->
Orders.index({
'q[created_at_lt]': $scope['q']['created_at_lt'],
'q[created_at_gt]': $scope['q']['created_at_gt'],
'q[state_eq]': $scope['q']['state_eq'],
'q[number_cont]': $scope['q']['number_cont'],
'q[email_cont]': $scope['q']['email_cont'],
'q[bill_address_firstname_start]': $scope['q']['bill_address_firstname_start'],
'q[bill_address_lastname_start]': $scope['q']['bill_address_lastname_start'],
'q[completed_at_not_null]': $scope['q']['completed_at_not_null'],
'q[inventory_units_shipment_id_null]': $scope['q']['inventory_units_shipment_id_null'],
'q[distributor_id_in]': $scope['q']['distributor_id_in'],
'q[order_cycle_id_in]': $scope['q']['order_cycle_id_in'],
'q[order_cycle_id_in]': $scope['q']['order_cycle_id_in'],
'q[s]': $scope.sorting || 'id desc',
per_page: $scope.per_page,
page: page
})
$scope.distributorHasOrderCycles = (distributor) ->
(oc for oc in orderCycles when @orderCycleHasDistributor(oc, distributor.id)).length > 0
$scope.$watch 'sortOptions', (sort) ->
if sort && sort.predicate != ""
$scope.sorting = sort.predicate + ' desc' if sort.reverse
$scope.sorting = sort.predicate + ' asc' if !sort.reverse
$scope.fetchResults()
, true
$scope.orderCycleHasDistributor = (oc, distributor_id) ->
distributor_ids = (d.id for d in oc.distributors)
distributor_ids.indexOf(distributor_id) != -1
$scope.distributionChosen = ->
$scope.distributor_id && $scope.order_cycle_id
for oc in $scope.orderCycles
oc.name_and_status = "#{oc.name} (#{oc.status})"
for shop in $scope.shops
shop.disabled = !$scope.distributorHasOrderCycles(shop)
$scope.changePage = (newPage) ->
$scope.page = newPage
$scope.fetchResults(newPage)

View File

@@ -51,7 +51,7 @@ angular.module("admin.productImport").controller "ImportFormCtrl", ($scope, $htt
$scope.start = () ->
$scope.started = true
total = ams_data.item_count
size = 100
size = 50
$scope.chunks = Math.ceil(total / size)
i = 0

View File

@@ -10,7 +10,7 @@ angular.module("admin.productImport").filter 'entriesFilterValid', ->
if type == 'valid' and validates_as != '' \
or type == 'invalid' and validates_as == '' \
or type == 'create_product' and validates_as == 'new_product' or validates_as == 'new_variant' \
or type == 'create_product' and (validates_as == 'new_product' or validates_as == 'new_variant') \
or type == 'update_product' and validates_as == 'existing_variant' \
or type == 'create_inventory' and validates_as == 'new_inventory_item' \
or type == 'update_inventory' and validates_as == 'existing_inventory_item'

View File

@@ -8,4 +8,10 @@ angular.module("admin.resources").factory 'EnterpriseResource', ($resource) ->
isArray: true
'update':
method: 'PUT'
'removeLogo':
url: '/api/enterprises/:id/logo.json'
method: 'DELETE'
'removePromoImage':
url: '/api/enterprises/:id/promo_image.json'
method: 'DELETE'
})

View File

@@ -2,7 +2,6 @@ angular.module("admin.resources").factory 'OrderResource', ($resource) ->
$resource('/admin/orders/:id/:action.json', {}, {
'index':
method: 'GET'
isArray: true
'update':
method: 'PUT'
})

View File

@@ -38,3 +38,17 @@ angular.module("admin.resources").factory 'Enterprises', ($q, EnterpriseResource
resetAttribute: (enterprise, attribute) ->
enterprise[attribute] = @pristineByID[enterprise.id][attribute]
performActionOnEnterpriseResource = (resourceAction) ->
(enterprise) ->
deferred = $q.defer()
resourceAction({id: enterprise.permalink}, ((data) =>
@pristineByID[enterprise.id] = angular.copy(data)
deferred.resolve(data)
), ((response) ->
deferred.reject(response)
))
deferred.promise
removeLogo: performActionOnEnterpriseResource(EnterpriseResource.removeLogo)
removePromoImage: performActionOnEnterpriseResource(EnterpriseResource.removePromoImage)

View File

@@ -1,18 +1,30 @@
angular.module("admin.resources").factory 'Orders', ($q, OrderResource) ->
angular.module("admin.resources").factory 'Orders', ($q, OrderResource, RequestMonitor) ->
new class Orders
all: []
byID: {}
pristineByID: {}
pagination: {}
index: (params={}, callback=null) ->
OrderResource.index params, (data) =>
request = OrderResource.index params, (data) =>
@load(data)
(callback || angular.noop)(data)
RequestMonitor.load(request.$promise)
@all
load: (orders) ->
for order in orders
load: (data) ->
angular.extend(@pagination, data.pagination)
@clearData()
for order in data.orders
@all.push order
@byID[order.id] = order
@pristineByID[order.id] = angular.copy(order)
clearData: ->
@all.length = 0
@byID = {}
@pristineByID = {}
save: (order) ->
deferred = $q.defer()
order.$update({id: order.number})

View File

@@ -11,7 +11,7 @@
#= require lodash.underscore.js
#= require angular-scroll.min.js
#= require angular-google-maps.min.js
#= require ../shared/mm-foundation-tpls-0.8.0.min.js
#= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
#= require ../shared/ng-infinite-scroll.min.js
#= require ../shared/angular-local-storage.js
#= require ../shared/angular-slideables.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +0,0 @@
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require 'jquery'
//= require store/spree_frontend
//= require store/spree_auth
//= require_tree .

View File

@@ -4,6 +4,9 @@
.large-12.columns
.alert-box.success{ng: {show: 'messages != null'}}
{{ messages }}
.large-12.columns
.alert-box.alert{ng: {show: 'errors.message != null'}}
{{ errors.message }}
.row
.large-12.columns
%label{for: "email"} {{'signup_email' | t}}

View File

@@ -15,4 +15,6 @@
*/
@import 'variables';
@import '**/*';
@import 'components/*';
@import '*';
@import 'pages/*';

View File

@@ -0,0 +1,20 @@
@import "admin/variables";
.pagination {
text-align: center;
margin: 2em 0 1em;
button {
margin: 0 0.35em;
&.active {
background-color: darken($spree-blue, 15%);
cursor: default;
}
&.disabled {
background-color: $disabled_button;
cursor: default;
}
}
}

View File

@@ -0,0 +1,7 @@
.per-page {
float: left;
.per-page-feedback {
margin-left: 1em;
}
}

View File

@@ -87,3 +87,19 @@ div#group_buy_calculation {
th.actions {
white-space: nowrap;
}
table.index td.actions {
text-align: left;
}
.orders-loading {
margin-top: 1em;
img {
width: 85px;
}
span {
font-size: 1.2em;
}
}

View File

@@ -0,0 +1,20 @@
@import '../variables';
.reveal-modal.product-image-upload {
width: 300px;
.close-reveal-modal {
color: $modal-close-button-color;
font-size: 23px;
right: .45rem;
top: .35rem;
:hover {
color: $modal-close-button-hover-color;
}
}
label {
margin-top: 20px;
}
}

View File

@@ -1,15 +1,22 @@
@import "variables";
div.panel-section {
$pi-red: $warning-red;
$pi-green: lighten($spree-green, 10%);
$pi-orange: $bright-orange;
$pi-blue: lighten($spree-blue, 10%);
$pi-light-yellow: #faffaf;
.neutral {
color: #bfbfbf;
// scss-lint:disable NestingDepth
div.panel-section {
.error {
color: $pi-red;
}
.warning {
color: $warning-red;
color: $bright-orange;
}
.success {
color: #86d83a;
color: $pi-green;
}
.info {
color: #68b7c0;
@@ -85,21 +92,29 @@ div.panel-section {
td, th {
white-space: nowrap;
}
tr.error {
color: #c84C4c;
tr {
&.error {
color: #c84C4c;
}
&:hover td.invalid {
background-color: darken(#f05c51, 5%);
}
i {
display: block;
margin-bottom: -0.2em;
font-size: 1.4em !important;
}
}
tr:hover td.invalid {
background-color: #ed5135;
}
tr i {
display: block;
margin-bottom: -0.2em;
font-size: 1.4em !important;
}
td.invalid {
background-color: #f05c51;
box-shadow: inset 0px 0px 1px red;
color: white;
td {
&.invalid {
background-color: #f05c51;
box-shadow: inset 0px 0px 1px red;
color: white;
}
}
}
@@ -123,52 +138,6 @@ br.panels.clearfix {
clear: both;
}
table.import-settings {
background-color: transparent !important;
width: auto;
tbody tr:hover td {
background-color: #f3f3f3;
}
td {
border: 0;
border-bottom: 1px solid #eee;
text-align: left;
input {
width: 15em;
}
input[type="checkbox"] {
width: auto;
}
}
td.description {
font-weight: bold;
padding-right: 2.5em;
}
tr:first-child td {
border-top: 0;
}
tr:last-child td {
border-bottom: 0;
}
div.select2-container {
width: 13.5em;
}
div.select2-container.select2-container-disabled {
a.select2-choice, span.select2-arrow {
background-color: #d5d5d5;
}
}
input[disabled], input:disabled {
background-color: #d5d5d5;
opacity: 1;
border-color: transparent;
color: white !important;
}
}
.panel-section.import-settings {
.header-description {
@@ -177,7 +146,7 @@ table.import-settings {
span.header-error {
font-size: 0.85em;
color: $warning-red;
color: $pi-red;
}
.select2-search {
@@ -208,10 +177,10 @@ table.import-settings {
}
i.fa-check-circle {
color: #86d83a;
color: $pi-green;
}
i.fa-info-circle {
color: #68b7c0;
color: $pi-blue;
}
}
@@ -234,6 +203,10 @@ form.product-import, div.post-save-results, div.import-wrapper {
div.import-wrapper {
.alert-box {
margin: 0 0 1.75em;
}
.ng-hide:not(.ng-hide-animate) {
// We have to use !important here to override angular's display properties
// scss-lint:disable ImportantRule
@@ -281,7 +254,7 @@ div.progress-bar {
span.progress-track{
display: block;
background: #b7ea53;
background: lighten($pi-green, 10%);
height: 100%;
border-radius: 0.3em;
box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
@@ -312,7 +285,7 @@ div.progress-bar {
span.category {
display: inline-block;
background-color: lighten($spree-blue, 10%);
background-color: $pi-blue;
color: white;
padding: 0.3em 0.6em;
margin: 0 0.4em 0.5em 0;

View File

@@ -98,25 +98,6 @@ table#listing_products.bulk {
}
}
.reveal-modal.product-image-upload {
width: 300px;
a.close-reveal-modal {
font-size: 23px;
color: #de6060;
right: 0.45rem;
top: 0.35rem;
:hover {
color: #bf4545;
}
}
div.image-preview {
//float: left;
}
label {
margin-top: 20px;
}
}
form#image_upload {
text-align: center;
.spinner {

View File

@@ -6,7 +6,13 @@ $spree-light-blue: #eff5fc;
$warning-red: #da5354;
$warning-orange: #da7f52;
$bright-orange: #ffa92e;
$medium-grey: #919191;
$pale-blue: #cee1f4;
$light-grey: #ccc;
$admin-table-border: $pale-blue;
$modal-close-button-color: #de6060;
$modal-close-button-hover-color: #bf4545;
$disabled-button: $light-grey;

View File

@@ -9,8 +9,11 @@
@import 'foundation';
@import 'foundation-icons';
@import 'base/*';
@import '*';
@import 'pages/*';
@import '../web/all';
ofn-modal {
display: block;
}
}

View File

@@ -1,3 +0,0 @@
/*
*= require 'darkswarm/all'
*/

View File

@@ -123,9 +123,12 @@
-moz-transition: -moz-transform 0.2s ease-out;
-o-transition: -o-transform 0.2s ease-out;
transition: transform 0.2s ease-out;
-webkit-transform: translate(0, -25%);
-ms-transform: translate(0, -25%);
transform: translate(0, -25%);
@media only screen and (min-width: 641px) {
-webkit-transform: translate(0, -5%);
-ms-transform: translate(0, -5%);
transform: translate(0, -5%);
}
}
.reveal-modal.in {

View File

@@ -0,0 +1,4 @@
$modal-background-color: #efefef;
$modal-content-background-color: #fff;
$modal-alert-link-color: #fff;
$modal-alert-link-hover-color: rgba(255, 255, 255, .7);

View File

@@ -1,25 +0,0 @@
// Styling for login modal to style tabs
.reveal-modal.login-modal {
border-bottom-color: #efefef;
}
.login-modal {
background: #efefef;
.tabs-content {
background: #fff;
padding-top: 10px;
}
.alert-box {
a {
color: white;
text-decoration: underline;
&:hover {
color: rgba(255, 255, 255, 0.7);
text-decoration: underline;
}
}
}
}

View File

@@ -20,16 +20,16 @@ dialog
// Small - when modal IS full screen
@media only screen and (max-width: 640px) {
height: 500px;
left: 0;
max-height: 100%;
position: absolute !important;
top: 0;
left: 0;
}
// Medium and up - when modal IS NOT full screen
@media only screen and (min-width: 641px) {
top: 10%;
max-height: 100%;
max-height: 90%;
top: 5%;
}
}

View File

@@ -0,0 +1,25 @@
@import '../base/colors';
// Styling for login modal to style tabs
.reveal-modal.login-modal {
border-bottom-color: $modal-background-color;
}
.login-modal {
background: $modal-background-color;
.tabs-content {
background: $modal-content-background-color;
padding-top: 10px;
}
.alert-box a {
color: $modal-alert-link-color;
text-decoration: underline;
&:hover {
color: $modal-alert-link-hover-color;
text-decoration: underline;
}
}
}

View File

@@ -1,12 +0,0 @@
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*
*= require store/spree_frontend
*= require store/spree_auth
*= require_self
*= require_tree .
*/

View File

@@ -1,21 +1,15 @@
module Admin
class ContentsController < Spree::Admin::BaseController
def edit
@preference_sections = [{name: I18n.t('admin.contents.edit.header'), preferences: [:logo, :logo_mobile, :logo_mobile_svg]},
{name: I18n.t('admin.contents.edit.home_page'), preferences: [:home_hero, :home_show_stats]},
{name: I18n.t('admin.contents.edit.producer_signup_page'), preferences: [:producer_signup_pricing_table_html, :producer_signup_case_studies_html, :producer_signup_detail_html]},
{name: I18n.t('admin.contents.edit.hub_signup_page'), preferences: [:hub_signup_pricing_table_html, :hub_signup_case_studies_html, :hub_signup_detail_html]},
{name: I18n.t('admin.contents.edit.group_signup_page'), preferences: [:group_signup_pricing_table_html, :group_signup_case_studies_html, :group_signup_detail_html]},
{name: I18n.t('admin.contents.edit.main_links'), preferences: [:menu_1, :menu_1_icon_name, :menu_2, :menu_2_icon_name, :menu_3, :menu_3_icon_name, :menu_4, :menu_4_icon_name, :menu_5, :menu_5_icon_name, :menu_6, :menu_6_icon_name, :menu_7, :menu_7_icon_name]},
{name: I18n.t('admin.contents.edit.footer_and_external_links'), preferences: [:footer_logo,
:footer_facebook_url, :footer_twitter_url, :footer_instagram_url, :footer_linkedin_url, :footer_googleplus_url, :footer_pinterest_url,
:footer_email, :community_forum_url, :footer_links_md, :footer_about_url]}]
@preference_sections = preference_sections.map do |preference_section|
{ name: preference_section.name, preferences: preference_section.preferences }
end
end
def update
params.each do |name, value|
if ContentConfig.has_preference?(name) || ContentConfig.has_attachment?(name)
ContentConfig.send("#{name}=", value)
ContentConfig.public_send("#{name}=", value)
end
end
@@ -26,5 +20,20 @@ module Admin
redirect_to main_app.edit_admin_content_path
end
private
def preference_sections
[
PreferenceSections::HeaderSection.new,
PreferenceSections::HomePageSection.new,
PreferenceSections::ProducerSignupPageSection.new,
PreferenceSections::HubSignupPageSection.new,
PreferenceSections::GroupSignupPageSection.new,
PreferenceSections::MainLinksSection.new,
PreferenceSections::FooterAndExternalLinksSection.new,
PreferenceSections::UserGuideSection.new
]
end
end
end

View File

@@ -19,7 +19,7 @@ module Admin
# we can authorise #create using an object with required attributes
def build_resource
if parent_data.present?
parent.send(controller_name).build
parent.public_send(controller_name).build
else
model_class.new(params[object_name]) # This line changed
end

View File

@@ -14,6 +14,7 @@ module Admin
@filepath = save_uploaded_file(params[:file])
@importer = ProductImport::ProductImporter.new(File.new(@filepath), spree_current_user, params[:settings])
@original_filename = params[:file].try(:original_filename)
@non_updatable_fields = ProductImport::EntryValidator.non_updatable_fields
check_file_errors @importer
check_spreadsheet_has_data @importer
@@ -53,7 +54,7 @@ module Admin
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]), spree_current_user, start: params[:start], end: params[:end], settings: params[:settings])
begin
@importer.send("#{method}_entries")
@importer.public_send("#{method}_entries")
rescue StandardError => e
render json: e.message, response: 500
return false

View File

@@ -15,18 +15,18 @@ module Admin
def edit_object_url(object, options = {})
if parent_data.present?
main_app.send "edit_admin_#{model_name}_#{object_name}_url", parent, object, options
main_app.public_send "edit_admin_#{model_name}_#{object_name}_url", parent, object, options
else
main_app.send "edit_admin_#{object_name}_url", object, options
main_app.public_send "edit_admin_#{object_name}_url", object, options
end
end
def object_url(object = nil, options = {})
target = object ? object : @object
if parent_data.present?
main_app.send "admin_#{model_name}_#{object_name}_url", parent, target, options
main_app.public_send "admin_#{model_name}_#{object_name}_url", parent, target, options
else
main_app.send "admin_#{object_name}_url", target, options
main_app.public_send "admin_#{object_name}_url", target, options
end
end

View File

@@ -1,5 +1,6 @@
require 'open_food_network/permissions'
require 'open_food_network/order_cycle_permissions'
require 'open_food_network/scope_variant_to_hub'
module Admin
class SubscriptionLineItemsController < ResourceController

View File

@@ -1,5 +0,0 @@
class AngularTemplatesController < ApplicationController
def show
render params[:id].to_s, layout: nil
end
end

View File

@@ -9,5 +9,9 @@ module Api
include ActionController::UrlFor
include Rails.application.routes.url_helpers
use_renderers :json
def respond_with_conflict(json_hash)
render json: json_hash, status: :conflict
end
end
end

View File

@@ -1,26 +0,0 @@
module Api
class CookiesConsentController < BaseController
include ActionController::Cookies
respond_to :json
def show
render json: { cookies_consent: cookies_consent.exists? }
end
def create
cookies_consent.set
show
end
def destroy
cookies_consent.destroy
show
end
private
def cookies_consent
@cookies_consent ||= CookiesConsent.new(cookies, request.host)
end
end
end

View File

@@ -0,0 +1,37 @@
module Api
class EnterpriseAttachmentController < BaseController
class MissingImplementationError < StandardError; end
class UnknownEnterpriseAuthorizationActionError < StandardError; end
before_filter :load_enterprise
respond_to :json
def destroy
return respond_with_conflict(error: destroy_attachment_does_not_exist_error_message) unless @enterprise.public_send("#{attachment_name}?")
@enterprise.update_attributes!(attachment_name => nil)
render json: @enterprise, serializer: Admin::EnterpriseSerializer, spree_current_user: spree_current_user
end
protected
def attachment_name
raise MissingImplementationError, "Method attachment_name should be defined"
end
def enterprise_authorize_action
raise MissingImplementationError, "Method enterprise_authorize_action should be defined"
end
def load_enterprise
@enterprise = Enterprise.find_by_permalink(params[:enterprise_id].to_s)
raise UnknownEnterpriseAuthorizationActionError if enterprise_authorize_action.blank?
authorize!(enterprise_authorize_action, @enterprise)
end
def destroy_attachment_does_not_exist_error_message
I18n.t("api.enterprise_#{attachment_name}.destroy_attachment_does_not_exist")
end
end
end

View File

@@ -0,0 +1,16 @@
module Api
class LogosController < EnterpriseAttachmentController
private
def attachment_name
:logo
end
def enterprise_authorize_action
case action_name.to_sym
when :destroy
:remove_logo
end
end
end
end

View File

@@ -0,0 +1,16 @@
module Api
class PromoImagesController < EnterpriseAttachmentController
private
def attachment_name
:promo_image
end
def enterprise_authorize_action
case action_name.to_sym
when :destroy
:remove_promo_image
end
end
end
end

View File

@@ -7,7 +7,6 @@ class ApplicationController < ActionController::Base
before_filter :set_cache_headers # Issue #1213, prevent cart emptying via cache when using back button
include EnterprisesHelper
helper CssSplitter::ApplicationHelper
def redirect_to(options = {}, response_status = {})
::Rails.logger.error("Redirected by #{caller(1).first rescue "unknown"}")

View File

@@ -77,7 +77,7 @@ class EnterprisesController < BaseController
def reset_user_and_customer(order)
order.associate_user!(spree_current_user) if order.user.blank? || order.email.blank?
order.send(:associate_customer) if order.customer.nil? # Only associates existing customers
order.__send__(:associate_customer) if order.customer.nil? # Only associates existing customers
end
def reset_order_cycle(order, distributor)

View File

@@ -44,7 +44,7 @@ class ShopController < BaseController
private
def filtered_json(products_json)
if applicator.send(:rules).any?
if applicator.rules.any?
filter(products_json)
else
products_json

View File

@@ -28,7 +28,11 @@ Spree::Admin::BaseController.class_eval do
record = self.class.to_s.sub("Controller", "").underscore.split('/').last.singularize.to_sym
end
authorize! :admin, record
authorize! action, record
authorize! resource_authorize_action, record
end
def resource_authorize_action
action
end
# This is in Spree::Core::ControllerHelpers::Auth

View File

@@ -10,6 +10,6 @@ module Spree
@preferences_general << :bugherd_api_key
end
end
GeneralSettingsController.send(:prepend, GeneralSettingsEditPreferences)
GeneralSettingsController.prepend(GeneralSettingsEditPreferences)
end
end

View File

@@ -1,3 +1,5 @@
require 'open_food_network/scope_variant_to_hub'
Spree::Admin::LineItemsController.class_eval do
prepend_before_filter :load_order, except: :index
around_filter :apply_enterprise_fees_with_lock, only: :update

View File

@@ -61,7 +61,15 @@ Spree::Admin::OrdersController.class_eval do
respond_with(@orders) do |format|
format.html
format.json do
render_as_json @orders
render json: {
orders: ActiveModel::ArraySerializer.new(@orders, each_serializer: Api::Admin::OrderSerializer),
pagination: {
results: @orders.total_count,
pages: @orders.num_pages.to_i,
page: params[:page].to_i,
per_page: params[:per_page].to_i
}
}
end
end
end
@@ -102,16 +110,14 @@ Spree::Admin::OrdersController.class_eval do
def orders
if json_request?
@search = OpenFoodNetwork::Permissions.new(spree_current_user).editable_orders.ransack(params[:q])
@search.result.reorder('id ASC')
else
@search = Spree::Order.accessible_by(current_ability, :index).ransack(params[:q])
# Replaced this search to filter orders to only show those distributed by current user (or all for admin user)
@search.result.includes([:user, :shipments, :payments]).
distributed_by_user(spree_current_user).
page(params[:page]).
per(params[:per_page] || Spree::Config[:orders_per_page])
@search.result.includes([:user, :shipments, :payments]).distributed_by_user(spree_current_user)
end
@search.result.page(params[:page]).per(params[:per_page] || Spree::Config[:orders_per_page])
end
def require_distributor_abn

View File

@@ -10,7 +10,7 @@ module Spree
# Only show payment methods that user has access to and sort by distributor name
# ! Redundant code copied from Spree::Admin::ResourceController with modifications marked
def collection
return parent.send(controller_name) if parent_data.present?
return parent.public_send(controller_name) if parent_data.present?
collection = if model_class.respond_to?(:accessible_by) &&
!current_ability.has_block?(params[:action], model_class)

View File

@@ -10,7 +10,7 @@ Spree::Admin::PaymentsController.class_eval do
# Because we have a transition method also called void, we do this to avoid conflicts.
event = "void_transaction" if event == "void"
if @payment.send("#{event}!")
if @payment.public_send("#{event}!")
flash[:success] = t(:payment_updated)
else
flash[:error] = t(:cannot_perform_operation)

View File

@@ -13,4 +13,4 @@ module AuthorizeOnLoadResource
end
end
Spree::Admin::ResourceController.send(:prepend, AuthorizeOnLoadResource)
Spree::Admin::ResourceController.prepend(AuthorizeOnLoadResource)

View File

@@ -1,10 +1,12 @@
require 'spree/core/controller_helpers/order_decorator'
require 'spree/core/controller_helpers/auth_decorator'
Spree::OrdersController.class_eval do
before_filter :update_distribution, only: :update
before_filter :filter_order_params, only: :update
before_filter :enable_embedded_shopfront
prepend_before_filter :require_order_authentication, only: :show
prepend_before_filter :require_order_cycle, only: :edit
prepend_before_filter :require_distributor_chosen, only: :edit
before_filter :check_hub_ready_for_checkout, only: :edit
@@ -128,6 +130,13 @@ Spree::OrdersController.class_eval do
private
def require_order_authentication
return if session[:access_token] || params[:token] || spree_current_user
flash[:error] = I18n.t("spree.orders.edit.login_to_view_order")
require_login_then_redirect_to request.env['PATH_INFO']
end
def order_to_update
return @order_to_update if defined? @order_to_update
return @order_to_update = current_order unless params[:id]

View File

@@ -1,4 +1,8 @@
require 'open_food_network/error_logger'
class UserRegistrationsController < Spree::UserRegistrationsController
I18N_SCOPE = 'devise.user_registrations.spree_user'.freeze
before_filter :set_checkout_redirect, only: :create
# POST /resource/sign_up
@@ -19,14 +23,23 @@ class UserRegistrationsController < Spree::UserRegistrationsController
end
end
else
clean_up_passwords(resource)
respond_to do |format|
format.html do
render :new
end
format.js do
render json: @user.errors, status: :unauthorized
end
render_error(@user.errors)
end
rescue StandardError => error
OpenFoodNetwork::ErrorLogger.notify(error)
render_error(message: I18n.t('unknown_error', scope: I18N_SCOPE))
end
private
def render_error(errors = {})
clean_up_passwords(resource)
respond_to do |format|
format.html do
render :new
end
format.js do
render json: errors, status: :unauthorized
end
end
end

View File

@@ -7,10 +7,6 @@ class AngularFormBuilder < ActionView::Helpers::FormBuilder
end
def ng_text_field(method, options = {})
# @object_name --> "enterprise_fee_set"
# @fields_for_record_name --> :collection
# @object.send(@fields_for_record_name).first.class.to_s.underscore --> enterprise_fee
value = "{{ #{angular_model(method)} }}"
options.reverse_merge!({'id' => angular_id(method)})
@@ -46,6 +42,6 @@ class AngularFormBuilder < ActionView::Helpers::FormBuilder
end
def angular_model(method)
"#{@object.send(@fields_for_record_name).first.class.to_s.underscore}.#{method}"
"#{@object.public_send(@fields_for_record_name).first.class.to_s.underscore}.#{method}"
end
end

View File

@@ -11,7 +11,7 @@ module AngularFormHelper
def ng_options_from_collection_for_select(collection, value_method, text_method, angular_field)
options = collection.map do |element|
[element.send(text_method), element.send(value_method)]
[element.public_send(text_method), element.public_send(value_method)]
end
ng_options_for_select(options, angular_field)

View File

@@ -15,7 +15,7 @@ module ApplicationHelper
# spree.foo_path in any view rendered from non-spree-namespaced controllers.
def method_missing(method, *args, &block)
if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && spree.respond_to?(method)
spree.send(method, *args)
spree.public_send(method, *args)
else
super
end

View File

@@ -1,8 +0,0 @@
module CookiesPolicyHelper
def render_cookie_entry(cookie_name, cookie_desc, cookie_domain = nil)
render partial: 'cookies_policy_entry',
locals: { cookie_name: cookie_name,
cookie_desc: cookie_desc,
cookie_domain: cookie_domain }
end
end

View File

@@ -0,0 +1,11 @@
require 'web/cookies_consent'
module FooterLinksHelper
def cookies_policy_link
link_to( t( '.footer_data_cookies_policy' ), '', 'cookies-policy-modal' => true, 'cookies-banner' => !Web::CookiesConsent.new(cookies, request.host).exists? && Spree::Config.cookies_consent_banner_toggle)
end
def privacy_policy_link
link_to( t( '.footer_data_privacy_policy' ), Spree::Config.privacy_policy_url, target: '_blank' )
end
end

View File

@@ -13,8 +13,14 @@ Spree::UserMailer.class_eval do
@contact = ContentConfig.footer_email
subject = t('spree.user_mailer.confirmation_instructions.subject')
mail(to: user.email,
mail(to: confirmation_email_address,
from: from_address,
subject: subject)
end
private
def confirmation_email_address
@user.pending_reconfirmation? ? @user.unconfirmed_email : @user.email
end
end

View File

@@ -20,7 +20,7 @@ class ColumnPreference < ActiveRecord::Base
def self.for(user, action_name)
stored_preferences = where(user_id: user.id, action_name: action_name)
default_preferences = send("#{action_name}_columns")
default_preferences = __send__("#{action_name}_columns")
filter(default_preferences, user, action_name)
default_preferences.each_with_object([]) do |(column_name, default_attributes), preferences|
stored_preference = stored_preferences.find_by_column_name(column_name)
@@ -37,7 +37,7 @@ class ColumnPreference < ActiveRecord::Base
private
def self.valid_columns_for(action_name)
send("#{action_name}_columns").keys.map(&:to_s)
__send__("#{action_name}_columns").keys.map(&:to_s)
end
def self.known_actions

View File

@@ -69,4 +69,7 @@ class ContentConfiguration < Spree::Preferences::FileConfiguration
EOS
preference :footer_about_url, :string, default: "http://www.openfoodnetwork.org/ofn-local/open-food-network-australia/"
#User Guide
preference :user_guide_link, :string, default: 'https://guide.openfoodnetwork.org/'
end

View File

@@ -12,7 +12,7 @@ class ModelSet
@collection = attributes[:collection] if attributes[:collection]
attributes.each do |name, value|
send("#{name}=", value)
public_send("#{name}=", value)
end
end
@@ -30,8 +30,11 @@ class ModelSet
def errors
errors = ActiveModel::Errors.new self
full_messages = @collection.map { |ef| ef.errors.full_messages }.flatten
full_messages.each { |fm| errors.add(:base, fm) }
full_messages = @collection
.map { |model| model.errors.full_messages }
.flatten
full_messages.each { |message| errors.add(:base, message) }
errors
end

View File

@@ -1,3 +1,5 @@
require 'open_food_network/scope_variant_to_hub'
class OrderCycle < ActiveRecord::Base
belongs_to :coordinator, :class_name => 'Enterprise'
@@ -121,7 +123,7 @@ class OrderCycle < ActiveRecord::Base
def clone!
oc = self.dup
oc.name = "COPY OF #{oc.name}"
oc.name = I18n.t("models.order_cycle.cloned_order_cycle_name", order_cycle: oc.name)
oc.orders_open_at = oc.orders_close_at = nil
oc.coordinator_fee_ids = self.coordinator_fee_ids
oc.preferred_product_selection_from_coordinator_inventory_only = self.preferred_product_selection_from_coordinator_inventory_only

View File

@@ -9,27 +9,13 @@ class OrderUpdater < SimpleDelegator
# https://github.com/spree/spree/commit/38b8456183d11fc1e00e395e7c9154c76ef65b85
# https://github.com/spree/spree/commit/7b264acff7824f5b3dc6651c106631d8f30b147a
def update_payment_state
last_state = order.payment_state
if payments.present? && payments.valid.empty?
order.payment_state = 'failed'
elsif order.state == 'canceled' && order.payment_total.zero?
order.payment_state = 'void'
else
# This part added so that we don't need to override order.outstanding_balance
balance = order.outstanding_balance
balance = -1 * order.payment_total if canceled_and_paid_for?
order.payment_state = 'balance_due' if balance > 0
order.payment_state = 'credit_owed' if balance < 0
order.payment_state = 'paid' if balance.zero?
last_payment_state = order.payment_state
# Original logic
# order.payment_state = 'balance_due' if order.outstanding_balance > 0
# order.payment_state = 'credit_owed' if order.outstanding_balance < 0
# order.payment_state = 'paid' if !order.outstanding_balance?
order.payment_state = infer_payment_state
track_payment_state_change(last_payment_state)
order.payment_state
end
order.state_changed('payment') if last_state != order.payment_state
order.payment_state
end
def before_save_hook
shipping_address_from_distributor
@@ -37,10 +23,61 @@ class OrderUpdater < SimpleDelegator
private
def infer_payment_state
if failed_payments?
'failed'
elsif canceled_and_not_paid_for?
'void'
else
infer_payment_state_from_balance
end
end
def infer_payment_state_from_balance
# This part added so that we don't need to override
# order.outstanding_balance
balance = order.outstanding_balance
balance = -1 * order.payment_total if canceled_and_paid_for?
infer_state(balance)
end
def infer_state(balance)
if balance > 0
'balance_due'
elsif balance < 0
'credit_owed'
elsif balance.zero?
'paid'
end
end
# Tracks the state transition through a state_change for this order. It
# does so until the last state is reached. That is, when the infered next
# state is the same as the order has now.
#
# @param last_payment_state [String]
def track_payment_state_change(last_payment_state)
return if last_payment_state == order.payment_state
order.state_changed('payment')
end
# Taken from order.outstanding_balance in Spree 2.4
# See: https://github.com/spree/spree/commit/7b264acff7824f5b3dc6651c106631d8f30b147a
def canceled_and_paid_for?
order.canceled? && order.payments.present? && !order.payments.completed.empty?
order.canceled? && paid?
end
def canceled_and_not_paid_for?
order.state == 'canceled' && order.payment_total.zero?
end
def paid?
payments.present? && !payments.completed.empty?
end
def failed_payments?
payments.present? && payments.valid.empty?
end
# Sets the distributor's address as shipping address of the order for those

View File

@@ -0,0 +1,23 @@
module PreferenceSections
class FooterAndExternalLinksSection
def name
I18n.t('admin.contents.edit.footer_and_external_links')
end
def preferences
[
:footer_logo,
:footer_facebook_url,
:footer_twitter_url,
:footer_instagram_url,
:footer_linkedin_url,
:footer_googleplus_url,
:footer_pinterest_url,
:footer_email,
:community_forum_url,
:footer_links_md,
:footer_about_url
]
end
end
end

View File

@@ -0,0 +1,15 @@
module PreferenceSections
class GroupSignupPageSection
def name
I18n.t('admin.contents.edit.group_signup_page')
end
def preferences
[
:group_signup_pricing_table_html,
:group_signup_case_studies_html,
:group_signup_detail_html
]
end
end
end

View File

@@ -0,0 +1,15 @@
module PreferenceSections
class HeaderSection
def name
I18n.t('admin.contents.edit.header')
end
def preferences
[
:logo,
:logo_mobile,
:logo_mobile_svg
]
end
end
end

View File

@@ -0,0 +1,14 @@
module PreferenceSections
class HomePageSection
def name
I18n.t('admin.contents.edit.home_page')
end
def preferences
[
:home_hero,
:home_show_stats
]
end
end
end

View File

@@ -0,0 +1,15 @@
module PreferenceSections
class HubSignupPageSection
def name
I18n.t('admin.contents.edit.hub_signup_page')
end
def preferences
[
:hub_signup_pricing_table_html,
:hub_signup_case_studies_html,
:hub_signup_detail_html
]
end
end
end

View File

@@ -0,0 +1,26 @@
module PreferenceSections
class MainLinksSection
def name
I18n.t('admin.contents.edit.main_links')
end
def preferences
[
:menu_1,
:menu_1_icon_name,
:menu_2,
:menu_2_icon_name,
:menu_3,
:menu_3_icon_name,
:menu_4,
:menu_4_icon_name,
:menu_5,
:menu_5_icon_name,
:menu_6,
:menu_6_icon_name,
:menu_7,
:menu_7_icon_name
]
end
end
end

View File

@@ -0,0 +1,15 @@
module PreferenceSections
class ProducerSignupPageSection
def name
I18n.t('admin.contents.edit.producer_signup_page')
end
def preferences
[
:producer_signup_pricing_table_html,
:producer_signup_case_studies_html,
:producer_signup_detail_html
]
end
end
end

View File

@@ -0,0 +1,11 @@
module PreferenceSections
class UserGuideSection
def name
I18n.t('admin.contents.edit.user_guide')
end
def preferences
[:user_guide_link]
end
end
end

View File

@@ -4,12 +4,14 @@
module ProductImport
class EntryProcessor
attr_reader :inventory_created, :inventory_updated, :products_created, :variants_created, :variants_updated, :products_reset_count, :supplier_products, :total_supplier_products
attr_reader :inventory_created, :inventory_updated, :products_created,
:variants_created, :variants_updated, :supplier_products,
:total_supplier_products, :products_reset_count
def initialize(importer, validator, import_settings, spreadsheet_data, editable_enterprises, import_time, updated_ids)
@importer = importer
@validator = validator
@import_settings = import_settings
@settings = Settings.new(import_settings)
@spreadsheet_data = spreadsheet_data
@editable_enterprises = editable_enterprises
@import_time = import_time
@@ -43,7 +45,7 @@ module ProductImport
next unless supplier_id && permission_by_id?(supplier_id)
products_count =
if importing_into_inventory?
if settings.importing_into_inventory?
VariantOverride.where('variant_overrides.hub_id IN (?)', supplier_id).count
else
Spree::Variant.
@@ -60,45 +62,39 @@ module ProductImport
end
def reset_absent_items
# For selected enterprises; set stock to zero for all products/inventory
# that were not listed in the newly uploaded spreadsheet
return unless data_for_stock_reset?
suppliers_to_reset_products = []
suppliers_to_reset_inventories = []
return unless settings.data_for_stock_reset? && settings.reset_all_absent?
settings = @import_settings[:settings]
@products_reset_count = reset_absent.call
end
@import_settings[:enterprises_to_reset].each do |enterprise_id|
suppliers_to_reset_products.push Integer(enterprise_id) if settings['reset_all_absent'] && permission_by_id?(enterprise_id) && !importing_into_inventory?
suppliers_to_reset_inventories.push Integer(enterprise_id) if settings['reset_all_absent'] && permission_by_id?(enterprise_id) && importing_into_inventory?
def reset_absent
@reset_absent ||= ResetAbsent.new(self, settings, reset_stock_strategy)
end
def reset_stock_strategy_factory
if settings.importing_into_inventory?
InventoryResetStrategy
else
ProductsResetStrategy
end
end
unless suppliers_to_reset_inventories.empty?
@products_reset_count += VariantOverride.
where('variant_overrides.hub_id IN (?)
AND variant_overrides.id NOT IN (?)', suppliers_to_reset_inventories, @import_settings[:updated_ids]).
update_all(count_on_hand: 0)
end
return if suppliers_to_reset_products.empty?
@products_reset_count += Spree::Variant.joins(:product).
where('spree_products.supplier_id IN (?)
AND spree_variants.id NOT IN (?)
AND spree_variants.is_master = false
AND spree_variants.deleted_at IS NULL', suppliers_to_reset_products, @import_settings[:updated_ids]).
update_all(count_on_hand: 0)
def reset_stock_strategy
@reset_stock_strategy ||= reset_stock_strategy_factory
.new(settings.updated_ids)
end
def total_saved_count
@products_created + @variants_created + @variants_updated + @inventory_created + @inventory_updated
end
def permission_by_id?(supplier_id)
@editable_enterprises.value?(Integer(supplier_id))
end
private
def data_for_stock_reset?
@import_settings[:settings] && @import_settings[:updated_ids] && @import_settings[:enterprises_to_reset]
end
attr_reader :settings
def save_to_inventory(entry)
save_new_inventory_item entry if entry.validates_as? 'new_inventory_item'
@@ -115,12 +111,18 @@ module ProductImport
return unless entry.validates_as? 'existing_variant'
save_variant entry
begin
save_variant entry
rescue ActiveRecord::StaleObjectError
entry.product_object.reload
save_variant entry
end
@variants_updated += 1
end
def import_into_inventory?(entry)
entry.supplier_id && @import_settings[:settings]['import_into'] == 'inventories'
entry.supplier_id && settings.importing_into_inventory?
end
def save_new_inventory_item(entry)
@@ -195,16 +197,16 @@ module ProductImport
# Assigns a default value for a specified field e.g. category='Vegetables', setting this value
# either for all entries (overwrite_all), or only for those entries where the field was blank
# in the spreadsheet (overwrite_empty), depending on selected import settings
return unless @import_settings.key?(:settings) && @import_settings[:settings][entry.supplier_id.to_s] && @import_settings[:settings][entry.supplier_id.to_s]['defaults']
return unless settings.defaults(entry)
@import_settings[:settings][entry.supplier_id.to_s]['defaults'].each do |attribute, setting|
settings.defaults(entry).each do |attribute, setting|
next unless setting['active']
case setting['mode']
when 'overwrite_all'
object.assign_attributes(attribute => setting['value'])
when 'overwrite_empty'
if object.send(attribute).blank? || ((attribute == 'on_hand' || attribute == 'count_on_hand') && entry.on_hand_nil)
if object.public_send(attribute).blank? || ((attribute == 'on_hand' || attribute == 'count_on_hand') && entry.on_hand_nil)
object.assign_attributes(attribute => setting['value'])
end
end
@@ -233,13 +235,5 @@ module ProductImport
variant.import_date = @import_time
variant.save
end
def permission_by_id?(supplier_id)
@editable_enterprises.value?(Integer(supplier_id))
end
def importing_into_inventory?
@import_settings[:settings] && @import_settings[:settings]['import_into'] == 'inventories'
end
end
end

View File

@@ -14,6 +14,17 @@ module ProductImport
@import_settings = import_settings
end
def self.non_updatable_fields
{
category: :primary_taxon_id,
description: :description,
unit_type: :variant_unit_scale,
variant_unit_name: :variant_unit_name,
tax_category: :tax_category_id,
shipping_category: :shipping_category_id
}
end
def validate_all(entries)
entries.each do |entry|
supplier_validation(entry)
@@ -124,16 +135,15 @@ module ProductImport
end
def inventory_validation(entry)
# Checks a potential inventory item corresponds to a valid variant
match = Spree::Product.where(supplier_id: entry.producer_id, name: entry.name, deleted_at: nil).first
products = Spree::Product.where(supplier_id: entry.producer_id, name: entry.name, deleted_at: nil)
if match.nil?
if products.empty?
mark_as_invalid(entry, attribute: 'name', error: I18n.t('admin.product_import.model.no_product'))
return
end
match.variants.each do |existing_variant|
unit_scale = match.variant_unit_scale
products.flat_map(&:variants).each do |existing_variant|
unit_scale = existing_variant.product.variant_unit_scale
unscaled_units = entry.unscaled_units || 0
entry.unit_value = unscaled_units * unit_scale
@@ -169,31 +179,29 @@ module ProductImport
return if category.blank?
if index.key? category
entry.send("#{type}_category_id=", index[category])
entry.public_send("#{type}_category_id=", index[category])
else
mark_as_invalid(entry, attribute: "#{type}_category", error: I18n.t('admin.product_import.model.not_found'))
end
end
def product_validation(entry)
# Find product with matching supplier and name
match = Spree::Product.where(supplier_id: entry.supplier_id, name: entry.name, deleted_at: nil).first
products = Spree::Product.where(supplier_id: entry.supplier_id, name: entry.name, deleted_at: nil)
# If no matching product was found, create a new product
if match.nil?
if products.empty?
mark_as_new_product(entry)
return
end
# Otherwise, if a variant exists with matching display_name and unit_value, update it
match.variants.each do |existing_variant|
products.each { |product| product_field_errors(entry, product) }
products.flat_map(&:variants).each do |existing_variant|
if entry_matches_existing_variant?(entry, existing_variant) && existing_variant.deleted_at.nil?
return mark_as_existing_variant(entry, existing_variant)
end
end
# Otherwise, a variant with sufficiently matching attributes doesn't exist; create a new one
mark_as_new_variant(entry, match.id)
mark_as_new_variant(entry, products.first.id)
end
def mark_as_new_product(entry)
@@ -220,6 +228,21 @@ module ProductImport
end
end
def product_field_errors(entry, existing_product)
EntryValidator.non_updatable_fields.each do |display_name, attribute|
next if attributes_match?(attribute, existing_product, entry) || attributes_blank?(attribute, existing_product, entry)
mark_as_invalid(entry, attribute: display_name, error: I18n.t('admin.product_import.model.not_updatable'))
end
end
def attributes_match?(attribute, existing_product, entry)
existing_product.public_send(attribute) == entry.public_send(attribute)
end
def attributes_blank?(attribute, existing_product, entry)
existing_product.public_send(attribute).blank? && entry.public_send(attribute).blank?
end
def permission_by_name?(supplier_name)
@editable_enterprises.key?(supplier_name)
end

View File

@@ -0,0 +1,28 @@
module ProductImport
class InventoryResetStrategy
def initialize(excluded_items_ids)
@excluded_items_ids = excluded_items_ids
end
def reset(supplier_ids)
@supplier_ids = supplier_ids
if supplier_ids.present?
relation.update_all(count_on_hand: 0)
else
0
end
end
private
attr_reader :excluded_items_ids, :supplier_ids
def relation
relation = VariantOverride.where(hub_id: supplier_ids)
return relation if excluded_items_ids.blank?
relation.where('id NOT IN (?)', excluded_items_ids)
end
end
end

View File

@@ -57,6 +57,13 @@ module ProductImport
@sheet ? @sheet.last_row - 1 : 0
end
def product_field_errors?
@entries.each do |entry|
return true if entry.errors.messages.values.include? [I18n.t('admin.product_import.model.not_updatable')]
end
false
end
def reset_counts
# Return indexed data about existing product count, reset count, and updates count per supplier
@reset_counts.each do |supplier_id, values|

View File

@@ -0,0 +1,34 @@
module ProductImport
class ProductsResetStrategy
def initialize(excluded_items_ids)
@excluded_items_ids = excluded_items_ids
end
def reset(supplier_ids)
@supplier_ids = supplier_ids
if supplier_ids.present?
relation.update_all(count_on_hand: 0)
else
0
end
end
private
attr_reader :excluded_items_ids, :supplier_ids
def relation
relation = Spree::Variant
.joins(:product)
.where(
spree_products: { supplier_id: supplier_ids },
spree_variants: { is_master: false, deleted_at: nil }
)
return relation if excluded_items_ids.blank?
relation.where('spree_variants.id NOT IN (?)', excluded_items_ids)
end
end
end

View File

@@ -0,0 +1,31 @@
module ProductImport
class ResetAbsent
def initialize(entry_processor, settings, reset_stock_strategy)
@entry_processor = entry_processor
@settings = settings
@reset_stock_strategy = reset_stock_strategy
end
# For selected enterprises; set stock to zero for all products/inventory
# that were not listed in the newly uploaded spreadsheet
#
# @return [Integer] number of items affected by the reset
def call
reset_stock_strategy.reset(authorized_enterprises)
end
private
attr_reader :settings, :reset_stock_strategy, :entry_processor
# Returns the enterprises that have permissions to be reset
#
# @return [Array<Integer>] array of Enterprise ids
def authorized_enterprises
settings.enterprises_to_reset.map do |enterprise_id|
next unless entry_processor.permission_by_id?(enterprise_id)
enterprise_id.to_i
end
end
end
end

View File

@@ -0,0 +1,37 @@
module ProductImport
class Settings
def initialize(import_settings)
@import_settings = import_settings
end
def defaults(entry)
@import_settings.key?(:settings) &&
settings[entry.supplier_id.to_s] &&
settings[entry.supplier_id.to_s]['defaults']
end
def settings
@import_settings[:settings]
end
def updated_ids
@import_settings[:updated_ids]
end
def enterprises_to_reset
@import_settings[:enterprises_to_reset]
end
def importing_into_inventory?
settings && settings['import_into'] == 'inventories'
end
def reset_all_absent?
settings['reset_all_absent']
end
def data_for_stock_reset?
!!(settings && updated_ids && enterprises_to_reset)
end
end
end

View File

@@ -71,7 +71,7 @@ module ProductImport
units.converted_attributes.each do |attr, value|
if respond_to?("#{attr}=")
send("#{attr}=", value) unless non_product_attributes.include?(attr)
public_send("#{attr}=", value) unless non_product_attributes.include?(attr)
end
end
end

View File

@@ -19,7 +19,7 @@ class ProxyOrder < ActiveRecord::Base
def state
# NOTE: the order is important here
%w(canceled paused pending cart).each do |state|
return state if send("#{state}?")
return state if __send__("#{state}?")
end
order.state
end
@@ -32,7 +32,7 @@ class ProxyOrder < ActiveRecord::Base
return false unless order_cycle.orders_close_at.andand > Time.zone.now
transaction do
update_column(:canceled_at, Time.zone.now)
order.send('cancel') if order
order.cancel if order
true
end
end
@@ -41,7 +41,7 @@ class ProxyOrder < ActiveRecord::Base
return false unless order_cycle.orders_close_at.andand > Time.zone.now
transaction do
update_column(:canceled_at, nil)
order.send('resume') if order
order.resume if order
true
end
end

View File

@@ -97,7 +97,7 @@ class AbilityDecorator
end
can [:admin, :index, :create], Enterprise
can [:read, :edit, :update, :bulk_update, :resend_confirmation], Enterprise do |enterprise|
can [:read, :edit, :update, :remove_logo, :remove_promo_image, :bulk_update, :resend_confirmation], Enterprise do |enterprise|
OpenFoodNetwork::Permissions.new(user).editable_enterprises.include? enterprise
end
can [:welcome, :register], Enterprise do |enterprise|

View File

@@ -18,15 +18,15 @@ Spree::Calculator::DefaultTax.class_eval do
# Added this block, finds relevant fees for each line_item, calculates the tax on them, and returns the total tax
per_item_fees_total = order.line_items.sum do |line_item|
calculator.send(:per_item_enterprise_fee_applicators_for, line_item.variant)
calculator.per_item_enterprise_fee_applicators_for(line_item.variant)
.select { |applicator| (!applicator.enterprise_fee.inherits_tax_category && applicator.enterprise_fee.tax_category == rate.tax_category) ||
(applicator.enterprise_fee.inherits_tax_category && line_item.product.tax_category == rate.tax_category)
(applicator.enterprise_fee.inherits_tax_category && line_item.product.tax_category == rate.tax_category)
}
.sum { |applicator| applicator.enterprise_fee.compute_amount(line_item) }
end
# Added this block, finds relevant fees for whole order, calculates the tax on them, and returns the total tax
per_order_fees_total = calculator.send(:per_order_enterprise_fee_applicators_for, order)
per_order_fees_total = calculator.per_order_enterprise_fee_applicators_for(order)
.select { |applicator| applicator.enterprise_fee.tax_category == rate.tax_category }
.sum { |applicator| applicator.enterprise_fee.compute_amount(order) }

View File

@@ -1,3 +1,4 @@
require 'open_food_network/scope_variant_to_hub'
require 'open_food_network/variant_and_line_item_naming'
Spree::LineItem.class_eval do

View File

@@ -33,6 +33,12 @@ Spree::Order.class_eval do
# See: https://guides.spreecommerce.org/developer/checkout.html#modifying-the-checkout-flow
remove_checkout_step :confirm
state_machine.after_transition to: :payment, do: :charge_shipping_and_payment_fees!
state_machine.event :restart_checkout do
transition to: :cart, unless: :completed?
end
# -- Scopes
scope :managed_by, lambda { |user|
if user.has_spree_role?('admin')
@@ -390,17 +396,13 @@ Spree::Order.class_eval do
adjustment.state = state
end
# object_params sets the payment amount to the order total, but it does this before
# the shipping method is set. This results in the customer not being charged for their
# order's shipping. To fix this, we refresh the payment amount here.
# object_params sets the payment amount to the order total, but it does this
# before the shipping method is set. This results in the customer not being
# charged for their order's shipping. To fix this, we refresh the payment
# amount here.
def charge_shipping_and_payment_fees!
update_totals
return unless payments.any?
payments.first.update_attribute :amount, total
end
end
Spree::Order.state_machine.after_transition to: :payment, do: :charge_shipping_and_payment_fees!
Spree::Order.state_machine.event :restart_checkout do
transition :to => :cart, unless: :completed?
end

View File

@@ -15,7 +15,7 @@ module Spree::Preferences
def get_preference(key)
if !has_preference?(key) && has_attachment?(key)
send key
public_send key
else
super key
end

View File

@@ -177,10 +177,7 @@ Spree::Product.class_eval do
# Get the most recent import_date of a product's variants
def import_date
variants.map do |variant|
next if variant.import_date.blank?
variant.import_date
end.sort.last
variants.map(&:import_date).compact.max
end
# Build a product distribution for each distributor

View File

@@ -3,23 +3,69 @@ class Spree::ProductSet < ModelSet
super(Spree::Product, [], attributes, proc { |attrs| attrs[:product_id].blank? })
end
# A separate method of updating products was required due to an issue with the way Rails' assign_attributes and updates_attributes behave when delegated attributes of a nested
# object are updated via the parent object (ie. price of variants). Updating such attributes by themselves did not work using:
# product.update_attributes( { variants_attributes: [ { id: y, price: xx.x } ] } )
# and so an explicit call to update attributes on each individual variant was required. ie:
# variant.update_attributes( { price: xx.x } )
# A separate method of updating products was required due to an issue with
# the way Rails' assign_attributes and updates_attributes behave when
# delegated attributes of a nested object are updated via the parent object
# (ie. price of variants). Updating such attributes by themselves did not
# work using:
#
# product.update_attributes(variants_attributes: [{ id: y, price: xx.x }])
#
# and so an explicit call to update attributes on each individual variant was
# required. ie:
#
# variant.update_attributes( { price: xx.x } )
#
def update_attributes(attributes)
attributes[:taxon_ids] = attributes[:taxon_ids].split(',') if attributes[:taxon_ids].present?
e = @collection.detect { |e| e.id.to_s == attributes[:id].to_s && !e.id.nil? }
if e.nil?
if attributes[:taxon_ids].present?
attributes[:taxon_ids] = attributes[:taxon_ids].split(',')
end
found_model = @collection.find do |model|
model.id.to_s == attributes[:id].to_s && model.persisted?
end
if found_model.nil?
@klass.new(attributes).save unless @reject_if.andand.call(attributes)
else
( attributes.except(:id, :variants_attributes, :master_attributes).present? ? e.update_attributes(attributes.except(:id, :variants_attributes, :master_attributes)) : true) and
(attributes[:variants_attributes] ? update_variants_attributes(e, attributes[:variants_attributes]) : true ) and
(attributes[:master_attributes] ? update_variant(e, attributes[:master_attributes]) : true )
update_product_only_attributes(found_model, attributes) &&
update_product_variants(found_model, attributes) &&
update_product_master(found_model, attributes)
end
end
def update_product_only_attributes(product, attributes)
variant_related_attrs = [:id, :variants_attributes, :master_attributes]
product_related_attrs = attributes.except(*variant_related_attrs)
return true if product_related_attrs.blank?
product.assign_attributes(product_related_attrs)
product.variants.each do |variant|
validate_presence_of_unit_value(product, variant)
end
product.save if errors.empty?
end
def validate_presence_of_unit_value(product, variant)
return unless %w(weight volume).include?(product.variant_unit)
return if variant.unit_value.present?
product.errors.add(:unit_value, "can't be blank")
end
def update_product_variants(product, attributes)
return true unless attributes[:variants_attributes]
update_variants_attributes(product, attributes[:variants_attributes])
end
def update_product_master(product, attributes)
return true unless attributes[:master_attributes]
update_variant(product, attributes[:master_attributes])
end
def update_variants_attributes(product, variants_attributes)
variants_attributes.each do |attributes|
update_variant(product, attributes)
@@ -27,16 +73,20 @@ class Spree::ProductSet < ModelSet
end
def update_variant(product, variant_attributes)
e = product.variants_including_master.detect { |e| e.id.to_s == variant_attributes[:id].to_s && !e.id.nil? }
if e.present?
e.update_attributes(variant_attributes.except(:id))
found_variant = product.variants_including_master.find do |variant|
variant.id.to_s == variant_attributes[:id].to_s && variant.persisted?
end
if found_variant.present?
found_variant.update_attributes(variant_attributes.except(:id))
else
product.variants.create variant_attributes
product.variants.create(variant_attributes)
end
end
def collection_attributes=(attributes)
@collection = Spree::Product.where( :id => attributes.each_value.map{ |p| p[:id] } )
@collection = Spree::Product
.where(id: attributes.each_value.map { |product| product[:id] })
@collection_hash = attributes
end

Some files were not shown because too many files have changed in this diff Show More