mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-13 18:46:49 +00:00
Compare commits
167 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
165f4f9201 | ||
|
|
0d1740ba4a | ||
|
|
cbb3f202ca | ||
|
|
ff076fd7be | ||
|
|
d30192207b | ||
|
|
19afc1a6da | ||
|
|
4ef682915c | ||
|
|
e693e8ac37 | ||
|
|
07fe8e8390 | ||
|
|
6e58ffa927 | ||
|
|
8a8e612fd3 | ||
|
|
1e8ad4748a | ||
|
|
4c346549f5 | ||
|
|
427e44aee9 | ||
|
|
8dfc62b206 | ||
|
|
ef4a99eadc | ||
|
|
8337e43e64 | ||
|
|
689eb88332 | ||
|
|
698210c849 | ||
|
|
e2087bcc8c | ||
|
|
b066b87141 | ||
|
|
d88a766de4 | ||
|
|
6c7910c8fa | ||
|
|
f83d469833 | ||
|
|
1cea5327e9 | ||
|
|
26c854df5b | ||
|
|
a43ef174f6 | ||
|
|
99f8bf039a | ||
|
|
bdb2c6efb3 | ||
|
|
21512e9722 | ||
|
|
008921c201 | ||
|
|
0882887abe | ||
|
|
0eb4574b37 | ||
|
|
b54edff4cc | ||
|
|
0d6911f41c | ||
|
|
498acaefbc | ||
|
|
585135d27e | ||
|
|
06fabe491d | ||
|
|
052cc2848f | ||
|
|
b5b9d42764 | ||
|
|
d8e2239438 | ||
|
|
403ca3e538 | ||
|
|
ed65c80869 | ||
|
|
ca6ec9ee68 | ||
|
|
04fa4d3587 | ||
|
|
eedbcb6f1e | ||
|
|
61e3798533 | ||
|
|
bca978aacc | ||
|
|
190cb1dede | ||
|
|
9c8c71bd08 | ||
|
|
2b37592280 | ||
|
|
8546e11ffc | ||
|
|
76659d63d8 | ||
|
|
4d9cbf5d16 | ||
|
|
2166791554 | ||
|
|
879e2f5c3a | ||
|
|
471ec2023e | ||
|
|
5026afc011 | ||
|
|
7c9cdccb49 | ||
|
|
179ec6a3e9 | ||
|
|
19fbdb1848 | ||
|
|
c9b53022f2 | ||
|
|
a00b770229 | ||
|
|
16f570b8f7 | ||
|
|
49bd21f29a | ||
|
|
f1c055805f | ||
|
|
5cadb0d16f | ||
|
|
6875e9a41e | ||
|
|
b6f1d6e395 | ||
|
|
14433e7764 | ||
|
|
5fdb86ae43 | ||
|
|
6615469f8b | ||
|
|
d281837dd9 | ||
|
|
7c63e59ae9 | ||
|
|
7c19fe418e | ||
|
|
46d0023018 | ||
|
|
43cf249184 | ||
|
|
537dbd3dc0 | ||
|
|
7c54781d90 | ||
|
|
3b4241c70d | ||
|
|
a290e83501 | ||
|
|
6e0019227b | ||
|
|
7845b6c6fb | ||
|
|
e03e3ae50a | ||
|
|
305d7b1125 | ||
|
|
5ef751d409 | ||
|
|
683232dd10 | ||
|
|
5f1360e226 | ||
|
|
1a5eea3303 | ||
|
|
a1146aed1b | ||
|
|
ab30307b1a | ||
|
|
35b68239b0 | ||
|
|
9e09a3b379 | ||
|
|
77105e265e | ||
|
|
e73f2d682c | ||
|
|
f4d71ae352 | ||
|
|
c2823b3ffe | ||
|
|
c1366fced5 | ||
|
|
170bc94d92 | ||
|
|
2a5403e23f | ||
|
|
dc540444a2 | ||
|
|
ca5ecc4696 | ||
|
|
5082a133a1 | ||
|
|
1f8e0ae637 | ||
|
|
24e66b635b | ||
|
|
891db4b81b | ||
|
|
8a57977b44 | ||
|
|
77e70fd7d3 | ||
|
|
7b5e5f4039 | ||
|
|
ed15bc422e | ||
|
|
030747cff8 | ||
|
|
3e318e5c4e | ||
|
|
3eb4caeb3e | ||
|
|
555ae12b35 | ||
|
|
553d4ebaa0 | ||
|
|
73ee14cc7c | ||
|
|
c9177feb19 | ||
|
|
71ea281424 | ||
|
|
9404aacfb2 | ||
|
|
5e99ecd9cc | ||
|
|
c94713c1ef | ||
|
|
6864c0d3c3 | ||
|
|
5591525160 | ||
|
|
4d00b79d8d | ||
|
|
e3007db324 | ||
|
|
de1d7f2877 | ||
|
|
215f2897f3 | ||
|
|
2d240f23a8 | ||
|
|
f8b0ad29df | ||
|
|
af1eff9427 | ||
|
|
05ddebd78e | ||
|
|
fd6639c7d1 | ||
|
|
314ecf6d90 | ||
|
|
ea8eb0ee14 | ||
|
|
9bb940ae43 | ||
|
|
9e713e449f | ||
|
|
34f4bbe06c | ||
|
|
babe2247a5 | ||
|
|
3295aedeee | ||
|
|
eaaf082572 | ||
|
|
f8803888f2 | ||
|
|
032fbc7348 | ||
|
|
b64633d2d8 | ||
|
|
bc46b2bccb | ||
|
|
fc8bd530e6 | ||
|
|
8e6079ad5b | ||
|
|
f29922312d | ||
|
|
1b8863b63d | ||
|
|
5def2f6f5f | ||
|
|
b5e69c883b | ||
|
|
5f0ad3fd71 | ||
|
|
5095df251e | ||
|
|
75dfde2552 | ||
|
|
10f0906689 | ||
|
|
472aef0904 | ||
|
|
c1f427b0e3 | ||
|
|
c477f8c230 | ||
|
|
04bf5a8742 | ||
|
|
6bc0d505e4 | ||
|
|
9a0f1adfd2 | ||
|
|
1eafb1a3fe | ||
|
|
ec3c3aa644 | ||
|
|
0f128f43f9 | ||
|
|
ea9f3ad6a0 | ||
|
|
e48ac64d37 | ||
|
|
1c257cca3f | ||
|
|
c51e4d657a |
10
.github/ISSUE_TEMPLATE/release-template.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/release-template.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
Draft: x
|
||||
|
||||
Target commit: x
|
||||
|
||||
Build: x
|
||||
|
||||
- [ ] Draft
|
||||
- [ ] Test
|
||||
- [ ] Publish
|
||||
- [ ] Deploy
|
||||
@@ -14,8 +14,7 @@
|
||||
# rubocop > rubo.log
|
||||
# # inspect log file to see which cops are failing
|
||||
# # copy cop configurations and add Exclude parameter
|
||||
# grep ExampleCop rubo.log | cut -d ":" -f 1 | sort -u >> .rubocop.yml
|
||||
# # use vim to add `- ` before each line
|
||||
# grep ExampleCop rubo.log | cut -d ":" -f 1 | sort -u | while read f; do echo " - $f"; done >> .rubocop.yml
|
||||
#
|
||||
# This process probably doesn't need repeating. Otherwise there is plenty
|
||||
# of room for improvements and automation.
|
||||
@@ -26,21 +25,19 @@ Metrics/LineLength:
|
||||
- app/controllers/admin/bulk_line_items_controller.rb
|
||||
- app/controllers/admin/contents_controller.rb
|
||||
- app/controllers/admin/customers_controller.rb
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/admin/enterprise_fees_controller.rb
|
||||
- app/controllers/admin/enterprise_groups_controller.rb
|
||||
- app/controllers/admin/enterprise_relationships_controller.rb
|
||||
- app/controllers/admin/enterprise_roles_controller.rb
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/admin/inventory_items_controller.rb
|
||||
- app/controllers/admin/manager_invitations_controller.rb
|
||||
- app/controllers/admin/order_cycles_controller.rb
|
||||
- app/controllers/admin/product_import_controller.rb
|
||||
- app/controllers/admin/proxy_orders_controller.rb
|
||||
- app/controllers/admin/schedules_controller.rb
|
||||
- app/controllers/admin/subscriptions_controller.rb
|
||||
- app/controllers/admin/variant_overrides_controller.rb
|
||||
- app/controllers/api/enterprise_attachment_controller.rb
|
||||
- app/controllers/api/order_cycles_controller.rb
|
||||
- app/controllers/api/product_images_controller.rb
|
||||
- app/controllers/application_controller.rb
|
||||
- app/controllers/checkout_controller.rb
|
||||
@@ -48,19 +45,14 @@ Metrics/LineLength:
|
||||
- app/controllers/spree/admin/base_controller_decorator.rb
|
||||
- app/controllers/spree/admin/orders_controller_decorator.rb
|
||||
- app/controllers/spree/admin/payments_controller_decorator.rb
|
||||
- app/controllers/spree/admin/payment_methods_controller_decorator.rb
|
||||
- app/controllers/spree/admin/reports_controller_decorator.rb
|
||||
- app/controllers/spree/api/products_controller_decorator.rb
|
||||
- app/controllers/spree/credit_cards_controller.rb
|
||||
- app/controllers/spree/orders_controller_decorator.rb
|
||||
- app/controllers/spree/paypal_controller_decorator.rb
|
||||
- app/controllers/stripe/callbacks_controller.rb
|
||||
- app/helpers/admin/injection_helper.rb
|
||||
- app/helpers/angular_form_builder.rb
|
||||
- app/helpers/angular_form_helper.rb
|
||||
- app/helpers/checkout_helper.rb
|
||||
- app/helpers/enterprises_helper.rb
|
||||
- app/helpers/footer_links_helper.rb
|
||||
- app/helpers/injection_helper.rb
|
||||
- app/helpers/markdown_helper.rb
|
||||
- app/helpers/order_cycles_helper.rb
|
||||
@@ -89,7 +81,6 @@ Metrics/LineLength:
|
||||
- app/models/proxy_order.rb
|
||||
- app/models/schedule.rb
|
||||
- app/models/spree/ability_decorator.rb
|
||||
- app/models/spree/adjustment_decorator.rb
|
||||
- app/models/spree/app_configuration_decorator.rb
|
||||
- app/models/spree/calculator/default_tax_decorator.rb
|
||||
- app/models/spree/classification_decorator.rb
|
||||
@@ -100,16 +91,14 @@ Metrics/LineLength:
|
||||
- app/models/spree/payment_decorator.rb
|
||||
- app/models/spree/payment_method_decorator.rb
|
||||
- app/models/spree/product_decorator.rb
|
||||
- app/models/spree/shipment_decorator.rb
|
||||
- app/models/spree/shipping_method_decorator.rb
|
||||
- app/models/spree/tax_rate_decorator.rb
|
||||
- app/models/spree/taxon_decorator.rb
|
||||
- app/models/spree/user_decorator.rb
|
||||
- app/models/spree/user.rb
|
||||
- app/models/spree/variant_decorator.rb
|
||||
- app/models/subscription.rb
|
||||
- app/models/variant_override.rb
|
||||
- app/models/variant_override_set.rb
|
||||
- app/overrides/add_enterprise_fees_to_admin_configurations_menu.rb
|
||||
- app/services/cart_service.rb
|
||||
- app/services/default_stock_location.rb
|
||||
- app/services/embedded_page_service.rb
|
||||
@@ -117,11 +106,6 @@ Metrics/LineLength:
|
||||
- app/services/order_factory.rb
|
||||
- app/services/subscriptions_count.rb
|
||||
- app/services/variants_stock_levels.rb
|
||||
- app/views/json/_groups.rabl
|
||||
- app/views/json/_producer.rabl
|
||||
- app/views/json/partials/_enterprise.rabl
|
||||
- app/views/spree/api/products/bulk_show.v1.rabl
|
||||
- app/views/spree/api/variants/bulk_show.v1.rabl
|
||||
- engines/web/app/helpers/web/cookies_policy_helper.rb
|
||||
- lib/discourse/single_sign_on.rb
|
||||
- lib/open_food_network/available_payment_method_filter.rb
|
||||
@@ -135,21 +119,16 @@ Metrics/LineLength:
|
||||
- lib/open_food_network/order_and_distributor_report.rb
|
||||
- lib/open_food_network/order_cycle_form_applicator.rb
|
||||
- lib/open_food_network/order_cycle_management_report.rb
|
||||
- lib/open_food_network/order_grouper.rb
|
||||
- lib/open_food_network/payments_report.rb
|
||||
- lib/open_food_network/permalink_generator.rb
|
||||
- lib/open_food_network/products_cache.rb
|
||||
- lib/open_food_network/reports/bulk_coop_allocation_report.rb
|
||||
- lib/open_food_network/reports/line_items.rb
|
||||
- lib/open_food_network/sales_tax_report.rb
|
||||
- lib/open_food_network/users_and_enterprises_report.rb
|
||||
- lib/open_food_network/variant_and_line_item_naming.rb
|
||||
- lib/open_food_network/xero_invoices_report.rb
|
||||
- lib/spree/core/controller_helpers/respond_with_decorator.rb
|
||||
- lib/spree/localized_number.rb
|
||||
- lib/spree/product_filters.rb
|
||||
- lib/stripe/profile_storer.rb
|
||||
- lib/tasks/cache.rake
|
||||
- lib/tasks/data.rake
|
||||
- lib/tasks/enterprises.rake
|
||||
- spec/controllers/admin/bulk_line_items_controller_spec.rb
|
||||
@@ -166,11 +145,15 @@ Metrics/LineLength:
|
||||
- spec/controllers/admin/subscription_line_items_controller_spec.rb
|
||||
- spec/controllers/admin/subscriptions_controller_spec.rb
|
||||
- spec/controllers/admin/variant_overrides_controller_spec.rb
|
||||
- spec/controllers/api/base_controller_spec.rb
|
||||
- spec/controllers/api/logos_controller_spec.rb
|
||||
- spec/controllers/api/order_cycles_controller_spec.rb
|
||||
- spec/controllers/api/orders_controller_spec.rb
|
||||
- spec/controllers/api/product_images_controller_spec.rb
|
||||
- spec/controllers/api/products_controller_spec.rb
|
||||
- spec/controllers/api/promo_images_controller_spec.rb
|
||||
- spec/controllers/api/shipments_controller_spec.rb
|
||||
- spec/controllers/api/variants_controller_spec.rb
|
||||
- spec/controllers/cart_controller_spec.rb
|
||||
- spec/controllers/checkout_controller_spec.rb
|
||||
- spec/controllers/enterprises_controller_spec.rb
|
||||
@@ -183,12 +166,9 @@ Metrics/LineLength:
|
||||
- spec/controllers/spree/admin/orders_controller_spec.rb
|
||||
- spec/controllers/spree/admin/payment_methods_controller_spec.rb
|
||||
- spec/controllers/spree/admin/payments_controller_spec.rb
|
||||
- spec/controllers/spree/admin/products_controller_spec.rb
|
||||
- spec/controllers/spree/admin/reports_controller_spec.rb
|
||||
- spec/controllers/spree/admin/variants_controller_spec.rb
|
||||
- spec/controllers/spree/api/line_items_controller_spec.rb
|
||||
- spec/controllers/spree/api/products_controller_spec.rb
|
||||
- spec/controllers/spree/api/shipments_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
|
||||
@@ -196,7 +176,6 @@ Metrics/LineLength:
|
||||
- spec/controllers/stripe/callbacks_controller_spec.rb
|
||||
- spec/controllers/stripe/webhooks_controller_spec.rb
|
||||
- spec/controllers/user_confirmations_controller_spec.rb
|
||||
- spec/controllers/user_registrations_controller_spec.rb
|
||||
- spec/features/admin/adjustments_spec.rb
|
||||
- spec/features/admin/bulk_order_management_spec.rb
|
||||
- spec/features/admin/bulk_product_update_spec.rb
|
||||
@@ -221,6 +200,7 @@ Metrics/LineLength:
|
||||
- spec/features/admin/shipping_methods_spec.rb
|
||||
- spec/features/admin/subscriptions_spec.rb
|
||||
- spec/features/admin/tag_rules_spec.rb
|
||||
- spec/features/admin/users_spec.rb
|
||||
- spec/features/admin/variant_overrides_spec.rb
|
||||
- spec/features/consumer/account/cards_spec.rb
|
||||
- spec/features/consumer/account/settings_spec.rb
|
||||
@@ -255,7 +235,6 @@ Metrics/LineLength:
|
||||
- spec/lib/open_food_network/customers_report_spec.rb
|
||||
- spec/lib/open_food_network/enterprise_fee_applicator_spec.rb
|
||||
- spec/lib/open_food_network/enterprise_fee_calculator_spec.rb
|
||||
- spec/lib/open_food_network/enterprise_injection_data_spec.rb
|
||||
- spec/lib/open_food_network/group_buy_report_spec.rb
|
||||
- spec/lib/open_food_network/lettuce_share_report_spec.rb
|
||||
- spec/lib/open_food_network/option_value_namer_spec.rb
|
||||
@@ -267,7 +246,6 @@ Metrics/LineLength:
|
||||
- spec/lib/open_food_network/packing_report_spec.rb
|
||||
- spec/lib/open_food_network/permissions_spec.rb
|
||||
- spec/lib/open_food_network/products_and_inventory_report_spec.rb
|
||||
- spec/lib/open_food_network/products_cache_spec.rb
|
||||
- spec/lib/open_food_network/proxy_order_syncer_spec.rb
|
||||
- spec/lib/open_food_network/scope_variant_to_hub_spec.rb
|
||||
- spec/lib/open_food_network/subscription_payment_updater_spec.rb
|
||||
@@ -280,6 +258,7 @@ Metrics/LineLength:
|
||||
- spec/mailers/order_mailer_spec.rb
|
||||
- spec/mailers/producer_mailer_spec.rb
|
||||
- spec/mailers/subscription_mailer_spec.rb
|
||||
- spec/models/calculator/weight_spec.rb
|
||||
- spec/models/column_preference_spec.rb
|
||||
- spec/models/concerns/order_shipment_spec.rb
|
||||
- spec/models/concerns/product_stock_spec.rb
|
||||
@@ -301,11 +280,11 @@ Metrics/LineLength:
|
||||
- spec/models/spree/calculator/price_sack_spec.rb
|
||||
- spec/models/spree/classification_spec.rb
|
||||
- spec/models/spree/gateway/stripe_connect_spec.rb
|
||||
- spec/models/spree/image_spec.rb
|
||||
- spec/models/spree/line_item_spec.rb
|
||||
- spec/models/spree/order_spec.rb
|
||||
- spec/models/spree/payment_method_spec.rb
|
||||
- spec/models/spree/payment_spec.rb
|
||||
- spec/models/spree/product_set_spec.rb
|
||||
- spec/models/spree/product_spec.rb
|
||||
- spec/models/spree/property_spec.rb
|
||||
- spec/models/spree/shipping_method_spec.rb
|
||||
@@ -324,22 +303,24 @@ Metrics/LineLength:
|
||||
- spec/performance/shop_controller_spec.rb
|
||||
- spec/requests/checkout/failed_checkout_spec.rb
|
||||
- spec/requests/embedded_shopfronts_headers_spec.rb
|
||||
- spec/requests/shop_spec.rb
|
||||
- spec/serializers/admin/customer_serializer_spec.rb
|
||||
- spec/serializers/admin/exchange_serializer_spec.rb
|
||||
- spec/serializers/admin/for_order_cycle/enterprise_serializer_spec.rb
|
||||
- spec/serializers/admin/for_order_cycle/supplied_product_serializer_spec.rb
|
||||
- spec/serializers/admin/subscription_customer_serializer_spec.rb
|
||||
- spec/serializers/admin/variant_override_serializer_spec.rb
|
||||
- spec/serializers/api/admin/customer_serializer_spec.rb
|
||||
- spec/serializers/api/admin/exchange_serializer_spec.rb
|
||||
- spec/serializers/api/admin/for_order_cycle/enterprise_serializer_spec.rb
|
||||
- spec/serializers/api/admin/for_order_cycle/supplied_product_serializer_spec.rb
|
||||
- spec/serializers/api/admin/subscription_customer_serializer_spec.rb
|
||||
- spec/serializers/api/admin/variant_override_serializer_spec.rb
|
||||
- spec/serializers/api/current_order_serializer_spec.rb
|
||||
- spec/serializers/api/enterprise_shopfront_serializer_spec.rb
|
||||
- spec/serializers/current_order_serializer_spec.rb
|
||||
- spec/serializers/order_serializer_spec.rb
|
||||
- spec/serializers/api/order_serializer_spec.rb
|
||||
- spec/services/cart_service_spec.rb
|
||||
- spec/services/embedded_page_service_spec.rb
|
||||
- spec/services/order_cycle_distributed_products_spec.rb
|
||||
- spec/services/order_cycle_distributed_variants_spec.rb
|
||||
- spec/services/order_cycle_form_spec.rb
|
||||
- spec/services/order_factory_spec.rb
|
||||
- spec/services/order_syncer_spec.rb
|
||||
- spec/services/product_tag_rules_filterer_spec.rb
|
||||
- spec/services/products_renderer_spec.rb
|
||||
- spec/services/subscription_estimator_spec.rb
|
||||
- spec/services/subscription_form_spec.rb
|
||||
- spec/services/subscription_validator_spec.rb
|
||||
@@ -360,8 +341,8 @@ Metrics/AbcSize:
|
||||
Exclude:
|
||||
- app/controllers/admin/bulk_line_items_controller.rb
|
||||
- app/controllers/admin/customers_controller.rb
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/admin/enterprise_fees_controller.rb
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/admin/order_cycles_controller.rb
|
||||
- app/controllers/admin/product_import_controller.rb
|
||||
- app/controllers/admin/schedules_controller.rb
|
||||
@@ -369,28 +350,36 @@ Metrics/AbcSize:
|
||||
- app/controllers/admin/subscription_line_items_controller.rb
|
||||
- app/controllers/admin/subscriptions_controller.rb
|
||||
- app/controllers/api/enterprises_controller.rb
|
||||
- app/controllers/api/order_cycles_controller.rb
|
||||
- app/controllers/api/product_images_controller.rb
|
||||
- app/controllers/api/products_controller.rb
|
||||
- app/controllers/api/shipments_controller.rb
|
||||
- app/controllers/api/taxons_controller.rb
|
||||
- app/controllers/api/variants_controller.rb
|
||||
- app/controllers/base_controller.rb
|
||||
- app/controllers/cart_controller.rb
|
||||
- app/controllers/checkout_controller.rb
|
||||
- app/controllers/discourse_sso_controller.rb
|
||||
- app/controllers/enterprises_controller.rb
|
||||
- app/controllers/spree/admin/adjustments_controller_decorator.rb
|
||||
- app/controllers/spree/admin/image_settings_controller.rb
|
||||
- app/controllers/spree/admin/orders/customer_details_controller_decorator.rb
|
||||
- app/controllers/spree/admin/orders_controller_decorator.rb
|
||||
- app/controllers/spree/admin/overview_controller_decorator.rb
|
||||
- app/controllers/spree/admin/payment_methods_controller.rb
|
||||
- app/controllers/spree/admin/payments_controller_decorator.rb
|
||||
- app/controllers/spree/admin/payment_methods_controller_decorator.rb
|
||||
- app/controllers/spree/admin/products_controller_decorator.rb
|
||||
- app/controllers/spree/admin/reports_controller_decorator.rb
|
||||
- app/controllers/spree/admin/search_controller_decorator.rb
|
||||
- app/controllers/spree/admin/taxons_controller.rb
|
||||
- app/controllers/spree/admin/users_controller.rb
|
||||
- app/controllers/spree/admin/variants_controller_decorator.rb
|
||||
- app/controllers/spree/api/products_controller_decorator.rb
|
||||
- app/controllers/spree/api/shipments_controller_decorator.rb
|
||||
- app/controllers/spree/checkout_controller.rb
|
||||
- app/controllers/spree/credit_cards_controller.rb
|
||||
- app/controllers/spree/orders_controller_decorator.rb
|
||||
- app/controllers/spree/user_sessions_controller_decorator.rb
|
||||
- app/controllers/spree/orders_controller.rb
|
||||
- app/controllers/spree/user_passwords_controller.rb
|
||||
- app/controllers/spree/user_registrations_controller.rb
|
||||
- app/controllers/spree/user_sessions_controller.rb
|
||||
- app/controllers/spree/users_controller.rb
|
||||
- app/controllers/stripe/callbacks_controller.rb
|
||||
- app/controllers/user_confirmations_controller.rb
|
||||
- app/controllers/user_passwords_controller.rb
|
||||
@@ -398,6 +387,7 @@ Metrics/AbcSize:
|
||||
- app/helpers/checkout_helper.rb
|
||||
- app/helpers/i18n_helper.rb
|
||||
- app/helpers/order_cycles_helper.rb
|
||||
- app/helpers/spree/admin/navigation_helper_decorator.rb
|
||||
- app/helpers/spree/orders_helper.rb
|
||||
- app/jobs/subscription_placement_job.rb
|
||||
- app/mailers/producer_mailer.rb
|
||||
@@ -419,6 +409,7 @@ Metrics/AbcSize:
|
||||
- app/models/spree/product_decorator.rb
|
||||
- app/models/spree/taxon_decorator.rb
|
||||
- app/serializers/api/admin/enterprise_serializer.rb
|
||||
- app/serializers/api/admin/order_cycle_serializer.rb
|
||||
- app/serializers/api/product_serializer.rb
|
||||
- app/serializers/api/variant_serializer.rb
|
||||
- app/services/cart_service.rb
|
||||
@@ -440,24 +431,26 @@ Metrics/AbcSize:
|
||||
- lib/open_food_network/payments_report.rb
|
||||
- lib/open_food_network/permissions.rb
|
||||
- lib/open_food_network/products_and_inventory_report.rb
|
||||
- lib/open_food_network/rack_request_blocker.rb
|
||||
- lib/open_food_network/reports/line_items.rb
|
||||
- lib/open_food_network/sales_tax_report.rb
|
||||
- lib/open_food_network/users_and_enterprises_report.rb
|
||||
- lib/open_food_network/variant_and_line_item_naming.rb
|
||||
- lib/open_food_network/xero_invoices_report.rb
|
||||
- lib/spree/api/controller_setup.rb
|
||||
- lib/spree/core/controller_helpers/respond_with_decorator.rb
|
||||
- lib/spree/localized_number.rb
|
||||
- lib/stripe/account_connector.rb
|
||||
- lib/tasks/enterprises.rake
|
||||
- lib/tasks/sample_data/product_factory.rb
|
||||
- spec/controllers/spree/api/shipments_controller_spec.rb
|
||||
- spec/features/admin/product_import_spec.rb
|
||||
- spec/features/admin/reports_spec.rb
|
||||
- spec/features/admin/subscriptions_spec.rb
|
||||
- spec/features/consumer/shopping/checkout_spec.rb
|
||||
- spec/features/consumer/shopping/checkout_paypal_spec.rb
|
||||
- spec/features/consumer/shopping/variant_overrides_spec.rb
|
||||
- spec/models/enterprise_spec.rb
|
||||
- spec/models/product_importer_spec.rb
|
||||
- spec/services/restart_checkout_spec.rb
|
||||
- spec/support/performance_helper.rb
|
||||
|
||||
Metrics/BlockLength:
|
||||
@@ -477,8 +470,14 @@ Metrics/BlockLength:
|
||||
]
|
||||
Exclude:
|
||||
- lib/tasks/data.rake
|
||||
- lib/tasks/dev.rake
|
||||
- spec/controllers/spree/admin/invoices_controller_spec.rb
|
||||
- spec/factories.rb
|
||||
- spec/factories/enterprise_factory.rb
|
||||
- spec/factories/order_cycle_factory.rb
|
||||
- spec/factories/order_factory.rb
|
||||
- spec/factories/product_factory.rb
|
||||
- spec/factories/shipping_method_factory.rb
|
||||
- spec/factories/subscription_factory.rb
|
||||
- spec/factories/variant_factory.rb
|
||||
- spec/features/admin/orders_spec.rb
|
||||
- spec/features/consumer/shopping/embedded_shopfronts_spec.rb
|
||||
@@ -492,11 +491,12 @@ Metrics/BlockLength:
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 6
|
||||
Exclude:
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/admin/enterprise_fees_controller.rb
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/checkout_controller.rb
|
||||
- app/controllers/spree/admin/payments_controller_decorator.rb
|
||||
- app/controllers/spree/orders_controller_decorator.rb
|
||||
- app/controllers/spree/admin/taxons_controller.rb
|
||||
- app/controllers/spree/orders_controller.rb
|
||||
- app/helpers/checkout_helper.rb
|
||||
- app/helpers/i18n_helper.rb
|
||||
- app/helpers/order_cycles_helper.rb
|
||||
@@ -522,9 +522,11 @@ Metrics/PerceivedComplexity:
|
||||
Max: 7
|
||||
Exclude:
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/api/variants_controller.rb
|
||||
- app/controllers/checkout_controller.rb
|
||||
- app/controllers/spree/admin/payments_controller_decorator.rb
|
||||
- app/controllers/spree/orders_controller_decorator.rb
|
||||
- app/controllers/spree/admin/taxons_controller.rb
|
||||
- app/controllers/spree/orders_controller.rb
|
||||
- app/helpers/checkout_helper.rb
|
||||
- app/helpers/i18n_helper.rb
|
||||
- app/helpers/order_cycles_helper.rb
|
||||
@@ -546,25 +548,34 @@ Metrics/MethodLength:
|
||||
Max: 10
|
||||
Exclude:
|
||||
- app/controllers/admin/customers_controller.rb
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/admin/enterprise_fees_controller.rb
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/admin/manager_invitations_controller.rb
|
||||
- app/controllers/admin/order_cycles_controller.rb
|
||||
- app/controllers/admin/stripe_accounts_controller.rb
|
||||
- app/controllers/admin/subscriptions_controller.rb
|
||||
- app/controllers/api/products_controller.rb
|
||||
- app/controllers/api/shipments_controller.rb
|
||||
- app/controllers/api/taxons_controller.rb
|
||||
- app/controllers/api/variants_controller.rb
|
||||
- app/controllers/base_controller.rb
|
||||
- app/controllers/cart_controller.rb
|
||||
- app/controllers/checkout_controller.rb
|
||||
- app/controllers/shop_controller.rb
|
||||
- app/controllers/spree/admin/image_settings_controller.rb
|
||||
- app/controllers/spree/admin/orders/customer_details_controller_decorator.rb
|
||||
- app/controllers/spree/admin/payment_methods_controller.rb
|
||||
- app/controllers/spree/admin/payments_controller_decorator.rb
|
||||
- app/controllers/spree/admin/payment_methods_controller_decorator.rb
|
||||
- app/controllers/spree/admin/products_controller_decorator.rb
|
||||
- app/controllers/spree/admin/reports_controller_decorator.rb
|
||||
- app/controllers/spree/admin/search_controller_decorator.rb
|
||||
- app/controllers/spree/admin/tax_categories_controller.rb
|
||||
- app/controllers/spree/admin/taxons_controller.rb
|
||||
- app/controllers/spree/admin/users_controller.rb
|
||||
- app/controllers/spree/credit_cards_controller.rb
|
||||
- app/controllers/spree/orders_controller_decorator.rb
|
||||
- app/controllers/spree/user_sessions_controller_decorator.rb
|
||||
- app/controllers/spree/orders_controller.rb
|
||||
- app/controllers/spree/user_registrations_controller.rb
|
||||
- app/controllers/spree/user_sessions_controller.rb
|
||||
- app/controllers/stripe/callbacks_controller.rb
|
||||
- app/controllers/user_confirmations_controller.rb
|
||||
- app/controllers/user_passwords_controller.rb
|
||||
@@ -617,11 +628,12 @@ Metrics/MethodLength:
|
||||
- lib/open_food_network/sales_tax_report.rb
|
||||
- lib/open_food_network/users_and_enterprises_report.rb
|
||||
- lib/open_food_network/xero_invoices_report.rb
|
||||
- lib/spree/api/controller_setup.rb
|
||||
- lib/spree/core/controller_helpers/respond_with_decorator.rb
|
||||
- lib/spree/localized_number.rb
|
||||
- lib/stripe/profile_storer.rb
|
||||
- lib/tasks/sample_data/product_factory.rb
|
||||
- spec/features/consumer/shopping/checkout_spec.rb
|
||||
- spec/features/consumer/shopping/checkout_paypal_spec.rb
|
||||
- spec/features/consumer/shopping/variant_overrides_spec.rb
|
||||
- spec/models/product_importer_spec.rb
|
||||
- spec/support/request/authentication_workflow.rb
|
||||
@@ -632,13 +644,18 @@ Metrics/ClassLength:
|
||||
- app/controllers/admin/enterprises_controller.rb
|
||||
- app/controllers/admin/order_cycles_controller.rb
|
||||
- app/controllers/admin/subscriptions_controller.rb
|
||||
- app/controllers/api/products_controller.rb
|
||||
- app/controllers/checkout_controller.rb
|
||||
- app/controllers/spree/admin/payment_methods_controller.rb
|
||||
- app/controllers/spree/admin/users_controller.rb
|
||||
- app/controllers/spree/orders_controller.rb
|
||||
- app/models/enterprise.rb
|
||||
- app/models/order_cycle.rb
|
||||
- app/models/product_import/entry_processor.rb
|
||||
- app/models/product_import/entry_validator.rb
|
||||
- app/models/product_import/product_importer.rb
|
||||
- app/models/spree/ability_decorator.rb
|
||||
- app/models/spree/user.rb
|
||||
- app/serializers/api/cached_enterprise_serializer.rb
|
||||
- app/serializers/api/enterprise_shopfront_serializer.rb
|
||||
- app/services/cart_service.rb
|
||||
@@ -651,18 +668,20 @@ Metrics/ClassLength:
|
||||
- lib/open_food_network/packing_report.rb
|
||||
- lib/open_food_network/payments_report.rb
|
||||
- lib/open_food_network/permissions.rb
|
||||
- lib/open_food_network/products_cache.rb
|
||||
- lib/open_food_network/users_and_enterprises_report.rb
|
||||
- lib/open_food_network/xero_invoices_report.rb
|
||||
|
||||
Metrics/ModuleLength:
|
||||
Max: 100
|
||||
Exclude:
|
||||
- app/helpers/admin/injection_helper.rb
|
||||
- app/helpers/injection_helper.rb
|
||||
- lib/open_food_network/column_preference_defaults.rb
|
||||
- spec/controllers/admin/enterprises_controller_spec.rb
|
||||
- spec/controllers/admin/order_cycles_controller_spec.rb
|
||||
- spec/controllers/api/order_cycles_controller_spec.rb
|
||||
- spec/controllers/api/orders_controller_spec.rb
|
||||
- spec/controllers/spree/api/products_controller_spec.rb
|
||||
- spec/controllers/spree/admin/payment_methods_controller_spec.rb
|
||||
- spec/lib/open_food_network/address_finder_spec.rb
|
||||
- spec/lib/open_food_network/customers_report_spec.rb
|
||||
- spec/lib/open_food_network/enterprise_fee_calculator_spec.rb
|
||||
@@ -672,7 +691,6 @@ Metrics/ModuleLength:
|
||||
- spec/lib/open_food_network/order_grouper_spec.rb
|
||||
- spec/lib/open_food_network/permissions_spec.rb
|
||||
- spec/lib/open_food_network/products_and_inventory_report_spec.rb
|
||||
- spec/lib/open_food_network/products_cache_spec.rb
|
||||
- spec/lib/open_food_network/proxy_order_syncer_spec.rb
|
||||
- spec/lib/open_food_network/scope_variant_to_hub_spec.rb
|
||||
- spec/lib/open_food_network/subscription_payment_updater_spec.rb
|
||||
@@ -691,6 +709,5 @@ Metrics/ParameterLists:
|
||||
Exclude:
|
||||
- app/helpers/angular_form_builder.rb
|
||||
- app/models/product_import/entry_processor.rb
|
||||
- app/models/product_import/entry_validator.rb
|
||||
- lib/open_food_network/xero_invoices_report.rb
|
||||
- spec/features/admin/reports_spec.rb
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
# rubocop locally, the default configuration file `.rubocop.yml` loads
|
||||
# our "todo lists" to ignore all current violations.
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.1
|
||||
TargetRubyVersion: 2.2
|
||||
TargetRailsVersion: 3.2
|
||||
Exclude:
|
||||
- 'bin/**/*'
|
||||
- 'db/**/*'
|
||||
- 'config/**/*'
|
||||
- 'script/**/*'
|
||||
|
||||
@@ -1,37 +1,11 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --exclude-limit 1400`
|
||||
# on 2019-07-23 14:09:18 +0100 using RuboCop version 0.57.2.
|
||||
# on 2019-11-10 18:40:51 +0000 using RuboCop version 0.68.1.
|
||||
# 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: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
||||
# SupportedStylesAlignWith: start_of_line, def
|
||||
Layout/DefEndAlignment:
|
||||
Exclude:
|
||||
- 'app/models/order_updater.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
||||
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
||||
Layout/EndAlignment:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/order_cycles_controller.rb'
|
||||
- 'app/controllers/api/order_cycles_controller.rb'
|
||||
- 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb'
|
||||
- 'app/serializers/api/admin/order_cycle_serializer.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: IndentationWidth.
|
||||
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
||||
Layout/IndentHash:
|
||||
EnforcedStyle: consistent
|
||||
|
||||
# Offense count: 4
|
||||
Lint/AmbiguousOperator:
|
||||
Exclude:
|
||||
@@ -46,10 +20,16 @@ Lint/DuplicateMethods:
|
||||
- 'lib/discourse/single_sign_on.rb'
|
||||
- 'lib/open_food_network/subscription_summary.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Offense count: 1
|
||||
Lint/DuplicatedKey:
|
||||
Exclude:
|
||||
- 'spec/models/calculator/weight_spec.rb'
|
||||
|
||||
# Offense count: 10
|
||||
Lint/IneffectiveAccessModifier:
|
||||
Exclude:
|
||||
- 'app/models/column_preference.rb'
|
||||
- 'app/models/spree/user.rb'
|
||||
- 'app/services/mail_configuration.rb'
|
||||
- 'lib/open_food_network/feature_toggle.rb'
|
||||
- 'spec/lib/open_food_network/reports/report_spec.rb'
|
||||
@@ -66,16 +46,11 @@ Lint/ShadowingOuterLocalVariable:
|
||||
- 'spec/models/model_set_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: AllowKeywordBlockArguments.
|
||||
Lint/UnderscorePrefixedVariableName:
|
||||
Exclude:
|
||||
- 'spec/support/cancan_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Lint/UnneededCopDisableDirective:
|
||||
Exclude:
|
||||
- 'app/models/product_import/entry_validator.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
|
||||
Lint/UselessAccessModifier:
|
||||
@@ -86,51 +61,21 @@ Lint/UselessAccessModifier:
|
||||
- 'lib/open_food_network/reports/bulk_coop_report.rb'
|
||||
- 'spec/lib/open_food_network/reports/report_spec.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Offense count: 1
|
||||
# Configuration parameters: CheckForMethodsWithNoSideEffects.
|
||||
Lint/Void:
|
||||
Exclude:
|
||||
- 'app/serializers/api/enterprise_serializer.rb'
|
||||
- 'spec/features/admin/bulk_product_update_spec.rb'
|
||||
- 'spec/features/consumer/shopping/checkout_spec.rb'
|
||||
- 'spec/features/consumer/shopping/shopping_spec.rb'
|
||||
- 'spec/features/consumer/shopping/variant_overrides_spec.rb'
|
||||
|
||||
# Offense count: 15
|
||||
Metrics/AbcSize:
|
||||
Max: 36
|
||||
|
||||
# Offense count: 13
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
Metrics/BlockLength:
|
||||
Max: 115
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ClassLength:
|
||||
Max: 169
|
||||
|
||||
# Offense count: 1
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 8
|
||||
|
||||
# Offense count: 8
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/MethodLength:
|
||||
Max: 31
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ModuleLength:
|
||||
Max: 208
|
||||
Max: 141
|
||||
|
||||
# Offense count: 2
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 11
|
||||
|
||||
# Offense count: 7
|
||||
# Offense count: 8
|
||||
Naming/AccessorMethodName:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/taxonomies_controller.rb'
|
||||
- 'app/models/spree/adjustment_decorator.rb'
|
||||
- 'app/models/spree/order_decorator.rb'
|
||||
- 'spec/support/request/shop_workflow.rb'
|
||||
@@ -144,6 +89,8 @@ Naming/HeredocDelimiterNaming:
|
||||
- 'app/models/content_configuration.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
||||
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
|
||||
Naming/MemoizedInstanceVariableName:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/payments_controller_decorator.rb'
|
||||
@@ -176,12 +123,11 @@ Naming/PredicateName:
|
||||
- 'lib/open_food_network/packing_report.rb'
|
||||
- 'lib/tasks/data.rake'
|
||||
|
||||
# Offense count: 11
|
||||
# Offense count: 8
|
||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||
# AllowedNames: io, id, to, by, on, in, at
|
||||
# AllowedNames: io, id, to, by, on, in, at, ip, db
|
||||
Naming/UncommunicativeMethodParamName:
|
||||
Exclude:
|
||||
- 'app/helpers/admin/injection_helper.rb'
|
||||
- 'app/helpers/spree/admin/base_helper_decorator.rb'
|
||||
- 'app/helpers/spree/base_helper_decorator.rb'
|
||||
- 'app/services/subscription_validator.rb'
|
||||
@@ -190,25 +136,6 @@ Naming/UncommunicativeMethodParamName:
|
||||
- 'spec/lib/open_food_network/reports/report_spec.rb'
|
||||
- 'spec/mailers/producer_mailer_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: snake_case, camelCase
|
||||
Naming/VariableName:
|
||||
Exclude:
|
||||
- 'app/helpers/admin/injection_helper.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: snake_case, normalcase, non_integer
|
||||
Naming/VariableNumber:
|
||||
Exclude:
|
||||
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Performance/Caller:
|
||||
Exclude:
|
||||
- 'app/controllers/application_controller.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: strict, flexible
|
||||
@@ -216,7 +143,7 @@ Rails/Date:
|
||||
Exclude:
|
||||
- 'app/models/order_cycle.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Offense count: 7
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: slashes, arguments
|
||||
Rails/FilePath:
|
||||
@@ -225,7 +152,6 @@ Rails/FilePath:
|
||||
- 'spec/features/admin/bulk_product_update_spec.rb'
|
||||
- 'spec/features/admin/content_spec.rb'
|
||||
- 'spec/models/content_configuration_spec.rb'
|
||||
- 'spec/models/spree/image_spec.rb'
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
- 'spec/spec_helper.rb'
|
||||
|
||||
@@ -241,7 +167,7 @@ Rails/HasAndBelongsToMany:
|
||||
- 'app/models/spree/concerns/payment_method_distributors.rb'
|
||||
- 'app/models/spree/line_item_decorator.rb'
|
||||
|
||||
# Offense count: 25
|
||||
# Offense count: 26
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/HasManyOrHasOneDependent:
|
||||
@@ -254,7 +180,7 @@ Rails/HasManyOrHasOneDependent:
|
||||
- 'app/models/spree/payment_method_decorator.rb'
|
||||
- 'app/models/spree/property_decorator.rb'
|
||||
- 'app/models/spree/shipping_method_decorator.rb'
|
||||
- 'app/models/spree/user_decorator.rb'
|
||||
- 'app/models/spree/user.rb'
|
||||
- 'app/models/spree/variant_decorator.rb'
|
||||
- 'app/models/subscription.rb'
|
||||
|
||||
@@ -268,20 +194,13 @@ Rails/OutputSafety:
|
||||
- 'lib/spree/money_decorator.rb'
|
||||
- 'spec/features/admin/orders_spec.rb'
|
||||
|
||||
# Offense count: 15
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: strict, flexible
|
||||
Rails/TimeZone:
|
||||
# Offense count: 9
|
||||
Rails/ReflectionClassName:
|
||||
Exclude:
|
||||
- 'app/controllers/api/statuses_controller.rb'
|
||||
- 'app/jobs/heartbeat_job.rb'
|
||||
- 'lib/open_food_network/rack_request_blocker.rb'
|
||||
- 'lib/open_food_network/users_and_enterprises_report.rb'
|
||||
- 'spec/controllers/api/statuses_controller_spec.rb'
|
||||
- 'spec/jobs/heartbeat_job_spec.rb'
|
||||
- 'spec/lib/open_food_network/products_cache_refreshment_spec.rb'
|
||||
- 'spec/lib/open_food_network/products_cache_spec.rb'
|
||||
- 'spec/models/enterprise_relationship_spec.rb'
|
||||
- 'app/models/customer.rb'
|
||||
- 'app/models/distributor_shipping_method.rb'
|
||||
- 'app/models/enterprise_role.rb'
|
||||
- 'app/models/subscription.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: Environments.
|
||||
@@ -290,21 +209,13 @@ Rails/UnknownEnv:
|
||||
Exclude:
|
||||
- 'app/models/spree/app_configuration_decorator.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: braces, no_braces, context_dependent
|
||||
Style/BracesAroundHashParameters:
|
||||
Exclude:
|
||||
- 'spec/spec_helper.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Style/CaseEquality:
|
||||
Exclude:
|
||||
- 'app/helpers/angular_form_helper.rb'
|
||||
- 'spec/models/spree/payment_spec.rb'
|
||||
|
||||
# Offense count: 78
|
||||
# Offense count: 76
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
||||
# SupportedStyles: nested, compact
|
||||
@@ -394,26 +305,13 @@ Style/CommentedKeyword:
|
||||
Exclude:
|
||||
- 'app/controllers/application_controller.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
||||
# SupportedStyles: assign_to_condition, assign_inside_condition
|
||||
Style/ConditionalAssignment:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/api/products_controller.rb'
|
||||
- 'app/controllers/spree/api/taxons_controller.rb'
|
||||
- 'app/controllers/spree/api/variants_controller.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Style/DateTime:
|
||||
Exclude:
|
||||
- 'lib/open_food_network/users_and_enterprises_report.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/EachWithObject:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/api/base_controller.rb'
|
||||
- 'app/controllers/api/taxons_controller.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
@@ -424,7 +322,7 @@ Style/FormatStringToken:
|
||||
- 'lib/open_food_network/sales_tax_report.rb'
|
||||
- 'spec/models/enterprise_spec.rb'
|
||||
|
||||
# Offense count: 68
|
||||
# Offense count: 61
|
||||
# Configuration parameters: MinBodyLength.
|
||||
Style/GuardClause:
|
||||
Exclude:
|
||||
@@ -438,27 +336,22 @@ Style/GuardClause:
|
||||
- 'app/controllers/spree/admin/adjustments_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/base_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/orders_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/products_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/resource_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/variants_controller_decorator.rb'
|
||||
- 'app/controllers/spree/api/base_controller.rb'
|
||||
- 'app/controllers/spree/checkout_controller.rb'
|
||||
- 'app/controllers/spree/orders_controller.rb'
|
||||
- 'app/controllers/spree/paypal_controller_decorator.rb'
|
||||
- 'app/jobs/products_cache_integrity_checker_job.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_group.rb'
|
||||
- 'app/models/producer_property.rb'
|
||||
- 'app/models/spree/classification_decorator.rb'
|
||||
- 'app/models/spree/order_decorator.rb'
|
||||
- 'app/models/spree/preference_decorator.rb'
|
||||
- 'app/models/spree/price_decorator.rb'
|
||||
- 'app/models/spree/product_decorator.rb'
|
||||
- 'app/models/spree/user_decorator.rb'
|
||||
- 'app/services/advance_order_service.rb'
|
||||
- 'app/services/order_syncer.rb'
|
||||
- 'lib/discourse/single_sign_on.rb'
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.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'
|
||||
- 'lib/spree/core/controller_helpers/order_decorator.rb'
|
||||
@@ -467,23 +360,13 @@ Style/GuardClause:
|
||||
- 'spec/support/request/distribution_helper.rb'
|
||||
- 'spec/support/request/shop_workflow.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
||||
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
||||
Style/HashSyntax:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/api/base_controller.rb'
|
||||
- 'app/controllers/spree/checkout_controller.rb'
|
||||
- 'app/controllers/spree/orders_controller.rb'
|
||||
|
||||
# Offense count: 4
|
||||
Style/IfInsideElse:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/column_preferences_controller.rb'
|
||||
- 'app/controllers/admin/variant_overrides_controller.rb'
|
||||
- 'app/controllers/api/taxons_controller.rb'
|
||||
- 'app/controllers/spree/admin/products_controller_decorator.rb'
|
||||
- 'app/controllers/spree/api/taxons_controller.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Style/MissingRespondToMissing:
|
||||
@@ -499,15 +382,14 @@ Style/MixinUsage:
|
||||
- 'spec/lib/open_food_network/order_cycle_management_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/packing_report_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Style/NestedTernaryOperator:
|
||||
# Offense count: 1
|
||||
Style/MultipleComparison:
|
||||
Exclude:
|
||||
- 'app/views/spree/api/products/bulk_show.v1.rabl'
|
||||
- 'app/views/spree/api/variants/bulk_show.v1.rabl'
|
||||
- 'spec/models/product_importer_spec.rb'
|
||||
|
||||
# Offense count: 10
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
||||
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
||||
# SupportedStyles: predicate, comparison
|
||||
Style/NumericPredicate:
|
||||
Exclude:
|
||||
@@ -516,34 +398,17 @@ Style/NumericPredicate:
|
||||
- 'app/models/spree/calculator/flexi_rate_decorator.rb'
|
||||
- 'app/models/spree/line_item_decorator.rb'
|
||||
- 'app/models/spree/order_decorator.rb'
|
||||
- 'lib/open_food_network/integrity_checker.rb'
|
||||
- 'lib/open_food_network/rack_request_blocker.rb'
|
||||
- 'lib/open_food_network/xero_invoices_report.rb'
|
||||
- 'lib/spree/money_decorator.rb'
|
||||
|
||||
# Offense count: 15
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
||||
# SupportedStyles: slashes, percent_r, mixed
|
||||
Style/RegexpLiteral:
|
||||
Exclude:
|
||||
- 'app/helpers/groups_helper.rb'
|
||||
- 'app/helpers/html_helper.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- '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: 244
|
||||
# Offense count: 235
|
||||
Style/Send:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/checkout_controller.rb'
|
||||
- 'app/models/spree/shipping_method_decorator.rb'
|
||||
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
|
||||
- 'spec/controllers/checkout_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/base_controller_spec.rb'
|
||||
- 'spec/controllers/spree/orders_controller_spec.rb'
|
||||
- 'spec/helpers/order_cycles_helper_spec.rb'
|
||||
@@ -557,20 +422,18 @@ Style/Send:
|
||||
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/permissions_spec.rb'
|
||||
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/products_cache_spec.rb'
|
||||
- 'spec/lib/open_food_network/products_renderer_spec.rb'
|
||||
- 'spec/lib/open_food_network/sales_tax_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/subscription_payment_updater_spec.rb'
|
||||
- 'spec/lib/open_food_network/subscription_summarizer_spec.rb'
|
||||
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/xero_invoices_report_spec.rb'
|
||||
- 'spec/lib/stripe/webhook_handler_spec.rb'
|
||||
- 'spec/models/calculator/weight_spec.rb'
|
||||
- 'spec/models/enterprise_spec.rb'
|
||||
- 'spec/models/exchange_spec.rb'
|
||||
- 'spec/models/spree/gateway/stripe_connect_spec.rb'
|
||||
- 'spec/models/spree/order_spec.rb'
|
||||
- 'spec/models/spree/payment_spec.rb'
|
||||
- 'spec/models/spree/preference_spec.rb'
|
||||
- 'spec/models/spree/tax_rate_spec.rb'
|
||||
- 'spec/models/tag_rule/discount_order_spec.rb'
|
||||
- 'spec/models/tag_rule/filter_order_cycles_spec.rb'
|
||||
@@ -578,6 +441,7 @@ Style/Send:
|
||||
- 'spec/models/tag_rule/filter_products_spec.rb'
|
||||
- 'spec/models/tag_rule/filter_shipping_methods_spec.rb'
|
||||
- 'spec/services/cart_service_spec.rb'
|
||||
- 'spec/services/products_renderer_spec.rb'
|
||||
- 'spec/spec_helper.rb'
|
||||
- 'spec/support/localized_number_helper.rb'
|
||||
- 'spec/support/matchers/delegate_matchers.rb'
|
||||
@@ -586,9 +450,3 @@ Style/Send:
|
||||
Style/StructInheritance:
|
||||
Exclude:
|
||||
- 'lib/open_food_network/enterprise_fee_applicator.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/UnlessElse:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/api/variants_controller.rb'
|
||||
|
||||
9
Gemfile
9
Gemfile
@@ -3,7 +3,7 @@ ruby "2.2.10"
|
||||
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
|
||||
|
||||
gem 'i18n', '~> 0.6.11'
|
||||
gem 'i18n-js', '~> 3.4.1'
|
||||
gem 'i18n-js', '~> 3.5.0'
|
||||
gem 'rails', '~> 3.2.22'
|
||||
gem 'rails-i18n', '~> 3.0.0'
|
||||
gem 'rails_safe_tasks', '~> 1.0'
|
||||
@@ -84,7 +84,7 @@ gem 'paper_trail', '~> 5.2.3'
|
||||
gem 'paperclip', '~> 3.4.1'
|
||||
gem 'rack-rewrite'
|
||||
gem 'rack-ssl', require: 'rack/ssl'
|
||||
gem 'roadie-rails', '~> 1.1.1'
|
||||
gem 'roadie-rails', '~> 1.3.0'
|
||||
gem 'spinjs-rails'
|
||||
|
||||
gem 'combine_pdf'
|
||||
@@ -98,7 +98,7 @@ gem 'roo-xls', '~> 1.1.0'
|
||||
|
||||
gem 'whenever', require: false
|
||||
|
||||
gem 'test-unit', '~> 3.0'
|
||||
gem 'test-unit', '~> 3.3'
|
||||
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
@@ -161,7 +161,6 @@ end
|
||||
group :development do
|
||||
gem 'byebug', '~> 9.0.0' # 9.1 requires ruby 2.2
|
||||
gem 'debugger-linecache'
|
||||
gem 'listen', '3.0.8' # 3.1.0 requires ruby 2.2
|
||||
gem "newrelic_rpm", "~> 3.0"
|
||||
gem 'pry-byebug', '>= 3.4.3'
|
||||
gem 'rubocop', '>= 0.49.1'
|
||||
@@ -173,5 +172,5 @@ group :development do
|
||||
# greater than 1.0.9, so we just required the latest available version here.
|
||||
gem 'eventmachine', '>= 1.2.3'
|
||||
|
||||
gem 'rack-mini-profiler', '< 1.0.0'
|
||||
gem 'rack-mini-profiler', '< 2.0.0'
|
||||
end
|
||||
|
||||
46
Gemfile.lock
46
Gemfile.lock
@@ -216,7 +216,7 @@ GEM
|
||||
connection_pool (2.2.2)
|
||||
crack (0.4.3)
|
||||
safe_yaml (~> 1.0.0)
|
||||
css_parser (1.6.0)
|
||||
css_parser (1.7.0)
|
||||
addressable
|
||||
daemons (1.3.1)
|
||||
dalli (2.7.10)
|
||||
@@ -439,12 +439,12 @@ GEM
|
||||
httparty (0.16.2)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (0.6.11)
|
||||
i18n-js (3.4.1)
|
||||
i18n-js (3.5.0)
|
||||
i18n (>= 0.6.6)
|
||||
immigrant (0.3.6)
|
||||
activerecord (>= 3.0)
|
||||
ipaddress (0.8.3)
|
||||
jaro_winkler (1.5.1)
|
||||
jaro_winkler (1.5.4)
|
||||
journey (1.0.4)
|
||||
jquery-migrate-rails (1.2.1)
|
||||
jquery-rails (3.0.4)
|
||||
@@ -468,9 +468,6 @@ GEM
|
||||
letter_opener (1.7.0)
|
||||
launchy (~> 2.2)
|
||||
libv8 (6.3.292.48.1)
|
||||
listen (3.0.8)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
mail (2.5.5)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
@@ -485,7 +482,7 @@ GEM
|
||||
money (5.1.1)
|
||||
i18n (~> 0.6.0)
|
||||
msgpack (1.3.1)
|
||||
multi_json (1.13.1)
|
||||
multi_json (1.14.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
net-http-persistent (3.1.0)
|
||||
@@ -510,10 +507,10 @@ GEM
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (~> 0.5.0)
|
||||
mime-types
|
||||
parallel (1.11.2)
|
||||
parallel (1.18.0)
|
||||
paranoia (1.3.4)
|
||||
activerecord (~> 3.1)
|
||||
parser (2.5.1.0)
|
||||
parser (2.6.5.0)
|
||||
ast (~> 2.4.0)
|
||||
paypal-sdk-core (0.2.10)
|
||||
multi_json (~> 1.0)
|
||||
@@ -525,7 +522,6 @@ GEM
|
||||
activerecord (~> 3.0)
|
||||
polyglot (0.3.5)
|
||||
power_assert (1.1.5)
|
||||
powerpack (0.1.1)
|
||||
pry (0.12.2)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.9.0)
|
||||
@@ -538,7 +534,7 @@ GEM
|
||||
rack (1.4.7)
|
||||
rack-cache (1.9.0)
|
||||
rack (>= 0.4)
|
||||
rack-mini-profiler (0.10.7)
|
||||
rack-mini-profiler (1.0.0)
|
||||
rack (>= 1.2.0)
|
||||
rack-protection (1.5.5)
|
||||
rack
|
||||
@@ -568,7 +564,7 @@ GEM
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
raindrops (0.19.0)
|
||||
rake (12.3.3)
|
||||
rake (13.0.0)
|
||||
ransack (0.7.2)
|
||||
actionpack (~> 3.0)
|
||||
activerecord (~> 3.0)
|
||||
@@ -589,8 +585,8 @@ GEM
|
||||
roadie (3.4.0)
|
||||
css_parser (~> 1.4)
|
||||
nokogiri (~> 1.5)
|
||||
roadie-rails (1.1.1)
|
||||
railties (>= 3.0, < 5.1)
|
||||
roadie-rails (1.3.0)
|
||||
railties (>= 3.0, < 5.3)
|
||||
roadie (~> 3.1)
|
||||
roo (2.7.1)
|
||||
nokogiri (~> 1)
|
||||
@@ -622,14 +618,13 @@ GEM
|
||||
rspec-retry (0.6.1)
|
||||
rspec-core (> 3.3)
|
||||
rspec-support (3.9.0)
|
||||
rubocop (0.57.2)
|
||||
rubocop (0.68.1)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.5)
|
||||
powerpack (~> 0.1)
|
||||
parser (>= 2.5, != 2.5.1.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
unicode-display_width (>= 1.4.0, < 1.6)
|
||||
ruby-ole (1.2.12.1)
|
||||
ruby-progressbar (1.10.1)
|
||||
ruby-rc4 (0.1.5)
|
||||
@@ -674,7 +669,7 @@ GEM
|
||||
stripe (4.24.0)
|
||||
faraday (~> 0.13)
|
||||
net-http-persistent (~> 3.0)
|
||||
test-unit (3.3.3)
|
||||
test-unit (3.3.4)
|
||||
power_assert
|
||||
thor (0.20.3)
|
||||
tilt (1.4.1)
|
||||
@@ -690,7 +685,7 @@ GEM
|
||||
tzinfo (0.3.55)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode-display_width (1.3.2)
|
||||
unicode-display_width (1.5.0)
|
||||
unicorn (5.5.1)
|
||||
kgio (~> 2.6)
|
||||
raindrops (~> 0.7)
|
||||
@@ -715,7 +710,7 @@ GEM
|
||||
whenever (0.11.0)
|
||||
chronic (>= 0.6.3)
|
||||
wicked_pdf (1.1.0)
|
||||
wkhtmltopdf-binary (0.12.4)
|
||||
wkhtmltopdf-binary (0.12.5)
|
||||
xml-simple (1.1.5)
|
||||
xpath (2.1.0)
|
||||
nokogiri (~> 1.3)
|
||||
@@ -768,7 +763,7 @@ DEPENDENCIES
|
||||
gmaps4rails
|
||||
haml
|
||||
i18n (~> 0.6.11)
|
||||
i18n-js (~> 3.4.1)
|
||||
i18n-js (~> 3.5.0)
|
||||
immigrant
|
||||
jquery-migrate-rails
|
||||
jquery-rails (= 3.0.4)
|
||||
@@ -778,7 +773,6 @@ DEPENDENCIES
|
||||
knapsack
|
||||
letter_opener (>= 1.4.1)
|
||||
libv8 (= 6.3.292.48.1)
|
||||
listen (= 3.0.8)
|
||||
mini_racer (= 0.1.15)
|
||||
momentjs-rails
|
||||
newrelic_rpm (~> 3.0)
|
||||
@@ -792,14 +786,14 @@ DEPENDENCIES
|
||||
pg (~> 0.21.0)
|
||||
pry-byebug (>= 3.4.3)
|
||||
rabl
|
||||
rack-mini-profiler (< 1.0.0)
|
||||
rack-mini-profiler (< 2.0.0)
|
||||
rack-rewrite
|
||||
rack-ssl
|
||||
rails (~> 3.2.22)
|
||||
rails-i18n (~> 3.0.0)
|
||||
rails_safe_tasks (~> 1.0)
|
||||
redcarpet
|
||||
roadie-rails (~> 1.1.1)
|
||||
roadie-rails (~> 1.3.0)
|
||||
roo (~> 2.7.0)
|
||||
roo-xls (~> 1.1.0)
|
||||
rspec-rails (>= 3.5.2)
|
||||
@@ -819,7 +813,7 @@ DEPENDENCIES
|
||||
spring (= 1.7.2)
|
||||
spring-commands-rspec
|
||||
stripe
|
||||
test-unit (~> 3.0)
|
||||
test-unit (~> 3.3)
|
||||
timecop
|
||||
truncate_html
|
||||
turbo-sprockets-rails3
|
||||
|
||||
@@ -1,92 +1,12 @@
|
||||
angular.module('admin.orderCycles')
|
||||
.controller 'AdminCreateOrderCycleCtrl', ($scope, $filter, $window, OrderCycle, Enterprise, EnterpriseFee, Schedules, RequestMonitor, ocInstance, StatusMessage) ->
|
||||
$scope.enterprises = Enterprise.index(coordinator_id: ocInstance.coordinator_id)
|
||||
$scope.supplier_enterprises = Enterprise.producer_enterprises
|
||||
$scope.distributor_enterprises = Enterprise.hub_enterprises
|
||||
$scope.supplied_products = Enterprise.supplied_products
|
||||
$scope.enterprise_fees = EnterpriseFee.index(coordinator_id: ocInstance.coordinator_id)
|
||||
$scope.schedules = Schedules.index({enterprise_id: ocInstance.coordinator_id})
|
||||
.controller 'AdminCreateOrderCycleCtrl', ($scope, $controller, $filter, $window, OrderCycle, Enterprise, EnterpriseFee, Schedules, RequestMonitor, ocInstance, StatusMessage) ->
|
||||
$controller('AdminOrderCycleBasicCtrl', {$scope: $scope, ocInstance: ocInstance})
|
||||
|
||||
$scope.OrderCycle = OrderCycle
|
||||
$scope.order_cycle = OrderCycle.new({ coordinator_id: ocInstance.coordinator_id})
|
||||
|
||||
$scope.StatusMessage = StatusMessage
|
||||
|
||||
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
|
||||
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
|
||||
|
||||
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
|
||||
StatusMessage.setValidation(isValid)
|
||||
|
||||
$scope.loaded = ->
|
||||
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded && !RequestMonitor.loading
|
||||
|
||||
$scope.suppliedVariants = (enterprise_id) ->
|
||||
Enterprise.suppliedVariants(enterprise_id)
|
||||
|
||||
$scope.exchangeSelectedVariants = (exchange) ->
|
||||
OrderCycle.exchangeSelectedVariants(exchange)
|
||||
|
||||
$scope.setExchangeVariants = (exchange, variants, selected) ->
|
||||
OrderCycle.setExchangeVariants(exchange, variants, selected)
|
||||
|
||||
$scope.enterpriseTotalVariants = (enterprise) ->
|
||||
Enterprise.totalVariants(enterprise)
|
||||
|
||||
$scope.productSuppliedToOrderCycle = (product) ->
|
||||
OrderCycle.productSuppliedToOrderCycle(product)
|
||||
|
||||
$scope.variantSuppliedToOrderCycle = (variant) ->
|
||||
OrderCycle.variantSuppliedToOrderCycle(variant)
|
||||
|
||||
$scope.incomingExchangeVariantsFor = (enterprise_id) ->
|
||||
$filter('filterExchangeVariants')(OrderCycle.incomingExchangesVariants(), $scope.order_cycle.visible_variants_for_outgoing_exchanges[enterprise_id])
|
||||
|
||||
$scope.exchangeDirection = (exchange) ->
|
||||
OrderCycle.exchangeDirection(exchange)
|
||||
|
||||
$scope.enterprisesWithFees = ->
|
||||
$scope.enterprises[id] for id in OrderCycle.participatingEnterpriseIds() when $scope.enterpriseFeesForEnterprise(id).length > 0
|
||||
|
||||
$scope.enterpriseFeesForEnterprise = (enterprise_id) ->
|
||||
EnterpriseFee.forEnterprise(parseInt(enterprise_id))
|
||||
|
||||
$scope.addSupplier = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addSupplier($scope.new_supplier_id)
|
||||
|
||||
$scope.addDistributor = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addDistributor($scope.new_distributor_id)
|
||||
|
||||
$scope.removeExchange = ($event, exchange) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeExchange(exchange)
|
||||
$scope.order_cycle_form.$dirty = true
|
||||
|
||||
$scope.addCoordinatorFee = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
$scope.removeCoordinatorFee = ($event, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeCoordinatorFee(index)
|
||||
|
||||
$scope.addExchangeFee = ($event, exchange) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addExchangeFee(exchange)
|
||||
|
||||
$scope.removeExchangeFee = ($event, exchange, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeExchangeFee(exchange, index)
|
||||
|
||||
$scope.removeDistributionOfVariant = (variant_id) ->
|
||||
OrderCycle.removeDistributionOfVariant(variant_id)
|
||||
$scope.enterprises = Enterprise.index(coordinator_id: ocInstance.coordinator_id)
|
||||
$scope.enterprise_fees = EnterpriseFee.index(coordinator_id: ocInstance.coordinator_id)
|
||||
|
||||
$scope.submit = ($event, destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
OrderCycle.create(destination)
|
||||
|
||||
$scope.cancel = (destination) ->
|
||||
$window.location = destination
|
||||
|
||||
@@ -1,91 +1,17 @@
|
||||
angular.module('admin.orderCycles')
|
||||
.controller 'AdminEditOrderCycleCtrl', ($scope, $filter, $location, $window, OrderCycle, Enterprise, EnterpriseFee, StatusMessage, Schedules, RequestMonitor, ocInstance) ->
|
||||
.controller 'AdminEditOrderCycleCtrl', ($scope, $controller, $filter, $location, $window, OrderCycle, Enterprise, EnterpriseFee, StatusMessage, Schedules, RequestMonitor, ocInstance) ->
|
||||
$controller('AdminOrderCycleBasicCtrl', {$scope: $scope, ocInstance: ocInstance})
|
||||
|
||||
order_cycle_id = $location.absUrl().match(/\/admin\/order_cycles\/(\d+)/)[1]
|
||||
$scope.enterprises = Enterprise.index(order_cycle_id: order_cycle_id)
|
||||
$scope.supplier_enterprises = Enterprise.producer_enterprises
|
||||
$scope.distributor_enterprises = Enterprise.hub_enterprises
|
||||
$scope.supplied_products = Enterprise.supplied_products
|
||||
$scope.enterprise_fees = EnterpriseFee.index(order_cycle_id: order_cycle_id)
|
||||
$scope.schedules = Schedules.index({enterprise_id: ocInstance.coordinator_id})
|
||||
|
||||
$scope.OrderCycle = OrderCycle
|
||||
$scope.order_cycle = OrderCycle.load(order_cycle_id)
|
||||
|
||||
$scope.StatusMessage = StatusMessage
|
||||
|
||||
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
|
||||
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
|
||||
|
||||
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
|
||||
StatusMessage.setValidation(isValid)
|
||||
|
||||
$scope.loaded = ->
|
||||
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded && !RequestMonitor.loading
|
||||
|
||||
$scope.suppliedVariants = (enterprise_id) ->
|
||||
Enterprise.suppliedVariants(enterprise_id)
|
||||
|
||||
$scope.exchangeSelectedVariants = (exchange) ->
|
||||
OrderCycle.exchangeSelectedVariants(exchange)
|
||||
|
||||
$scope.setExchangeVariants = (exchange, variants, selected) ->
|
||||
OrderCycle.setExchangeVariants(exchange, variants, selected)
|
||||
|
||||
$scope.enterpriseTotalVariants = (enterprise) ->
|
||||
Enterprise.totalVariants(enterprise)
|
||||
|
||||
$scope.productSuppliedToOrderCycle = (product) ->
|
||||
OrderCycle.productSuppliedToOrderCycle(product)
|
||||
|
||||
$scope.variantSuppliedToOrderCycle = (variant) ->
|
||||
OrderCycle.variantSuppliedToOrderCycle(variant)
|
||||
|
||||
$scope.incomingExchangeVariantsFor = (enterprise_id) ->
|
||||
$filter('filterExchangeVariants')(OrderCycle.incomingExchangesVariants(), $scope.order_cycle.visible_variants_for_outgoing_exchanges[enterprise_id])
|
||||
|
||||
$scope.exchangeDirection = (exchange) ->
|
||||
OrderCycle.exchangeDirection(exchange)
|
||||
|
||||
$scope.enterprisesWithFees = ->
|
||||
$scope.enterprises[id] for id in OrderCycle.participatingEnterpriseIds() when $scope.enterpriseFeesForEnterprise(id).length > 0
|
||||
|
||||
$scope.enterpriseFeesForEnterprise = (enterprise_id) ->
|
||||
EnterpriseFee.forEnterprise(parseInt(enterprise_id))
|
||||
|
||||
$scope.addSupplier = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addSupplier($scope.new_supplier_id)
|
||||
|
||||
$scope.addDistributor = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addDistributor($scope.new_distributor_id)
|
||||
|
||||
$scope.removeExchange = ($event, exchange) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeExchange(exchange)
|
||||
$scope.order_cycle_form.$dirty = true
|
||||
|
||||
$scope.addCoordinatorFee = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
$scope.enterprises = Enterprise.index(order_cycle_id: order_cycle_id)
|
||||
$scope.enterprise_fees = EnterpriseFee.index(order_cycle_id: order_cycle_id)
|
||||
|
||||
$scope.removeCoordinatorFee = ($event, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeCoordinatorFee(index)
|
||||
$scope.order_cycle_form.$dirty = true
|
||||
|
||||
$scope.addExchangeFee = ($event, exchange) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addExchangeFee(exchange)
|
||||
|
||||
$scope.removeExchangeFee = ($event, exchange, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeExchangeFee(exchange, index)
|
||||
$scope.order_cycle_form.$dirty = true
|
||||
|
||||
$scope.removeDistributionOfVariant = (variant_id) ->
|
||||
OrderCycle.removeDistributionOfVariant(variant_id)
|
||||
|
||||
$scope.submit = (destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
@@ -94,6 +20,3 @@ angular.module('admin.orderCycles')
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
OrderCycle.update(destination, $scope.order_cycle_form)
|
||||
|
||||
$scope.cancel = (destination) ->
|
||||
$window.location = destination
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
angular.module('admin.orderCycles').controller 'AdminOrderCycleIncomingCtrl', ($scope, $controller, $location, Enterprise, ocInstance) ->
|
||||
$controller('AdminOrderCycleExchangesCtrl', {$scope: $scope, ocInstance: ocInstance, $location: $location})
|
||||
|
||||
$scope.enterpriseTotalVariants = (enterprise) ->
|
||||
Enterprise.totalVariants(enterprise)
|
||||
@@ -0,0 +1,40 @@
|
||||
angular.module('admin.orderCycles')
|
||||
.controller 'AdminOrderCycleBasicCtrl', ($scope, $filter, $window, OrderCycle, Enterprise, EnterpriseFee, Schedules, RequestMonitor, ocInstance, StatusMessage) ->
|
||||
$scope.StatusMessage = StatusMessage
|
||||
$scope.OrderCycle = OrderCycle
|
||||
|
||||
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
|
||||
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
|
||||
|
||||
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
|
||||
StatusMessage.setValidation(isValid)
|
||||
|
||||
$scope.loaded = ->
|
||||
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded && !RequestMonitor.loading
|
||||
|
||||
$scope.enterpriseFeesForEnterprise = (enterprise_id) ->
|
||||
EnterpriseFee.forEnterprise(parseInt(enterprise_id))
|
||||
|
||||
$scope.cancel = (destination) ->
|
||||
$window.location = destination
|
||||
|
||||
# Used in panels/exchange_supplied_products.html
|
||||
$scope.suppliedVariants = (enterprise_id) ->
|
||||
Enterprise.suppliedVariants(enterprise_id)
|
||||
|
||||
# Used in panels/exchange_supplied_products.html and panels/exchange_distributed_products.html
|
||||
$scope.setExchangeVariants = (exchange, variants, selected) ->
|
||||
OrderCycle.setExchangeVariants(exchange, variants, selected)
|
||||
|
||||
# The following methods are specific to the general settings pages:
|
||||
# - simple create, simple edit and general settings pages
|
||||
|
||||
$scope.schedules = Schedules.index({enterprise_id: ocInstance.coordinator_id})
|
||||
|
||||
$scope.addCoordinatorFee = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
$scope.removeCoordinatorFee = ($event, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeCoordinatorFee(index)
|
||||
@@ -0,0 +1,46 @@
|
||||
angular.module('admin.orderCycles')
|
||||
.controller 'AdminOrderCycleExchangesCtrl', ($scope, $controller, $filter, $window, $location, $timeout, OrderCycle, Enterprise, EnterpriseFee, Schedules, RequestMonitor, ocInstance, StatusMessage) ->
|
||||
$controller('AdminEditOrderCycleCtrl', {$scope: $scope, ocInstance: ocInstance, $location: $location})
|
||||
|
||||
$scope.supplier_enterprises = Enterprise.producer_enterprises
|
||||
$scope.distributor_enterprises = Enterprise.hub_enterprises
|
||||
$scope.supplied_products = Enterprise.supplied_products
|
||||
|
||||
$scope.exchangeSelectedVariants = (exchange) ->
|
||||
OrderCycle.exchangeSelectedVariants(exchange)
|
||||
|
||||
$scope.exchangeDirection = (exchange) ->
|
||||
OrderCycle.exchangeDirection(exchange)
|
||||
|
||||
$scope.enterprisesWithFees = ->
|
||||
$scope.enterprises[id] for id in OrderCycle.participatingEnterpriseIds() when $scope.enterpriseFeesForEnterprise(id).length > 0
|
||||
|
||||
$scope.removeExchange = ($event, exchange) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeExchange(exchange)
|
||||
$scope.order_cycle_form.$dirty = true
|
||||
|
||||
$scope.addExchangeFee = ($event, exchange) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addExchangeFee(exchange)
|
||||
|
||||
$scope.removeExchangeFee = ($event, exchange, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeExchangeFee(exchange, index)
|
||||
$scope.order_cycle_form.$dirty = true
|
||||
|
||||
$scope.addSupplier = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addSupplier($scope.new_supplier_id)
|
||||
|
||||
$scope.addDistributor = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addDistributor($scope.new_distributor_id)
|
||||
|
||||
$scope.setPickupTimeFieldDirty = (index) ->
|
||||
$timeout ->
|
||||
pickup_time_field_name = "order_cycle_outgoing_exchange_" + index + "_pickup_time"
|
||||
$scope.order_cycle_form[pickup_time_field_name].$setDirty()
|
||||
|
||||
$scope.removeDistributionOfVariant = (variant_id) ->
|
||||
OrderCycle.removeDistributionOfVariant(variant_id)
|
||||
@@ -0,0 +1,16 @@
|
||||
angular.module('admin.orderCycles').controller 'AdminOrderCycleOutgoingCtrl', ($scope, $controller, $filter, $location, OrderCycle, ocInstance, StatusMessage) ->
|
||||
$controller('AdminOrderCycleExchangesCtrl', {$scope: $scope, ocInstance: ocInstance, $location: $location})
|
||||
|
||||
$scope.productSuppliedToOrderCycle = (product) ->
|
||||
OrderCycle.productSuppliedToOrderCycle(product)
|
||||
|
||||
$scope.variantSuppliedToOrderCycle = (variant) ->
|
||||
OrderCycle.variantSuppliedToOrderCycle(variant)
|
||||
|
||||
$scope.incomingExchangeVariantsFor = (enterprise_id) ->
|
||||
$filter('filterExchangeVariants')(OrderCycle.incomingExchangesVariants(), $scope.order_cycle.visible_variants_for_outgoing_exchanges[enterprise_id])
|
||||
|
||||
$scope.submit = ($event, destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
OrderCycle.update(destination, $scope.order_cycle_form) if OrderCycle.confirmNoDistributors()
|
||||
@@ -1,19 +1,12 @@
|
||||
angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl", ($scope, $window, OrderCycle, Enterprise, EnterpriseFee, StatusMessage, Schedules, RequestMonitor, ocInstance) ->
|
||||
$scope.StatusMessage = StatusMessage
|
||||
$scope.OrderCycle = OrderCycle
|
||||
$scope.schedules = Schedules.index({enterprise_id: ocInstance.coordinator_id})
|
||||
angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl", ($scope, $controller, $window, OrderCycle, Enterprise, EnterpriseFee, StatusMessage, Schedules, RequestMonitor, ocInstance) ->
|
||||
$controller('AdminOrderCycleBasicCtrl', {$scope: $scope, ocInstance: ocInstance})
|
||||
|
||||
$scope.order_cycle = OrderCycle.new {coordinator_id: ocInstance.coordinator_id}, =>
|
||||
# TODO: make this a get method, which only fetches one enterprise
|
||||
$scope.enterprises = Enterprise.index {coordinator_id: ocInstance.coordinator_id}, (enterprises) =>
|
||||
$scope.init(enterprises)
|
||||
$scope.enterprise_fees = EnterpriseFee.index(coordinator_id: ocInstance.coordinator_id)
|
||||
|
||||
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
|
||||
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
|
||||
|
||||
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
|
||||
StatusMessage.setValidation(isValid)
|
||||
|
||||
$scope.init = (enterprises) ->
|
||||
enterprise = enterprises[Object.keys(enterprises)[0]]
|
||||
OrderCycle.addSupplier enterprise.id
|
||||
@@ -26,33 +19,10 @@ angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl"
|
||||
|
||||
OrderCycle.order_cycle.coordinator_id = enterprise.id
|
||||
|
||||
$scope.loaded = ->
|
||||
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded && !RequestMonitor.loading
|
||||
|
||||
$scope.removeDistributionOfVariant = angular.noop
|
||||
|
||||
$scope.setExchangeVariants = (exchange, variants, selected) ->
|
||||
OrderCycle.setExchangeVariants(exchange, variants, selected)
|
||||
|
||||
$scope.suppliedVariants = (enterprise_id) ->
|
||||
Enterprise.suppliedVariants(enterprise_id)
|
||||
|
||||
$scope.addCoordinatorFee = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
$scope.removeCoordinatorFee = ($event, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeCoordinatorFee(index)
|
||||
|
||||
$scope.enterpriseFeesForEnterprise = (enterprise_id) ->
|
||||
EnterpriseFee.forEnterprise(parseInt(enterprise_id))
|
||||
|
||||
$scope.submit = ($event, destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
OrderCycle.mirrorIncomingToOutgoingProducts()
|
||||
OrderCycle.create(destination)
|
||||
|
||||
$scope.cancel = (destination) ->
|
||||
$window.location = destination
|
||||
OrderCycle.create(destination) if OrderCycle.confirmNoDistributors()
|
||||
|
||||
@@ -1,51 +1,21 @@
|
||||
angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl", ($scope, $location, $window, OrderCycle, Enterprise, EnterpriseFee, Schedules, RequestMonitor, StatusMessage, ocInstance) ->
|
||||
angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl", ($scope, $controller, $location, $window, OrderCycle, Enterprise, EnterpriseFee, Schedules, RequestMonitor, StatusMessage, ocInstance) ->
|
||||
$controller('AdminOrderCycleBasicCtrl', {$scope: $scope, ocInstance: ocInstance})
|
||||
|
||||
$scope.orderCycleId = ->
|
||||
$location.absUrl().match(/\/admin\/order_cycles\/(\d+)/)[1]
|
||||
|
||||
$scope.StatusMessage = StatusMessage
|
||||
$scope.enterprises = Enterprise.index(order_cycle_id: $scope.orderCycleId())
|
||||
$scope.enterprise_fees = EnterpriseFee.index(order_cycle_id: $scope.orderCycleId())
|
||||
$scope.schedules = Schedules.index({enterprise_id: ocInstance.coordinator_id})
|
||||
$scope.OrderCycle = OrderCycle
|
||||
$scope.order_cycle = OrderCycle.load $scope.orderCycleId(), (order_cycle) =>
|
||||
$scope.init()
|
||||
|
||||
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
|
||||
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
|
||||
|
||||
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
|
||||
StatusMessage.setValidation(isValid)
|
||||
|
||||
$scope.loaded = ->
|
||||
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded && !RequestMonitor.loading
|
||||
|
||||
$scope.init = ->
|
||||
$scope.outgoing_exchange = OrderCycle.order_cycle.outgoing_exchanges[0]
|
||||
|
||||
$scope.enterpriseFeesForEnterprise = (enterprise_id) ->
|
||||
EnterpriseFee.forEnterprise(parseInt(enterprise_id))
|
||||
|
||||
$scope.removeDistributionOfVariant = angular.noop
|
||||
|
||||
$scope.setExchangeVariants = (exchange, variants, selected) ->
|
||||
OrderCycle.setExchangeVariants(exchange, variants, selected)
|
||||
|
||||
$scope.suppliedVariants = (enterprise_id) ->
|
||||
Enterprise.suppliedVariants(enterprise_id)
|
||||
|
||||
$scope.addCoordinatorFee = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
$scope.removeCoordinatorFee = ($event, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeCoordinatorFee(index)
|
||||
|
||||
$scope.submit = ($event, destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
OrderCycle.mirrorIncomingToOutgoingProducts()
|
||||
OrderCycle.update(destination, $scope.order_cycle_form)
|
||||
|
||||
$scope.cancel = (destination) ->
|
||||
$window.location = destination
|
||||
OrderCycle.update(destination, $scope.order_cycle_form) if OrderCycle.confirmNoDistributors()
|
||||
|
||||
@@ -148,10 +148,12 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
|
||||
this.order_cycle
|
||||
|
||||
create: (destination) ->
|
||||
return unless @confirmNoDistributors()
|
||||
oc = new OrderCycleResource({order_cycle: this.dataForSubmit()})
|
||||
oc.$create (data) ->
|
||||
$window.location = destination
|
||||
if destination? && destination.length != 0
|
||||
$window.location = destination
|
||||
else if data.edit_path?
|
||||
$window.location = data.edit_path
|
||||
, (response) ->
|
||||
if response.data.errors?
|
||||
StatusMessage.display('failure', response.data.errors[0])
|
||||
@@ -159,7 +161,6 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
|
||||
StatusMessage.display('failure', t('js.order_cycles.create_failure'))
|
||||
|
||||
update: (destination, form) ->
|
||||
return unless @confirmNoDistributors()
|
||||
oc = new OrderCycleResource({order_cycle: this.dataForSubmit()})
|
||||
oc.$update {order_cycle_id: this.order_cycle.id, reloading: (if destination? then 1 else 0)}, (data) =>
|
||||
form.$setPristine() if form
|
||||
@@ -173,7 +174,6 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
|
||||
else
|
||||
StatusMessage.display('failure', t('js.order_cycles.update_failure'))
|
||||
|
||||
|
||||
confirmNoDistributors: ->
|
||||
if @order_cycle.outgoing_exchanges.length == 0
|
||||
confirm t('js.order_cycles.no_distributors')
|
||||
|
||||
@@ -13,31 +13,11 @@
|
||||
-# No need to scope product list based on permissions, because if an incoming exchange is visible,
|
||||
-# then all of the variants within it should be visible. May change in the future?
|
||||
.exchange-product{'ng-repeat' => 'product in enterprises[exchange.enterprise_id].supplied_products'}
|
||||
|
||||
.exchange-product-details
|
||||
%label
|
||||
%input{ type: 'checkbox', name: 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
value: 1,
|
||||
'ng-hide' => 'product.variants.length > 0',
|
||||
'ng-model' => 'exchange.variants[product.master_id]',
|
||||
'ofn-sync-distributions' => '{{ product.master_id }}',
|
||||
'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
'ng-disabled' => 'product.variants.length > 0 || !order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(product.master_id) < 0' }
|
||||
%img{'ng-src' => '{{ product.image_url }}'}
|
||||
{{ product.name }}
|
||||
|
||||
-# When the master variant is in the order cycle but the product has variants, we want to
|
||||
-# be able to remove the master variant, since it serves no purpose. Display a checkbox to do so.
|
||||
.exchange-product-variant{'ng-show' => 'exchange.variants[product.master_id] && product.variants.length > 0'}
|
||||
%label
|
||||
%input{ type: 'checkbox', name: 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
value: 1,
|
||||
'ng-model' => 'exchange.variants[product.master_id]',
|
||||
'ofn-sync-distributions' => '{{ product.master_id }}',
|
||||
'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
'ng-disabled' => '!order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(product.master_id) < 0' }
|
||||
{{ 'admin.obsolete_master' | t }}
|
||||
|
||||
.exchange-product-variant{'ng-repeat' => 'variant in product.variants'}
|
||||
%label
|
||||
%input{ type: 'checkbox', name: 'order_cycle_incoming_exchange_{{ $parent.$parent.$index }}_variants_{{ variant.id }}',
|
||||
|
||||
@@ -19,6 +19,9 @@ ul.wizard-progress {
|
||||
line-height: 30px;
|
||||
padding: 0 25px 0 40px;
|
||||
position: relative;
|
||||
a {
|
||||
color: #494949;
|
||||
}
|
||||
&:first-child {
|
||||
padding-left: 25px;
|
||||
border-top-left-radius: 3px;
|
||||
@@ -62,6 +65,9 @@ ul.wizard-progress {
|
||||
&.current {
|
||||
background-color: $color_selected;
|
||||
color: #fff;
|
||||
a {
|
||||
color: #fff;
|
||||
}
|
||||
&:after {
|
||||
background-color: $color_selected;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,17 @@ module Admin
|
||||
#
|
||||
def index
|
||||
order_params = params[:q].andand.delete :order
|
||||
orders = OpenFoodNetwork::Permissions.new(spree_current_user).editable_orders.ransack(order_params).result
|
||||
line_items = OpenFoodNetwork::Permissions.new(spree_current_user).editable_line_items.where(order_id: orders).ransack(params[:q])
|
||||
render_as_json line_items.result.reorder('order_id ASC, id ASC')
|
||||
|
||||
orders = OpenFoodNetwork::Permissions.new(spree_current_user).
|
||||
editable_orders.ransack(order_params).result
|
||||
|
||||
line_items = OpenFoodNetwork::Permissions.new(spree_current_user).
|
||||
editable_line_items.where(order_id: orders).
|
||||
includes(variant: { option_values: :option_type }).
|
||||
ransack(params[:q]).result.
|
||||
reorder('spree_line_items.order_id ASC, spree_line_items.id ASC')
|
||||
|
||||
render_as_json line_items
|
||||
end
|
||||
|
||||
# PUT /admin/bulk_line_items/:id.json
|
||||
|
||||
@@ -63,6 +63,7 @@ module Admin
|
||||
|
||||
def collection
|
||||
return Customer.where("1=0") unless json_request? && params[:enterprise_id].present?
|
||||
|
||||
enterprise = Enterprise.managed_by(spree_current_user).find_by_id(params[:enterprise_id])
|
||||
Customer.of(enterprise)
|
||||
end
|
||||
|
||||
@@ -148,7 +148,8 @@ module Admin
|
||||
|
||||
unless enterprises.empty?
|
||||
enterprises.includes(
|
||||
supplied_products: [:supplier, :variants, master: [:images]]
|
||||
supplied_products:
|
||||
[:supplier, master: [:images], variants: { option_values: :option_type }]
|
||||
)
|
||||
end
|
||||
when :index
|
||||
|
||||
@@ -2,6 +2,7 @@ module Admin
|
||||
class OrderCyclesController < ResourceController
|
||||
include OrderCyclesHelper
|
||||
|
||||
prepend_before_filter :set_order_cycle_id, only: [:incoming, :outgoing]
|
||||
before_filter :load_data_for_index, only: :index
|
||||
before_filter :require_coordinator, only: :new
|
||||
before_filter :remove_protected_attrs, only: [:update]
|
||||
@@ -12,7 +13,10 @@ module Admin
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json do
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix], current_user: spree_current_user, subscriptions_count: SubscriptionsCount.new(@collection)
|
||||
render_as_json @collection,
|
||||
ams_prefix: params[:ams_prefix],
|
||||
current_user: spree_current_user,
|
||||
subscriptions_count: SubscriptionsCount.new(@collection)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -40,12 +44,17 @@ module Admin
|
||||
|
||||
if @order_cycle_form.save
|
||||
flash[:notice] = I18n.t(:order_cycles_create_notice)
|
||||
render json: { success: true }
|
||||
render json: { success: true,
|
||||
edit_path: main_app.admin_order_cycle_incoming_path(@order_cycle) }
|
||||
else
|
||||
render json: { errors: @order_cycle.errors.full_messages }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def set_order_cycle_id
|
||||
params[:id] = params[:order_cycle_id]
|
||||
end
|
||||
|
||||
def update
|
||||
@order_cycle_form = OrderCycleForm.new(@order_cycle, params, spree_current_user)
|
||||
|
||||
@@ -62,7 +71,10 @@ module Admin
|
||||
|
||||
def bulk_update
|
||||
if order_cycle_set.andand.save
|
||||
render_as_json @order_cycles, ams_prefix: 'index', current_user: spree_current_user, subscriptions_count: SubscriptionsCount.new(@collection)
|
||||
render_as_json @order_cycles,
|
||||
ams_prefix: 'index',
|
||||
current_user: spree_current_user,
|
||||
subscriptions_count: SubscriptionsCount.new(@collection)
|
||||
else
|
||||
order_cycle = order_cycle_set.collection.find{ |oc| oc.errors.present? }
|
||||
render json: { errors: order_cycle.errors.full_messages }, status: :unprocessable_entity
|
||||
@@ -72,14 +84,16 @@ module Admin
|
||||
def clone
|
||||
@order_cycle = OrderCycle.find params[:id]
|
||||
@order_cycle.clone!
|
||||
redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_clone_notice, name: @order_cycle.name)
|
||||
redirect_to main_app.admin_order_cycles_path,
|
||||
notice: I18n.t(:order_cycles_clone_notice, name: @order_cycle.name)
|
||||
end
|
||||
|
||||
# Send notifications to all producers who are part of the order cycle
|
||||
def notify_producers
|
||||
Delayed::Job.enqueue OrderCycleNotificationJob.new(params[:id].to_i)
|
||||
|
||||
redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_email_to_producers_notice)
|
||||
redirect_to main_app.admin_order_cycles_path,
|
||||
notice: I18n.t(:order_cycles_email_to_producers_notice)
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -87,20 +101,9 @@ module Admin
|
||||
def collection
|
||||
return Enterprise.where("1=0") unless json_request?
|
||||
return order_cycles_from_set if params[:order_cycle_set]
|
||||
ocs = if params[:as] == "distributor"
|
||||
OrderCycle.preload(:schedules).ransack(params[:q]).result.
|
||||
involving_managed_distributors_of(spree_current_user).order('updated_at DESC')
|
||||
elsif params[:as] == "producer"
|
||||
OrderCycle.preload(:schedules).ransack(params[:q]).result.
|
||||
involving_managed_producers_of(spree_current_user).order('updated_at DESC')
|
||||
else
|
||||
OrderCycle.preload(:schedules).ransack(params[:q]).result.accessible_by(spree_current_user)
|
||||
end
|
||||
|
||||
ocs.undated |
|
||||
ocs.soonest_closing |
|
||||
ocs.soonest_opening |
|
||||
ocs.closed
|
||||
ocs = order_cycles
|
||||
ocs.undated | ocs.soonest_closing | ocs.soonest_opening | ocs.closed
|
||||
end
|
||||
|
||||
def collection_actions
|
||||
@@ -109,21 +112,60 @@ module Admin
|
||||
|
||||
private
|
||||
|
||||
def order_cycles
|
||||
if params[:as] == "distributor"
|
||||
order_cycles_as_distributor
|
||||
elsif params[:as] == "producer"
|
||||
order_cycles_as_producer
|
||||
else
|
||||
order_cycles_as_both
|
||||
end
|
||||
end
|
||||
|
||||
def order_cycles_as_distributor
|
||||
OrderCycle.
|
||||
preload(:schedules).
|
||||
ransack(params[:q]).
|
||||
result.
|
||||
involving_managed_distributors_of(spree_current_user).
|
||||
order('updated_at DESC')
|
||||
end
|
||||
|
||||
def order_cycles_as_producer
|
||||
OrderCycle.
|
||||
preload(:schedules).
|
||||
ransack(params[:q]).
|
||||
result.
|
||||
involving_managed_producers_of(spree_current_user).
|
||||
order('updated_at DESC')
|
||||
end
|
||||
|
||||
def order_cycles_as_both
|
||||
OrderCycle.
|
||||
preload(:schedules).
|
||||
ransack(params[:q]).
|
||||
result.
|
||||
accessible_by(spree_current_user)
|
||||
end
|
||||
|
||||
def load_data_for_index
|
||||
if json_request?
|
||||
# Split ransack params into all those that currently exist and new ones to limit returned ocs to recent or undated
|
||||
# Split ransack params into all those that currently exist and new ones
|
||||
# to limit returned ocs to recent or undated
|
||||
orders_close_at_gt = params[:q].andand.delete(:orders_close_at_gt) || 31.days.ago
|
||||
params[:q] = {
|
||||
g: [params.delete(:q) || {}, { m: 'or', orders_close_at_gt: orders_close_at_gt, orders_close_at_null: true }]
|
||||
g: [params.delete(:q) || {}, { m: 'or',
|
||||
orders_close_at_gt: orders_close_at_gt,
|
||||
orders_close_at_null: true }]
|
||||
}
|
||||
@collection = collection
|
||||
end
|
||||
end
|
||||
|
||||
def require_coordinator
|
||||
if params[:coordinator_id] && @order_cycle.coordinator = permitted_coordinating_enterprises_for(@order_cycle).find_by_id(params[:coordinator_id])
|
||||
return
|
||||
end
|
||||
@order_cycle.coordinator =
|
||||
permitted_coordinating_enterprises_for(@order_cycle).find_by_id(params[:coordinator_id])
|
||||
return if params[:coordinator_id] && @order_cycle.coordinator
|
||||
|
||||
available_coordinators = permitted_coordinating_enterprises_for(@order_cycle)
|
||||
case available_coordinators.count
|
||||
@@ -133,7 +175,9 @@ module Admin
|
||||
when 1
|
||||
@order_cycle.coordinator = available_coordinators.first
|
||||
else
|
||||
flash[:error] = I18n.t(:order_cycles_no_permission_to_create_error) if params[:coordinator_id]
|
||||
if params[:coordinator_id]
|
||||
flash[:error] = I18n.t(:order_cycles_no_permission_to_create_error)
|
||||
end
|
||||
render :set_coordinator
|
||||
end
|
||||
end
|
||||
@@ -157,7 +201,9 @@ module Admin
|
||||
params[:order_cycle].delete :coordinator_id
|
||||
|
||||
unless Enterprise.managed_by(spree_current_user).include?(@order_cycle.coordinator)
|
||||
params[:order_cycle].delete_if{ |k, _v| [:name, :orders_open_at, :orders_close_at].include? k.to_sym }
|
||||
params[:order_cycle].delete_if do |k, _v|
|
||||
[:name, :orders_open_at, :orders_close_at].include? k.to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -181,7 +227,9 @@ module Admin
|
||||
|
||||
def require_order_cycle_set_params
|
||||
return if params[:order_cycle_set]
|
||||
render json: { errors: t('admin.order_cycles.bulk_update.no_data') }, status: :unprocessable_entity
|
||||
|
||||
render json: { errors: t('admin.order_cycles.bulk_update.no_data') },
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def ams_prefix_whitelist
|
||||
|
||||
@@ -23,11 +23,13 @@ module Admin
|
||||
|
||||
def validate_data
|
||||
return unless process_data('validate')
|
||||
|
||||
render json: @importer.import_results, response: 200
|
||||
end
|
||||
|
||||
def save_data
|
||||
return unless process_data('save')
|
||||
|
||||
render json: @importer.save_results, response: 200
|
||||
end
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ module Admin
|
||||
|
||||
def collection
|
||||
return Schedule.where("1=0") unless json_request?
|
||||
|
||||
if params[:enterprise_id]
|
||||
filter_schedules_by_enterprise_id(permissions.visible_schedules, params[:enterprise_id])
|
||||
else
|
||||
@@ -49,6 +50,7 @@ module Admin
|
||||
|
||||
def check_editable_order_cycle_ids
|
||||
return unless params[:schedule][:order_cycle_ids]
|
||||
|
||||
requested = params[:schedule][:order_cycle_ids]
|
||||
@existing_order_cycle_ids = @schedule.persisted? ? @schedule.order_cycle_ids : []
|
||||
permitted = OrderCycle.where(id: params[:schedule][:order_cycle_ids] | @existing_order_cycle_ids).merge(OrderCycle.managed_by(spree_current_user)).pluck(:id)
|
||||
@@ -61,19 +63,23 @@ module Admin
|
||||
|
||||
def check_dependent_subscriptions
|
||||
return if Subscription.where(schedule_id: @schedule).empty?
|
||||
|
||||
render json: { errors: [t('admin.schedules.destroy.associated_subscriptions_error')] }, status: :conflict
|
||||
end
|
||||
|
||||
def permissions
|
||||
return @permissions unless @permission.nil?
|
||||
|
||||
@permissions = OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
end
|
||||
|
||||
def sync_subscriptions
|
||||
return unless params[:schedule][:order_cycle_ids]
|
||||
|
||||
removed_ids = @existing_order_cycle_ids - @schedule.order_cycle_ids
|
||||
new_ids = @schedule.order_cycle_ids - @existing_order_cycle_ids
|
||||
return unless removed_ids.any? || new_ids.any?
|
||||
|
||||
subscriptions = Subscription.where(schedule_id: @schedule)
|
||||
syncer = OpenFoodNetwork::ProxyOrderSyncer.new(subscriptions)
|
||||
syncer.sync!
|
||||
|
||||
@@ -27,8 +27,10 @@ module Admin
|
||||
|
||||
def status
|
||||
return render json: { status: :stripe_disabled } unless Spree::Config.stripe_connect_enabled
|
||||
|
||||
stripe_account = StripeAccount.find_by_enterprise_id(params[:enterprise_id])
|
||||
return render json: { status: :account_missing } unless stripe_account
|
||||
|
||||
authorize! :status, stripe_account
|
||||
|
||||
begin
|
||||
|
||||
@@ -8,6 +8,7 @@ module Admin
|
||||
|
||||
def edit
|
||||
return @stripe_account = { status: :empty_api_key_error_html } if Stripe.api_key.blank?
|
||||
|
||||
attrs = %i[id business_name charges_enabled]
|
||||
@obfuscated_secret_key = obfuscated_secret_key
|
||||
@stripe_account = Stripe::Account.retrieve.to_hash.slice(*attrs).merge(status: :ok)
|
||||
|
||||
@@ -36,17 +36,20 @@ module Admin
|
||||
|
||||
def ensure_shop
|
||||
return if @shop
|
||||
|
||||
render json: { errors: ['Unauthorised'] }, status: :unauthorized
|
||||
end
|
||||
|
||||
def ensure_variant
|
||||
return if @variant
|
||||
|
||||
error = "#{@shop.name} is not permitted to sell the selected product"
|
||||
render json: { errors: [error] }, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def price_estimate
|
||||
return unless @order_cycle
|
||||
|
||||
fee_calculator = OpenFoodNetwork::EnterpriseFeeCalculator.new(@shop, @order_cycle)
|
||||
OpenFoodNetwork::ScopeVariantToHub.new(@shop).scope(@variant)
|
||||
@variant.price + fee_calculator.indexed_fees_for(@variant)
|
||||
|
||||
@@ -80,6 +80,7 @@ module Admin
|
||||
|
||||
def permissions
|
||||
return @permissions unless @permissions.nil?
|
||||
|
||||
@permissions = OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
end
|
||||
|
||||
@@ -126,14 +127,17 @@ module Admin
|
||||
|
||||
def check_for_open_orders
|
||||
return if params[:open_orders] == 'cancel'
|
||||
|
||||
@open_orders_to_keep = @subscription.proxy_orders.placed_and_open.pluck(:id)
|
||||
return if @open_orders_to_keep.empty? || params[:open_orders] == 'keep'
|
||||
|
||||
render json: { errors: { open_orders: t('admin.subscriptions.confirm_cancel_open_orders_msg') } }, status: :conflict
|
||||
end
|
||||
|
||||
def check_for_canceled_orders
|
||||
return if params[:canceled_orders] == 'notified'
|
||||
return if @subscription.proxy_orders.active.canceled.empty?
|
||||
|
||||
render json: { errors: { canceled_orders: t('admin.subscriptions.resume_canceled_orders_msg') } }, status: :conflict
|
||||
end
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ module Api
|
||||
# Use logged in user (spree_current_user) for API authentication (current_api_user)
|
||||
def authenticate_user
|
||||
return if @current_api_user = try_spree_current_user
|
||||
|
||||
if api_key.blank?
|
||||
# An anonymous user
|
||||
@current_api_user = Spree.user_class.new
|
||||
|
||||
@@ -27,6 +27,7 @@ module Api
|
||||
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
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ module Api
|
||||
@product = Spree::Product.new(params[:product])
|
||||
begin
|
||||
if @product.save
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: 201
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: :created
|
||||
else
|
||||
invalid_resource!(@product)
|
||||
end
|
||||
@@ -33,7 +33,7 @@ module Api
|
||||
authorize! :update, Spree::Product
|
||||
@product = find_product(params[:id])
|
||||
if @product.update_attributes(params[:product])
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: 200
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: :ok
|
||||
else
|
||||
invalid_resource!(@product)
|
||||
end
|
||||
@@ -44,7 +44,7 @@ module Api
|
||||
@product = find_product(params[:id])
|
||||
@product.update_attribute(:deleted_at, Time.zone.now)
|
||||
@product.variants_including_master.update_all(deleted_at: Time.zone.now)
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: 204
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: :no_content
|
||||
end
|
||||
|
||||
def bulk_products
|
||||
@@ -76,7 +76,7 @@ module Api
|
||||
@product = find_product(params[:product_id])
|
||||
authorize! :delete, @product
|
||||
@product.destroy
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: 204
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: :no_content
|
||||
end
|
||||
|
||||
# POST /api/products/:product_id/clone
|
||||
@@ -88,7 +88,7 @@ module Api
|
||||
|
||||
@product = original_product.duplicate
|
||||
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: 201
|
||||
render json: @product, serializer: Api::Admin::ProductSerializer, status: :created
|
||||
end
|
||||
|
||||
private
|
||||
@@ -109,7 +109,15 @@ module Api
|
||||
scope = Spree::Product.active
|
||||
end
|
||||
|
||||
scope.includes(:master)
|
||||
scope.includes(product_query_includes)
|
||||
end
|
||||
|
||||
def product_query_includes
|
||||
[
|
||||
master: [:images],
|
||||
variants: [:default_price, :stock_locations, :stock_items, :variant_overrides,
|
||||
{ option_values: :option_type }]
|
||||
]
|
||||
end
|
||||
|
||||
def paged_products_for_producers(producers)
|
||||
|
||||
@@ -10,7 +10,7 @@ module Api
|
||||
|
||||
def job_queue_alive?
|
||||
Spree::Config.last_job_queue_heartbeat_at.present? &&
|
||||
Time.parse(Spree::Config.last_job_queue_heartbeat_at) > 6.minutes.ago
|
||||
Time.parse(Spree::Config.last_job_queue_heartbeat_at).in_time_zone > 6.minutes.ago
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,6 +61,7 @@ module Api
|
||||
|
||||
def taxonomy
|
||||
return if params[:taxonomy_id].blank?
|
||||
|
||||
@taxonomy ||= Spree::Taxonomy.find(params[:taxonomy_id])
|
||||
end
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ module Api
|
||||
before_filter :product
|
||||
|
||||
def index
|
||||
@variants = scope.includes(:option_values).ransack(params[:q]).result
|
||||
@variants = scope.includes(option_values: :option_type).ransack(params[:q]).result
|
||||
render json: @variants, each_serializer: Api::VariantSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
@variant = scope.includes(:option_values).find(params[:id])
|
||||
@variant = scope.includes(option_values: :option_type).find(params[:id])
|
||||
render json: @variant, serializer: Api::VariantSerializer
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ module Api
|
||||
authorize! :create, Spree::Variant
|
||||
@variant = scope.new(params[:variant])
|
||||
if @variant.save
|
||||
render json: @variant, serializer: Api::VariantSerializer, status: 201
|
||||
render json: @variant, serializer: Api::VariantSerializer, status: :created
|
||||
else
|
||||
invalid_resource!(@variant)
|
||||
end
|
||||
@@ -29,7 +29,7 @@ module Api
|
||||
authorize! :update, Spree::Variant
|
||||
@variant = scope.find(params[:id])
|
||||
if @variant.update_attributes(params[:variant])
|
||||
render json: @variant, serializer: Api::VariantSerializer, status: 200
|
||||
render json: @variant, serializer: Api::VariantSerializer, status: :ok
|
||||
else
|
||||
invalid_resource!(@product)
|
||||
end
|
||||
@@ -40,14 +40,14 @@ module Api
|
||||
authorize! :delete, @variant
|
||||
|
||||
VariantDeleter.new.delete(@variant)
|
||||
render json: @variant, serializer: Api::VariantSerializer, status: 204
|
||||
render json: @variant, serializer: Api::VariantSerializer, status: :no_content
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize! :delete, Spree::Variant
|
||||
@variant = scope.find(params[:id])
|
||||
@variant.destroy
|
||||
render json: @variant, serializer: Api::VariantSerializer, status: 204
|
||||
render json: @variant, serializer: Api::VariantSerializer, status: :no_content
|
||||
end
|
||||
|
||||
private
|
||||
@@ -58,11 +58,11 @@ module Api
|
||||
|
||||
def scope
|
||||
if @product
|
||||
unless current_api_user.has_spree_role?("admin") || params[:show_deleted]
|
||||
variants = @product.variants_including_master
|
||||
else
|
||||
variants = @product.variants_including_master.with_deleted
|
||||
end
|
||||
variants = if current_api_user.has_spree_role?("admin") || params[:show_deleted]
|
||||
@product.variants_including_master.with_deleted
|
||||
else
|
||||
@product.variants_including_master
|
||||
end
|
||||
else
|
||||
variants = Spree::Variant.scoped
|
||||
if current_api_user.has_spree_role?("admin")
|
||||
|
||||
@@ -47,6 +47,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def after_sign_in_path_for(resource_or_scope)
|
||||
return session[:shopfront_redirect] if session[:shopfront_redirect]
|
||||
|
||||
stored_location_for(resource_or_scope) || signed_in_root_path(resource_or_scope)
|
||||
end
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class EnterprisesController < BaseController
|
||||
|
||||
def shop
|
||||
return redirect_to main_app.cart_path unless enough_stock?
|
||||
|
||||
set_noindex_meta_tag
|
||||
|
||||
@enterprise = current_distributor
|
||||
|
||||
@@ -23,6 +23,7 @@ class LineItemsController < BaseController
|
||||
# List all items the user already ordered in the current order cycle
|
||||
def bought_items
|
||||
return [] unless current_order_cycle && spree_current_user && current_distributor
|
||||
|
||||
current_order_cycle.items_bought_by_user(spree_current_user, current_distributor)
|
||||
end
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ Spree::Admin::BaseController.class_eval do
|
||||
if Spree.const_defined?(const_name)
|
||||
return "Spree::#{const_name}".constantize
|
||||
end
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ module Spree
|
||||
def update
|
||||
params.each do |name, value|
|
||||
next unless Spree::Config.has_preference? name
|
||||
|
||||
Spree::Config[name] = value
|
||||
end
|
||||
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:general_settings))
|
||||
@@ -22,6 +23,7 @@ module Spree
|
||||
|
||||
def dismiss_alert
|
||||
return unless request.xhr? && params[:alert_id]
|
||||
|
||||
dismissed = Spree::Config[:dismissed_spree_alerts] || ''
|
||||
Spree::Config.set(dismissed_spree_alerts: dismissed.
|
||||
split(',').
|
||||
|
||||
39
app/controllers/spree/admin/images_controller.rb
Normal file
39
app/controllers/spree/admin/images_controller.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ImagesController < ResourceController
|
||||
# This will make resource controller redirect correctly after deleting product images.
|
||||
# This can be removed after upgrading to Spree 2.1.
|
||||
# See here https://github.com/spree/spree/commit/334a011d2b8e16355e4ae77ae07cd93f7cbc8fd1
|
||||
belongs_to 'spree/product', find_by: :permalink
|
||||
|
||||
before_filter :load_data
|
||||
|
||||
create.before :set_viewable
|
||||
update.before :set_viewable
|
||||
destroy.before :destroy_before
|
||||
|
||||
private
|
||||
|
||||
def location_after_save
|
||||
admin_product_images_url(@product)
|
||||
end
|
||||
|
||||
def load_data
|
||||
@product = Product.find_by_permalink(params[:product_id])
|
||||
@variants = @product.variants.collect do |variant|
|
||||
[variant.options_text, variant.id]
|
||||
end
|
||||
@variants.insert(0, [Spree.t(:all), @product.master.id])
|
||||
end
|
||||
|
||||
def set_viewable
|
||||
@image.viewable_type = 'Spree::Variant'
|
||||
@image.viewable_id = params[:image][:viewable_id]
|
||||
end
|
||||
|
||||
def destroy_before
|
||||
@viewable = @image.viewable
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
Spree::Admin::ImagesController.class_eval do
|
||||
# This will make resource controller redirect correctly after deleting product images.
|
||||
# This can be removed after upgrading to Spree 2.1.
|
||||
# See here https://github.com/spree/spree/commit/334a011d2b8e16355e4ae77ae07cd93f7cbc8fd1
|
||||
belongs_to 'spree/product', find_by: :permalink
|
||||
end
|
||||
@@ -10,6 +10,7 @@ module Spree
|
||||
|
||||
params.each do |name, value|
|
||||
next unless Spree::Config.has_preference? name
|
||||
|
||||
Spree::Config[name] = value
|
||||
end
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ Spree::Admin::Orders::CustomerDetailsController.class_eval do
|
||||
params[:order][:guest_checkout] = registered_user.nil?
|
||||
|
||||
return unless registered_user
|
||||
|
||||
@order.user_id = registered_user.id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,16 +1,68 @@
|
||||
module Spree
|
||||
module Admin
|
||||
PaymentMethodsController.class_eval do
|
||||
before_filter :restrict_stripe_account_change, only: [:update]
|
||||
before_filter :force_environment, only: [:create, :update]
|
||||
skip_before_filter :load_resource, only: [:show_provider_preferences]
|
||||
class PaymentMethodsController < ResourceController
|
||||
skip_before_filter :load_resource, only: [:create, :show_provider_preferences]
|
||||
before_filter :load_data
|
||||
before_filter :validate_payment_method_provider, only: [:create]
|
||||
before_filter :load_hubs, only: [:new, :edit, :update]
|
||||
create.before :load_hubs
|
||||
|
||||
respond_to :html
|
||||
|
||||
def create
|
||||
force_environment
|
||||
|
||||
@payment_method = params[:payment_method].
|
||||
delete(:type).
|
||||
constantize.
|
||||
new(params[:payment_method])
|
||||
@object = @payment_method
|
||||
|
||||
invoke_callbacks(:create, :before)
|
||||
if @payment_method.save
|
||||
invoke_callbacks(:create, :after)
|
||||
flash[:success] = Spree.t(:successfully_created, resource: Spree.t(:payment_method))
|
||||
redirect_to edit_admin_payment_method_path(@payment_method)
|
||||
else
|
||||
invoke_callbacks(:create, :fails)
|
||||
respond_with(@payment_method)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
restrict_stripe_account_change
|
||||
force_environment
|
||||
|
||||
invoke_callbacks(:update, :before)
|
||||
payment_method_type = params[:payment_method].delete(:type)
|
||||
if @payment_method['type'].to_s != payment_method_type
|
||||
@payment_method.update_column(:type, payment_method_type)
|
||||
@payment_method = PaymentMethod.find(params[:id])
|
||||
end
|
||||
|
||||
payment_method_params = params[ActiveModel::Naming.param_key(@payment_method)] || {}
|
||||
attributes = params[:payment_method].merge(payment_method_params)
|
||||
attributes.each do |k, _v|
|
||||
if k.include?("password") && attributes[k].blank?
|
||||
attributes.delete(k)
|
||||
end
|
||||
end
|
||||
|
||||
if @payment_method.update_attributes(attributes)
|
||||
invoke_callbacks(:update, :after)
|
||||
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:payment_method))
|
||||
redirect_to edit_admin_payment_method_path(@payment_method)
|
||||
else
|
||||
invoke_callbacks(:update, :fails)
|
||||
respond_with(@payment_method)
|
||||
end
|
||||
end
|
||||
|
||||
# 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.public_send(controller_name) if parent_data.present?
|
||||
|
||||
collection = if model_class.respond_to?(:accessible_by) &&
|
||||
!current_ability.has_block?(params[:action], model_class)
|
||||
|
||||
@@ -62,6 +114,14 @@ module Spree
|
||||
@calculators = PaymentMethod.calculators.sort_by(&:name)
|
||||
end
|
||||
|
||||
def validate_payment_method_provider
|
||||
valid_payment_methods = Rails.application.config.spree.payment_methods.map(&:to_s)
|
||||
return if valid_payment_methods.include?(params[:payment_method][:type])
|
||||
|
||||
flash[:error] = Spree.t(:invalid_payment_provider)
|
||||
redirect_to new_admin_payment_method_path
|
||||
end
|
||||
|
||||
def load_hubs
|
||||
# rubocop:disable Style/TernaryParentheses
|
||||
@hubs = Enterprise.managed_by(spree_current_user).is_distributor.sort_by! do |d|
|
||||
@@ -73,7 +133,8 @@ module Spree
|
||||
# Show Stripe as an option if enabled, or if the
|
||||
# current payment_method is already a Stripe method
|
||||
def show_stripe?
|
||||
Spree::Config.stripe_connect_enabled || @payment_method.try(:type) == "Spree::Gateway::StripeConnect"
|
||||
Spree::Config.stripe_connect_enabled ||
|
||||
@payment_method.try(:type) == "Spree::Gateway::StripeConnect"
|
||||
end
|
||||
|
||||
def restrict_stripe_account_change
|
||||
@@ -43,8 +43,8 @@ Spree::Admin::PaymentsController.class_eval do
|
||||
else
|
||||
flash[:error] = t(:cannot_perform_operation)
|
||||
end
|
||||
rescue Spree::Core::GatewayError => ge
|
||||
flash[:error] = ge.message
|
||||
rescue Spree::Core::GatewayError => e
|
||||
flash[:error] = e.message
|
||||
ensure
|
||||
redirect_to request.referer
|
||||
end
|
||||
|
||||
19
app/controllers/spree/admin/product_properties_controller.rb
Normal file
19
app/controllers/spree/admin/product_properties_controller.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ProductPropertiesController < ResourceController
|
||||
belongs_to 'spree/product', find_by: :permalink
|
||||
before_filter :find_properties
|
||||
before_filter :setup_property, only: [:index]
|
||||
|
||||
private
|
||||
|
||||
def find_properties
|
||||
@properties = Spree::Property.pluck(:name)
|
||||
end
|
||||
|
||||
def setup_property
|
||||
@product.product_properties.build
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -79,6 +79,7 @@ Spree::Admin::ProductsController.class_eval do
|
||||
# enterprise users.
|
||||
# TODO: There has to be a better way!!!
|
||||
return @collection if @collection.present?
|
||||
|
||||
params[:q] ||= {}
|
||||
params[:q][:deleted_at_null] ||= "1"
|
||||
|
||||
@@ -147,6 +148,7 @@ Spree::Admin::ProductsController.class_eval do
|
||||
|
||||
def strip_new_properties
|
||||
return if spree_current_user.admin? || params[:product][:product_properties_attributes].nil?
|
||||
|
||||
names = Spree::Property.pluck(:name)
|
||||
params[:product][:product_properties_attributes].each do |key, property|
|
||||
unless names.include? property[:property_name]
|
||||
@@ -170,9 +172,9 @@ Spree::Admin::ProductsController.class_eval do
|
||||
begin
|
||||
variant.on_demand = on_demand if on_demand.present?
|
||||
variant.on_hand = on_hand.to_i if on_hand.present?
|
||||
rescue StandardError => error
|
||||
notify_bugsnag(error, product, variant)
|
||||
raise error
|
||||
rescue StandardError => e
|
||||
notify_bugsnag(e, product, variant)
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
6
app/controllers/spree/admin/properties_controller.rb
Normal file
6
app/controllers/spree/admin/properties_controller.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class PropertiesController < ResourceController
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -258,14 +258,14 @@ Spree::Admin::ReportsController.class_eval do
|
||||
def describe_report(report)
|
||||
name = I18n.t(:name, scope: [:admin, :reports, report])
|
||||
description = begin
|
||||
I18n.t!(:description, scope: [:admin, :reports, report])
|
||||
rescue I18n::MissingTranslationData
|
||||
render_to_string(
|
||||
partial: "#{report}_description",
|
||||
layout: false,
|
||||
locals: { report_types: report_types[report] }
|
||||
).html_safe
|
||||
end
|
||||
I18n.t!(:description, scope: [:admin, :reports, report])
|
||||
rescue I18n::MissingTranslationData
|
||||
render_to_string(
|
||||
partial: "#{report}_description",
|
||||
layout: false,
|
||||
locals: { report_types: report_types[report] }
|
||||
).html_safe
|
||||
end
|
||||
{ name: name, url: url_for_report(report), description: description }
|
||||
end
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@ end
|
||||
Spree::Admin::ResourceController.prepend(AuthorizeOnLoadResource)
|
||||
|
||||
Spree::Admin::ResourceController.class_eval do
|
||||
rescue_from CanCan::AccessDenied, :with => :unauthorized
|
||||
rescue_from CanCan::AccessDenied, with: :unauthorized
|
||||
end
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ReturnAuthorizationsController < ResourceController
|
||||
belongs_to 'spree/order', find_by: :number
|
||||
|
||||
update.after :associate_inventory_units
|
||||
create.after :associate_inventory_units
|
||||
|
||||
def fire
|
||||
@return_authorization.public_send("#{params[:e]}!")
|
||||
flash[:success] = Spree.t(:return_authorization_updated)
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def associate_inventory_units
|
||||
(params[:return_quantity] || []).each do |variant_id, qty|
|
||||
@return_authorization.add_variant(variant_id.to_i, qty.to_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -58,6 +58,7 @@ module Spree
|
||||
|
||||
def set_shipping_category
|
||||
return true if params["shipping_method"][:shipping_categories] == ""
|
||||
|
||||
@shipping_method.shipping_categories =
|
||||
Spree::ShippingCategory.where(id: params["shipping_method"][:shipping_categories])
|
||||
@shipping_method.save
|
||||
@@ -66,6 +67,7 @@ module Spree
|
||||
|
||||
def set_zones
|
||||
return true if params["shipping_method"][:zones] == ""
|
||||
|
||||
@shipping_method.zones = Spree::Zone.where(id: params["shipping_method"][:zones])
|
||||
@shipping_method.save
|
||||
params[:shipping_method].delete(:zones)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxonomiesController < ResourceController
|
||||
respond_to :json, :only => [:get_children]
|
||||
respond_to :json, only: [:get_children]
|
||||
|
||||
def get_children
|
||||
@taxons = Taxon.find(params[:parent_id]).children
|
||||
|
||||
@@ -4,11 +4,11 @@ module Spree
|
||||
respond_to :html, :json, :js
|
||||
|
||||
def search
|
||||
if params[:ids]
|
||||
@taxons = Spree::Taxon.where(id: params[:ids].split(','))
|
||||
else
|
||||
@taxons = Spree::Taxon.limit(20).search(name_cont: params[:q]).result
|
||||
end
|
||||
@taxons = if params[:ids]
|
||||
Spree::Taxon.where(id: params[:ids].split(','))
|
||||
else
|
||||
Spree::Taxon.limit(20).search(name_cont: params[:q]).result
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -74,6 +74,7 @@ module Spree
|
||||
|
||||
def collection
|
||||
return @collection if @collection.present?
|
||||
|
||||
if request.xhr? && params[:q].present?
|
||||
# Disabling proper nested include here due to rails 3.1 bug
|
||||
@collection = Spree::User.
|
||||
@@ -125,6 +126,7 @@ module Spree
|
||||
|
||||
def sign_in_if_change_own_password
|
||||
return unless spree_current_user == @user && @user.password.present?
|
||||
|
||||
sign_in(@user, event: :authentication, bypass: true)
|
||||
end
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ module Spree
|
||||
|
||||
helper 'spree/orders'
|
||||
|
||||
rescue_from Spree::Core::GatewayError, :with => :rescue_from_spree_gateway_error
|
||||
rescue_from Spree::Core::GatewayError, with: :rescue_from_spree_gateway_error
|
||||
|
||||
def edit
|
||||
flash.keep
|
||||
|
||||
@@ -19,6 +19,7 @@ module Spree
|
||||
def update
|
||||
@credit_card = Spree::CreditCard.find_by_id(params[:id])
|
||||
return update_failed unless @credit_card
|
||||
|
||||
authorize! :update, @credit_card
|
||||
|
||||
if @credit_card.update_attributes(params[:credit_card])
|
||||
@@ -63,6 +64,7 @@ module Spree
|
||||
|
||||
def stored_card_attributes
|
||||
return {} unless @customer.try(:default_source)
|
||||
|
||||
{
|
||||
month: params[:exp_month],
|
||||
year: params[:exp_year],
|
||||
|
||||
@@ -9,7 +9,7 @@ module Spree
|
||||
ssl_required :show
|
||||
|
||||
before_filter :check_authorization
|
||||
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
|
||||
rescue_from ActiveRecord::RecordNotFound, with: :render_404
|
||||
helper 'spree/products', 'spree/orders'
|
||||
|
||||
respond_to :html
|
||||
@@ -200,6 +200,7 @@ module Spree
|
||||
def order_to_update
|
||||
return @order_to_update if defined? @order_to_update
|
||||
return @order_to_update = current_order unless params[:id]
|
||||
|
||||
@order_to_update = changeable_order_from_number
|
||||
end
|
||||
|
||||
@@ -208,6 +209,7 @@ module Spree
|
||||
def changeable_order_from_number
|
||||
order = Spree::Order.complete.find_by_number(params[:id])
|
||||
return nil unless order.andand.changes_allowed? && can?(:update, order)
|
||||
|
||||
order
|
||||
end
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ Spree::PaypalController.class_eval do
|
||||
# the payment details have been confirmed, but before any payments have been processed
|
||||
def destroy_orphaned_paypal_payments
|
||||
return unless payment_method.is_a?(Spree::Gateway::PayPalExpress)
|
||||
|
||||
orphaned_payments = current_order.payments.where(payment_method_id: payment_method.id, source_id: nil)
|
||||
orphaned_payments.each(&:destroy)
|
||||
end
|
||||
|
||||
@@ -25,8 +25,8 @@ class UserRegistrationsController < Spree::UserRegistrationsController
|
||||
render json: { email: @user.email }
|
||||
end
|
||||
end
|
||||
rescue StandardError => error
|
||||
OpenFoodNetwork::ErrorLogger.notify(error)
|
||||
rescue StandardError => e
|
||||
OpenFoodNetwork::ErrorLogger.notify(e)
|
||||
render_error(message: I18n.t('unknown_error', scope: I18N_SCOPE))
|
||||
end
|
||||
|
||||
|
||||
@@ -1,83 +1,133 @@
|
||||
module Admin
|
||||
module InjectionHelper
|
||||
def admin_inject_enterprise
|
||||
admin_inject_json_ams "admin.enterprises", "enterprise", @enterprise, Api::Admin::EnterpriseSerializer
|
||||
admin_inject_json_ams "admin.enterprises",
|
||||
"enterprise",
|
||||
@enterprise,
|
||||
Api::Admin::EnterpriseSerializer
|
||||
end
|
||||
|
||||
def admin_inject_enterprises
|
||||
admin_inject_json_ams_array("ofn.admin", "my_enterprises", @my_enterprises, Api::Admin::BasicEnterpriseSerializer) +
|
||||
admin_inject_json_ams_array("ofn.admin", "all_enterprises", @all_enterprises, Api::Admin::BasicEnterpriseSerializer)
|
||||
admin_inject_json_ams_array("ofn.admin",
|
||||
"my_enterprises",
|
||||
@my_enterprises,
|
||||
Api::Admin::BasicEnterpriseSerializer) +
|
||||
admin_inject_json_ams_array("ofn.admin",
|
||||
"all_enterprises",
|
||||
@all_enterprises,
|
||||
Api::Admin::BasicEnterpriseSerializer)
|
||||
end
|
||||
|
||||
def admin_inject_enterprise_relationships
|
||||
admin_inject_json_ams_array "ofn.admin", "enterprise_relationships", @enterprise_relationships, Api::Admin::EnterpriseRelationshipSerializer
|
||||
admin_inject_json_ams_array "ofn.admin",
|
||||
"enterprise_relationships",
|
||||
@enterprise_relationships,
|
||||
Api::Admin::EnterpriseRelationshipSerializer
|
||||
end
|
||||
|
||||
def admin_inject_enterprise_roles
|
||||
admin_inject_json_ams_array "ofn.admin", "enterpriseRoles", @enterprise_roles, Api::Admin::EnterpriseRoleSerializer
|
||||
admin_inject_json_ams_array "ofn.admin",
|
||||
"enterpriseRoles",
|
||||
@enterprise_roles,
|
||||
Api::Admin::EnterpriseRoleSerializer
|
||||
end
|
||||
|
||||
def admin_inject_payment_methods
|
||||
admin_inject_json_ams_array "admin.paymentMethods", "paymentMethods", @payment_methods, Api::Admin::IdNameSerializer
|
||||
admin_inject_json_ams_array "admin.paymentMethods",
|
||||
"paymentMethods",
|
||||
@payment_methods,
|
||||
Api::Admin::IdNameSerializer
|
||||
end
|
||||
|
||||
def admin_inject_payment_method
|
||||
admin_inject_json_ams "admin.paymentMethods", "paymentMethod", @payment_method, Api::Admin::PaymentMethodSerializer
|
||||
admin_inject_json_ams "admin.paymentMethods",
|
||||
"paymentMethod",
|
||||
@payment_method,
|
||||
Api::Admin::PaymentMethodSerializer
|
||||
end
|
||||
|
||||
def admin_inject_shipping_methods
|
||||
admin_inject_json_ams_array "admin.shippingMethods", "shippingMethods", @shipping_methods, Api::Admin::IdNameSerializer
|
||||
admin_inject_json_ams_array "admin.shippingMethods",
|
||||
"shippingMethods",
|
||||
@shipping_methods,
|
||||
Api::Admin::IdNameSerializer
|
||||
end
|
||||
|
||||
def admin_inject_shipping_method
|
||||
admin_inject_json_ams "admin.shippingMethods", "shippingMethod", @shipping_method, Api::Admin::ShippingMethodSerializer
|
||||
admin_inject_json_ams "admin.shippingMethods",
|
||||
"shippingMethod",
|
||||
@shipping_method,
|
||||
Api::Admin::ShippingMethodSerializer
|
||||
end
|
||||
|
||||
def admin_inject_shops(opts = {})
|
||||
opts.reverse_merge!(module: 'admin.customers')
|
||||
admin_inject_json_ams_array opts[:module], "shops", @shops, Api::Admin::IdNameSerializer
|
||||
admin_inject_json_ams_array opts[:module],
|
||||
"shops",
|
||||
@shops,
|
||||
Api::Admin::IdNameSerializer
|
||||
end
|
||||
|
||||
def admin_inject_available_countries(opts = {})
|
||||
opts.reverse_merge!(module: 'admin.customers')
|
||||
admin_inject_json_ams_array opts[:module], 'availableCountries', available_countries, Api::CountrySerializer
|
||||
admin_inject_json_ams_array opts[:module],
|
||||
'availableCountries',
|
||||
available_countries,
|
||||
Api::CountrySerializer
|
||||
end
|
||||
|
||||
def admin_inject_hubs(opts = {})
|
||||
opts.reverse_merge!(module: 'ofn.admin')
|
||||
admin_inject_json_ams_array opts[:module], "hubs", @hubs, Api::Admin::IdNameSerializer
|
||||
admin_inject_json_ams_array opts[:module],
|
||||
"hubs",
|
||||
@hubs,
|
||||
Api::Admin::IdNameSerializer
|
||||
end
|
||||
|
||||
def admin_inject_producers(opts = {})
|
||||
opts.reverse_merge!(module: 'ofn.admin')
|
||||
admin_inject_json_ams_array opts[:module], "producers", @producers, Api::Admin::IdNameSerializer
|
||||
admin_inject_json_ams_array opts[:module],
|
||||
"producers",
|
||||
@producers,
|
||||
Api::Admin::IdNameSerializer
|
||||
end
|
||||
|
||||
def admin_inject_inventory_items(opts = { module: 'ofn.admin' })
|
||||
admin_inject_json_ams_array opts[:module], "inventoryItems", @inventory_items, Api::Admin::InventoryItemSerializer
|
||||
admin_inject_json_ams_array opts[:module],
|
||||
"inventoryItems",
|
||||
@inventory_items,
|
||||
Api::Admin::InventoryItemSerializer
|
||||
end
|
||||
|
||||
def admin_inject_column_preferences(opts = {})
|
||||
opts.reverse_merge!(module: 'ofn.admin', action: "#{controller_name}_#{action_name}")
|
||||
column_preferences = ColumnPreference.for(spree_current_user, opts[:action])
|
||||
admin_inject_json_ams_array opts[:module], "columns", column_preferences, Api::Admin::ColumnPreferenceSerializer
|
||||
admin_inject_json_ams_array opts[:module],
|
||||
"columns",
|
||||
column_preferences,
|
||||
Api::Admin::ColumnPreferenceSerializer
|
||||
end
|
||||
|
||||
def admin_inject_currency_config
|
||||
admin_inject_json_ams 'admin.utils', "currencyConfig", {}, Api::CurrencyConfigSerializer
|
||||
admin_inject_json_ams 'admin.utils',
|
||||
"currencyConfig",
|
||||
{},
|
||||
Api::CurrencyConfigSerializer
|
||||
end
|
||||
|
||||
def admin_inject_enterprise_permissions
|
||||
permissions =
|
||||
{ can_manage_shipping_methods: can?(:manage_shipping_methods, @enterprise),
|
||||
can_manage_payment_methods: can?(:manage_payment_methods, @enterprise),
|
||||
can_manage_enterprise_fees: can?(:manage_enterprise_fees, @enterprise) }
|
||||
can_manage_payment_methods: can?(:manage_payment_methods, @enterprise),
|
||||
can_manage_enterprise_fees: can?(:manage_enterprise_fees, @enterprise) }
|
||||
|
||||
admin_inject_json "admin.enterprises", "enterprisePermissions", permissions
|
||||
end
|
||||
|
||||
def admin_inject_hub_permissions
|
||||
render partial: "admin/json/injection_ams", locals: { ngModule: "admin.variantOverrides", name: "hubPermissions", json: @hub_permissions.to_json }
|
||||
render partial: "admin/json/injection_ams", locals: { ngModule: "admin.variantOverrides",
|
||||
name: "hubPermissions",
|
||||
json: @hub_permissions.to_json }
|
||||
end
|
||||
|
||||
def admin_inject_products
|
||||
@@ -85,46 +135,79 @@ module Admin
|
||||
end
|
||||
|
||||
def admin_inject_tax_categories(opts = { module: 'ofn.admin' })
|
||||
admin_inject_json_ams_array opts[:module], "tax_categories", @tax_categories, Api::Admin::TaxCategorySerializer
|
||||
admin_inject_json_ams_array opts[:module],
|
||||
"tax_categories",
|
||||
@tax_categories,
|
||||
Api::Admin::TaxCategorySerializer
|
||||
end
|
||||
|
||||
def admin_inject_taxons
|
||||
admin_inject_json_ams_array "admin.taxons", "taxons", @taxons, Api::Admin::TaxonSerializer
|
||||
admin_inject_json_ams_array "admin.taxons",
|
||||
"taxons",
|
||||
@taxons,
|
||||
Api::Admin::TaxonSerializer
|
||||
end
|
||||
|
||||
def admin_inject_users
|
||||
admin_inject_json_ams_array "ofn.admin", "users", @users, Api::Admin::UserSerializer
|
||||
admin_inject_json_ams_array "ofn.admin",
|
||||
"users",
|
||||
@users,
|
||||
Api::Admin::UserSerializer
|
||||
end
|
||||
|
||||
def admin_inject_variant_overrides
|
||||
admin_inject_json_ams_array "admin.variantOverrides", "variantOverrides", @variant_overrides, Api::Admin::VariantOverrideSerializer
|
||||
admin_inject_json_ams_array "admin.variantOverrides",
|
||||
"variantOverrides",
|
||||
@variant_overrides,
|
||||
Api::Admin::VariantOverrideSerializer
|
||||
end
|
||||
|
||||
def admin_inject_order_cycle_instance
|
||||
render partial: "admin/json/injection_ams", locals: { ngModule: 'admin.orderCycles', name: 'ocInstance', json: "{coordinator_id: '#{@order_cycle.coordinator.id}'}" }
|
||||
render partial: "admin/json/injection_ams",
|
||||
locals: { ngModule: 'admin.orderCycles',
|
||||
name: 'ocInstance',
|
||||
json: "{coordinator_id: '#{@order_cycle.coordinator.id}'}" }
|
||||
end
|
||||
|
||||
def admin_inject_order_cycles
|
||||
admin_inject_json_ams_array "admin.orders", "orderCycles", @order_cycles, Api::Admin::BasicOrderCycleSerializer, current_user: spree_current_user
|
||||
admin_inject_json_ams_array "admin.orders",
|
||||
"orderCycles",
|
||||
@order_cycles,
|
||||
Api::Admin::BasicOrderCycleSerializer,
|
||||
current_user: spree_current_user
|
||||
end
|
||||
|
||||
def admin_inject_spree_api_key
|
||||
render partial: "admin/json/injection_ams", locals: { ngModule: 'admin.indexUtils', name: 'SpreeApiKey', json: "'#{@spree_api_key}'" }
|
||||
render partial: "admin/json/injection_ams",
|
||||
locals: { ngModule: 'admin.indexUtils',
|
||||
name: 'SpreeApiKey',
|
||||
json: "'#{@spree_api_key}'" }
|
||||
end
|
||||
|
||||
def admin_inject_json(ngModule, name, data)
|
||||
def admin_inject_json(ng_module, name, data)
|
||||
json = data.to_json
|
||||
render partial: "admin/json/injection_ams", locals: { ngModule: ngModule, name: name, json: json }
|
||||
render partial: "admin/json/injection_ams",
|
||||
locals: { ngModule: ng_module,
|
||||
name: name,
|
||||
json: json }
|
||||
end
|
||||
|
||||
def admin_inject_json_ams(ngModule, name, data, serializer, opts = {})
|
||||
def admin_inject_json_ams(ng_module, name, data, serializer, opts = {})
|
||||
json = serializer.new(data, { scope: spree_current_user }.merge(opts)).to_json
|
||||
render partial: "admin/json/injection_ams", locals: { ngModule: ngModule, name: name, json: json }
|
||||
render partial: "admin/json/injection_ams",
|
||||
locals: { ngModule: ng_module,
|
||||
name: name,
|
||||
json: json }
|
||||
end
|
||||
|
||||
def admin_inject_json_ams_array(ngModule, name, data, serializer, opts = {})
|
||||
json = ActiveModel::ArraySerializer.new(data, { each_serializer: serializer, scope: spree_current_user }.merge(opts)).to_json
|
||||
render partial: "admin/json/injection_ams", locals: { ngModule: ngModule, name: name, json: json }
|
||||
def admin_inject_json_ams_array(ng_module, name, data, serializer, opts = {})
|
||||
json = ActiveModel::ArraySerializer.
|
||||
new(data, { each_serializer: serializer, scope: spree_current_user }.merge(opts)).to_json
|
||||
|
||||
render partial: "admin/json/injection_ams",
|
||||
locals: { ngModule: ng_module,
|
||||
name: name,
|
||||
json: json }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@ module Admin
|
||||
module SubscriptionsHelper
|
||||
def subscriptions_setup_complete?(shops)
|
||||
return false unless shops.any?
|
||||
|
||||
shops = shops.select{ |shop| shipping_and_payment_methods_ok?(shop) && customers_ok?(shop) }
|
||||
Schedule.joins(:order_cycles).where(order_cycles: { coordinator_id: shops }).any?
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class AngularFormBuilder < ActionView::Helpers::FormBuilder
|
||||
def ng_fields_for(record_name, *_args)
|
||||
raise "Nested ng_fields_for is not yet supported" if @fields_for_record_name.present?
|
||||
|
||||
@fields_for_record_name = record_name
|
||||
yield self
|
||||
@fields_for_record_name = nil
|
||||
|
||||
@@ -7,11 +7,13 @@ module EnterprisesHelper
|
||||
|
||||
def current_customer
|
||||
return nil unless spree_current_user && current_distributor
|
||||
|
||||
@current_customer ||= spree_current_user.customer_of(current_distributor)
|
||||
end
|
||||
|
||||
def available_shipping_methods
|
||||
return [] if current_distributor.blank?
|
||||
|
||||
shipping_methods = current_distributor.shipping_methods
|
||||
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor, "FilterShippingMethods", current_customer.andand.tag_list)
|
||||
@@ -22,6 +24,7 @@ module EnterprisesHelper
|
||||
|
||||
def available_payment_methods
|
||||
return [] if current_distributor.blank?
|
||||
|
||||
payment_methods = current_distributor.payment_methods.available(:front_end).all
|
||||
|
||||
filter = OpenFoodNetwork::AvailablePaymentMethodFilter.new
|
||||
|
||||
@@ -2,10 +2,17 @@ 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)
|
||||
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' )
|
||||
link_to( t( '.footer_data_privacy_policy' ),
|
||||
Spree::Config.privacy_policy_url,
|
||||
target: '_blank',
|
||||
rel: 'noopener' )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module GroupsHelper
|
||||
def link_to_service(baseurl, name, html_options = {})
|
||||
return if name.blank?
|
||||
|
||||
html_options = html_options.merge target: '_blank'
|
||||
link_to ext_url(baseurl, name), html_options do
|
||||
yield
|
||||
@@ -8,7 +9,7 @@ module GroupsHelper
|
||||
end
|
||||
|
||||
def ext_url(prefix, url)
|
||||
if url =~ /^https?:\/\//i
|
||||
if url =~ %r{^https?://}i
|
||||
url
|
||||
else
|
||||
prefix + url
|
||||
@@ -16,6 +17,6 @@ module GroupsHelper
|
||||
end
|
||||
|
||||
def strip_url(url)
|
||||
url.andand.sub(/^https?:\/\//i, '')
|
||||
url.andand.sub(%r{^https?://}i, '')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ module HtmlHelper
|
||||
# I know Cthulu is coming for me. Forgive me.
|
||||
# http://stackoverflow.com/a/1732454/2720566
|
||||
html.
|
||||
andand.gsub(/<\/h[^>]>|<\/p>|<\/div>/, "\\1\n\n").
|
||||
andand.gsub(%r{</h[^>]>|</p>|</div>}, "\\1\n\n").
|
||||
andand.gsub(/<br[^>]*>/, "\\1\n")
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module SerializerHelper
|
||||
def ids_to_objs(ids)
|
||||
return [] if ids.blank?
|
||||
|
||||
ids.map { |id| { id: id } }
|
||||
end
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ module Spree
|
||||
options = options.merge(args.last)
|
||||
end
|
||||
return '' if (klass = klass_for(options[:label])) && cannot?(:admin, klass)
|
||||
|
||||
tab_without_cancan_check(*args)
|
||||
end
|
||||
alias_method_chain :tab, :cancan_check
|
||||
|
||||
@@ -19,6 +19,7 @@ module Spree
|
||||
|
||||
def invoice_links
|
||||
return [] unless Spree::Config[:enable_invoices?]
|
||||
|
||||
[send_invoice_link, print_invoice_link]
|
||||
end
|
||||
|
||||
@@ -32,6 +33,7 @@ module Spree
|
||||
|
||||
def ticket_links
|
||||
return [] unless Spree::Config[:enable_receipt_printing?]
|
||||
|
||||
[print_ticket_link, select_ticket_printer_link]
|
||||
end
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ module Spree
|
||||
return @changeable_orders unless @changeable_orders.nil?
|
||||
return @changeable_orders = [] unless spree_current_user && current_distributor && current_order_cycle
|
||||
return @changeable_orders = [] unless current_distributor.allow_order_changes?
|
||||
|
||||
@changeable_orders = Spree::Order.complete.where(
|
||||
state: 'complete',
|
||||
user_id: spree_current_user.id,
|
||||
@@ -32,6 +33,7 @@ module Spree
|
||||
|
||||
def shop_changeable_orders_alert_html
|
||||
return "" unless changeable_orders.any?
|
||||
|
||||
t(:shop_changeable_orders_alert_html,
|
||||
count: changeable_orders.count,
|
||||
path: changeable_orders_link_path,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class HeartbeatJob
|
||||
def perform
|
||||
Spree::Config.last_job_queue_heartbeat_at = Time.now
|
||||
Spree::Config.last_job_queue_heartbeat_at = Time.now.in_time_zone
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,8 +36,10 @@ class SubscriptionConfirmJob
|
||||
record_order(@order)
|
||||
update_payment! if @order.payment_required?
|
||||
return send_failed_payment_email if @order.errors.present?
|
||||
|
||||
@order.process_payments! if @order.payment_required?
|
||||
return send_failed_payment_email if @order.errors.present?
|
||||
|
||||
send_confirm_email
|
||||
end
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class ProducerMailer < Spree::BaseMailer
|
||||
subject = "[#{Spree::Config.site_name}] #{order_cycle_subject}"
|
||||
|
||||
return unless has_orders?(order_cycle, producer)
|
||||
|
||||
mail(
|
||||
to: @producer.contact.email,
|
||||
from: from_address,
|
||||
@@ -34,6 +35,7 @@ class ProducerMailer < Spree::BaseMailer
|
||||
|
||||
def line_items_from(order_cycle, producer)
|
||||
Spree::LineItem.
|
||||
includes(variant: { option_values: :option_type }).
|
||||
from_order_cycle(order_cycle).
|
||||
sorted_by_name_and_unit_value.
|
||||
merge(Spree::Product.in_supplier(producer)).
|
||||
|
||||
@@ -48,6 +48,7 @@ class ColumnPreference < ActiveRecord::Base
|
||||
# Arbitrary filtering of default_preferences
|
||||
def self.filter(default_preferences, user, action_name)
|
||||
return unless action_name == 'order_cycles_index'
|
||||
|
||||
default_preferences.delete(:schedules) unless user.admin? || user.enterprises.where(enable_subscriptions: true).any?
|
||||
end
|
||||
end
|
||||
|
||||
19
app/models/concerns/adjustment_scopes.rb
Normal file
19
app/models/concerns/adjustment_scopes.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
module AdjustmentScopes
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
PAYMENT_FEE_SCOPE = { originator_type: 'Spree::PaymentMethod' }.freeze
|
||||
SHIPPING_SCOPE = { originator_type: 'Spree::ShippingMethod' }.freeze
|
||||
ELIGIBLE_SCOPE = { eligible: true }.freeze
|
||||
|
||||
def payment_fee_scope
|
||||
PAYMENT_FEE_SCOPE
|
||||
end
|
||||
|
||||
def shipping_scope
|
||||
SHIPPING_SCOPE
|
||||
end
|
||||
|
||||
def eligible_scope
|
||||
ELIGIBLE_SCOPE
|
||||
end
|
||||
end
|
||||
@@ -20,6 +20,7 @@ module OrderShipment
|
||||
# @return [ShippingMethod]
|
||||
def shipping_method
|
||||
return if shipments.blank?
|
||||
|
||||
shipments.first.shipping_method
|
||||
end
|
||||
|
||||
@@ -31,6 +32,7 @@ module OrderShipment
|
||||
# empty or if it cannot find the given shipping_method_id in the order
|
||||
def select_shipping_method(shipping_method_id)
|
||||
return if shipping_method_id.blank? || shipments.empty?
|
||||
|
||||
shipment = shipments.first
|
||||
|
||||
shipping_rate = shipment.shipping_rates.find_by_shipping_method_id(shipping_method_id)
|
||||
|
||||
@@ -6,6 +6,7 @@ module ProductStock
|
||||
def on_demand
|
||||
if has_variants?
|
||||
raise 'Cannot determine product on_demand value of product with multiple variants' if variants.size > 1
|
||||
|
||||
variants.first.on_demand
|
||||
else
|
||||
master.on_demand
|
||||
|
||||
@@ -41,6 +41,7 @@ class Customer < ActiveRecord::Base
|
||||
|
||||
def check_for_orders
|
||||
return true unless orders.any?
|
||||
|
||||
errors[:base] << I18n.t('admin.customers.destroy.has_associated_orders')
|
||||
false
|
||||
end
|
||||
|
||||
@@ -63,7 +63,7 @@ class Enterprise < ActiveRecord::Base
|
||||
|
||||
has_attached_file :logo,
|
||||
styles: { medium: "300x300>", small: "180x180>", thumb: "100x100>" },
|
||||
url: '/images/enterprises/logos/:id/:style/:basename.:extension',
|
||||
url: '/images/enterprises/logos/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprises/logos/:id/:style/:basename.:extension'
|
||||
|
||||
has_attached_file :promo_image,
|
||||
@@ -72,11 +72,11 @@ class Enterprise < ActiveRecord::Base
|
||||
medium: ["720x156#", :jpg],
|
||||
thumb: ["100x100>", :jpg]
|
||||
},
|
||||
url: '/images/enterprises/promo_images/:id/:style/:basename.:extension',
|
||||
url: '/images/enterprises/promo_images/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprises/promo_images/:id/:style/:basename.:extension'
|
||||
|
||||
validates_attachment_content_type :logo, content_type: /\Aimage\/.*\Z/
|
||||
validates_attachment_content_type :promo_image, content_type: /\Aimage\/.*\Z/
|
||||
validates_attachment_content_type :logo, content_type: %r{\Aimage/.*\Z}
|
||||
validates_attachment_content_type :promo_image, content_type: %r{\Aimage/.*\Z}
|
||||
|
||||
include Spree::Core::S3Support
|
||||
supports_s3 :logo
|
||||
@@ -394,7 +394,7 @@ class Enterprise < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def strip_url(url)
|
||||
url.andand.sub(/(https?:\/\/)?/, '')
|
||||
url.andand.sub(%r{(https?://)?}, '')
|
||||
end
|
||||
|
||||
def set_unused_address_fields
|
||||
|
||||
@@ -32,16 +32,16 @@ class EnterpriseGroup < ActiveRecord::Base
|
||||
|
||||
has_attached_file :logo,
|
||||
styles: { medium: "100x100" },
|
||||
url: '/images/enterprise_groups/logos/:id/:style/:basename.:extension',
|
||||
url: '/images/enterprise_groups/logos/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprise_groups/logos/:id/:style/:basename.:extension'
|
||||
|
||||
has_attached_file :promo_image,
|
||||
styles: { large: ["1200x260#", :jpg] },
|
||||
url: '/images/enterprise_groups/promo_images/:id/:style/:basename.:extension',
|
||||
url: '/images/enterprise_groups/promo_images/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprise_groups/promo_images/:id/:style/:basename.:extension'
|
||||
|
||||
validates_attachment_content_type :logo, content_type: /\Aimage\/.*\Z/
|
||||
validates_attachment_content_type :promo_image, content_type: /\Aimage\/.*\Z/
|
||||
validates_attachment_content_type :logo, content_type: %r{\Aimage/.*\Z}
|
||||
validates_attachment_content_type :promo_image, content_type: %r{\Aimage/.*\Z}
|
||||
|
||||
include Spree::Core::S3Support
|
||||
supports_s3 :logo
|
||||
@@ -71,6 +71,7 @@ class EnterpriseGroup < ActiveRecord::Base
|
||||
|
||||
def unset_undefined_address_fields
|
||||
return if address.blank?
|
||||
|
||||
address.phone.sub!(/^#{I18n.t(:undefined)}$/, '')
|
||||
address.address1.sub!(/^#{I18n.t(:undefined)}$/, '')
|
||||
address.city.sub!(/^#{I18n.t(:undefined)}$/, '')
|
||||
|
||||
@@ -168,6 +168,7 @@ class OrderCycle < ActiveRecord::Base
|
||||
|
||||
def variants_distributed_by(distributor)
|
||||
return Spree::Variant.where("1=0") if distributor.blank?
|
||||
|
||||
Spree::Variant.
|
||||
joins(:exchanges).
|
||||
merge(distributor.inventory_variants).
|
||||
@@ -262,6 +263,7 @@ class OrderCycle < ActiveRecord::Base
|
||||
def orders_close_at_after_orders_open_at?
|
||||
return if orders_open_at.blank? || orders_close_at.blank?
|
||||
return if orders_close_at > orders_open_at
|
||||
|
||||
errors.add(:orders_close_at, :after_orders_open_at)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class OrderUpdater < SimpleDelegator
|
||||
track_payment_state_change(last_payment_state)
|
||||
|
||||
order.payment_state
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_hook
|
||||
shipping_address_from_distributor
|
||||
@@ -68,6 +68,7 @@ class OrderUpdater < SimpleDelegator
|
||||
# @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
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ module ProductImport
|
||||
|
||||
def name_presence_error(entry)
|
||||
return if entry.enterprise.present?
|
||||
|
||||
mark_as_invalid(entry,
|
||||
attribute: enterprise_field,
|
||||
error: I18n.t(:error_required))
|
||||
@@ -117,6 +118,7 @@ module ProductImport
|
||||
|
||||
def enterprise_not_found_error(entry)
|
||||
return if @spreadsheet_data.enterprises_index[entry.enterprise][:id]
|
||||
|
||||
mark_as_invalid(entry,
|
||||
attribute: enterprise_field,
|
||||
error: I18n.t(:error_not_found_in_database,
|
||||
@@ -126,6 +128,7 @@ module ProductImport
|
||||
|
||||
def permissions_error(entry)
|
||||
return if permission_by_name?(entry.enterprise)
|
||||
|
||||
mark_as_invalid(entry,
|
||||
attribute: enterprise_field,
|
||||
error: I18n.t(:error_no_permission_for_enterprise,
|
||||
@@ -135,8 +138,7 @@ module ProductImport
|
||||
|
||||
def primary_producer_error(entry)
|
||||
return if import_into_inventory?
|
||||
return if @spreadsheet_data.
|
||||
enterprises_index[entry.enterprise][:is_primary_producer]
|
||||
return if @spreadsheet_data.enterprises_index[entry.enterprise][:is_primary_producer]
|
||||
|
||||
mark_as_invalid(entry,
|
||||
attribute: enterprise_field,
|
||||
@@ -174,15 +176,19 @@ module ProductImport
|
||||
|
||||
def validate_unit_type_unchanged(entry)
|
||||
return if entry.unit_type.blank?
|
||||
|
||||
reference_entry = all_entries_for_product(entry).first
|
||||
return if entry.unit_type.to_s == reference_entry.unit_type.to_s
|
||||
|
||||
mark_as_not_updatable(entry, "unit_type")
|
||||
end
|
||||
|
||||
def validate_variant_unit_name_unchanged(entry)
|
||||
return if entry.variant_unit_name.blank?
|
||||
|
||||
reference_entry = all_entries_for_product(entry).first
|
||||
return if entry.variant_unit_name.to_s == reference_entry.variant_unit_name.to_s
|
||||
|
||||
mark_as_not_updatable(entry, "variant_unit_name")
|
||||
end
|
||||
|
||||
@@ -317,6 +323,7 @@ module ProductImport
|
||||
EntryValidator.non_updatable_fields.each do |display_name, attribute|
|
||||
next if attributes_match?(attribute, existing_product, entry) || attributes_blank?(attribute, existing_product, entry)
|
||||
next if ignore_when_updating_product?(attribute)
|
||||
|
||||
mark_as_invalid(entry, attribute: display_name, error: I18n.t('admin.product_import.model.not_updatable'))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -223,6 +223,7 @@ module ProductImport
|
||||
|
||||
def rows
|
||||
return [] unless @sheet && @sheet.last_row
|
||||
|
||||
(2..@sheet.last_row).map do |i|
|
||||
@sheet.row(i)
|
||||
end
|
||||
@@ -263,6 +264,7 @@ module ProductImport
|
||||
|
||||
def delete_uploaded_file
|
||||
return unless @file.path == Rails.root.join('tmp', 'product_import').to_s
|
||||
|
||||
File.delete(@file)
|
||||
end
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ module ProductImport
|
||||
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
|
||||
|
||||
@@ -58,6 +58,7 @@ module ProductImport
|
||||
@producers_index = {}
|
||||
@entries.each do |entry|
|
||||
next unless entry.producer
|
||||
|
||||
producer_name = entry.producer
|
||||
producer_id = @producers_index[producer_name] || Enterprise.find_by_name(producer_name, select: 'id, name').try(:id)
|
||||
@producers_index[producer_name] = producer_id
|
||||
|
||||
@@ -30,6 +30,7 @@ class ProxyOrder < ActiveRecord::Base
|
||||
|
||||
def cancel
|
||||
return false unless order_cycle.orders_close_at.andand > Time.zone.now
|
||||
|
||||
transaction do
|
||||
update_column(:canceled_at, Time.zone.now)
|
||||
order.cancel if order
|
||||
@@ -39,6 +40,7 @@ class ProxyOrder < ActiveRecord::Base
|
||||
|
||||
def resume
|
||||
return false unless order_cycle.orders_close_at.andand > Time.zone.now
|
||||
|
||||
transaction do
|
||||
update_column(:canceled_at, nil)
|
||||
order.resume if order
|
||||
@@ -48,6 +50,7 @@ class ProxyOrder < ActiveRecord::Base
|
||||
|
||||
def initialise_order!
|
||||
return order if order.present?
|
||||
|
||||
factory = OrderFactory.new(order_attrs, skip_stock_check: true)
|
||||
self.order = factory.create
|
||||
save!
|
||||
|
||||
@@ -192,7 +192,7 @@ class AbilityDecorator
|
||||
end
|
||||
|
||||
def add_order_cycle_management_abilities(user)
|
||||
can [:admin, :index, :read, :edit, :update], OrderCycle do |order_cycle|
|
||||
can [:admin, :index, :read, :edit, :update, :incoming, :outgoing], OrderCycle do |order_cycle|
|
||||
OrderCycle.accessible_by(user).include? order_cycle
|
||||
end
|
||||
can [:admin, :index, :create], Schedule
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require 'spree/localized_number'
|
||||
require 'concerns/adjustment_scopes'
|
||||
|
||||
module Spree
|
||||
Adjustment.class_eval do
|
||||
@@ -19,7 +20,9 @@ module Spree
|
||||
|
||||
scope :with_tax, -> { where('spree_adjustments.included_tax > 0') }
|
||||
scope :without_tax, -> { where('spree_adjustments.included_tax = 0') }
|
||||
scope :payment_fee, -> { where(originator_type: 'Spree::PaymentMethod') }
|
||||
scope :payment_fee, -> { where(AdjustmentScopes::PAYMENT_FEE_SCOPE) }
|
||||
scope :shipping, -> { where(AdjustmentScopes::SHIPPING_SCOPE) }
|
||||
scope :eligible, -> { where(AdjustmentScopes::ELIGIBLE_SCOPE) }
|
||||
|
||||
attr_accessible :included_tax
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ module Spree
|
||||
|
||||
def compute(object = nil)
|
||||
return 0 if object.nil?
|
||||
|
||||
preferred_amount * line_items_for(object).reduce(0) do |sum, value|
|
||||
value_to_add = if matching_products.blank? || matching_products.include?(value.product)
|
||||
value.quantity
|
||||
|
||||
@@ -46,6 +46,7 @@ Spree::CreditCard.class_eval do
|
||||
def ensure_single_default_card
|
||||
return unless user
|
||||
return unless is_default? || (reusable? && default_missing?)
|
||||
|
||||
user.credit_cards.update_all(['is_default=(id=?)', id])
|
||||
self.is_default = true
|
||||
end
|
||||
|
||||
@@ -107,6 +107,7 @@ module Spree
|
||||
|
||||
def ensure_enterprise_selected
|
||||
return if preferred_enterprise_id.andand > 0
|
||||
|
||||
errors.add(:stripe_account_owner, I18n.t(:error_required))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -83,6 +83,7 @@ Spree::LineItem.class_eval do
|
||||
def cap_quantity_at_stock!
|
||||
scoper.scope(variant)
|
||||
return if variant.on_demand
|
||||
|
||||
update_attributes!(quantity: variant.on_hand) if quantity > variant.on_hand
|
||||
end
|
||||
|
||||
@@ -101,8 +102,11 @@ Spree::LineItem.class_eval do
|
||||
def price_with_adjustments
|
||||
# EnterpriseFee#create_adjustment applies adjustments on line items to their parent order,
|
||||
# so line_item.adjustments returns an empty array
|
||||
return 0 if quantity == 0
|
||||
(price + order.adjustments.where(source_id: id).sum(&:amount) / quantity).round(2)
|
||||
return 0 if quantity.zero?
|
||||
|
||||
line_item_adjustments = OrderAdjustmentsFetcher.new(order).line_item_adjustments(self)
|
||||
|
||||
(price + line_item_adjustments.sum(&:amount) / quantity).round(2)
|
||||
end
|
||||
|
||||
def single_display_amount_with_adjustments
|
||||
@@ -127,6 +131,7 @@ Spree::LineItem.class_eval do
|
||||
|
||||
def unit_value
|
||||
return variant.unit_value if quantity == 0 || !final_weight_volume
|
||||
|
||||
final_weight_volume / quantity
|
||||
end
|
||||
|
||||
@@ -137,6 +142,7 @@ Spree::LineItem.class_eval do
|
||||
def sufficient_stock?
|
||||
return true if skip_stock_check
|
||||
return true if quantity <= 0
|
||||
|
||||
scoper.scope(variant)
|
||||
variant.can_supply?(quantity)
|
||||
end
|
||||
|
||||
@@ -10,6 +10,8 @@ end
|
||||
Spree::Order.class_eval do
|
||||
prepend OrderShipment
|
||||
|
||||
delegate :admin_and_handling_total, :payment_fee, :ship_total, to: :adjustments_fetcher
|
||||
|
||||
belongs_to :order_cycle
|
||||
belongs_to :distributor, class_name: 'Enterprise'
|
||||
belongs_to :customer
|
||||
@@ -165,6 +167,7 @@ Spree::Order.class_eval do
|
||||
def update_shipping_fees!
|
||||
shipments.each do |shipment|
|
||||
next if shipment.shipped?
|
||||
|
||||
update_adjustment! shipment.adjustment if shipment.adjustment
|
||||
save_or_rescue_shipment(shipment)
|
||||
end
|
||||
@@ -172,14 +175,14 @@ Spree::Order.class_eval do
|
||||
|
||||
def save_or_rescue_shipment(shipment)
|
||||
shipment.save # updates included tax
|
||||
rescue ActiveRecord::RecordNotUnique => error
|
||||
rescue ActiveRecord::RecordNotUnique => e
|
||||
# This error was seen in production on `shipment.save` above.
|
||||
# It caused lost payments and duplicate payments due to database rollbacks.
|
||||
# While we don't understand the cause of this error yet, we rescue here
|
||||
# because an outdated shipping fee is not as bad as a lost payment.
|
||||
# And the shipping fee is already up-to-date when this error occurs.
|
||||
# https://github.com/openfoodfoundation/openfoodnetwork/issues/3924
|
||||
Bugsnag.notify(error) do |report|
|
||||
Bugsnag.notify(e) do |report|
|
||||
report.add_tab(:order, attributes)
|
||||
report.add_tab(:shipment, shipment.attributes)
|
||||
report.add_tab(:shipment_in_db, Spree::Shipment.find_by_id(shipment.id).attributes)
|
||||
@@ -192,6 +195,7 @@ Spree::Order.class_eval do
|
||||
def update_payment_fees!
|
||||
payments.each do |payment|
|
||||
next if payment.completed?
|
||||
|
||||
update_adjustment! payment.adjustment if payment.adjustment
|
||||
payment.save
|
||||
end
|
||||
@@ -257,17 +261,10 @@ Spree::Order.class_eval do
|
||||
# Show already bought line items of this order cycle
|
||||
def finalised_line_items
|
||||
return [] unless order_cycle && user && distributor
|
||||
|
||||
order_cycle.items_bought_by_user(user, distributor)
|
||||
end
|
||||
|
||||
def admin_and_handling_total
|
||||
adjustments.eligible.where("originator_type = ? AND source_type != ?", 'EnterpriseFee', 'Spree::LineItem').sum(&:amount)
|
||||
end
|
||||
|
||||
def payment_fee
|
||||
adjustments.payment_fee.map(&:amount).sum
|
||||
end
|
||||
|
||||
# Does this order have shipments that can be shipped?
|
||||
def ready_to_ship?
|
||||
shipments.any?(&:can_ship?)
|
||||
@@ -352,6 +349,10 @@ Spree::Order.class_eval do
|
||||
|
||||
private
|
||||
|
||||
def adjustments_fetcher
|
||||
@adjustments_fetcher ||= OrderAdjustmentsFetcher.new(self)
|
||||
end
|
||||
|
||||
def skip_payment_for_subscription?
|
||||
subscription.present? && order_cycle.orders_close_at.andand > Time.zone.now
|
||||
end
|
||||
@@ -367,6 +368,7 @@ Spree::Order.class_eval do
|
||||
|
||||
def customer_is_valid?
|
||||
return true unless require_customer?
|
||||
|
||||
customer.present? && customer.enterprise_id == distributor_id && customer.email == email_for_customer
|
||||
end
|
||||
|
||||
@@ -376,6 +378,7 @@ Spree::Order.class_eval do
|
||||
|
||||
def associate_customer
|
||||
return customer if customer.present?
|
||||
|
||||
self.customer = Customer.of(distributor).find_by_email(email_for_customer)
|
||||
end
|
||||
|
||||
@@ -403,6 +406,7 @@ Spree::Order.class_eval do
|
||||
def charge_shipping_and_payment_fees!
|
||||
update_totals
|
||||
return unless payments.any?
|
||||
|
||||
payments.first.update_attribute :amount, total
|
||||
end
|
||||
end
|
||||
|
||||
@@ -93,6 +93,7 @@ module Spree
|
||||
return unless source.try(:save_requested_by_customer?)
|
||||
return unless source.number || source.gateway_payment_profile_id
|
||||
return unless source.gateway_customer_profile_id.nil?
|
||||
|
||||
payment_method.create_profile(self)
|
||||
rescue ActiveMerchant::ConnectionError => e
|
||||
gateway_error e
|
||||
@@ -105,6 +106,7 @@ module Spree
|
||||
def revoke_adjustment_eligibility
|
||||
return unless adjustment.try(:reload)
|
||||
return if adjustment.finalized?
|
||||
|
||||
adjustment.update_attribute(:eligible, false)
|
||||
adjustment.finalize!
|
||||
end
|
||||
|
||||
@@ -123,6 +123,7 @@ Spree::Product.class_eval do
|
||||
|
||||
scope :stockable_by, lambda { |enterprise|
|
||||
return where('1=0') if enterprise.blank?
|
||||
|
||||
permitted_producer_ids = EnterpriseRelationship.joins(:parent).permitting(enterprise.id)
|
||||
.with_permission(:add_to_order_cycle).where(enterprises: { is_primary_producer: true }).pluck(:parent_id)
|
||||
return where('spree_products.supplier_id IN (?)', [enterprise.id] | permitted_producer_ids)
|
||||
@@ -226,6 +227,7 @@ Spree::Product.class_eval do
|
||||
|
||||
def remove_previous_primary_taxon_from_taxons
|
||||
return unless primary_taxon_id_changed? && primary_taxon_id_was
|
||||
|
||||
taxons.destroy(primary_taxon_id_was)
|
||||
end
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ class Spree::ProductSet < ModelSet
|
||||
def update_product(product, attributes)
|
||||
original_supplier = product.supplier_id
|
||||
return false unless update_product_only_attributes(product, attributes)
|
||||
|
||||
ExchangeVariantDeleter.new.delete(product) if original_supplier != product.supplier_id
|
||||
|
||||
update_product_variants(product, attributes) &&
|
||||
@@ -81,11 +82,13 @@ class Spree::ProductSet < ModelSet
|
||||
|
||||
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]
|
||||
|
||||
create_or_update_variant(product, attributes[:master_attributes])
|
||||
end
|
||||
|
||||
@@ -113,9 +116,9 @@ class Spree::ProductSet < ModelSet
|
||||
begin
|
||||
variant.on_demand = on_demand if on_demand.present?
|
||||
variant.on_hand = on_hand.to_i if on_hand.present?
|
||||
rescue StandardError => error
|
||||
notify_bugsnag(error, product, variant, variant_attributes)
|
||||
raise error
|
||||
rescue StandardError => e
|
||||
notify_bugsnag(e, product, variant, variant_attributes)
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
12
app/models/spree/property.rb
Normal file
12
app/models/spree/property.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Spree
|
||||
class Property < ActiveRecord::Base
|
||||
has_many :product_properties, dependent: :destroy
|
||||
has_many :products, through: :product_properties
|
||||
|
||||
attr_accessible :name, :presentation
|
||||
|
||||
validates :name, :presentation, presence: true
|
||||
|
||||
scope :sorted, -> { order(:name) }
|
||||
end
|
||||
end
|
||||
@@ -33,6 +33,7 @@ module Spree
|
||||
# without line items (ie. user invoices) to not have inventory units
|
||||
def require_inventory
|
||||
return false unless line_items.count > 0 # This line altered
|
||||
|
||||
order.completed? && !order.canceled?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@ module Spree
|
||||
class << self
|
||||
def match_with_sales_tax_registration(order)
|
||||
return [] if order.distributor && !order.distributor.charges_sales_tax
|
||||
|
||||
match_without_sales_tax_registration(order)
|
||||
end
|
||||
alias_method_chain :match, :sales_tax_registration
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user