Compare commits

...

722 Commits

Author SHA1 Message Date
Maikel Linke
4a82a26830 Update all locales with the latest Transifex translations 2019-11-28 15:17:38 +11:00
Maikel
d546817f0a Merge pull request #4486 from openfoodfoundation/transifex
Transifex
2019-11-28 10:36:06 +11:00
Luis Ramos
e0e833b2f3 Merge pull request #4454 from luisramos0/sort_products
Sort products alphabetically in OC edit page
2019-11-27 22:27:42 +00:00
Luis Ramos
7cc034c2bc Merge pull request #4136 from mkllnk/4018-synchronise-checkout
Lock variants during checkout to avoid race condition
2019-11-27 15:40:28 +00:00
luisramos0
15bcde36cb Remove order by filter on outgoing exchanges list of products
The products are now coming from the server already sorted
2019-11-26 17:59:30 +00:00
Transifex-Openfoodnetwork
6e69960ee9 Updating translations for config/locales/nb.yml 2019-11-25 22:54:56 +11:00
Transifex-Openfoodnetwork
a7a03b04a9 Updating translations for config/locales/nb.yml 2019-11-25 22:51:50 +11:00
Pau Pérez Fabregat
5759dcee48 Merge pull request #4463 from jonleighton/docker-ruby-version
Use .ruby-version when building Docker container
2019-11-25 10:43:55 +01:00
Pau Pérez Fabregat
a9672011a5 Merge pull request #4479 from openfoodfoundation/dependabot/bundler/ddtrace-0.29.0
Bump ddtrace from 0.28.0 to 0.29.0
2019-11-25 09:42:48 +01:00
Pau Pérez Fabregat
808aa188ab Merge pull request #4478 from openfoodfoundation/dependabot/bundler/rspec-retry-0.6.2
Bump rspec-retry from 0.6.1 to 0.6.2
2019-11-25 09:42:06 +01:00
Transifex-Openfoodnetwork
ad7fc61228 Updating translations for config/locales/en_GB.yml 2019-11-24 05:29:07 +11:00
Transifex-Openfoodnetwork
3e32e5c16e Updating translations for config/locales/ar.yml 2019-11-24 03:48:31 +11:00
Transifex-Openfoodnetwork
f67a2120f4 Updating translations for config/locales/ar.yml 2019-11-24 03:45:25 +11:00
Matt-Yorkley
a4ee562387 Update all locales with the latest Transifex translations 2019-11-23 12:57:35 +01:00
Matt-Yorkley
165f4f9201 Merge pull request #4485 from openfoodfoundation/transifex
Transifex
2019-11-23 12:48:27 +01:00
Matt-Yorkley
0d1740ba4a Merge pull request #4430 from Matt-Yorkley/variant_option_types
Variant option_values
2019-11-23 12:37:34 +01:00
Matt-Yorkley
cbb3f202ca Eager-load option_values in OpenFoodNetwork::ScopeVariantsForSearch 2019-11-23 10:58:18 +01:00
Matt-Yorkley
ff076fd7be Eager-load option_values in Api::ProductsController 2019-11-23 10:58:18 +01:00
Matt-Yorkley
d30192207b Eager-load option_values in ProducerMailer 2019-11-23 10:58:18 +01:00
Matt-Yorkley
19afc1a6da Eager-load option_values in Api::VariantsController 2019-11-23 10:58:18 +01:00
Matt-Yorkley
4ef682915c Eager-load option_values in Admin::EnterprisesController 2019-11-23 10:58:18 +01:00
Matt-Yorkley
e693e8ac37 Eager-load option_values in Admin::BulkLineItemsController 2019-11-23 10:58:18 +01:00
Matt-Yorkley
07fe8e8390 Eager-load option_values in various reports 2019-11-23 10:58:18 +01:00
Matt-Yorkley
6e58ffa927 Enable variant option_values to be successfully eager-loaded 2019-11-23 10:58:18 +01:00
Transifex-Openfoodnetwork
8a8e612fd3 Updating translations for config/locales/fr.yml 2019-11-23 06:03:21 +11:00
Transifex-Openfoodnetwork
1e8ad4748a Updating translations for config/locales/fr.yml 2019-11-23 06:00:16 +11:00
Transifex-Openfoodnetwork
4c346549f5 Updating translations for config/locales/en_FR.yml 2019-11-23 05:58:47 +11:00
Transifex-Openfoodnetwork
427e44aee9 Updating translations for config/locales/fr.yml 2019-11-23 05:57:03 +11:00
Transifex-Openfoodnetwork
8dfc62b206 Updating translations for config/locales/ar.yml 2019-11-23 02:57:34 +11:00
Transifex-Openfoodnetwork
ef4a99eadc Updating translations for config/locales/ar.yml 2019-11-23 02:54:27 +11:00
Transifex-Openfoodnetwork
8337e43e64 Updating translations for config/locales/ar.yml 2019-11-23 02:51:17 +11:00
Luis Ramos
689eb88332 Merge pull request #4450 from luisramos0/return_auth
Move return authorizations from spree_backend to OFN
2019-11-22 14:33:45 +00:00
Matt-Yorkley
698210c849 Create release-template.md 2019-11-22 14:48:50 +01:00
luisramos0
e2087bcc8c Bring return authorizations view from spree_backend 2019-11-22 13:39:36 +00:00
luisramos0
b066b87141 Bring return authorizations controller from spree_backend 2019-11-22 13:39:04 +00:00
Matt-Yorkley
d88a766de4 Merge pull request #4461 from openfoodfoundation/dependabot/bundler/i18n-js-3.5.0
Bump i18n-js from 3.4.2 to 3.5.0
2019-11-22 14:37:10 +01:00
Matt-Yorkley
6c7910c8fa Merge pull request #4477 from openfoodfoundation/transifex
Transifex
2019-11-22 14:30:05 +01:00
Transifex-Openfoodnetwork
f83d469833 Updating translations for config/locales/en_CA.yml 2019-11-22 08:25:52 +11:00
Transifex-Openfoodnetwork
1cea5327e9 Updating translations for config/locales/en_CA.yml 2019-11-22 08:13:47 +11:00
dependabot-preview[bot]
6df7ec9dbd Bump ddtrace from 0.28.0 to 0.29.0
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 0.28.0 to 0.29.0.
- [Release notes](https://github.com/DataDog/dd-trace-rb/releases)
- [Changelog](https://github.com/DataDog/dd-trace-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/DataDog/dd-trace-rb/compare/v0.28.0...v0.29.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-21 19:20:49 +00:00
dependabot-preview[bot]
0f7357166d Bump rspec-retry from 0.6.1 to 0.6.2
Bumps [rspec-retry](https://github.com/noredink/rspec-retry) from 0.6.1 to 0.6.2.
- [Release notes](https://github.com/noredink/rspec-retry/releases)
- [Changelog](https://github.com/NoRedInk/rspec-retry/blob/master/changelog.md)
- [Commits](https://github.com/noredink/rspec-retry/compare/v0.6.1...v0.6.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-21 19:17:49 +00:00
Transifex-Openfoodnetwork
26c854df5b Updating translations for config/locales/en_FR.yml 2019-11-21 21:18:34 +11:00
Transifex-Openfoodnetwork
a43ef174f6 Updating translations for config/locales/nb.yml 2019-11-21 21:13:56 +11:00
Transifex-Openfoodnetwork
99f8bf039a Updating translations for config/locales/fr.yml 2019-11-21 21:12:07 +11:00
Transifex-Openfoodnetwork
bdb2c6efb3 Updating translations for config/locales/nb.yml 2019-11-21 21:10:49 +11:00
Transifex-Openfoodnetwork
21512e9722 Updating translations for config/locales/fr.yml 2019-11-21 21:09:00 +11:00
Luis Ramos
008921c201 Merge pull request #4447 from luisramos0/clickable_steps
Clickable steps on the OC edit page
2019-11-20 21:16:07 +00:00
Luis Ramos
0882887abe Merge pull request #4452 from luisramos0/ready_for
Make "Ready for" field show a red border when added to the list of outgoing exchanges
2019-11-20 21:14:25 +00:00
Luis Ramos
0eb4574b37 Merge pull request #4422 from luisramos0/the_poc
New Order Cycles edit page with steps
2019-11-20 21:11:23 +00:00
Maikel
b54edff4cc Merge pull request #4470 from luisramos0/oc_perms
Improve readability of OC permissions...
2019-11-20 11:38:38 +11:00
Maikel
0d6911f41c Merge pull request #4467 from openfoodfoundation/transifex
Transifex
2019-11-20 08:04:54 +11:00
Luis Ramos
498acaefbc Merge pull request #4469 from Matt-Yorkley/shipping_selection
Fix shipping_rate fetching in customer_totals_report
2019-11-19 09:39:13 +00:00
Maikel Linke
50093c325a Move checkout locking to its own service
It gives this complex logic more space and allows for better structure
and more comments at the right places.
2019-11-19 18:18:01 +11:00
Maikel Linke
4288428c70 Separating concurrency spec as it's entirely different 2019-11-19 18:18:01 +11:00
Maikel Linke
dc122a9450 Fix infinite loop in spec
The spec was setting the order's state to "complete" but didn't save
that state to the database. The new locking mechanism is was reloading
the order which loaded the cart state again. And since the order.next
method was mocked to just return true, the controller was trying to do
that in an infinite loop.
2019-11-19 18:18:01 +11:00
Maikel Linke
ec1b5a7a92 Test concurrent checkouts
When two people tried to buy the same item at the same time, it was
possible to oversell the item and end up with negative stock.

Parallel checkouts could also lead to other random failures. This spec
is testing that scenario by starting two threads which would run into a
race condition unless they use effective synchronisation. The added spec
fails if the synchronisation is removed from the CheckoutController.
2019-11-19 18:18:01 +11:00
Maikel Linke
df2306cf82 Lock variants during checkout to avoid race condition
It was possible that several people bought the same variant even though
there wasn't enough stock for everybody. That resulted in negative
stock.
2019-11-19 18:18:01 +11:00
Matt-Yorkley
585135d27e Fix shipping_method querying in customer totals reports 2019-11-18 15:14:10 +00:00
Matt-Yorkley
06fabe491d Add failing shipping_methods spec 2019-11-18 15:06:54 +00:00
luisramos0
052cc2848f Make visible_variants_for_incoming_exchanges_from and editable_variants_for_incoming_exchanges_from a bit easier to read 2019-11-18 13:25:38 +00:00
Transifex-Openfoodnetwork
b5b9d42764 Updating translations for config/locales/nb.yml 2019-11-18 19:04:54 +11:00
Transifex-Openfoodnetwork
d8e2239438 Updating translations for config/locales/nb.yml 2019-11-18 19:01:46 +11:00
Transifex-Openfoodnetwork
403ca3e538 Updating translations for config/locales/nb.yml 2019-11-18 18:58:37 +11:00
Transifex-Openfoodnetwork
ed65c80869 Updating translations for config/locales/ar.yml 2019-11-17 02:51:01 +11:00
Transifex-Openfoodnetwork
ca6ec9ee68 Updating translations for config/locales/ar.yml 2019-11-17 02:47:54 +11:00
Transifex-Openfoodnetwork
04fa4d3587 Updating translations for config/locales/fr.yml 2019-11-16 22:49:18 +11:00
Transifex-Openfoodnetwork
eedbcb6f1e Updating translations for config/locales/fr.yml 2019-11-16 22:46:21 +11:00
Transifex-Openfoodnetwork
61e3798533 Updating translations for config/locales/en_FR.yml 2019-11-16 22:44:43 +11:00
Transifex-Openfoodnetwork
bca978aacc Updating translations for config/locales/en_CA.yml 2019-11-16 15:06:46 +11:00
Transifex-Openfoodnetwork
190cb1dede Updating translations for config/locales/en_NZ.yml 2019-11-16 07:30:50 +11:00
Luis Ramos
9c8c71bd08 Merge pull request #4443 from openfoodfoundation/dependabot/bundler/roadie-rails-1.3.0
Bump roadie-rails from 1.1.1 to 1.3.0
2019-11-15 16:48:23 +00:00
Luis Ramos
2b37592280 Merge pull request #4449 from luisramos0/properties
Move properties and product properties from spree_backend to OFN
2019-11-15 08:57:32 +00:00
luisramos0
8546e11ffc Update all locales with the latest Transifex translations 2019-11-14 13:34:29 +00:00
Luis Ramos
76659d63d8 Merge pull request #4464 from openfoodfoundation/transifex
Transifex
2019-11-14 13:32:04 +00:00
Transifex-Openfoodnetwork
4d9cbf5d16 Updating translations for config/locales/nb.yml 2019-11-15 00:07:13 +11:00
Transifex-Openfoodnetwork
2166791554 Updating translations for config/locales/nb.yml 2019-11-15 00:04:04 +11:00
Luis Ramos
879e2f5c3a Merge pull request #4444 from openfoodfoundation/dependabot/bundler/wkhtmltopdf-binary-0.12.5
Bump wkhtmltopdf-binary from 0.12.4 to 0.12.5
2019-11-14 12:07:34 +00:00
Luis Ramos
471ec2023e Merge pull request #4426 from Matt-Yorkley/customer_totals
Orders and Fulfilment reports
2019-11-14 12:07:16 +00:00
Luis Ramos
5026afc011 Merge pull request #4141 from Matt-Yorkley/oc_performance
OC performance
2019-11-14 11:24:16 +00:00
Jon Leighton
172a79acc7 Use .ruby-version when building Docker container
The Ruby version was updated, but the Dockerfile wasn’t. This meant that
the Docker environment was broken. This change should prevent similar
breakage in the future by making .ruby-version the source of truth about
the correct version.
2019-11-14 15:44:49 +11:00
Maikel
7c9cdccb49 Merge pull request #4460 from openfoodfoundation/transifex
Transifex
2019-11-13 10:29:22 +11:00
dependabot-preview[bot]
179ec6a3e9 Bump i18n-js from 3.4.2 to 3.5.0
Bumps [i18n-js](https://github.com/fnando/i18n-js) from 3.4.2 to 3.5.0.
- [Release notes](https://github.com/fnando/i18n-js/releases)
- [Changelog](https://github.com/fnando/i18n-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/fnando/i18n-js/compare/v3.4.2...v3.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-12 19:34:42 +00:00
Transifex-Openfoodnetwork
19fbdb1848 Updating translations for config/locales/ar.yml 2019-11-13 05:24:53 +11:00
Transifex-Openfoodnetwork
c9b53022f2 Updating translations for config/locales/ar.yml 2019-11-13 05:21:47 +11:00
Pau Pérez Fabregat
a00b770229 Merge pull request #4459 from coopdevs/temporarily-disable-flaky-spec
Temporarily disable flaky line item spec
2019-11-12 13:59:02 +01:00
Pau Perez
16f570b8f7 Temporarily disable flaky line item spec
This is causing almost all PRs to fail in CI and blocking our delivery
pipe. We're already working on a solution in
https://github.com/openfoodfoundation/openfoodnetwork/pull/4458.
2019-11-12 13:23:04 +01:00
Luis Ramos
49bd21f29a Merge pull request #4456 from openfoodfoundation/dependabot/bundler/i18n-js-3.4.2
Bump i18n-js from 3.4.1 to 3.4.2
2019-11-12 12:09:34 +00:00
luisramos0
f1c055805f Use $timeout instead of setTimeout which makes it possible to remove apply() 2019-11-12 12:06:44 +00:00
luisramos0
5cadb0d16f Make ready for field show with red borders immediatly after exchange is added to the list 2019-11-12 12:06:44 +00:00
luisramos0
6875e9a41e Make view a bit simpler by removing unnecessary string interpolation 2019-11-12 12:05:40 +00:00
luisramos0
b6f1d6e395 Make OC edit page steps clickable when editing an OC 2019-11-12 12:05:40 +00:00
luisramos0
6e51be095b Add order to supplied products in enterprise serializer so that products in exchanges are sorted alphabetically 2019-11-12 12:04:42 +00:00
luisramos0
1c7237869a Refactor products_scope to make it more simple 2019-11-12 12:04:42 +00:00
luisramos0
14433e7764 Fix some rubocop issues in admin/order_cycles_controller 2019-11-12 12:02:36 +00:00
luisramos0
5fdb86ae43 Make simple create redirect to OC list but normal create to jump to incoming settings 2019-11-12 12:00:48 +00:00
luisramos0
6615469f8b Fix 3 more specs in OC edit pages 2019-11-12 12:00:48 +00:00
luisramos0
d281837dd9 Remove useless spec now that we have 3 steps in OC edit process 2019-11-12 12:00:48 +00:00
luisramos0
7c63e59ae9 Add OC imcoming and outgoing abilities to managers, this fixes a few OC feature specs 2019-11-12 12:00:48 +00:00
luisramos0
7c19fe418e Adapt OC specs to new page flow with 3 steps (these specs are not green yet) 2019-11-12 12:00:48 +00:00
luisramos0
46d0023018 Adapt OC spec to new page flow with 3 steps 2019-11-12 12:00:48 +00:00
luisramos0
43cf249184 Make NoDistributors warning only appear on simple_create and simple_edit and outgoing settings 2019-11-12 12:00:48 +00:00
luisramos0
537dbd3dc0 Fix angular specs by moving specs to the same place as the code was moved previously
Quite a few copy pasted specs were also removed
2019-11-12 12:00:48 +00:00
luisramos0
7c54781d90 Restructure OC page controllers so that methods related to exchanges are only loaded on the incoming and outgoing settings pages 2019-11-12 12:00:48 +00:00
luisramos0
3b4241c70d Remove more copy pasted code by adding new AdminOrderCycleCtrl with common code from create and edit OC controllers 2019-11-12 12:00:48 +00:00
luisramos0
a290e83501 Move more copy pasted code to basic OC controller 2019-11-12 12:00:48 +00:00
luisramos0
6e0019227b Remove some serious copy/paste party of the past... by extending from new AdminOrderCycleBasicCtrl where we put all the basic methods for the OC create/edit/simple_create/simple_edit controllers 2019-11-12 12:00:48 +00:00
luisramos0
7845b6c6fb Use only AdminOrderCycleIncomingCtrl in incoming view and make AdminOrderCycleIncomingCtrl extend AdminEditOrderCycleCtrl
Same for AdminOrderCycleOutgoingCtrl
2019-11-12 12:00:48 +00:00
luisramos0
e03e3ae50a Fix the simple edit OC and the new OC page flows 2019-11-12 12:00:48 +00:00
luisramos0
305d7b1125 Adapted navigation between OC edit pages by adding new previous and next buttons 2019-11-12 12:00:48 +00:00
luisramos0
5ef751d409 Add wizard to OC new and edit pages 2019-11-12 12:00:48 +00:00
luisramos0
683232dd10 Improve page titles and fix broken translation 2019-11-12 12:00:48 +00:00
luisramos0
5f1360e226 Move incoming and outgoing parts of the (not simple) OC new and edit pages to separate routes and views to make this page a multi step page 2019-11-12 12:00:48 +00:00
Matt-Yorkley
1a5eea3303 Refactor #all_incoming_editable_variants 2019-11-12 11:59:39 +00:00
Matt-Yorkley
a1146aed1b Refactor #sort_by_supplier_id 2019-11-12 11:59:39 +00:00
Matt-Yorkley
ab30307b1a Simplify #active_outgoing_variants 2019-11-12 11:59:39 +00:00
Matt-Yorkley
35b68239b0 Tidy up AR query syntax 2019-11-12 11:59:39 +00:00
Matt-Yorkley
9e09a3b379 Memoize #active_outgoing_variants result 2019-11-12 11:59:39 +00:00
Matt-Yorkley
77105e265e Memoize more repeated queries in #managed_enterprises 2019-11-12 11:59:38 +00:00
Matt-Yorkley
e73f2d682c Remove N+1 in editable_variants_for_incoming_exchanges 2019-11-12 11:59:13 +00:00
Matt-Yorkley
f4d71ae352 Fix order_cycle_permissions tests not running locally 2019-11-12 11:59:13 +00:00
Matt-Yorkley
c2823b3ffe Memoize #user_manages_coordinator_or result 2019-11-12 11:59:13 +00:00
Matt-Yorkley
c1366fced5 DRY some more variant queries 2019-11-12 11:59:13 +00:00
Matt-Yorkley
170bc94d92 Refactor order_cycle_serializer 2019-11-12 11:59:13 +00:00
Matt-Yorkley
2a5403e23f Clean up "visible and editable" variants 2019-11-12 11:59:13 +00:00
Matt-Yorkley
dc540444a2 Remove pointless code 2019-11-12 11:59:13 +00:00
Matt-Yorkley
ca5ecc4696 Refactor "active outgoing variants" 2019-11-12 11:59:13 +00:00
Matt-Yorkley
5082a133a1 Refactor adjustment fetching into new service and module 2019-11-12 11:57:54 +00:00
Matt-Yorkley
1f8e0ae637 Improve SupplierTotalsByDistributorReport 2019-11-12 11:57:19 +00:00
Matt-Yorkley
24e66b635b Improve DistributorTotalsBySupplierReport 2019-11-12 11:57:19 +00:00
Matt-Yorkley
891db4b81b Move methods to helper 2019-11-12 11:57:19 +00:00
Matt-Yorkley
8a57977b44 Increase eager-loading and adjustment calculations 2019-11-12 11:57:19 +00:00
Matt-Yorkley
77e70fd7d3 Eager-load adjustments and calculate in place 2019-11-12 11:57:19 +00:00
Matt-Yorkley
7b5e5f4039 Clean up OpenFoodNetwork::Permissions 2019-11-12 11:57:19 +00:00
Pau Pérez Fabregat
ed15bc422e Merge pull request #4453 from luisramos0/rubo
run rubocop --auto-correct
2019-11-12 10:30:21 +01:00
dependabot-preview[bot]
030747cff8 Bump i18n-js from 3.4.1 to 3.4.2
Bumps [i18n-js](https://github.com/fnando/i18n-js) from 3.4.1 to 3.4.2.
- [Release notes](https://github.com/fnando/i18n-js/releases)
- [Changelog](https://github.com/fnando/i18n-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/fnando/i18n-js/compare/v3.4.1...v3.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-11 19:15:49 +00:00
Luis Ramos
3e318e5c4e Merge pull request #4425 from Matt-Yorkley/admin_eager_loading
Eager-load variant associations in admin ProductsController
2019-11-11 15:29:45 +00:00
Luis Ramos
3eb4caeb3e Merge pull request #4408 from luisramos0/poc_oc
Remove dead code from OC edit page code
2019-11-11 14:55:37 +00:00
luisramos0
555ae12b35 Add exceptions to some unresolved rubocop issues 2019-11-10 19:40:41 +00:00
luisramos0
553d4ebaa0 Fix a few rubocop issues in reports code 2019-11-10 19:27:41 +00:00
luisramos0
73ee14cc7c Fix long line in injection helper 2019-11-10 19:21:08 +00:00
luisramos0
c9177feb19 Fix a few more rubocop issues manually 2019-11-10 19:14:12 +00:00
luisramos0
71ea281424 Regenerate rubocop todo files after last large fix of issues 2019-11-10 19:07:16 +00:00
luisramos0
9404aacfb2 run rubocop --auto-correct 2019-11-10 18:42:43 +00:00
Matt-Yorkley
5e99ecd9cc Merge pull request #4446 from luisramos0/remove_listen
Remove unused dependency listen
2019-11-10 10:03:19 +00:00
Matt-Yorkley
c94713c1ef Merge pull request #4451 from openfoodfoundation/dependabot/bundler/rack-mini-profiler-1.0.0
Bump rack-mini-profiler from 0.10.7 to 1.0.0
2019-11-09 19:28:54 +00:00
Maikel
6864c0d3c3 Merge pull request #4448 from luisramos0/rubo_kanp
Update rubocop todo lists and regenrate knapsack report
2019-11-09 10:59:14 +11:00
Maikel
5591525160 Merge pull request #4445 from openfoodfoundation/dependabot/bundler/test-unit-3.3.4
Bump test-unit from 3.3.3 to 3.3.4
2019-11-09 10:40:41 +11:00
luisramos0
4d00b79d8d Add new knapsack report so build jobs are more balanced 2019-11-08 20:43:49 +00:00
dependabot-preview[bot]
e3007db324 Bump rack-mini-profiler from 0.10.7 to 1.0.0
Bumps [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler) from 0.10.7 to 1.0.0.
- [Release notes](https://github.com/MiniProfiler/rack-mini-profiler/releases)
- [Changelog](https://github.com/MiniProfiler/rack-mini-profiler/blob/master/CHANGELOG.md)
- [Commits](https://github.com/MiniProfiler/rack-mini-profiler/compare/v0.10.7...v1.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-08 19:18:25 +00:00
luisramos0
de1d7f2877 Remove references to prototype (inexistent in OFN) in model properties 2019-11-08 17:49:35 +00:00
luisramos0
215f2897f3 Bring Property model from spree core 2019-11-08 17:48:49 +00:00
luisramos0
2d240f23a8 Converted erb properties views to haml and added lazy lookups for translations 2019-11-08 17:31:43 +00:00
luisramos0
f8b0ad29df Bring properties views from spree_backend 2019-11-08 17:18:26 +00:00
luisramos0
af1eff9427 Bring properties and product_properties controllers from spree_backend 2019-11-08 17:18:04 +00:00
luisramos0
05ddebd78e Update rubocop todo lists with payment_methods_controler exceptions 2019-11-08 17:05:51 +00:00
Luis Ramos
fd6639c7d1 Merge pull request #4415 from lin-d-hop/delivery-report
Update end date on delivery report
2019-11-08 16:58:27 +00:00
Luis Ramos
314ecf6d90 Merge pull request #4372 from luisramos0/images
Move Images from spree_backend to OFN
2019-11-08 16:21:33 +00:00
Luis Ramos
ea8eb0ee14 Merge pull request #4371 from luisramos0/payment_methods
Move Payment methods from spree_backend to OFN
2019-11-08 14:26:21 +00:00
luisramos0
9bb940ae43 Remove unused dependency listen, it was used in guard but guard was deleted 2019-11-08 12:49:06 +00:00
Luis Ramos
9e713e449f Merge pull request #4441 from openfoodfoundation/dependabot/bundler/rubocop-0.68.1
Bump rubocop from 0.57.2 to 0.68.1
2019-11-08 12:35:11 +00:00
Matt-Yorkley
34f4bbe06c Eager-load variant associations in admin ProductsController 2019-11-08 10:44:47 +00:00
Maikel Linke
babe2247a5 Put new violations on the todo list 2019-11-08 19:08:36 +11:00
Maikel Linke
3295aedeee Update Rubocop config for new version 2019-11-08 19:08:36 +11:00
dependabot-preview[bot]
eaaf082572 Bump rubocop from 0.57.2 to 0.68.1
Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.57.2 to 0.68.1.
- [Release notes](https://github.com/rubocop-hq/rubocop/releases)
- [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.57.2...v0.68.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-08 19:08:36 +11:00
Maikel Linke
f8803888f2 Update Rubocop config to pass local run 2019-11-08 19:08:36 +11:00
Maikel
032fbc7348 Merge pull request #4440 from openfoodfoundation/transifex
Transifex
2019-11-08 17:44:02 +11:00
Matt-Yorkley
b64633d2d8 Merge pull request #4434 from coopdevs/remove-duplicate-feature-spec
Don't test existence of a field used in next spec
2019-11-08 00:43:57 +00:00
Transifex-Openfoodnetwork
bc46b2bccb Updating translations for config/locales/en_FR.yml 2019-11-08 07:28:30 +11:00
Transifex-Openfoodnetwork
fc8bd530e6 Updating translations for config/locales/en_GB.yml 2019-11-08 07:13:52 +11:00
Transifex-Openfoodnetwork
8e6079ad5b Updating translations for config/locales/en_GB.yml 2019-11-08 07:10:42 +11:00
dependabot-preview[bot]
f29922312d Bump test-unit from 3.3.3 to 3.3.4
Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.3.3 to 3.3.4.
- [Release notes](https://github.com/test-unit/test-unit/releases)
- [Commits](https://github.com/test-unit/test-unit/compare/3.3.3...3.3.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-07 19:20:30 +00:00
dependabot-preview[bot]
1b8863b63d Bump wkhtmltopdf-binary from 0.12.4 to 0.12.5
Bumps [wkhtmltopdf-binary](https://github.com/zakird/wkhtmltopdf_binary_gem) from 0.12.4 to 0.12.5.
- [Release notes](https://github.com/zakird/wkhtmltopdf_binary_gem/releases)
- [Changelog](https://github.com/zakird/wkhtmltopdf_binary_gem/blob/master/CHANGELOG)
- [Commits](https://github.com/zakird/wkhtmltopdf_binary_gem/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-07 19:19:47 +00:00
dependabot-preview[bot]
5def2f6f5f Bump roadie-rails from 1.1.1 to 1.3.0
Bumps [roadie-rails](https://github.com/Mange/roadie-rails) from 1.1.1 to 1.3.0.
- [Release notes](https://github.com/Mange/roadie-rails/releases)
- [Changelog](https://github.com/Mange/roadie-rails/blob/master/Changelog.md)
- [Commits](https://github.com/Mange/roadie-rails/compare/v1.1.1...v1.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-07 19:18:56 +00:00
Transifex-Openfoodnetwork
b5e69c883b Updating translations for config/locales/fr.yml 2019-11-07 23:50:03 +11:00
Transifex-Openfoodnetwork
5f0ad3fd71 Updating translations for config/locales/fr.yml 2019-11-07 23:46:53 +11:00
Pau Perez
a6ba956355 Update all locales with the latest Transifex translations 2019-11-07 12:47:10 +01:00
Luis Ramos
76cffe4c7f Merge pull request #4301 from Matt-Yorkley/ruby-2.2.10
Use Ruby 2.2.10
2019-11-07 10:17:54 +00:00
Pau Perez
5095df251e Don't test existence of a field used in next spec
If the next example doesn't find the quick_search field it will fail so
no need to duplicate it with the consequent costly test setup.
2019-11-06 18:28:59 +01:00
Pau Pérez Fabregat
26477a8d4b Merge pull request #4421 from openfoodfoundation/transifex
Transifex
2019-11-06 18:04:23 +01:00
Luis Ramos
52ab6c52bf Merge pull request #4057 from luisramos0/remove_spree_api_2
Remove dependency to spree_api - step 2 - routes and views
2019-11-06 13:23:32 +00:00
Luis Ramos
413e93fe40 Merge pull request #4431 from Matt-Yorkley/fix_migration_clash
Fix migration mismatch
2019-11-06 09:49:15 +00:00
Matt-Yorkley
9e1b2eb4ca Fix migration mismatch
It looks like this was probably changed whilst resolving a merge conflict somewhere. The number doesn't match the last migration file, and it's breaking the ofn-install CI build (as well as migrations on fresh servers).
2019-11-05 22:58:14 +00:00
Luis Ramos
1ceae6cf8d Merge pull request #4225 from HugsDaniel/4106-edit-product-missing-translations
Add missing translations on product edit page
2019-11-05 19:30:08 +00:00
Transifex-Openfoodnetwork
5183d93601 Updating translations for config/locales/en_DE.yml 2019-11-05 23:45:05 +11:00
Luis Ramos
247854b7fe Merge pull request #4423 from openfoodfoundation/dependabot/bundler/i18n-js-3.4.1
Bump i18n-js from 3.4.0 to 3.4.1
2019-11-04 11:47:13 +00:00
dependabot-preview[bot]
85bd803785 Bump i18n-js from 3.4.0 to 3.4.1
Bumps [i18n-js](https://github.com/fnando/i18n-js) from 3.4.0 to 3.4.1.
- [Release notes](https://github.com/fnando/i18n-js/releases)
- [Changelog](https://github.com/fnando/i18n-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/fnando/i18n-js/compare/v3.4.0...v3.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-01 19:39:31 +00:00
luisramos0
75dfde2552 In the Edit OC page, the list of supplied products should only include checkboxes for normal variants: removed html to display product checkbox and also master variants
Two rules we can use to make this more simple: all products have variants (at least what is called the standard variant) and master variants cannot be added to OCs
2019-11-01 17:18:48 +00:00
luisramos0
10f0906689 Remove obsolete view, this code is now in app/assets/javascripts/templates/admin/panels/exchange_supplied_products.html.haml 2019-11-01 17:18:48 +00:00
Transifex-Openfoodnetwork
c6543edc85 Updating translations for config/locales/en_GB.yml 2019-11-02 01:42:11 +11:00
Transifex-Openfoodnetwork
a91d0973d4 Updating translations for config/locales/en_GB.yml 2019-11-02 01:39:02 +11:00
Kristina Lim
61c581ae52 Update all locales with the latest Transifex translations 2019-11-01 20:38:13 +08:00
Luis Ramos
db8e2891d4 Merge pull request #4417 from Matt-Yorkley/shopfront_patchination
Ensure variants returned in #variant_relation are DISTINCT
2019-11-01 12:16:01 +00:00
Luis Ramos
a947d8df6c Merge pull request #4397 from luisramos0/delete_option_types_page
Remove option types menu entry
2019-11-01 12:14:59 +00:00
Maikel
818d41ffac Merge pull request #4418 from AndrewCleve/readme-grammar-fix
Improve readability of README.md
2019-11-01 16:48:12 +11:00
Maikel
14f67053c8 Merge pull request #4400 from coopdevs/task-to-remove-enterprise-limit
Task to remove limit of ent. that can be created
2019-11-01 15:57:12 +11:00
luisramos0
76e32b126f Add a few more missing translation keys for product images and variants display as and display name 2019-11-01 10:40:02 +11:00
luisramos0
c234cfb890 Add missing translation in the new variant page 2019-11-01 10:40:02 +11:00
luisramos0
38bda1697d Add missing translations in the product variants list page 2019-11-01 10:40:02 +11:00
luisramos0
5fb9ebc594 Add missing translations for variants edit page 2019-11-01 10:40:02 +11:00
luisramos0
acbd4b076d Move product page tabs to a separate translations key namespace 2019-11-01 10:40:01 +11:00
luisramos0
123f7aa68e Use root translation keys for basic actions 2019-11-01 10:39:09 +11:00
luisramos0
2c4af84a81 Move product seo translation keys to specific namespace 2019-11-01 10:39:09 +11:00
luisramos0
34ed16ff30 Add missing translation keys to product properties list 2019-11-01 10:39:09 +11:00
Hugo Daniel
0b20b80219 Add missing translations on product edit page 2019-11-01 10:38:06 +11:00
Luis Ramos
bef745378e Merge pull request #4395 from luisramos0/delete_prototypes
Delete prototypes tables and all references in pages
2019-10-31 20:06:38 +00:00
lin-d-hop
472aef0904 Fixing spec 2019-10-31 18:28:13 +00:00
luisramos0
a6cb5903d6 Delete prototypes tables and all references in pages 2019-10-31 13:23:42 +00:00
Luis Ramos
d1b36aded0 Merge pull request #4359 from daningenthron/daningenthron/required-fields-new-order-cycle
Add asterisks to required fields in New Order Cycle form
2019-10-31 12:50:48 +00:00
Luis Ramos
9c3c74aa93 Merge pull request #4394 from luisramos0/fix_product_sub_menu
Merge duplicated product_sub_menu partials
2019-10-31 12:48:27 +00:00
Matt-Yorkley
67a5a1cdc2 Fix incorrectly ordered entries with duplicate product names in OC and custom taxon ordering applied 2019-10-31 12:14:14 +00:00
Matt-Yorkley
9723e2cd49 Add failing spec for taxon ordering issue 2019-10-31 12:07:16 +00:00
Pau Pérez Fabregat
4af014df6b Merge pull request #4342 from JacksonBates/edit-button-new-window
makes edit button action open a new tab
2019-10-31 11:45:11 +01:00
Pau Pérez Fabregat
be6c64db75 Merge pull request #4354 from agustinariq/3832-WYSIWYG-highlight-links
#3832 - Added color to links in WYSIWYG editor
2019-10-31 11:44:11 +01:00
AndrewCleve
1aebc30128 Improve readability of README.md
Made minor changes to grammar to improve consistency and readability.
2019-10-30 19:43:38 -07:00
lin-d-hop
c1f427b0e3 Modifications for variable consistency etc 2019-10-30 19:06:49 +00:00
Matt-Yorkley
f8209ac7d5 Ensure results in #products_relation are DISTINCT 2019-10-30 19:04:28 +00:00
Matt-Yorkley
6d50176e6b Ensure results in #variants_relation are DISTINCT 2019-10-30 17:13:52 +00:00
Pau Pérez Fabregat
d6d2c19dc7 Merge pull request #4398 from Matt-Yorkley/db_indexes
Add order_cycle_id and distributor_id indexes to spree_orders table
2019-10-30 16:36:23 +01:00
Pau Pérez Fabregat
f897478736 Merge pull request #4402 from coopdevs/task-to-remove-unused-enterprise
Task to remove an unused enterprise
2019-10-30 16:34:28 +01:00
Pau Pérez Fabregat
064b86da5d Merge pull request #4407 from luisramos0/fix_sample_data
Add tax category to sample products
2019-10-30 15:37:53 +01:00
Pau Pérez Fabregat
f7b58300f9 Merge pull request #4362 from openfoodfoundation/dependabot/bundler/activerecord-import-1.0.3
Bump activerecord-import from 1.0.2 to 1.0.3
2019-10-30 15:13:47 +01:00
luisramos0
0fe4edfbf5 Make product_tag_rules_filterer_spec a bit more flexible and not test for the order of the elements 2019-10-30 11:06:25 +00:00
luisramos0
f45eb35eb1 Make user_registrations_controller_spec keep I18n.locale as it was before the spec, so that other specs wont fail 2019-10-30 10:43:46 +00:00
Luis Ramos
1a0e99dce2 Merge pull request #4414 from openfoodfoundation/dependabot/bundler/fuubar-2.5.0
Bump fuubar from 2.4.1 to 2.5.0
2019-10-30 10:12:19 +00:00
lin-d-hop
c477f8c230 Update end date on delivery report to ensure all of todays orders are included 2019-10-29 19:47:38 +00:00
dependabot-preview[bot]
d7caf91de1 Bump fuubar from 2.4.1 to 2.5.0
Bumps [fuubar](https://github.com/thekompanee/fuubar) from 2.4.1 to 2.5.0.
- [Release notes](https://github.com/thekompanee/fuubar/releases)
- [Changelog](https://github.com/thekompanee/fuubar/blob/master/CHANGELOG.md)
- [Commits](https://github.com/thekompanee/fuubar/compare/releases/v2.4.1...releases/v2.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-29 19:30:45 +00:00
Luis Ramos
1e2ab27cda Merge pull request #4327 from kristinalim/feature/4315-prefill_dates_in_orders_and_fulfillment_report
4315 Set default date range for Orders and Fulfillment report
2019-10-29 11:11:59 +00:00
Luis Ramos
3e7bd7dc19 Merge pull request #4376 from luisramos0/ghosts
Remove product from Order Cycles if product supplier changes
2019-10-28 21:17:48 +00:00
luisramos0
c60261a847 Make taxonomies edit page use api route instead of spree_api route that is now gone. 2019-10-28 16:01:23 +00:00
luisramos0
11fea650d6 Remove inexistent routes api/enterprises/managed and api/enterprises/acessible
The :managed endpoint was delete here 1d92d6cc33
2019-10-28 16:01:23 +00:00
luisramos0
92f1fa3b52 Remove dead route api/orders/managed 2019-10-28 16:01:23 +00:00
luisramos0
ad52022927 Add feature spec to cover api api generation in admin user edit form 2019-10-28 16:01:22 +00:00
luisramos0
9cffe48c70 Do not use Spree.t in spree admin users 2019-10-28 16:01:22 +00:00
luisramos0
d006ded439 Convert spree admin users api fields partial from erb to haml 2019-10-28 16:01:22 +00:00
luisramos0
b2e5ff46a8 Bring missing admin user edit form api_fields partial from spree_api and insert into the form (there was a deface override in spree_api injecting it before) 2019-10-28 16:01:22 +00:00
luisramos0
f46e0a2a31 Remove outdated comment, action managed has already been removed 2019-10-28 16:01:22 +00:00
luisramos0
dd66df6379 Remove dead routes api/order_cycles, these endpoints were removed in PR 4059 because they were unused, implemented in rabl and not correctly named for the future 2019-10-28 16:01:22 +00:00
luisramos0
d7b9dc1190 Fix some rubocop issues 2019-10-28 16:00:36 +00:00
luisramos0
5b6efaf687 Delete now unused rabl template authorise_api 2019-10-28 16:00:36 +00:00
luisramos0
8aab9bacbe Delete now irrelevant authorize_api endpoint and logic
OFN API is now authenticating all users, if no session and no key is provided an anonymous user will be created so that user can access public endpoints, authorization is then done at each individual endpoint. This makes this spree api auth call irrelevant
2019-10-28 16:00:36 +00:00
luisramos0
66fdbe4379 Remove spree_api dependency. Spree_api will keep being a dependency until we remove spree_backend as a dependency but now ofn works without spree_api 2019-10-28 16:00:36 +00:00
luisramos0
abcc22c34b Merge Spree::Api::BaseController with Api::BaseController. All api controllers inherit from Api::BaseController now. We can probably simplify this controller even more now 2019-10-28 16:00:36 +00:00
luisramos0
0d34b607c3 Move spree/api/base_controller#find_product to api/product_controller where it is used exclusively
Also, product_scope stops being an override
2019-10-28 16:00:36 +00:00
luisramos0
f840179573 Remove .json from Spree.routes.orders_api. This path is only used to compose the order shipments path and thus cannot have the .json 2019-10-28 16:00:36 +00:00
luisramos0
b5a521476b Remove unused method from api/base_controller 2019-10-28 16:00:36 +00:00
luisramos0
7c64777a50 Remove requires_authentication check from api/base_controller. OFN api does not require auth, it always generates an anonymous user for public endpoints 2019-10-28 16:00:36 +00:00
luisramos0
c98b4b276b Adapt spree/admin/shared/_routes.html.erb to new location of the api/taxons routes AND move spree/api/orders route to ofn api/orders route 2019-10-28 16:00:36 +00:00
luisramos0
f1138709aa Add spree_api translation keys, mostly from api standard errors and api fields in admin/users 2019-10-28 16:00:36 +00:00
luisramos0
b29983ac60 Add AMS versions of the error responses in api/base_controller and cover not_found case with a unit test 2019-10-28 16:00:36 +00:00
luisramos0
91188c5724 Adapt api/base_controller_spec from spree/api/base_controller_spec 2019-10-28 16:00:36 +00:00
luisramos0
bf291ec318 Move spree/api/base_controller_spec to api/base_controller_spec 2019-10-28 16:00:36 +00:00
luisramos0
5846593637 Remove dependency to spree_api rabl responders, we should only use AMS from now on 2019-10-28 16:00:36 +00:00
Luis Ramos
688dad2334 Merge pull request #4384 from chaserx/4378_display_customer_name_on_orders_table
adds the full_name of the customer ordering beneath email
2019-10-28 15:52:54 +00:00
Luis Ramos
6d419d60ae Merge pull request #4405 from openfoodfoundation/dependabot/bundler/bugsnag-6.12.2
Bump bugsnag from 6.12.1 to 6.12.2
2019-10-28 11:37:30 +00:00
luisramos0
0dc8ae1561 Merging find_product and find_variant into one single method
This fixes rubocop issue, class has too many lines
2019-10-27 20:09:42 +00:00
luisramos0
f396f6bebd Add tax category to sample products 2019-10-27 19:59:35 +00:00
luisramos0
07fcc8f361 Refactor ExchangeVariantDeleter.new.delete out of update_product_only_attributes into correct place update_product
Also extracted find_product from update_attributes and find_variant out of create_or_update_variant to make code simpler
2019-10-27 19:13:57 +00:00
Pau Pérez Fabregat
237cd5438b Merge pull request #4373 from openfoodfoundation/dependabot/bundler/i18n-js-3.4.0
Bump i18n-js from 3.3.0 to 3.4.0
2019-10-25 13:47:25 +02:00
Pau Pérez Fabregat
4e366d0f2e Merge pull request #4390 from Matt-Yorkley/3831_flaky_spec
Fix flaky product import spec
2019-10-25 13:42:54 +02:00
dependabot-preview[bot]
fb3af77d0b Bump bugsnag from 6.12.1 to 6.12.2
Bumps [bugsnag](https://github.com/bugsnag/bugsnag-ruby) from 6.12.1 to 6.12.2.
- [Release notes](https://github.com/bugsnag/bugsnag-ruby/releases)
- [Changelog](https://github.com/bugsnag/bugsnag-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bugsnag/bugsnag-ruby/compare/v6.12.1...v6.12.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-24 19:19:06 +00:00
Luis Ramos
1fa6e4bea8 Merge pull request #4385 from chaserx/4304_fixes_missing_translation
adds missing :spree to i18n scopes
2019-10-24 17:06:50 +01:00
Luis Ramos
498a2b7462 Merge pull request #4386 from andrewjprice/missing-translations-inventory-page
Missing translations inventory page
2019-10-24 17:06:43 +01:00
Pau Perez
80edfe469c Task to remove limit of ent. that can be created
It does so by updating a user's enterprise_limit attribute to the
maximum integer the database supports.

This is used at least in Katuma to remove the limitation of the number
of enterprises a user can create. This is the agreement the community
reached for the pricing plans.

Eventually, this logic could be triggered with a button from the UI but
for now this is for internal usage only.
2019-10-24 15:53:43 +02:00
Pau Perez
b2616d317f Task to remove an unused enterprise
Note this task is still rather naive and only covers the simple case
where an enterprise was created but never used and thus, does not have
any associated entities like orders.

This is enough for the case I have at hand where a hub's manager created
an enterprise while he wanted to create a user account #ux. He ended up
with an enterprise named after him and now he asked us to clean that up.
2019-10-24 15:23:54 +02:00
Matt-Yorkley
0ac0bdc381 Update all locales with the latest Transifex translations 2019-10-23 21:20:11 +01:00
Matt-Yorkley
1a756cbc6b Merge pull request #4387 from openfoodfoundation/transifex
Transifex
2019-10-23 21:17:20 +01:00
Matt-Yorkley
34466c8218 Add order_cycle_id and distributor_id indexes to spree_orders table 2019-10-23 18:29:34 +01:00
Matt-Yorkley
00e869f40c Merge pull request #4393 from mkllnk/4392-rescue-network-fails
Avoid asking the cloud if an image exists
2019-10-23 16:55:49 +01:00
luisramos0
42cd9a5152 Remove menu entry option types because this page is not really usable
We keep the underlying data structures because option types and option values are used internally to keep units in OFN: weight, volume and items, but otherwise, custom option types are no longer possible in OFN
2019-10-23 12:57:47 +01:00
luisramos0
cc342387cc Make all calls to content_for use dash not equals when setting content_for 2019-10-23 12:42:29 +01:00
luisramos0
6715f872e3 Merge duplicated product_sub_menu partials and make all references point to the one located in the spree folder (we keep this one because we still have some views in spree backend referencing this partial 2019-10-23 12:26:18 +01:00
Transifex-Openfoodnetwork
e849c4867b Updating translations for config/locales/nb.yml 2019-10-23 18:58:07 +11:00
Maikel Linke
ada34d27ca Avoid asking the cloud if an image exists
https://github.com/openfoodfoundation/openfoodnetwork/issues/4392

Amazon's DNS is failing at the moment and some users can't access the
admin panel because of this error.

While `exists?` asks the storage server if the file is actually there,
`file?` just checks if we have the file name stored in the database
and the file should be there. It's much faster and less error prone.
2019-10-23 11:36:20 +11:00
Dan Ingenthron
40c329ba68 Distinguish between simple create form and full interface in OC feature spec 2019-10-22 17:41:38 -05:00
Dan Ingenthron
3c7af90dfa Revert I18n change and reflect correct required fields on OC form 2019-10-22 17:41:38 -05:00
Dan Ingenthron
241e581779 Add required fields to order cycle spec 2019-10-22 17:41:38 -05:00
Dan Ingenthron
85dede84cc Update order cycle forms & en.yml to include asterisks 2019-10-22 17:41:37 -05:00
Transifex-Openfoodnetwork
0288dfc992 Updating translations for config/locales/ar.yml 2019-10-23 07:18:46 +11:00
luisramos0
3372339907 Fix default stock translation by using t filter instead of t function 2019-10-22 17:29:04 +01:00
Matt-Yorkley
f7bb609546 Fix flaky product import spec 2019-10-22 12:02:11 +01:00
Luis Ramos
02c0b89fa0 Merge pull request #4345 from Matt-Yorkley/shopfront_pagination
Shopfront pagination
2019-10-21 16:02:12 +01:00
luisramos0
f57c9d4a25 Fix rubocop issue in product_set.update_product_only_attributes: method has too many lines 2019-10-21 15:20:53 +01:00
luisramos0
783c3c9e90 Add spec to product set to cover case where product and variants attributes are both provided and the product supplier is not, in that case, ExchangeVariantDeleter would not execute and update_product_only_attributes would return nil cancelling update_product_variants from being executed. Now, update_product_only_attributes always returns true if product.save suceeeds, no matter what ExchangeVariantDeleter returns 2019-10-21 14:45:27 +01:00
luisramos0
44753d0320 Add spec coverage for case in product_set where variants_attributes are used 2019-10-21 13:27:21 +01:00
luisramos0
dd7d5803ba Add new context to spec so that some basic setup can be shared with new specs that will be added, it's mostly indentation here 2019-10-21 13:01:39 +01:00
Luis Ramos
c9e23154d8 Merge pull request #4352 from tkusuki/fix-translation-in-enterprise-welcome-email
Add missing translation in non English enterprise welcome email
2019-10-21 11:41:53 +01:00
Rachel Arnould
279b633513 Add welcome board to the contributing page 2019-10-21 12:19:01 +02:00
Transifex-Openfoodnetwork
9d0ac79983 Updating translations for config/locales/pt_BR.yml 2019-10-21 11:29:14 +11:00
Andrew
deb17f47a7 Add default_stock to en.yml and _products_variants 2019-10-19 16:33:31 -07:00
Chase Southard
61ee0f04a6 adds missing :spree to i18n scopes 2019-10-19 13:55:11 -04:00
Chase Southard
353804a3fa adds the full_name of the customer ordering beneath email 2019-10-19 12:32:59 -04:00
Andrew
598426a5e9 Add Save Changes button translation 2019-10-18 22:18:54 -07:00
Matt-Yorkley
7b0c55e15a Ensure producer properties are included in properties results 2019-10-18 21:15:13 +01:00
Matt-Yorkley
cbe2477d04 Fix property filters and improve test coverage 2019-10-18 21:15:13 +01:00
Matt-Yorkley
c730958fe4 Restrict search params passed to ProductsRenderer 2019-10-18 21:15:13 +01:00
Matt-Yorkley
37e5e1923c Improve filter buttons UX 2019-10-18 21:15:13 +01:00
Matt-Yorkley
542c1bf684 #slice :params in controller and rename to :args in service context 2019-10-18 21:15:13 +01:00
Matt-Yorkley
06c896b93b Add spec for Api::ProductSerializer 2019-10-18 21:15:13 +01:00
Matt-Yorkley
6433d69d02 Add comments on scoping ProductsRenderer results 2019-10-18 21:15:13 +01:00
Matt-Yorkley
bf8c632fce Refactor ProductsCtrl request params 2019-10-18 21:15:13 +01:00
Matt-Yorkley
b3c89a9d6c Move OpenFoodNetwork::ProductsRenderer (lib) to ProductsRenderer (service) and refactor 2019-10-18 21:15:13 +01:00
Matt-Yorkley
d45403f1d4 Add specs for Api::OrderCyclesController 2019-10-18 21:15:13 +01:00
Matt-Yorkley
f2affe80cd Reduce assignment branching and complexity for ProductsRenderer#products 2019-10-18 21:15:13 +01:00
Matt-Yorkley
573a69477f Fix filters not updating on OC change 2019-10-18 21:15:13 +01:00
Matt-Yorkley
c6ce516129 Fix prices not updating with new exchange fees when changing OC 2019-10-18 21:15:13 +01:00
Matt-Yorkley
2539b84b33 Fix product.meta_keywords not searchable 2019-10-18 21:15:13 +01:00
Matt-Yorkley
dd6d0d25da Fix problematic feature specs 2019-10-18 21:15:13 +01:00
Matt-Yorkley
c54cff10d4 Adjust API endpoint params 2019-10-18 21:15:13 +01:00
Matt-Yorkley
ab330e882e Remove product cache 2019-10-18 21:15:11 +01:00
luisramos0
a50ae3f8ce Clarify the API of product_set class by making all other methods to private 2019-10-18 10:37:23 +01:00
luisramos0
9f3b4100c3 Improve code by incorporating code review feedback 2019-10-18 10:26:03 +01:00
luisramos0
b625ea0c61 Extract to class ExchangeVariantDeleter 2019-10-17 19:13:45 +01:00
luisramos0
8857404ddf Remove product variants from all Order Cycles if supplier is changed 2019-10-17 19:12:24 +01:00
luisramos0
49f98422fd Remove product from Order Cycles if supplier changes as with a new supplier the rules/permissions to add a product to an Order Cycle may be different 2019-10-17 17:47:15 +01:00
Maikel Linke
20cabe6f12 Update from Transifex 2019-10-17 17:11:10 +11:00
Maikel
fe849b8dfd Merge pull request #4367 from openfoodfoundation/transifex
Transifex
2019-10-17 17:07:23 +11:00
Luis Ramos
167b44c30f Merge pull request #4365 from kristinalim/fix/4308-eager_load_associations_in_orders_and_fulfillment_reports
4308 Eager-load associations in Orders and Fulfillment reports
2019-10-16 21:39:30 +01:00
Luis Ramos
ad247e2116 Merge pull request #4268 from luisramos0/add_order_endpoint
Add api/orders/{order_number} API endpoint
2019-10-16 21:22:27 +01:00
Luis Ramos
e46875376e Merge pull request #4168 from mkllnk/4160-product-report-filters
4160 Fix product report filters
2019-10-16 14:47:55 +01:00
Jackson Bates
4d49dc3689 adds line breaks to methods for readability 2019-10-16 23:01:38 +11:00
Luis Ramos
d7223c508a Merge pull request #4289 from luisramos0/spree_be_config_general
Move general_settings, mail_methods and image_settings from spree_backend to OFN
2019-10-16 12:08:36 +01:00
Kristina Lim
a91a23aa39 Eager-load associations for Orders and Fulfillment report subtypes 2019-10-16 19:06:35 +08:00
luisramos0
04bf5a8742 Convert images views from erb to haml 2019-10-16 11:58:08 +01:00
Jackson Bates
8d30dc997f adds better description to specs and refactors editProductUrl and confirm_unsaved_changes 2019-10-16 21:55:52 +11:00
luisramos0
6bc0d505e4 Fix some rubocop issues 2019-10-16 10:40:16 +01:00
luisramos0
9a0f1adfd2 Reorganize/simplify before filters 2019-10-16 10:40:09 +01:00
Luis Ramos
370f66e36b Merge pull request #4364 from kristinalim/refactor/4308-refactor_orders_and_fulfillment_report_types
4308 Refactor Orders and Fulfillment report subtypes
2019-10-16 10:30:24 +01:00
Luis Ramos
f7cdcf02e0 Merge pull request #4343 from openfoodfoundation/dependabot/bundler/oauth2-1.4.2
Bump oauth2 from 1.4.1 to 1.4.2
2019-10-16 10:29:25 +01:00
luisramos0
1eafb1a3fe Bring specs from spree_backend to payment methods controller spec 2019-10-15 18:49:35 +01:00
luisramos0
cf40bfa58e Simbolize keys in opts hash in xero report so that opts access works again 2019-10-15 18:05:40 +01:00
Matt-Yorkley
8e03f402b1 Use Ruby 2.2.10 2019-10-15 14:59:24 +01:00
Pau Pérez Fabregat
1ee43fb495 Merge pull request #4358 from openfoodfoundation/dependabot/bundler/rspec-rails-3.9.0
Bump rspec-rails from 3.8.2 to 3.9.0
2019-10-15 10:25:23 +02:00
dependabot-preview[bot]
5a84a3688b Bump i18n-js from 3.3.0 to 3.4.0
Bumps [i18n-js](https://github.com/fnando/i18n-js) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/fnando/i18n-js/releases)
- [Changelog](https://github.com/fnando/i18n-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/fnando/i18n-js/compare/v3.3.0...v3.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-15 04:57:00 +00:00
Transifex-Openfoodnetwork
e139d24639 Updating translations for config/locales/en_CA.yml 2019-10-15 12:06:18 +11:00
luisramos0
ec3c3aa644 Bring images views from spree_backend 2019-10-15 00:02:40 +01:00
luisramos0
0f128f43f9 Merge images controller decorator with the controller brought from spree_backend 2019-10-15 00:02:16 +01:00
luisramos0
ea9f3ad6a0 Bring images controller from spree_backend so we can merge it with ofn's decorator 2019-10-15 00:00:54 +01:00
luisramos0
e48ac64d37 Prepare spec to integrate some specs coming from spree_backend 2019-10-14 23:17:43 +01:00
luisramos0
1c257cca3f Merge payment methods controller brought from spree_backend with its decorator that was in OFN 2019-10-14 23:14:09 +01:00
luisramos0
c51e4d657a Bring payment method controller from spree_backend 2019-10-14 23:09:23 +01:00
Luis Ramos
0dfe749496 Merge pull request #4356 from kristinalim/fix/4256-set_dalli_value_max_size
4256 Configure dalli store value max bytes from env variable
2019-10-14 18:41:00 +01:00
Luis Ramos
d6eade6fa3 Merge pull request #4363 from jonleighton/fix-docker-setup
Fix error during first run of docker-compose
2019-10-14 13:38:04 +01:00
Luis Ramos
109aed684e Merge pull request #4344 from openfoodfoundation/dependabot/bundler/ddtrace-0.28.0
Bump ddtrace from 0.27.0 to 0.28.0
2019-10-14 12:39:52 +01:00
Luis Ramos
35d76ac991 Merge pull request #4298 from luisramos0/variant_edit
Make unit description visible in the variant edit page even for products which variant_unit is items
2019-10-13 19:54:41 +01:00
Luis Ramos
1ab9e9d7a5 Merge pull request #4299 from luisramos0/drop_order_ship_method_id
Remove unused field orders.shipping_method_id
2019-10-13 19:54:13 +01:00
Luis Ramos
e5e716e150 Merge pull request #4336 from openfoodfoundation/dependabot/bundler/rubyzip-1.3.0
[Security] Bump rubyzip from 1.2.2 to 1.3.0
2019-10-13 19:53:48 +01:00
Luis Ramos
b6510c3ab6 Merge pull request #4262 from daningenthron/daningenthron/default-shipping-category
Prefill shipping category forms with default values
2019-10-13 19:52:43 +01:00
Transifex-Openfoodnetwork
a158a986c6 Updating translations for config/locales/en_US.yml 2019-10-11 13:06:17 +11:00
Kristina Lim
c7643db66f Remove unnecessary Orders and Fulfillment lines in .rubocop_manual_todo.yml 2019-10-10 21:05:06 +08:00
Kristina Lim
eb8c22aa06 Disable violated cops in Order and Fulfillment report subtypes 2019-10-10 21:01:46 +08:00
Kristina Lim
d0656485d7 Make report_klass in OrdersAndFulfillmentsReport compact 2019-10-10 21:01:46 +08:00
Kristina Lim
640cc1b6d3 Address Metrics/LineLength in Orders and Fulfillments reports 2019-10-10 21:01:45 +08:00
Kristina Lim
d65d17a9f3 Freeze report type string in Order and Fulfillment reports 2019-10-10 21:01:45 +08:00
Kristina Lim
bbea00e431 Delegate methods in Orders and Fulfillment report to report object 2019-10-10 21:01:45 +08:00
Kristina Lim
3cecba70e8 Refactor and memoize report object in Orders and Fulfillment report 2019-10-10 21:01:44 +08:00
Kristina Lim
8bbff09066 Refactor report class in Orders and Fulfillment report 2019-10-10 21:01:44 +08:00
Kristina Lim
a7a89d7ccb Add attr reader for report type in Orders and Fulfillment report 2019-10-10 21:01:44 +08:00
Kristina Lim
3ccf76ff5f Add smoke test for Customer Totals report 2019-10-10 21:01:34 +08:00
Kristina Lim
6004208496 Move specific logic for Customer Totals report to class 2019-10-10 20:05:35 +08:00
Kristina Lim
3ce9c712cf Add smoke test for Distributor Totals by Supplier report 2019-10-10 20:05:35 +08:00
Kristina Lim
bfb0032fd2 Move specific logic for Distributor Totals by Supplier report to class 2019-10-10 20:05:29 +08:00
Kristina Lim
fe37516ead Add smoke test for Supplier Totals by Distributor report 2019-10-10 19:58:49 +08:00
Kristina Lim
289b75e143 Move specific logic for Supplier Totals by Distributor report to class 2019-10-10 19:57:41 +08:00
Kristina Lim
09f0f8c33f Move "order_cycle_supplier_totals" report type to constant 2019-10-10 19:54:29 +08:00
Kristina Lim
8bc1718978 Add smoke test for Supplier Totals report 2019-10-10 19:50:28 +08:00
Kristina Lim
cbfce69a6d Move specific logic for Supplier Totals report to class 2019-10-10 19:48:59 +08:00
Kristina Lim
4e0ecdd44c Rename params in OrdersAndFulfillmentsReport to options 2019-10-10 15:57:51 +08:00
Jon Leighton
23ab9a4bed Fix error during first run of docker-compose
Prior to this commit, the db container would create a database named
“ofn” (the same as $POSTGRES_USER).

Then, when the web container started, it would run `rake db:reset`. This
would load the Rails environment, which ends up requiring some model
files, which eventually end up trying to connect to the
“open_food_network_dev” database, which doesn’t exist. Therefore setting
up the database fails, and it’s impossible to boot the web container.

As a side note, I’m not convinced that bootstrapping the database as
part of the container’s command is the best strategy (if for no other
reason that this will wipe my database every time I run `docker-compose
up`). But this commit doesn’t change that.

What it does is add the $POSTGRES_DB environment variable so that the db
container creates the “open_food_network_dev” database (which is blank).
Then, when `rake db:reset` runs, it’ll successfully connect to this
(empty) database while loading the environment, before deleting and recreating it.

Note that I had to manually delete the `openfoodnetwork_postgres` volume
in order to reset my local state, after making this change.
2019-10-10 12:17:22 +11:00
Maikel Linke
f623446e3e Avoid additional query in inventory reports 2019-10-10 11:11:14 +11:00
Maikel Linke
6944fe1e46 Make order cycle filter chainable with other filters 2019-10-10 10:06:36 +11:00
Maikel Linke
7c9e3d7f06 Spec combination of all variant filters 2019-10-10 10:06:36 +11:00
dependabot-preview[bot]
614dc5d255 Bump activerecord-import from 1.0.2 to 1.0.3
Bumps [activerecord-import](https://github.com/zdennis/activerecord-import) from 1.0.2 to 1.0.3.
- [Release notes](https://github.com/zdennis/activerecord-import/releases)
- [Changelog](https://github.com/zdennis/activerecord-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zdennis/activerecord-import/compare/v1.0.2...v1.0.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-09 21:47:12 +00:00
Matt-Yorkley
da7456e6e0 Remove old shop/products route, action, and spec 2019-10-09 17:27:00 +01:00
Matt-Yorkley
f134cd9473 Extract tag_rule filtering into separate service 2019-10-09 17:26:58 +01:00
Dan Ingenthron
bdcadf9fc6 Update changes to reflect new non-Spree shipping method controller 2019-10-08 18:37:16 -05:00
Dan Ingenthron
9b7139fd45 Add default shipping category during object creation; revert forms 2019-10-08 18:37:16 -05:00
Dan Ingenthron
543e275d2e Add custom shipping category to pass package spec 2019-10-08 18:37:16 -05:00
Dan Ingenthron
560fa6b949 Update shipping category factory with default 2019-10-08 18:37:16 -05:00
Dan Ingenthron
dbf34da87b Rubocop fixes 2019-10-08 18:37:16 -05:00
Dan Ingenthron
d6022062e1 Use default for create product spec; auto-fill field 2019-10-08 18:37:16 -05:00
Dan Ingenthron
b082d3301b Add prechecked category to shipping method spec 2019-10-08 18:37:16 -05:00
Dan Ingenthron
48cd542138 Service spec 2019-10-08 18:37:15 -05:00
Dan Ingenthron
e2d341c9c2 Add default category to seeds 2019-10-08 18:37:15 -05:00
Dan Ingenthron
89873a2640 Add and auto-check default category in shipping method create 2019-10-08 18:37:15 -05:00
Dan Ingenthron
b4be2cc2d4 Add default shipping category service and update create product form 2019-10-08 18:37:15 -05:00
Dan Ingenthron
35f89a9750 Update spec to prefill shipping category in Create form 2019-10-08 18:37:15 -05:00
Dan Ingenthron
592a53b6f5 Remove blank option from shipping category dropdown 2019-10-08 18:37:15 -05:00
dependabot-preview[bot]
eab9d42eb0 Bump rspec-rails from 3.8.2 to 3.9.0
Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 3.8.2 to 3.9.0.
- [Release notes](https://github.com/rspec/rspec-rails/releases)
- [Changelog](https://github.com/rspec/rspec-rails/blob/master/Changelog.md)
- [Commits](https://github.com/rspec/rspec-rails/compare/v3.8.2...v3.9.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-08 20:56:10 +00:00
Kristina Lim
cf05369ca9 Configure dalli store value max bytes from env variable 2019-10-08 17:58:43 +08:00
Matt-Yorkley
e96252f2ed Add tag_rules logic to main query before pagination 2019-10-08 10:11:24 +01:00
Matt-Yorkley
06e1f56ae9 Extract filter list fetching into a separate endpoint 2019-10-08 10:11:24 +01:00
Matt-Yorkley
fe0de98821 Add pagination in Angular and views 2019-10-08 10:11:22 +01:00
luisramos0
5077b0e625 Update all locales with the latest Transifex translations 2019-10-08 10:02:54 +01:00
Luis Ramos
1299c0b5eb Merge pull request #4339 from openfoodfoundation/transifex
Transifex
2019-10-08 09:40:54 +01:00
luisramos0
a2bc61cb4d Remove unused field orders.shipping_method_id 2019-10-08 09:09:19 +01:00
Pau Pérez Fabregat
057572a445 Merge pull request #4321 from luisramos0/fix_pt_br
Delete old pt-BR translations file (it's now correctly called pt_BR)
2019-10-08 08:49:12 +02:00
Pau Pérez Fabregat
3403ab4162 Merge pull request #4340 from openfoodfoundation/sigmundpetersen-patch-1
Delete ISSUE_TEMPLATE.md
2019-10-08 08:48:47 +02:00
Thais Kusuki
d997b8f5ee Change translations from enterprise_mailer to lazy lookup 2019-10-07 23:29:11 -03:00
agustina
cf3f321632 Added color to links in WYSIWYG editor 2019-10-07 12:15:37 -03:00
Luis Ramos
9a036d18b7 Merge pull request #4271 from luisramos0/no_obsolete_master
Remove logic related to master variants in Exchanges and migrate data
2019-10-07 15:22:53 +01:00
luisramos0
f2b57057cd Add migration to delete all master variants from exchanges and replace them with standard variants 2019-10-07 14:53:44 +01:00
luisramos0
95bc8fa984 Remove logic from OrderCycleDistributedProducts related to obsolete master variants in OCs, this is a condition that will never happen now since we ensure products always have a standard variants
A migration will be added as well to clean up any very old master variants available in order cycles
2019-10-07 14:53:44 +01:00
Luis Ramos
54c44c33eb Merge pull request #4324 from Matt-Yorkley/reports_memoize
Reports memoization
2019-10-07 13:20:03 +01:00
Luis Ramos
8a732568e7 Merge pull request #4325 from kristinalim/feature/4312-remove_find_variant_in_orders_and_fulfillment_report
4312 Use association instead of OrderAndFulfillmentsReport#find_variant
2019-10-07 11:38:37 +01:00
Thais Kusuki
797a3ad091 Add missing translation in non English enterprise welcome email 2019-10-05 12:50:12 -03:00
Pau Pérez Fabregat
f4523f0305 Merge pull request #4350 from luisramos0/docker
Update ruby version in dockerfile and in getting started
2019-10-04 16:21:22 +02:00
Transifex-Openfoodnetwork
56a7a49ea2 Updating translations for config/locales/es.yml 2019-10-04 21:23:11 +10:00
Transifex-Openfoodnetwork
7d1ae3bf67 Updating translations for config/locales/es.yml 2019-10-04 21:20:03 +10:00
Transifex-Openfoodnetwork
b9aa4e11da Updating translations for config/locales/ca.yml 2019-10-04 21:19:57 +10:00
Matt-Yorkley
01d1e8243c Add pagination to ProductsRenderer 2019-10-04 10:38:43 +01:00
Matt-Yorkley
a1a5c3b7fe Add new Angular OrderCycleResource 2019-10-04 10:38:41 +01:00
Matt-Yorkley
bc826f73a1 Add temporary placeholder for API endpoint 2019-10-03 18:11:40 +01:00
Luis Ramos
96428c11c6 Merge pull request #4334 from Matt-Yorkley/products_renderer
Products renderer
2019-10-03 13:47:04 +01:00
Luis Ramos
c15660da0e Merge pull request #4269 from luisramos0/spree_be_config
Move shipping_methods and shipping categories from spree_backend to OFN
2019-10-03 13:45:17 +01:00
Jackson Bates
7c264af0c2 updates specs for new edit button behaviour 2019-10-03 22:32:43 +10:00
Transifex-Openfoodnetwork
9ea05b0794 Updating translations for config/locales/de_DE.yml 2019-10-03 20:48:44 +10:00
luisramos0
c5b939c8ee Update ruby version in dockerfile and in getting started 2019-10-02 23:45:23 +01:00
luisramos0
c5a17bcde0 Fix rubocop issues in feature specs related to configuration 2019-10-02 21:26:10 +01:00
luisramos0
b712ec7f13 Transpec feature specs brought from spre_backend 2019-10-02 21:26:09 +01:00
luisramos0
32a7f13dd2 Bring feature specs for configuration pages from spree_backend 2019-10-02 21:26:09 +01:00
luisramos0
713769b497 Fix rubocop issues in mail_methods_controller_spec 2019-10-02 21:26:09 +01:00
luisramos0
495de37620 Fix more rubocop issues in image_settings_controller_spec 2019-10-02 21:26:09 +01:00
luisramos0
05d24cf11a Transpec image_setting_controller_spec 2019-10-02 21:26:09 +01:00
luisramos0
edd84530af Fix simle rubocopo issues in image_settings ctrl spec 2019-10-02 21:26:09 +01:00
luisramos0
6677543de0 bring 2 specs from spree_backend to cover image_settings page and mail_methods page 2019-10-02 21:26:09 +01:00
luisramos0
30aa31252b Fix simple rubocop issues in helpers 2019-10-02 21:26:09 +01:00
luisramos0
b83d74a609 Bring general_settings_helper from spree_backend 2019-10-02 21:26:09 +01:00
luisramos0
d31b50be3d Bring spree/admin configuration routes to ofn 2019-10-02 21:26:09 +01:00
luisramos0
42e3f2f2f4 Convert spree/admin/mail_methods from erb to haml 2019-10-02 21:25:23 +01:00
luisramos0
96737da128 Add spree_backend mail methods views that are missing in ofn 2019-10-02 21:25:23 +01:00
luisramos0
7f9f0d840c Merge decorators into controllers and remove decorators 2019-10-02 21:25:23 +01:00
luisramos0
686840e262 Fix basic rubocop issues in recently added controllers from spree_backend 2019-10-02 21:25:23 +01:00
luisramos0
2377b833ee Bring general settings and image settings controllers that are overrides in ofn to ofn so we can merge them with their decorators in a second step 2019-10-02 21:25:23 +01:00
luisramos0
3f3c33bce6 Fix basic rubocop issues in newly added controller 2019-10-02 21:25:23 +01:00
luisramos0
e35eff95bb Add mail_methods controller from spree_backend related to config 2019-10-02 21:25:23 +01:00
Luis Ramos
e6408161db Merge pull request #4291 from luisramos0/spree_be_config_taxons
Move taxons and taxonomies from spree_backend to OFN
2019-10-02 21:13:12 +01:00
Luis Ramos
4540b32d3a Merge branch 'master' into spree_be_config_taxons 2019-10-02 15:35:15 +01:00
Luis Ramos
9f8d2fddbc Merge pull request #4292 from luisramos0/spree_be_config_tax
Move tax_rates, tax categories and tax settings from spree_backend to OFN
2019-10-02 15:33:32 +01:00
Luis Ramos
14047c620a Merge branch 'master' into spree_be_config_tax 2019-10-02 15:31:25 +01:00
Luis Ramos
2be1c231f7 Merge pull request #4290 from luisramos0/spree_be_config_zones
Move zones, countries and states from spree_backend to OFN
2019-10-02 14:30:59 +01:00
Luis Ramos
c34646724c Merge pull request #4254 from luisramos0/swagger
Update API swagger docs to reflect current API state
2019-10-02 10:31:13 +01:00
Luis Ramos
b731635270 Merge pull request #4303 from luisramos0/missing_translation
Add missing translation for order.shipment.state "on hand" (with a space between on and hand)
2019-10-02 10:27:33 +01:00
Transifex-Openfoodnetwork
c9a62fad4c Updating translations for config/locales/nb.yml 2019-10-02 16:50:07 +10:00
Transifex-Openfoodnetwork
70169d477c Updating translations for config/locales/nb.yml 2019-10-02 16:47:01 +10:00
Transifex-Openfoodnetwork
d95646ea98 Updating translations for config/locales/en_NZ.yml 2019-10-02 14:29:29 +10:00
Transifex-Openfoodnetwork
d50bf928e1 Updating translations for config/locales/de_DE.yml 2019-10-02 10:58:44 +10:00
Luis Ramos
3f7aff4b8b Merge pull request #4305 from luisramos0/new_product_translations
Make translations in new product page relative and specific to the page
2019-10-01 22:38:49 +01:00
dependabot-preview[bot]
de9476a8a5 Bump ddtrace from 0.27.0 to 0.28.0
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 0.27.0 to 0.28.0.
- [Release notes](https://github.com/DataDog/dd-trace-rb/releases)
- [Changelog](https://github.com/DataDog/dd-trace-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/DataDog/dd-trace-rb/compare/v0.27.0...v0.28.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-01 21:12:18 +00:00
Sigmund Petersen
5fded022d4 Update README.md
Slack invite link changed
2019-10-01 23:09:47 +02:00
dependabot-preview[bot]
bce41a2247 Bump oauth2 from 1.4.1 to 1.4.2
Bumps [oauth2](https://github.com/oauth-xx/oauth2) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/oauth-xx/oauth2/releases)
- [Changelog](https://github.com/oauth-xx/oauth2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/oauth-xx/oauth2/compare/v1.4.1...v1.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-01 21:04:45 +00:00
Pau Pérez Fabregat
1f644f4020 Merge pull request #4281 from Matt-Yorkley/memcached-apm
Add memcached APM
2019-10-01 18:46:22 +02:00
Matt-Yorkley
cc11d4e5f0 Remove unused user parameter from OrdersAndFulfillmentsReport 2019-10-01 15:59:51 +01:00
Pau Pérez Fabregat
5ecac77aa5 Merge branch 'master' into memcached-apm 2019-10-01 16:58:01 +02:00
Matt-Yorkley
a5d2579c69 Pluck line_item ids instead of all line_items 2019-10-01 15:51:45 +01:00
Matt-Yorkley
112adb11db Pass permissions object into OrdersAndFulfillMentsReport 2019-10-01 15:51:43 +01:00
Transifex-Openfoodnetwork
5fdc11bdc7 Updating translations for config/locales/fr.yml 2019-10-01 23:59:19 +10:00
Matt-Yorkley
c038b485b1 Rename service and methods to remove use of "shop" term 2019-10-01 14:43:47 +01:00
Jackson Bates
4c4bdd78e7 makes edit button action open a new tab 2019-10-01 22:13:28 +10:00
Luis Ramos
19eb93012c Merge pull request #4326 from kristinalim/feature/4310-remove_shipments_count
4310 Do not count order shipments in Order#shipping_method
2019-10-01 11:17:42 +01:00
Luis Ramos
d998ec8453 Merge pull request #4331 from openfoodfoundation/dependabot/bundler/uglifier-4.2.0
Bump uglifier from 4.1.20 to 4.2.0
2019-10-01 11:11:35 +01:00
Luis Ramos
0c93665030 Merge pull request #4335 from Matt-Yorkley/remove_deprecations
Remove deprecation warnings from VariantStock methods
2019-10-01 10:59:57 +01:00
Luis Ramos
c4d298d732 Merge branch 'master' into remove_deprecations 2019-10-01 10:57:10 +01:00
dependabot-preview[bot]
36883bc051 [Security] Bump rubyzip from 1.2.2 to 1.3.0
Bumps [rubyzip](https://github.com/rubyzip/rubyzip) from 1.2.2 to 1.3.0. **This update includes a security fix.**
- [Release notes](https://github.com/rubyzip/rubyzip/releases)
- [Changelog](https://github.com/rubyzip/rubyzip/blob/master/Changelog.md)
- [Commits](https://github.com/rubyzip/rubyzip/compare/v1.2.2...v1.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-01 09:55:53 +00:00
Luis Ramos
8c252fc160 Merge pull request #4341 from openfoodfoundation/dependabot/bundler/webmock-3.7.6
Bump webmock from 3.7.5 to 3.7.6
2019-10-01 10:53:54 +01:00
Pau Pérez Fabregat
c2f8803d72 Merge pull request #4297 from luisramos0/inv_levels
Remove all usages of Spree Config track_inventory_levels
2019-10-01 10:35:20 +02:00
dependabot-preview[bot]
07967275d8 Bump webmock from 3.7.5 to 3.7.6
Bumps [webmock](https://github.com/bblimke/webmock) from 3.7.5 to 3.7.6.
- [Release notes](https://github.com/bblimke/webmock/releases)
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.7.5...v3.7.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-30 22:02:54 +00:00
Sigmund Petersen
c7db1b7fc0 Delete ISSUE_TEMPLATE.md
This ISSUE_TEMPLATE.md file is the old way of handling templates on Github. OFN is now using the new method for handling templates, so this file can be removed. 
This template still comes up as 'Default template' when opening an issue from the Zenhub board. This gives 2 almost equal template choices which is confusing.
2019-09-30 21:18:51 +02:00
Rachel Arnould
fa57d71a23 Merge pull request #4332 from openfoodfoundation/RachL-patch-2
Update story template
2019-09-30 20:06:12 +02:00
Rachel Arnould
be5e7bd18d Merge pull request #4330 from openfoodfoundation/RachL-patch-1
Update bug template
2019-09-30 20:05:51 +02:00
Transifex-Openfoodnetwork
5cfc2613ac Updating translations for config/locales/en_GB.yml 2019-10-01 04:01:28 +10:00
Transifex-Openfoodnetwork
903eb23122 Updating translations for config/locales/en_GB.yml 2019-10-01 03:58:19 +10:00
Luis Ramos
d162e8c087 Merge pull request #4300 from daningenthron/daningenthron/add-a-new-card
Translation: "Add new credit card"
2019-09-30 13:27:25 +01:00
Luis Ramos
75a56c2be5 Merge pull request #4293 from jasonk357/4031-change-user-email-alert
Improve user email change flash alert message
2019-09-30 13:19:40 +01:00
Luis Ramos
07a5963554 Merge pull request #4311 from mkllnk/rails3-deprecations
Replace deprecated validates_presence_of
2019-09-30 13:19:25 +01:00
luisramos0
a6888cf0be Update all locales with the latest Transifex translations 2019-09-30 13:15:45 +01:00
Luis Ramos
ef35db6db2 Merge pull request #4296 from luisramos0/subs_line_items
Make subscription line items handle soft deleted variants
2019-09-30 13:07:10 +01:00
Rachel Arnould
375d4fbffd Add workaround item 2019-09-30 11:02:36 +02:00
Matt-Yorkley
6153789055 Eager-load serialized objects in variant query 2019-09-29 20:44:48 +01:00
Matt-Yorkley
032741c54f Refactor ProductsRenderer variants queries
This removes another N+1 and allows pagination applied to the inital query to also affect the returned variants
2019-09-29 17:41:58 +01:00
Matt-Yorkley
e9acf6e0de Refactor #load_products and memoize 2019-09-29 14:30:04 +01:00
Matt-Yorkley
d5e90c3c6c Extract #load_products logic into a new service 2019-09-29 00:10:47 +01:00
Kristina Lim
bb56e9a5b9 Set default date range for Orders and Fulfillment report 2019-09-28 02:39:41 +08:00
Matt-Yorkley
7e7429446d Remove deprecation warnings from VariantStock methods 2019-09-27 17:28:16 +01:00
Matt-Yorkley
535e389fb4 Query variant stock including overrides
This allows the results to be properly filtered and paginated whilst showing the correct stock, and removes a big N+1
2019-09-27 17:25:52 +01:00
Matt-Yorkley
cecebb82f4 Move distributed products relation out from OrderCycleDistributedProducts 2019-09-27 17:25:50 +01:00
Pau Pérez Fabregat
49665ae360 Merge pull request #4167 from luisramos0/last_dedeface
Move app_wrapper deface to spree/layouts/admin view
2019-09-27 09:21:28 +02:00
Pau Pérez Fabregat
7e5c194515 Merge pull request #4295 from coopdevs/enable-datadog-analytics
Enable trace & search analytics in Datadog
2019-09-27 09:17:03 +02:00
Matt-Yorkley
fe0b3172c7 Move scoper to method 2019-09-27 01:52:45 +01:00
Matt-Yorkley
5b27ed6b9f Remove unnecessary #deleted? check
It should be included in te default product scope
2019-09-27 01:52:29 +01:00
Matt-Yorkley
bef4741e31 Enable analytics in all APM services 2019-09-26 22:38:20 +01:00
Rachel Arnould
d604328bfb Update story template 2019-09-26 21:25:01 +02:00
dependabot-preview[bot]
2af3de51c7 Bump uglifier from 4.1.20 to 4.2.0
Bumps [uglifier](https://github.com/lautis/uglifier) from 4.1.20 to 4.2.0.
- [Release notes](https://github.com/lautis/uglifier/releases)
- [Changelog](https://github.com/lautis/uglifier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/lautis/uglifier/compare/v4.1.20...v4.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-26 19:21:05 +00:00
Rachel Arnould
d0c77a8dc4 Update bug template 2019-09-26 21:20:50 +02:00
Kristina Lim
8fc4ca6f65 Do not use OrderAndFulfillmentsReport#find_variant 2019-09-26 11:45:05 +08:00
Kristina Lim
721a0d3a98 Do not count order shipments in Order#shipping_method 2019-09-26 11:01:06 +08:00
JASON KNOEPFLER
c46fe7b675 encapsulate new unconfirmed email logic 2019-09-25 19:41:33 -07:00
luisramos0
bb372984e1 Deleting old pt-BR translations file, it's now called pt_BR with underscore 2019-09-25 11:26:06 +01:00
Luis Ramos
2489a2f5f5 Merge pull request #4294 from openfoodfoundation/transifex
Transifex
2019-09-25 11:22:58 +01:00
Transifex-Openfoodnetwork
a6698230fe Updating translations for config/locales/en_NZ.yml 2019-09-25 20:13:57 +10:00
luisramos0
50731e929e Remove some attributes from test as they are already verified subsequently 2019-09-25 09:54:33 +01:00
luisramos0
baa09b88f7 Fix issue with nil current_order where shipping_method serializer requires a current_order to calculate the shipping fees 2019-09-25 09:52:10 +01:00
Luis Ramos
2f3509bf9b Merge pull request #4287 from luisramos0/mini_racer
Replace therubyracer with mini_racer.
2019-09-24 19:48:50 +01:00
Dan Ingenthron
e8f9ace8e6 Correct translation key on add card link 2019-09-24 13:42:31 -05:00
Luis Ramos
04270b6cec Merge pull request #4286 from luisramos0/transpec
Finish transpec
2019-09-24 19:33:26 +01:00
Matt-Yorkley
1155931ea9 Merge pull request #4280 from luisramos0/knapsack
Update knapsack report
2019-09-24 19:26:27 +01:00
Maikel Linke
efd450606e Replace deprecated validates_presence_of
This syntax has been deprecated in Rails 3:
https://guides.rubyonrails.org/3_0_release_notes.html#patches-and-deprecations
2019-09-24 19:16:05 +10:00
luisramos0
2f60a85593 Improve spec/controllers/api/orders_controller_spec, make it more readable 2019-09-23 23:50:42 +01:00
luisramos0
78cf35807a Improve preloading of order query to avoid N+1 queries 2019-09-23 23:50:39 +01:00
luisramos0
f3bc038c05 Make translations in new product page relative and specific to the page 2019-09-23 17:02:30 +01:00
luisramos0
7817a40a35 Add missing translation for shipment state on hand with space between on and hand 2019-09-23 16:33:59 +01:00
Transifex-Openfoodnetwork
a18f6f5b8f Updating translations for config/locales/fr_CA.yml 2019-09-24 01:01:41 +10:00
Transifex-Openfoodnetwork
403653381c Updating translations for config/locales/en_CA.yml 2019-09-24 00:59:20 +10:00
luisramos0
eb85dccac1 Remove single letter variable names 2019-09-22 21:07:32 +01:00
luisramos0
f32454b404 Add feature spec to validate unit_description is editable for products with unit items, regression for #3649 2019-09-22 21:02:32 +01:00
luisramos0
591efecde6 Make unit description field visible in the variant edit page even for products which variant_unit is items 2019-09-22 16:42:03 +01:00
luisramos0
24afa21885 Revert "Change products controller to clear variants unit description if variant_unit is items"
This reverts commit 1a4e83d633.
2019-09-22 16:31:26 +01:00
luisramos0
cd6d34663e Remove all usages of Spree Config track_inventory_levels, this is always true in OFN since v2.0.0 2019-09-22 15:25:24 +01:00
luisramos0
c66e5fe1e9 Make subscription line items handle soft deleted variants
This ensures subscription list page works. The variant can be removed from the subscription by the user in the edit subscription page
2019-09-22 14:59:59 +01:00
JASON KNOEPFLER
4ec8fcd3a6 Assign flash message var from conditional return 2019-09-21 08:10:58 -07:00
Pau Perez
88893a2968 Enable trace & search analytics in Datadog
This will enrich the quality of the reported traces for all web
frameworks in our stack. That means not only memcached as we did in
https://github.com/openfoodfoundation/openfoodnetwork/pull/4266 but
PostgreSQL and Rails too.

After enabling, the Trace Search & Analytics page populates which allows
us to search traces and add APM queries to dashboards.
2019-09-21 14:09:27 +02:00
JASON KNOEPFLER
62599e8dfc Edit user email feature spec 2019-09-20 15:28:25 -07:00
Transifex-Openfoodnetwork
b97c428f72 Updating translations for config/locales/pt_BR.yml 2019-09-21 04:00:00 +10:00
Transifex-Openfoodnetwork
42b074f02e Updating translations for config/locales/pt_BR.yml 2019-09-21 03:56:52 +10:00
JASON KNOEPFLER
07e0951490 Change users#update email change flash alert 2019-09-20 10:35:25 -07:00
luisramos0
fc433ff8f0 Refactor ship methods controller destroy action: remove single action before_filter 2019-09-20 16:29:36 +01:00
luisramos0
8e33437fbb MErge ship method controller decorator with the controller that came from spree 2019-09-20 15:59:24 +01:00
luisramos0
a5103c737d Fix rubocop issues in ship methods controller from spree 2019-09-20 15:58:05 +01:00
luisramos0
37c8f42244 Bring shipping methods and categories controllers from spree_backend 2019-09-20 15:56:24 +01:00
luisramos0
0e8765636b Bring tax_settings from spree_backend to ofn 2019-09-20 15:46:33 +01:00
luisramos0
6855e5c8f4 Fix rubocop issues in feature spec 2019-09-20 15:43:55 +01:00
luisramos0
a96b56239c Transpec feature specs brought from spre_backend 2019-09-20 15:43:55 +01:00
luisramos0
4f9eee2682 Fix feature specs added from spree_backend in the configuration area 2019-09-20 15:43:55 +01:00
luisramos0
44761315c2 Bring feature specs for configuration pages from spree_backend 2019-09-20 15:43:55 +01:00
luisramos0
0d18b1a032 Bring spree/admin configuration routes to ofn 2019-09-20 15:43:55 +01:00
luisramos0
cc0dabcd1e Convert spree/admin/tax_rates from erb to haml 2019-09-20 15:36:58 +01:00
luisramos0
e79c672263 Convert spree/admin/tax_categories from erb to haml 2019-09-20 15:36:54 +01:00
luisramos0
bc6f7934e0 Add spree_backend views related to admin/configuration menu that are missing in ofn 2019-09-20 15:35:49 +01:00
luisramos0
89029f46f9 Fix basic rubocop issues in newly added controller 2019-09-20 15:32:34 +01:00
luisramos0
144369e55f Add tax related controllers from spree_backend related to config 2019-09-20 15:31:30 +01:00
luisramos0
3833cbbf73 Fix rubocop issues in feature spec 2019-09-20 15:24:26 +01:00
luisramos0
5b703a02cd Transpec feature spec brought from spree_backend 2019-09-20 15:24:26 +01:00
luisramos0
1d4aebd3f9 Fix feature spec added from spree_backend 2019-09-20 15:24:15 +01:00
luisramos0
845a764320 Bring taxonomies feature spec from spree_backend 2019-09-20 15:24:06 +01:00
luisramos0
c66579a22f Fix simple rubocop issues in helper 2019-09-20 15:24:06 +01:00
luisramos0
9291bf5c82 Bring taxons_helper from spree 2019-09-20 15:24:06 +01:00
luisramos0
4781ab93ef Bring spree/admin configuration routes to ofn 2019-09-20 15:24:06 +01:00
luisramos0
def9ab7c47 Convert spree/admin/taxons from erb to haml 2019-09-20 15:24:06 +01:00
luisramos0
2a68d34fb0 Convert spree/admin/taxonomies from erb to haml 2019-09-20 15:24:06 +01:00
luisramos0
2ce56aef2c Add spree_backend views related to admin/configuration taxonomies that are missing in ofn 2019-09-20 15:23:45 +01:00
luisramos0
20f965731d Fix basic rubocop issues in recently added controller from spree_backend 2019-09-20 15:14:34 +01:00
luisramos0
8378dce752 Bring taxons config controller that is overriden in ofn to ofn so we can merge them with their decorator in a second step 2019-09-20 15:13:45 +01:00
luisramos0
d7a4e3a896 Add taxonomies controller from spree_backend 2019-09-20 15:12:38 +01:00
luisramos0
7d9de0ca70 Fix rubocop issues in feature specs 2019-09-20 15:07:34 +01:00
luisramos0
f9c6f09cd4 Transpec feature specs brought from spre_backend 2019-09-20 15:06:02 +01:00
luisramos0
4a83eca832 Fix feature specs added from spree_backend in the configuration area 2019-09-20 15:05:21 +01:00
luisramos0
4954db64b3 Bring feature specs for configuration pages from spree_backend 2019-09-20 15:04:45 +01:00
luisramos0
b2c4b97d94 Bring spree/admin configuration routes to ofn 2019-09-20 15:02:01 +01:00
luisramos0
32c1eecece Convert spree/admin/zones from erb to haml 2019-09-20 15:01:06 +01:00
luisramos0
6d8c7a4bee Fix minor detail in states and countries views 2019-09-20 14:57:48 +01:00
luisramos0
bd2045cad7 Convert spree/admin/states from erb to haml 2019-09-20 14:55:36 +01:00
luisramos0
e1c3d2442a Convert spree/admin/countries from erb to haml 2019-09-20 14:55:10 +01:00
luisramos0
3df65d0463 Add spree_backend views related to admin/configuration menu that are missing in ofn 2019-09-20 14:54:55 +01:00
luisramos0
822a17f732 Fix basic rubocop issues in newly added controllers 2019-09-20 14:50:38 +01:00
luisramos0
ffde0307e2 Add controllers from spree_backend related to config 2019-09-20 14:50:01 +01:00
luisramos0
9e57807dc2 Replace therubyracer with mini_racer.
This is being replaced to increase the reliability and speed of asset compilation.
2019-09-20 11:22:07 +01:00
luisramos0
052bac196b Fix problem in spec/features/consumer/shopping/shopping_spec introduced with transpec 2019-09-20 10:33:40 +01:00
luisramos0
00e789b95b Force use of expect over should in spec expectations 2019-09-20 10:29:56 +01:00
luisramos0
a004822019 Transpec spec/features/consumer/shopping/shopping_spec 2019-09-20 10:16:08 +01:00
luisramos0
49f7b4c8e2 Transpec spec/features/consumer/shopping/cart_spec.rb 2019-09-20 10:11:02 +01:00
luisramos0
8b503b51ca Fix typo in spec name 2019-09-20 10:03:52 +01:00
luisramos0
4e431ecf18 Transpec spec/features/consumer/shopping/products_spec.rb 2019-09-20 10:02:27 +01:00
luisramos0
81f8b127db Transpec spec/features/consumer/authentication_spec.rb and spec/features/consumer/producers_spec.rb 2019-09-20 09:53:23 +01:00
luisramos0
f9f81086fd Transpec features/consumer/shopping/variant_overrides_spec 2019-09-20 09:02:43 +01:00
Luis Ramos
9807b432f9 Merge pull request #4272 from openfoodfoundation/dependabot/bundler/webmock-3.7.5
Bump webmock from 3.7.4 to 3.7.5
2019-09-20 08:42:12 +01:00
luisramos0
6b0f3cd4f3 Transpec spec/performance/shop_controller_spec 2019-09-19 20:36:33 +01:00
luisramos0
3c412b7b7d Transpec spec/controllers/api/taxonomies_controller_spec, spec/controllers/api/taxons_controller_spec and spec/models/enterprise_spec 2019-09-19 20:34:30 +01:00
luisramos0
c4e6c0af2b Transpec features/consumer/registration_spec 2019-09-19 20:18:24 +01:00
Matt-Yorkley
e6387197ec Add memcached APM 2019-09-19 19:48:16 +01:00
Luis Ramos
746c4f03f6 Merge pull request #4261 from jasonk357/3979-malformed-referer-error
Guard against malformed request referer
2019-09-19 17:29:18 +01:00
Kristina Lim
3535c4d564 Merge pull request #4240 from Matt-Yorkley/backorder_to_the_future_2
Disentangle on_demand and backordered
2019-09-20 00:05:27 +08:00
luisramos0
37abdb7727 Update knapsack report 2019-09-19 16:58:06 +01:00
luisramos0
bdb3dd5aaf Fix long lines in app/serializers 2019-09-19 16:32:09 +01:00
luisramos0
25fbab2e37 Use memoized order method 2019-09-19 16:32:09 +01:00
luisramos0
4d37aaac64 Use have_http_status and remove check for error message, that's something for the base_controller test to test 2019-09-19 16:32:09 +01:00
luisramos0
19e28cb14a Make spec/controllers/api/orders_controller_spec more simple assuming adjustments will always come in the same order 2019-09-19 16:32:09 +01:00
luisramos0
a44a251d96 Remove duplicated attributes tag from all serializers to create consistency 2019-09-19 16:32:09 +01:00
luisramos0
2921ee19e1 Add api/order/{order_number} ednpoint and its new order detailed serializer 2019-09-19 16:32:09 +01:00
luisramos0
6796d91a07 Add some basic attributes to address and order serializers that will be used in the order show api endpoint 2019-09-19 16:32:09 +01:00
luisramos0
69afcf7510 Improve readability in order permissions 2019-09-19 16:32:09 +01:00
dependabot-preview[bot]
47056e3cc1 Bump webmock from 3.7.4 to 3.7.5
Bumps [webmock](https://github.com/bblimke/webmock) from 3.7.4 to 3.7.5.
- [Release notes](https://github.com/bblimke/webmock/releases)
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.7.4...v3.7.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-19 13:10:20 +00:00
Kristina Lim
311ee92e84 Update all locales with the latest Transifex translations 2019-09-19 17:08:17 +08:00
Kristina Lim
241e97d938 Merge pull request #4241 from openfoodfoundation/transifex
Transifex
2019-09-19 16:58:57 +08:00
Pau Pérez Fabregat
85b1ba8eae Merge pull request #4263 from coopdevs/index-frequent-spree-orders-query
Index spree_orders on various columns
2019-09-19 10:12:54 +02:00
Pau Pérez Fabregat
baa4783141 Merge pull request #4260 from jasonk357/4184-delivery-report-default-range
Add default date range to Delivery Report
2019-09-19 09:58:06 +02:00
Transifex-Openfoodnetwork
ce40fcaf7b Updating translations for config/locales/fr.yml 2019-09-19 07:44:00 +10:00
Luis Ramos
40438de7fe Merge pull request #4250 from Matt-Yorkley/ruby-2.1.9
Bump Ruby version from 2.1.5 to 2.1.9
2019-09-18 11:39:15 +01:00
Luis Ramos
29dcd96fca Merge pull request #4265 from openfoodfoundation/dependabot/bundler/simplecov-0.17.1
Bump simplecov from 0.17.0 to 0.17.1
2019-09-18 10:25:54 +01:00
Pau Pérez Fabregat
7fd6a7e654 Merge pull request #4270 from openfoodfoundation/dependabot/bundler/webmock-3.7.4
Bump webmock from 3.7.3 to 3.7.4
2019-09-18 10:11:11 +02:00
dependabot-preview[bot]
8f2a80f199 Bump webmock from 3.7.3 to 3.7.4
Bumps [webmock](https://github.com/bblimke/webmock) from 3.7.3 to 3.7.4.
- [Release notes](https://github.com/bblimke/webmock/releases)
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.7.3...v3.7.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-17 19:21:37 +00:00
Pau Perez
ea41405209 Index spree_orders on various columns
The following query

```sql
SELECT spree_orders . *
FROM spree_orders
WHERE spree_orders . user_id = ?
AND spree_orders . completed_at IS ?
AND spree_orders . created_by_id = ?
ORDER BY created_at DESC LIMIT ?
```

performs quite badly even though LIMIT is always 1 because:

* ORDER BY requires sorting by a column which is not indexed therefore
a sequential scan is performed.
* Although `completed_at` is indexed, `user_id` and `created_by_id` are
not causing a sequential scan.

To make it worse this query is executed very often in the following
controllers among others also related to checkout:

* CartController#populate
* EnterprisesController#Shop
* LineItemsController#bought
* ShopController#products
* ShopController#order_cycle

In some cases this query alone accounts for 66.8% of the total time
of the endpoint.

Results

See by yourself. We move from 56.643ms to 0.077ms. Pretty neat.

```
openfoodnetwork=> explain analyze SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = 1 AND "spree_orders"."completed_at" IS NULL AND "spree_orders"."created_by_id" = 1 ORDER BY created_at DESC LIMIT 1;
                                                        QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=11753.03..11753.04 rows=1 width=195) (actual time=56.580..56.580 rows=0 loops=1)
   ->  Sort  (cost=11753.03..11753.04 rows=1 width=195) (actual time=56.578..56.578 rows=0 loops=1)
         Sort Key: created_at DESC
         Sort Method: quicksort  Memory: 25kB
         ->  Seq Scan on spree_orders  (cost=0.00..11753.02 rows=1 width=195) (actual time=56.571..56.571 rows=0 loops=1)
               Filter: ((completed_at IS NULL) AND (user_id = 1) AND (created_by_id = 1))
               Rows Removed by Filter: 256135
 Planning time: 0.252 ms
 Execution time: 56.643 ms
(9 rows)

openfoodnetwork=> CREATE INDEX ON spree_orders (completed_at, user_id, created_by_id, created_at);
CREATE INDEX
openfoodnetwork=> explain analyze SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = 1 AND "spree_orders"."completed_at" IS NULL AND "spree_orders"."created_by_id" = 1 ORDER BY created_at DESC LIMIT 1;
mit  (cost=8.45..8.46 rows=1 width=195) (actual time=0.030..0.030 rows=0 loops=1)
   ->  Sort  (cost=8.45..8.46 rows=1 width=195) (actual time=0.029..0.029 rows=0 loops=1)
         Sort Key: created_at DESC
         Sort Method: quicksort  Memory: 25kB
         ->  Index Scan using spree_orders_completed_at_user_id_created_by_id_created_at_idx on spree_orders  (cost=0.42..8.44 rows=1 width=195) (actual time=0.021..0.021 rows=0 loops=1)
               Index Cond: ((completed_at IS NULL) AND (user_id = 1) AND (created_by_id = 1))
 Planning time: 0.199 ms
 Execution time: 0.077 ms
```
2019-09-17 17:02:14 +02:00
luisramos0
2683efdd3c Add missing update to db/schema by running db:migrate
This was missed in PR 4242
2019-09-17 15:27:56 +01:00
Luis Ramos
ed1c154b78 Merge pull request #4252 from luisramos0/remove_clear_ship_address
On checkout of pickup orders, set ship_address to shipping_address_from_distributor instead of empty Spree::Address.default
2019-09-17 13:18:20 +01:00
Pau Pérez Fabregat
4aba2730f7 Merge pull request #4230 from openfoodfoundation/dependabot/bundler/ddtrace-0.27.0
Bump ddtrace from 0.26.0 to 0.27.0
2019-09-17 13:11:12 +02:00
Pau Pérez Fabregat
07ae51560e Merge pull request #4259 from openfoodfoundation/dependabot/bundler/webmock-3.7.3
Bump webmock from 3.7.2 to 3.7.3
2019-09-17 09:32:21 +02:00
dependabot-preview[bot]
3c5c842bbf Bump simplecov from 0.17.0 to 0.17.1
Bumps [simplecov](https://github.com/colszowka/simplecov) from 0.17.0 to 0.17.1.
- [Release notes](https://github.com/colszowka/simplecov/releases)
- [Changelog](https://github.com/colszowka/simplecov/blob/master/CHANGELOG.md)
- [Commits](https://github.com/colszowka/simplecov/compare/v0.17.0...v0.17.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-16 21:08:17 +00:00
Luis Ramos
e7e4508555 Merge pull request #4242 from Matt-Yorkley/another_cartastrophe
Soft-delete price objects
2019-09-16 17:18:39 +01:00
Luis Ramos
9a3b5d0700 Merge pull request #4257 from daningenthron/daningenthron/payment-method-translation
Fix typo on 'no payment methods' translation keys
2019-09-16 13:18:46 +01:00
Luis Ramos
46353be9a3 Merge pull request #4237 from coopdevs/unobfuscate-bulk-management-action
Add implicit #bulk_management including filter
2019-09-15 12:15:11 +01:00
JASON KNOEPFLER
91a52ead58 Guard against malformed request referer 2019-09-14 09:13:44 -07:00
JASON KNOEPFLER
0f55049eda OrderCycleManagementReport sets default date range before querying for orders 2019-09-13 17:15:57 -07:00
Luis Ramos
83f1a7a9a9 Merge pull request #4258 from coopdevs/fix-test-example-name
Fix test example name
2019-09-13 23:04:45 +01:00
dependabot-preview[bot]
fac118fce2 Bump webmock from 3.7.2 to 3.7.3
Bumps [webmock](https://github.com/bblimke/webmock) from 3.7.2 to 3.7.3.
- [Release notes](https://github.com/bblimke/webmock/releases)
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.7.2...v3.7.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-13 19:19:34 +00:00
Dan Ingenthron
5270cdaa32 Fixed typo on 'no payment methods' translation keys
Modified to remove edits to translation files. These will be updated via Transifex webhook.
2019-09-13 13:43:13 -05:00
luisramos0
caebcdf184 Add correct schemas for EnterpriseShopfront and Variant (not Api::Admin::VariantSerializer but Api::VariantSerializer) 2019-09-13 15:33:54 +01:00
luisramos0
c66a659e8e Fix /products payloads: product, variants and variant overrides 2019-09-13 14:55:18 +01:00
luisramos0
b8b107dd2d Fix api_key header name 2019-09-13 14:27:39 +01:00
Luis Ramos
ecf336fe51 Merge pull request #4244 from luisramos0/fix_truncate_data
Adapt db truncate task to ofn v2 by removing db tables from v1
2019-09-13 13:09:07 +01:00
Matt-Yorkley
a3efd13d46 Update existing Spree::InventoryItem records: change backordered state to on_hand. 2019-09-13 13:05:15 +01:00
Matt-Yorkley
2ff0169016 Replace hard-deleted prices with empty (0.00) price records 2019-09-13 12:55:24 +01:00
Pau Perez
08d37bbed7 Fix test example name
The name wasn't reflecting the method being tested.
2019-09-13 12:55:34 +02:00
Transifex-Openfoodnetwork
b71443ccd8 Updating translations for config/locales/ca.yml 2019-09-13 20:45:12 +10:00
Transifex-Openfoodnetwork
8fd3d9e03c Updating translations for config/locales/es.yml 2019-09-13 20:42:43 +10:00
Transifex-Openfoodnetwork
787727872f Updating translations for config/locales/ca.yml 2019-09-13 20:42:04 +10:00
Pau Pérez Fabregat
5bf72ae780 Merge pull request #4234 from coopdevs/remove-hidden-integrity-check
Remove integrity check for deleted variants in OCs
2019-09-13 11:27:41 +02:00
Pau Pérez Fabregat
290d00f17d Merge pull request #4232 from coopdevs/remove-guard
Remove Guard and Guard-related gems
2019-09-13 11:25:29 +02:00
Pau Perez
3d7bbbbb19 Remove unused Guardfile 2019-09-13 08:25:54 +02:00
luisramos0
3d32987227 Fix taxonomies to represent the endpoints in OFN 2019-09-12 19:52:13 +01:00
luisramos0
902e51e580 Add api/customers endpoints 2019-09-12 19:11:53 +01:00
luisramos0
743cb3b33a Add update product image endpoint and delete enterprise fees endpoint 2019-09-12 18:02:06 +01:00
luisramos0
74e49787f4 Add the remaining missing enterprises endpoints 2019-09-12 15:16:35 +01:00
luisramos0
afa8f97627 Add post and put on enterprises and fix details in shipments endpoints 2019-09-12 13:42:40 +01:00
luisramos0
6e677fecce Remove now inexistent endpoints /new 2019-09-12 13:19:43 +01:00
luisramos0
889a3e6d9d Improve file layout and move Order model to correct place 2019-09-12 13:15:40 +01:00
luisramos0
664be47ac3 Add endpoints for /orders/shipments 2019-09-12 13:08:39 +01:00
Sigmund Petersen
fd77f48aca Merge pull request #4253 from openfoodfoundation/RachL-patch-1
Update Slack invite link
2019-09-12 09:17:37 +02:00
Rachel Arnould
9a31b99de6 Update missing second link 2019-09-11 15:52:44 +02:00
luisramos0
0e4b5ad9ec Remove now gone orders/{order_number} endpoint and its models, may be readded in the near future but the models may be different as these docs refer to the now gone spree_api order rabl representation 2019-09-11 11:35:01 +01:00
luisramos0
5634f4af18 Move orders endpoints above in the file as they are the most important endpoints 2019-09-11 11:34:57 +01:00
luisramos0
0dede39617 Make list of /products/{product_id}/variants endpoints correct according to current code 2019-09-11 11:15:55 +01:00
Transifex-Openfoodnetwork
d98e302047 Updating translations for config/locales/nb.yml 2019-09-11 19:47:09 +10:00
luisramos0
377b4a3755 Do not add ng-controller if main_ng_ctrl_name is not set 2019-09-11 10:36:19 +01:00
luisramos0
0c809b2911 Remove now unused override app_wrapper 2019-09-11 10:35:39 +01:00
luisramos0
33472014f1 Do not add main_ng_app_name if it is not defined 2019-09-11 10:32:30 +01:00
luisramos0
d038c27f1f Fix app_wrapper_attr code by making the content_for tag be only the name of the ng-app and ng-ctrller 2019-09-11 10:32:30 +01:00
luisramos0
3d718d9738 Move admin layout body contents to a separate partial 2019-09-11 10:32:29 +01:00
Luis Ramos
500ef901fd Merge pull request #4164 from luisramos0/little_de_deface
Remove some unused deface overrides and move some others to their views
2019-09-11 10:26:56 +01:00
Matt-Yorkley
a15db65e69 Reload tested variant and price objects 2019-09-11 04:32:19 +01:00
Matt-Yorkley
64a501ee20 Don't index new deleted_at column for spree_prices 2019-09-11 04:29:02 +01:00
Matt-Yorkley
95fcff8bb1 Add migration to remove broken variants from open carts 2019-09-11 04:29:00 +01:00
luisramos0
a2e6b84db2 List the actual actions available in the api/products endpoint 2019-09-10 17:22:52 +01:00
luisramos0
d319f97733 Remove now unexisting endpoints zones, states and countries 2019-09-10 12:36:34 +01:00
Luis Ramos
c0bf7e2e75 Merge pull request #4236 from mkllnk/4222-checkout-paypal-error-handling
4233 Add missing Spree route for Paypal
2019-09-10 12:24:21 +01:00
Luis Ramos
1d177a164b Merge pull request #4247 from mkllnk/4243-inventory-pagination
4243 Restore old pagination API for inventory products
2019-09-10 11:35:04 +01:00
Rachel Arnould
d846c31db9 Update Slack invite link
Updated Slack invite link in README
2019-09-10 09:51:59 +02:00
Maikel Linke
efd01f8c9e Move new inventory spec to existing variant overrides spec
I decided to not share the same data setup with the other parts of the
spec because we don't need as much data and it's slow to create.
2019-09-10 10:05:23 +10:00
luisramos0
fb65c64c68 Keep the ship_address clearing logic (this time reusing the OrderUpdate method) thus making the restart_checkout process work for these cases (because order.ship_address is not empty)
OrderUpdater#shipping_address_from_distributor uses order.address_from_distributor to set order.ship_address when order is not delivery: this will clear the ship address as it was done previously without setting an empty address like Spree::Address.default
2019-09-09 22:05:20 +01:00
Transifex-Openfoodnetwork
b8d8ee4edc Updating translations for config/locales/en_GB.yml 2019-09-10 05:14:09 +10:00
Luis Ramos
936784404e Merge pull request #4112 from luisramos0/convert_shipments_rabl
Convert spree/api/shipments views from rabl to ams
2019-09-09 18:34:02 +01:00
Matt-Yorkley
11ea852211 Add migration to reset negative stock levels to zero 2019-09-09 17:49:58 +01:00
Matt-Yorkley
4656c35f71 Don't change on_demand variant's stock when updating shipments 2019-09-09 17:49:58 +01:00
Matt-Yorkley
254315b79e Don't mark on_demand items and shipments as "backordered" 2019-09-09 17:49:56 +01:00
luisramos0
cc7461e692 Remove clear_ship_address from checkout_controller because it is setting an empty address on order.ship_address which is breaking the reset_checkout process in some cases.
This logic is already repeated in the before_save hook in the OrderUpdater where the distributor address is put into the ship_address on order.finalize

In cases the order is not to be finalized we keep the ship_address sent from the client as we may need it to make the order workflow work properly
2019-09-09 17:48:17 +01:00
luisramos0
c4d5eec7fd Covering restart_checkout code with more tests to clarify behaviour with different order.ship_address objects
The edge case here is when ship_address is present but empty, on the checkout_controller we are going to move from using an empty ship_address to using a non-empty one. We keep the original case where this spec was testing with a nil order.ship_address
2019-09-09 17:48:04 +01:00
Luis Ramos
2dc85463ce Merge pull request #4226 from HugsDaniel/4090-missing-translations-order
Add missing translations for orders
2019-09-09 15:16:47 +01:00
Matt-Yorkley
aa3bd93ad0 Bump Ruby version to 2.1.9 2019-09-09 12:22:20 +01:00
Maikel Linke
24c8bb95cb Restore old pagination API for products
It's still used by the inventory page. This is an easy fix that I can
deploy without risk. A rewrite of the inventory pagination should
follow.
2019-09-09 14:53:04 +10:00
Maikel Linke
2e361baeaa Ignore block length cop for feature and scenario
They are typically long and that's okay, same with `describe` and `it`.
2019-09-09 14:53:04 +10:00
luisramos0
a98a0bd264 Adapt db truncate task to ofn v2 by removing db tables from v1 2019-09-08 14:05:49 +01:00
luisramos0
b4de8ef899 Make enterprises/index_spec a bit more resilient 2019-09-08 12:17:36 +01:00
luisramos0
f0586af1c7 Re-organized api/orders resource routes 2019-09-08 12:17:36 +01:00
luisramos0
e9b5551c0f Adpat shipment controller to move out of Spree namespace 2019-09-08 12:17:36 +01:00
luisramos0
7cec24f1d4 Move shipments route, controller and ctrl spec from spree/api to api 2019-09-08 12:17:36 +01:00
luisramos0
26f5ece7c0 Add a few relevant attributes to shipment serializer and fix some details in shipment controller spec 2019-09-08 12:15:33 +01:00
luisramos0
a21a4aba5d Convert spree/api/shipments from rabl to AMS and adapt its spec 2019-09-08 12:15:33 +01:00
Matt-Yorkley
f413ce2a27 Soft-delete price objects 2019-09-06 17:50:19 +01:00
Transifex-Openfoodnetwork
5847b1a51e Updating translations for config/locales/en_ZA.yml 2019-09-07 01:50:35 +10:00
Transifex-Openfoodnetwork
f51ebc63c3 Updating translations for config/locales/en_AU.yml 2019-09-07 01:47:27 +10:00
Pau Pérez Fabregat
908e1dfcaf Merge pull request #4202 from coopdevs/remove-skylight
Remove Skylight
2019-09-06 17:09:14 +02:00
Matt-Yorkley
5bc2c96248 Add specs for existing on_demand behaviour 2019-09-06 15:47:59 +01:00
Pau Perez
ab8c7bad76 Remove Skylight
Since we adopted Skylight to get response times across endpoints and
instances, we failed to get accurate numbers. Our Rails version is not
supported and thus Skylight fails to provide data for the slowest
endpoints, the ones we care about the most. Even with a supported one we
could potentially hit any limits on tracing and have the same problem.

Recently, we started paying for Datadog's APM and the experience,
although it's still early, has been better. It makes it possible to
correlate between services and other metrics which helps spotting the
underlying issues.

Therefore, having two agents running on the server consumes system
resources so we better get rid of Skylight's one.
2019-09-06 16:25:33 +02:00
Pau Perez
55883a0efc Add implicit #bulk_management including filter
OFN it's hard enough. No need to abuse implicitness making things very
hard to follow.

I've spent around 20min trying to find out where this controller action
was implemented until I realized Rails renders the matching view if no
controller action is defined.

Making it git-greppable makes it a bit easier next time.
2019-09-06 16:02:44 +02:00
Pau Pérez Fabregat
2e519957ec Merge pull request #4231 from openfoodfoundation/dependabot/bundler/webmock-3.7.2
Bump webmock from 3.7.1 to 3.7.2
2019-09-06 13:31:55 +02:00
Pau Pérez Fabregat
cd5b3c7393 Merge pull request #4229 from openfoodfoundation/dependabot/bundler/bugsnag-6.12.1
Bump bugsnag from 6.12.0 to 6.12.1
2019-09-06 13:08:47 +02:00
Maikel Linke
eb9f02f3bd Add missing Spree route for Paypal 2019-09-06 19:07:41 +10:00
Maikel Linke
a1f3e8205f Add spec for failing Paypal checkout
https://github.com/openfoodfoundation/openfoodnetwork/issues/4233
2019-09-06 19:05:59 +10:00
Pau Perez
410e23085e Remove integrity check for deleted variants in OCs
We have no way to see the output of this weird RSpec integrity check
thus, it's pointless. It only adds unnecessary load the server.

However, the issue it checks seems to still be happening although
not very often. UK's server has 70 occurrences the last one being from
early 2019 while FR's server returns 10.
2019-09-06 10:30:26 +02:00
Pau Perez
e2b3ee7b3f Remove Guard and Guard-related gems
Guard and the other Guard-related gems should be removed from our
Gemfile. We think is not worth the extra dependencies given the effort
it requires to keep them up-to-date.

This came up in a PR that was upgrading Guard: #4213.
2019-09-06 10:11:17 +02:00
Maikel Linke
242767dc73 Give variables meaningful names in checkout spec 2019-09-06 12:27:15 +10:00
Maikel Linke
8e8c77c5bd Convert specs to RSpec 3.8.0 syntax with Transpec
This conversion is done by Transpec 3.4.0 with the following command:
    transpec spec/features/consumer/shopping/checkout_spec.rb

* 43 conversions
    from: obj.should
      to: expect(obj).to

* 8 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 3 conversions
    from: == expected
      to: eq(expected)

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2019-09-06 11:32:44 +10:00
Luis Ramos
e3ce2a7486 Merge pull request #4104 from luisramos0/convert_taxons_to_ams
Convert spree/api/taxons views from rabl to AMS
2019-09-06 00:04:10 +01:00
dependabot-preview[bot]
8524f49589 Bump webmock from 3.7.1 to 3.7.2
Bumps [webmock](https://github.com/bblimke/webmock) from 3.7.1 to 3.7.2.
- [Release notes](https://github.com/bblimke/webmock/releases)
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.7.1...v3.7.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-05 19:17:24 +00:00
dependabot-preview[bot]
36f9cd9cbf Bump ddtrace from 0.26.0 to 0.27.0
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 0.26.0 to 0.27.0.
- [Release notes](https://github.com/DataDog/dd-trace-rb/releases)
- [Changelog](https://github.com/DataDog/dd-trace-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/DataDog/dd-trace-rb/compare/v0.26.0...v0.27.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-05 19:16:35 +00:00
dependabot-preview[bot]
0fab4a3a8e Bump bugsnag from 6.12.0 to 6.12.1
Bumps [bugsnag](https://github.com/bugsnag/bugsnag-ruby) from 6.12.0 to 6.12.1.
- [Release notes](https://github.com/bugsnag/bugsnag-ruby/releases)
- [Changelog](https://github.com/bugsnag/bugsnag-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bugsnag/bugsnag-ruby/compare/v6.12.0...v6.12.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-05 19:15:41 +00:00
Luis Ramos
722884d8d8 Merge pull request #3895 from luisramos0/fees_based_on_final_weight
Make weight calculator use line_item.final_weight_volume rather than variant.weight
2019-09-05 19:24:56 +01:00
Hugo Daniel
f88d54b862 Add missing translations for orders 2019-09-05 15:13:10 +02:00
luisramos0
192bff4fed Move taxons and taxonomies api routes to api out of spree routes 2019-08-28 22:06:56 +01:00
luisramos0
92a270165e Add missing api taxonomies controller only for the required jstree action 2019-08-28 22:06:56 +01:00
luisramos0
9f5c9916ba Add back required api actions (create, update and destroy) and add AMS serializers for the jstree action 2019-08-28 22:06:56 +01:00
luisramos0
d08de4bdf9 Add extra fields to taxon serializer to be used in the api 2019-08-28 22:06:56 +01:00
luisramos0
45bdb85bf3 Add missing method and skip_authorization_check to taxons controller 2019-08-28 22:06:56 +01:00
luisramos0
ece0652ca3 Adapt spree/admin/shared/_routes.html.erb to new location of the api/taxons routes 2019-08-28 22:06:56 +01:00
luisramos0
7a652fd67b Adapt api/taxons controller to new namespace outside Spree: remove Spree module and add Spree namespace to Taxons and Taxonomy classes 2019-08-28 22:06:56 +01:00
luisramos0
4ca8feeef1 Move api/taxons route and controller out of spree namespace into /api and move the ctrl spec as well 2019-08-28 22:06:56 +01:00
luisramos0
367932a767 Make spree/api/taxons_controller use AMS serializer instead of rabl 2019-08-28 22:06:56 +01:00
luisramos0
e591658f48 Keep only used api/taxons index action, delete all others as not required right now 2019-08-28 22:06:56 +01:00
luisramos0
8a4e5b445f Delete unused frontend auth toekn script override and move the backend one to the head partial 2019-08-18 21:53:56 +01:00
luisramos0
2394eda2ac Remove unused sidebar override 2019-08-18 21:47:21 +01:00
luisramos0
f97a3a030a Remove unused nav_bar sessions route and override 2019-08-18 21:44:22 +01:00
luisramos0
ec645f8fa8 Remove unused login override of nav_bar 2019-08-18 21:43:18 +01:00
luisramos0
56a54db602 Remove admin login_nav override and move it to admin layout file 2019-08-18 21:39:19 +01:00
luisramos0
4c3d15b42b Remove users menu entry override and file and add it directly to the tabs view together with all the other entries 2019-08-18 21:36:50 +01:00
luisramos0
5f4429646d Move override to the view that is now in our code base (from spree_auth_devise originally) 2019-08-18 21:33:23 +01:00
luisramos0
f37db456f8 Delete dead overrides of spree frontend code 2019-08-18 21:32:53 +01:00
luisramos0
006c6e6b7b Add comment to explain method in weight calculator 2019-08-02 21:02:33 +01:00
luisramos0
41aa4ff479 Improve code readability and fix rubocop complexity issue in weight calculator 2019-08-02 20:54:41 +01:00
luisramos0
0e8f167ab9 Fix spec in weight calculator tests 2019-08-02 20:44:11 +01:00
Kristina Lim
e1fce8304d Update weight calculator and add specs 2019-07-23 23:24:00 +08:00
Kristina Lim
0d6ba90ea1 Round off fee from Calculator::Weight to nearest cent 2019-07-24 00:42:42 +10:00
luisramos0
160b535e2f Make weight calculator compute 0 for variants with unit different from weight 2019-06-18 15:21:13 +01:00
luisramos0
e8eeb3d5dc Further improve weight calculator code 2019-06-18 13:28:16 +01:00
luisramos0
4551149532 Improve code of weight calculator 2019-05-31 19:55:39 +01:00
luisramos0
82955b9fe5 Make weight calculator use line_item.final_weight_volume rather than variant.weight for cases where the final weight is set manually in the BOM 2019-05-31 19:55:17 +01:00
588 changed files with 28010 additions and 8917 deletions

View File

@@ -1,66 +0,0 @@
<!-- Provide a general summary of the issue in the Title above.
If your issue is not a bug, please use the Feature template instead:
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Feature-template
-->
## Description
<!-- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
## Expected Behavior
<!-- Tell us what should happen -->
## Actual Behavior
<!-- Tell us what happens instead -->
## Steps to Reproduce
<!-- Provide an unambiguous set of steps to reproduce this bug -->
<!-- Include code to reproduce if relevant -->
1.
2.
3.
4.
## Animated Gif/Screenshot
<!-- Provide a screenshot or brief animated gif reproducing the bug. Linux users can use
[Peek](https://github.com/phw/peek#ubuntu) while Mac users can use [Recordit](http://recordit.co/) -->
## Context
<!-- How has this bug affected you? What were you trying to accomplish? -->
## Severity
<!-- Assign a label and explain the impact.
bug-s1: a critical feature is broken: checkout, payments, signup, login
bug-s2: a non-critical feature is broken, no workaround
bug-s3: a feature is broken but there is a workaround
bug-s4: it's annoying, but you can use it
bug-s5: we can live with it, only a few users impacted
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Bug-severity
-->
## Your Environment
<!-- Include relevant details about the environment you experienced the bug in -->
* Version used:
* Browser name and version:
* Operating System and version (desktop or mobile):
## Possible Fix
<!-- Not obligatory, but suggest a fix or reason for the bug -->

View File

@@ -9,6 +9,7 @@ assignees: ''
## Description
<!-- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
<!-- How has this bug affected you? What were you trying to accomplish? -->
## Expected Behavior
@@ -22,6 +23,8 @@ assignees: ''
## Steps to Reproduce
<!-- Provide an unambiguous set of steps to reproduce this bug -->
<!-- Include code to reproduce if relevant -->
<!-- Include links -->
<!-- Include user ID -->
1.
2.
@@ -29,13 +32,11 @@ assignees: ''
4.
## Animated Gif/Screenshot
<!-- Provide a screenshot or brief animated gif reproducing the bug. Linux users can use
[Peek](https://github.com/phw/peek#ubuntu) while Mac users can use [Recordit](http://recordit.co/) -->
## Context
<!-- How has this bug affected you? What were you trying to accomplish? -->
<!-- Provide a screenshot or brief video reproducing the bug. -->
<!-- Please try to have the dev tools opened on the network tab (press F12 to open the devtools of your browser -->
## Workaround
<!-- Include a workaround for this bug (if relevant) -->
## Severity
<!-- Assign a label and explain the impact.
@@ -55,7 +56,6 @@ https://github.com/openfoodfoundation/openfoodnetwork/wiki/Bug-severity
* Version used:
* Browser name and version:
* Operating System and version (desktop or mobile):
* OFN Platform instance where you discovered the bug, and which version of the software they are using.
## Possible Fix
<!-- Not obligatory, but suggest a fix or reason for the bug -->

View File

@@ -0,0 +1,10 @@
Draft: x
Target commit: x
Build: x
- [ ] Draft
- [ ] Test
- [ ] Publish
- [ ] Deploy

View File

@@ -14,5 +14,12 @@ assignees: ''
**- I want to be able to do:** (specify the desired behavior)
(Link to others issues or resources to provide context > only if really necessary). -->
## Acceptance Criteria
<!-- Document the outcomes that need to be achieved before this component can be considered complete. -->
## Acceptance Criteria & Tests
<!-- Document the outcomes that need to be achieved before this component can be considered complete.
-->
<!-- Provide an unambiguous set of steps a tester should do to validate the PR that will solve this issue -->
1.
2.
3.
4.

View File

@@ -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,28 +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/serializers/api/admin/basic_enterprise_serializer.rb
- app/serializers/api/admin/enterprise_fee_serializer.rb
- app/serializers/api/admin/enterprise_serializer.rb
- app/serializers/api/admin/exchange_serializer.rb
- app/serializers/api/admin/for_order_cycle/enterprise_serializer.rb
- app/serializers/api/admin/index_enterprise_serializer.rb
- app/serializers/api/admin/index_order_cycle_serializer.rb
- app/serializers/api/admin/line_item_serializer.rb
- app/serializers/api/admin/order_cycle_serializer.rb
- app/serializers/api/admin/subscription_serializer.rb
- app/serializers/api/admin/tag_rule_serializer.rb
- app/serializers/api/admin/variant_override_serializer.rb
- app/services/cart_service.rb
- app/services/default_stock_location.rb
- app/services/embedded_page_service.rb
@@ -129,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
@@ -147,23 +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/orders_and_fulfillments_report.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/products_renderer.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
@@ -180,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
@@ -197,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
@@ -210,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
@@ -235,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
@@ -262,17 +228,13 @@ Metrics/LineLength:
- spec/helpers/order_cycles_helper_spec.rb
- spec/helpers/spree/admin/base_helper_spec.rb
- spec/jobs/confirm_order_job_spec.rb
- spec/jobs/products_cache_integrity_checker_job_spec.rb
- spec/jobs/refresh_products_cache_job_spec.rb
- spec/jobs/subscription_confirm_job_spec.rb
- spec/jobs/subscription_placement_job_spec.rb
- spec/lib/open_food_network/address_finder_spec.rb
- spec/lib/open_food_network/bulk_coop_report_spec.rb
- spec/lib/open_food_network/cached_products_renderer_spec.rb
- 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
@@ -284,8 +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/products_renderer_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
@@ -298,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
@@ -319,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
@@ -342,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
@@ -378,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
@@ -387,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
@@ -416,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
@@ -437,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
@@ -454,90 +427,60 @@ Metrics/AbcSize:
- lib/open_food_network/order_cycle_form_applicator.rb
- lib/open_food_network/order_cycle_management_report.rb
- lib/open_food_network/order_cycle_permissions.rb
- lib/open_food_network/orders_and_fulfillments_report.rb
- 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_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:
Max: 25
ExcludedMethods: ["class_eval", "collection", "context", "describe", "it", "member", "namespace", "resource", "resources"]
ExcludedMethods: [
"class_eval",
"collection",
"context",
"describe",
"feature",
"it",
"member",
"namespace",
"resource",
"resources",
"scenario"
]
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/adjustments_spec.rb
- spec/features/admin/bulk_order_management_spec.rb
- spec/features/admin/bulk_product_update_spec.rb
- spec/features/admin/caching_spec.rb
- spec/features/admin/content_spec.rb
- spec/features/admin/customers_spec.rb
- spec/features/admin/enterprise_fees_spec.rb
- spec/features/admin/enterprise_groups_spec.rb
- spec/features/admin/enterprise_relationships_spec.rb
- spec/features/admin/enterprise_roles_spec.rb
- spec/features/admin/enterprises/images_spec.rb
- spec/features/admin/enterprises/index_spec.rb
- spec/features/admin/enterprises_spec.rb
- spec/features/admin/enterprise_user_spec.rb
- spec/features/admin/multilingual_spec.rb
- spec/features/admin/order_cycles_spec.rb
- spec/features/admin/orders_spec.rb
- spec/features/admin/overview_spec.rb
- spec/features/admin/payment_method_spec.rb
- spec/features/admin/product_import_spec.rb
- spec/features/admin/products_spec.rb
- spec/features/admin/reports/enterprise_fee_summaries_spec.rb
- spec/features/admin/reports_spec.rb
- spec/features/admin/schedules_spec.rb
- spec/features/admin/shipping_methods_spec.rb
- spec/features/admin/subscriptions_spec.rb
- spec/features/admin/tag_rules_spec.rb
- spec/features/admin/tax_settings_spec.rb
- spec/features/admin/users_spec.rb
- spec/features/admin/variant_overrides_spec.rb
- spec/features/admin/variants_spec.rb
- spec/features/consumer/account/cards_spec.rb
- spec/features/consumer/account/settings_spec.rb
- spec/features/consumer/account_spec.rb
- spec/features/consumer/authentication_spec.rb
- spec/features/consumer/cookies_spec.rb
- spec/features/consumer/external_services_spec.rb
- spec/features/consumer/groups_spec.rb
- spec/features/consumer/multilingual_spec.rb
- spec/features/consumer/producers_spec.rb
- spec/features/consumer/registration_spec.rb
- spec/features/consumer/shopping/cart_spec.rb
- spec/features/consumer/shopping/checkout_auth_spec.rb
- spec/features/consumer/shopping/checkout_spec.rb
- spec/features/consumer/shopping/embedded_groups_spec.rb
- spec/features/consumer/shopping/embedded_shopfronts_spec.rb
- spec/features/consumer/shopping/orders_spec.rb
- spec/features/consumer/shopping/products_spec.rb
- spec/features/consumer/shopping/shopping_spec.rb
- spec/features/consumer/shopping/variant_overrides_spec.rb
- spec/features/consumer/shops_spec.rb
- spec/lib/open_food_network/group_buy_report_spec.rb
- spec/models/tag_rule/discount_order_spec.rb
- spec/spec_helper.rb
@@ -548,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
@@ -569,7 +513,6 @@ Metrics/CyclomaticComplexity:
- lib/discourse/single_sign_on.rb
- lib/open_food_network/bulk_coop_report.rb
- lib/open_food_network/enterprise_issue_validator.rb
- lib/open_food_network/orders_and_fulfillments_report.rb
- lib/spree/core/controller_helpers/order_decorator.rb
- lib/spree/core/controller_helpers/respond_with_decorator.rb
- lib/spree/localized_number.rb
@@ -579,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
@@ -594,7 +539,6 @@ Metrics/PerceivedComplexity:
- lib/discourse/single_sign_on.rb
- lib/open_food_network/bulk_coop_report.rb
- lib/open_food_network/enterprise_issue_validator.rb
- lib/open_food_network/orders_and_fulfillments_report.rb
- lib/spree/core/controller_helpers/order_decorator.rb
- lib/spree/core/controller_helpers/respond_with_decorator.rb
- lib/spree/localized_number.rb
@@ -604,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
@@ -664,12 +617,10 @@ Metrics/MethodLength:
- lib/open_food_network/order_cycle_management_report.rb
- lib/open_food_network/order_cycle_permissions.rb
- lib/open_food_network/order_grouper.rb
- lib/open_food_network/orders_and_fulfillments_report.rb
- 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_and_inventory_report.rb
- lib/open_food_network/products_renderer.rb
- lib/open_food_network/rack_request_blocker.rb
- lib/open_food_network/reports/bulk_coop_allocation_report.rb
- lib/open_food_network/reports/bulk_coop_supplier_report.rb
@@ -677,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
@@ -692,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
@@ -708,24 +665,24 @@ Metrics/ClassLength:
- lib/open_food_network/order_cycle_form_applicator.rb
- lib/open_food_network/order_cycle_management_report.rb
- lib/open_food_network/order_cycle_permissions.rb
- lib/open_food_network/orders_and_fulfillments_report.rb
- 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/cached_products_renderer_spec.rb
- spec/lib/open_food_network/customers_report_spec.rb
- spec/lib/open_food_network/enterprise_fee_calculator_spec.rb
- spec/lib/open_food_network/option_value_namer_spec.rb
@@ -734,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
@@ -753,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

View File

@@ -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/**/*'
@@ -186,7 +187,19 @@ Metrics/AbcSize:
Metrics/BlockLength:
Max: 25
ExcludedMethods: ["class_eval", "collection", "context", "describe", "it", "member", "namespace", "resource", "resources"]
ExcludedMethods: [
"class_eval",
"collection",
"context",
"describe",
"feature",
"it",
"member",
"namespace",
"resource",
"resources",
"scenario"
]
Metrics/BlockNesting:
Max: 3

View File

@@ -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'

View File

@@ -1 +1 @@
2.1.5
2.2.10

View File

@@ -19,6 +19,10 @@ If you want to run the whole test suite, we recommend using a free CI service to
bundle exec rspec spec
## Which issue to pick first?
We have curated all issues interesting for new members of the community within the [Welcome New Developers project board][welcome-dev]. Have a look and pick the one you would prefer working on!
## Internationalisation (i18n)
The locale `en` is maintained in the source code, but other locales are managed at [Transifex][ofn-transifex]. Read more about [internationalisation][i18n] in the developer wiki.
@@ -62,3 +66,4 @@ From here, your pull request will progress through the [Review, Test, Merge & De
[slack-dev]: https://openfoodnetwork.slack.com/messages/C2GQ45KNU
[ofn-transifex]: https://www.transifex.com/open-food-foundation/open-food-network/
[i18n]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/i18n
[welcome-dev]: https://github.com/openfoodfoundation/openfoodnetwork/projects/27

View File

@@ -6,16 +6,19 @@ RUN apt-get update && apt-get install -y curl git build-essential software-prope
# Setup ENV variables
ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:$PATH
ENV RBENV_ROOT /usr/local/src/rbenv
ENV RUBY_VERSION 2.1.5
ENV CONFIGURE_OPTS --disable-install-doc
ENV BUNDLE_PATH /bundles
WORKDIR /usr/src/app
COPY .ruby-version .
# Rbenv & Ruby part
RUN git clone https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \
git clone https://github.com/rbenv/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build && \
${RBENV_ROOT}/plugins/ruby-build/install.sh && \
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh && \
rbenv install $RUBY_VERSION && \
rbenv global $RUBY_VERSION && \
rbenv install $(cat .ruby-version) && \
rbenv global $(cat .ruby-version) && \
gem install bundler --version=1.17.2
# Postgres
@@ -24,8 +27,4 @@ RUN sh -c "echo 'deb https://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main'
apt-get update && \
apt-get install -yqq --no-install-recommends postgresql-client-9.5 libpq-dev
ENV BUNDLE_PATH /bundles
COPY . /usr/src/app/
WORKDIR /usr/src/app

View File

@@ -11,7 +11,7 @@ The following guides are located in the wiki and provide more OS-specific step-b
### Dependencies
* Rails 3.2.x
* Ruby 2.1.5
* Ruby 2.1.9
* PostgreSQL database
* PhantomJS (for testing)
* See Gemfile for a list of gems required

29
Gemfile
View File

@@ -1,9 +1,9 @@
source 'https://rubygems.org'
ruby "2.1.5"
ruby "2.2.10"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
gem 'i18n', '~> 0.6.11'
gem 'i18n-js', '~> 3.3.0'
gem 'i18n-js', '~> 3.5.0'
gem 'rails', '~> 3.2.22'
gem 'rails-i18n', '~> 3.0.0'
gem 'rails_safe_tasks', '~> 1.0'
@@ -15,12 +15,12 @@ gem 'nokogiri', '>= 1.6.7.1'
gem "order_management", path: "./engines/order_management"
gem 'web', path: './engines/web'
gem 'pg'
gem 'activerecord-postgresql-adapter'
gem 'pg', '~> 0.21.0'
# OFN-maintained and patched version of Spree v2.0.4. See
# https://github.com/openfoodfoundation/openfoodnetwork/wiki/Spree-2.0-upgrade
# for details.
gem 'spree_api', github: 'openfoodfoundation/spree', branch: '2-0-4-stable'
gem 'spree_backend', github: 'openfoodfoundation/spree', branch: '2-0-4-stable'
gem 'spree_core', github: 'openfoodfoundation/spree', branch: '2-0-4-stable'
@@ -39,7 +39,7 @@ gem 'activemerchant', '~> 1.78'
gem 'devise', '~> 2.2.5'
gem 'devise-encryptable', '0.2.0'
gem 'jwt', '~> 2.2'
gem 'oauth2', '~> 1.4.1' # Used for Stripe Connect
gem 'oauth2', '~> 1.4.2' # Used for Stripe Connect
gem 'daemons'
gem 'delayed_job_active_record'
@@ -84,8 +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 'skylight', '< 2.0'
gem 'roadie-rails', '~> 1.3.0'
gem 'spinjs-rails'
gem 'combine_pdf'
@@ -99,13 +98,18 @@ gem 'roo-xls', '~> 1.1.0'
gem 'whenever', require: false
gem 'test-unit', '~> 3.3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '~> 3.2.1'
gem 'compass-rails'
gem 'therubyracer', '=0.12.0'
gem 'mini_racer', '0.1.15'
# Previously we found that libv8 6.7.288.46.1 breakis the compilation of mini_racer.
# Now we see that we need to set the version explicitly. Nothing else depends on libv8.
gem 'libv8', '6.3.292.48.1'
gem 'uglifier', '>= 1.0.3'
@@ -134,7 +138,7 @@ group :test, :development do
gem 'capybara', '>= 2.15.4'
gem 'database_cleaner', '0.7.1', require: false
gem "factory_bot_rails", require: false
gem 'fuubar', '~> 2.4.1'
gem 'fuubar', '~> 2.5.0'
gem 'json_spec', '~> 1.1.4'
gem 'knapsack'
gem 'letter_opener', '>= 1.4.1'
@@ -157,11 +161,6 @@ end
group :development do
gem 'byebug', '~> 9.0.0' # 9.1 requires ruby 2.2
gem 'debugger-linecache'
gem 'guard'
gem 'guard-livereload'
gem 'guard-rails'
gem 'guard-rspec', '~> 4.7.3'
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

View File

@@ -129,8 +129,10 @@ GEM
activesupport (= 3.2.22.5)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activerecord-import (1.0.2)
activerecord-import (1.0.3)
activerecord (>= 3.2)
activerecord-postgresql-adapter (0.0.1)
pg
activeresource (3.2.22.5)
activemodel (= 3.2.22.5)
activesupport (= 3.2.22.5)
@@ -164,7 +166,7 @@ GEM
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
blockenspiel (0.5.0)
bugsnag (6.12.0)
bugsnag (6.12.2)
concurrent-ruby (~> 1.0)
builder (3.0.4)
byebug (9.0.6)
@@ -214,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)
@@ -223,7 +225,7 @@ GEM
activerecord (>= 3.2.0, < 5.0)
fog (~> 1.0)
rails (>= 3.2.0, < 5.0)
ddtrace (0.26.0)
ddtrace (0.29.0)
msgpack
debugger-linecache (1.2.0)
deface (1.0.2)
@@ -252,9 +254,6 @@ GEM
diffy (3.3.0)
docile (1.3.2)
dry-inflector (0.1.2)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
erubis (2.7.0)
eventmachine (1.2.7)
excon (0.62.0)
@@ -427,48 +426,25 @@ GEM
foundation-rails (5.5.2.1)
railties (>= 3.1.0)
sass (>= 3.3.0, < 3.5)
fuubar (2.4.1)
fuubar (2.5.0)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
geocoder (1.1.8)
gmaps4rails (1.5.6)
guard (2.15.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-livereload (2.5.2)
em-websocket (~> 0.5)
guard (~> 2.8)
guard-compat (~> 1.0)
multi_json (~> 1.8)
guard-rails (0.7.2)
guard (~> 2.11)
guard-compat (~> 1.0)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
haml (4.0.7)
tilt
hashdiff (1.0.0)
highline (1.6.18)
hike (1.2.3)
http_parser.rb (0.6.0)
httparty (0.16.2)
multi_xml (>= 0.5.2)
i18n (0.6.11)
i18n-js (3.3.0)
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)
@@ -491,11 +467,7 @@ GEM
addressable (~> 2.3)
letter_opener (1.7.0)
launchy (~> 2.2)
libv8 (3.16.14.19)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
lumberjack (1.0.13)
libv8 (6.3.292.48.1)
mail (2.5.5)
mime-types (~> 1.16)
treetop (~> 1.4.8)
@@ -503,25 +475,23 @@ GEM
mime-types (1.25.1)
mini_mime (1.0.1)
mini_portile2 (2.1.0)
mini_racer (0.1.15)
libv8 (~> 6.3)
momentjs-rails (2.20.1)
railties (>= 3.1)
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)
nenv (0.3.0)
net-http-persistent (3.1.0)
connection_pool (~> 2.2)
newrelic_rpm (3.18.1.330)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0)
oauth2 (1.4.2)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
@@ -537,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)
@@ -551,7 +521,7 @@ GEM
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.5)
powerpack (0.1.1)
power_assert (1.1.5)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
@@ -564,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
@@ -594,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)
@@ -610,14 +580,13 @@ GEM
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.5.0)
ref (2.0.0)
request_store (1.4.1)
rack (>= 1.4)
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)
@@ -626,41 +595,40 @@ GEM
nokogiri
roo (>= 2.0.0beta1, < 3)
spreadsheet (> 0.9.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.0)
rspec-support (~> 3.9.0)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
rspec-support (~> 3.9.0)
rspec-rails (3.9.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-retry (0.6.1)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.8.0)
rubocop (0.57.2)
rspec-support (3.9.0)
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)
rubyzip (1.2.2)
rubyzip (1.3.0)
safe_yaml (1.0.5)
sass (3.3.14)
sass-rails (3.2.6)
@@ -673,10 +641,9 @@ GEM
selenium-webdriver (3.141.0)
childprocess (~> 0.5)
rubyzip (~> 1.2, >= 1.2.2)
shellany (0.0.1)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
simplecov (0.17.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
@@ -685,8 +652,6 @@ GEM
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
skylight (1.7.2)
activesupport (>= 3.0.0)
spinjs-rails (1.4)
rails (>= 3.1)
spreadsheet (1.1.7)
@@ -704,9 +669,8 @@ GEM
stripe (4.24.0)
faraday (~> 0.13)
net-http-persistent (~> 3.0)
therubyracer (0.12.0)
libv8 (~> 3.16.14.0)
ref
test-unit (3.3.4)
power_assert
thor (0.20.3)
tilt (1.4.1)
timecop (0.9.1)
@@ -719,9 +683,9 @@ GEM
railties (> 3.2.8, < 4.0.0)
sprockets (>= 2.2.0)
tzinfo (0.3.55)
uglifier (4.1.20)
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)
@@ -739,14 +703,14 @@ GEM
nokogiri (~> 1.6)
rubyzip (~> 1.0)
selenium-webdriver (~> 3.0)
webmock (3.7.1)
webmock (3.7.6)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
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)
@@ -758,6 +722,7 @@ DEPENDENCIES
active_model_serializers (= 0.8.4)
activemerchant (~> 1.78)
activerecord-import
activerecord-postgresql-adapter
acts-as-taggable-on (~> 3.4)
andand
angular-rails-templates (~> 0.3.0)
@@ -793,16 +758,12 @@ DEPENDENCIES
foundation-icons-sass-rails
foundation-rails
foundation_rails_helper!
fuubar (~> 2.4.1)
fuubar (~> 2.5.0)
geocoder
gmaps4rails
guard
guard-livereload
guard-rails
guard-rspec (~> 4.7.3)
haml
i18n (~> 0.6.11)
i18n-js (~> 3.3.0)
i18n-js (~> 3.5.0)
immigrant
jquery-migrate-rails
jquery-rails (= 3.0.4)
@@ -811,27 +772,28 @@ DEPENDENCIES
kaminari (~> 0.14.1)
knapsack
letter_opener (>= 1.4.1)
listen (= 3.0.8)
libv8 (= 6.3.292.48.1)
mini_racer (= 0.1.15)
momentjs-rails
newrelic_rpm (~> 3.0)
nokogiri (>= 1.6.7.1)
oauth2 (~> 1.4.1)
oauth2 (~> 1.4.2)
ofn-qz!
oj
order_management!
paper_trail (~> 5.2.3)
paperclip (~> 3.4.1)
pg
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)
@@ -843,9 +805,7 @@ DEPENDENCIES
shoulda-matchers
simple_form!
simplecov
skylight (< 2.0)
spinjs-rails
spree_api!
spree_backend!
spree_core!
spree_i18n!
@@ -853,7 +813,7 @@ DEPENDENCIES
spring (= 1.7.2)
spring-commands-rspec
stripe
therubyracer (= 0.12.0)
test-unit (~> 3.3)
timecop
truncate_html
turbo-sprockets-rails3
@@ -868,7 +828,7 @@ DEPENDENCIES
wkhtmltopdf-binary
RUBY VERSION
ruby 2.1.5p273
ruby 2.2.10p489
BUNDLED WITH
1.17.2

View File

@@ -1,11 +0,0 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
end

View File

@@ -1,23 +1,22 @@
[![Build Status](https://semaphoreci.com/api/v1/openfoodfoundation/openfoodnetwork-2/branches/master/badge.svg)](https://semaphoreci.com/openfoodfoundation/openfoodnetwork-2)
[![Code Climate](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork.png)](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork)
[![View performance data on Skylight](https://badges.skylight.io/status/EiXQ6sSKij8y.svg)](https://oss.skylight.io/app/applications/EiXQ6sSKij8y)
# Open Food Network
The Open Food Network is an online marketplace for local food. It enables a network of independent online food stores that connect farmers and food hubs (including coops, online farmers' markets, independent food businesses etc); with individuals and local businesses. It gives farmers and food hubs an easier and fairer way to distribute their food.
The Open Food Network is an online marketplace for local food. It enables a network of independent online food stores that connects farmers and food hubs (including co-ops, online farmers markets, independent food businesses, etc) with individuals and local businesses. It gives farmers and food hubs an easier and fairer way to distribute their food.
Supported by the Open Food Foundation and a network of global affiliates, we are proudly open source and not-for-profit - we're trying to seriously disrupt the concentration of power in global agri-food systems, and we need as many smart people working together on this as possible.
We're part of global movement - get involved!
* Join the conversation [on Slack][slack-invite]. Make sure you introduce yourself in the #general channel
* Join the conversation [on Slack][slack-invite]. Make sure you introduce yourself in the #general channel.
* Head to [https://openfoodnetwork.org](https://openfoodnetwork.org) for more information about the global OFN project.
* Check out the [User Guide](https://guide.openfoodnetwork.org/) for a list of features and tutorials.
* Join our [discussion forum](https://community.openfoodnetwork.org).
## Contributing
If you are interested in contributing to the OFN in any capacity, please introducing yourself [on Slack][slack-invite], and have a look through our [Contributor Guide][contributor-guide]
If you are interested in contributing to the OFN in any capacity, please introduce yourself [on Slack][slack-invite], and have a look through our [Contributor Guide][contributor-guide].
Our [GETTING_STARTED](GETTING_STARTED.md) and [CONTRIBUTING](CONTRIBUTING.md) guides are the best place to start for developers looking to set up a development environment and make contributions to the codebase.
@@ -36,7 +35,7 @@ We use [BrowserStack](https://www.browserstack.com/) as a manual testing tool. B
Copyright (c) 2012 - 2019 Open Food Foundation, released under the AGPL licence.
[survey]: https://docs.google.com/a/eaterprises.com.au/forms/d/1zxR5vSiU9CigJ9cEaC8-eJLgYid8CR8er7PPH9Mc-30/edit#
[slack-invite]: https://openfoodnetwork.org/slack-invite
[slack-invite]: https://join.slack.com/t/openfoodnetwork/shared_invite/enQtNzY3NDEwNzM2MDM0LWFmNGRhNDUwYzNmNWNkYmFkMzgxNDg1OTg1ODNjNWY4Y2FhNDIwNmE4ZWI0OThiMGNmZjFkODczNGZiYTJmNWI
[contributor-guide]: https://ofn-user-guide.gitbook.io/ofn-contributor-guide/who-are-we
[ofn-install]: https://github.com/openfoodfoundation/ofn-install
[super-admin-guide]: https://ofn-user-guide.gitbook.io/ofn-super-admin-guide

View File

@@ -1,4 +1,4 @@
angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout, $filter, $http, $window, BulkProducts, DisplayProperties, DirtyProducts, VariantUnitManager, StatusMessage, producers, Taxons, SpreeApiAuth, Columns, tax_categories, RequestMonitor) ->
angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout, $filter, $http, $window, BulkProducts, DisplayProperties, DirtyProducts, VariantUnitManager, StatusMessage, producers, Taxons, Columns, tax_categories, RequestMonitor) ->
$scope.StatusMessage = StatusMessage
$scope.columns = Columns.columns
@@ -39,12 +39,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
$scope.DisplayProperties = DisplayProperties
$scope.initialise = ->
SpreeApiAuth.authorise()
.then ->
$scope.spree_api_key_ok = true
$scope.fetchProducts()
.catch (message) ->
$scope.api_error_msg = message
$scope.fetchProducts()
$scope.$watchCollection '[query, producerFilter, categoryFilter, importDateFilter, per_page]', ->
$scope.page = 1 # Reset page when changing filters for new search
@@ -108,9 +103,15 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
$scope.categoryFilter = "0"
$scope.importDateFilter = "0"
confirm_unsaved_changes = () ->
(DirtyProducts.count() > 0 and confirm(t("unsaved_changes_confirmation"))) or (DirtyProducts.count() == 0)
editProductUrl = (product, variant) ->
"/admin/products/" + product.permalink_live + ((if variant then "/variants/" + variant.id else "")) + "/edit"
$scope.editWarn = (product, variant) ->
if (DirtyProducts.count() > 0 and confirm(t("unsaved_changes_confirmation"))) or (DirtyProducts.count() == 0)
window.location = "/admin/products/" + product.permalink_live + ((if variant then "/variants/" + variant.id else "")) + "/edit"
if confirm_unsaved_changes()
window.open(editProductUrl(product, variant), "_blank")
$scope.toggleShowAllVariants = ->

View File

@@ -1,16 +0,0 @@
angular.module("admin.indexUtils").factory "SpreeApiAuth", ($q, $http, SpreeApiKey) ->
new class SpreeApiAuth
authorise: ->
deferred = $q.defer()
$http.get("/api/users/authorise_api?token=" + SpreeApiKey)
.success (response) ->
if response?.success == "Use of API Authorised"
$http.defaults.headers.common["X-Spree-Token"] = SpreeApiKey
deferred.resolve()
.error (response) ->
error = response?.error || t('js.unauthorized')
deferred.reject(error)
deferred.promise

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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')

View File

@@ -1,4 +1,4 @@
angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl", ($scope, $http, $timeout, Indexer, Columns, Views, SpreeApiAuth, PagedFetcher, StatusMessage, RequestMonitor, hubs, producers, hubPermissions, InventoryItems, VariantOverrides, DirtyVariantOverrides) ->
angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl", ($scope, $http, $timeout, Indexer, Columns, Views, PagedFetcher, StatusMessage, RequestMonitor, hubs, producers, hubPermissions, InventoryItems, VariantOverrides, DirtyVariantOverrides) ->
$scope.hubs = Indexer.index hubs
$scope.hub_id = if hubs.length == 1 then hubs[0].id else null
$scope.products = []
@@ -39,13 +39,7 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
$scope.producerFilter != 0 || $scope.query != ''
$scope.initialise = ->
SpreeApiAuth.authorise()
.then ->
$scope.spree_api_key_ok = true
$scope.fetchProducts()
.catch (message) ->
$scope.api_error_msg = message
$scope.fetchProducts()
$scope.fetchProducts = ->
url = "/api/products/overridable?page=::page::;per_page=100"

View File

@@ -1,4 +1,4 @@
Darkswarm.controller "OrderCycleCtrl", ($scope, $timeout, OrderCycle) ->
Darkswarm.controller "OrderCycleCtrl", ($scope, $rootScope, $timeout, OrderCycle) ->
$scope.order_cycle = OrderCycle.order_cycle
$scope.OrderCycle = OrderCycle
@@ -6,11 +6,12 @@ Darkswarm.controller "OrderCycleCtrl", ($scope, $timeout, OrderCycle) ->
# This is a hack. We should probably write our own "popover" directive
# That takes an expression instead of a trigger, and binds to that
$timeout =>
$rootScope.$broadcast 'orderCycleSelected'
if !$scope.OrderCycle.selected()
$("#order_cycle_id").trigger("openTrigger")
Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $timeout, OrderCycle, Products, Variants, Cart, ChangeableOrdersAlert) ->
Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $rootScope, $timeout, OrderCycle, Products, Variants, Cart, ChangeableOrdersAlert) ->
# Track previous order cycle id for use with revertOrderCycle()
$scope.previous_order_cycle_id = OrderCycle.order_cycle.order_cycle_id
$scope.$watch 'order_cycle.order_cycle_id', (newValue, oldValue)->
@@ -32,3 +33,4 @@ Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $timeout, OrderCycle, Prod
Products.update()
Cart.reloadFinalisedLineItems()
ChangeableOrdersAlert.reload()
$rootScope.$broadcast 'orderCycleSelected'

View File

@@ -1,41 +1,65 @@
Darkswarm.controller "ProductsCtrl", ($scope, $filter, $rootScope, Products, OrderCycle, FilterSelectorsService, Cart, Taxons, Properties) ->
Darkswarm.controller "ProductsCtrl", ($scope, $filter, $rootScope, Products, OrderCycle, OrderCycleResource, FilterSelectorsService, Cart, Dereferencer, Taxons, Properties, currentHub, $timeout) ->
$scope.Products = Products
$scope.Cart = Cart
$scope.query = ""
$scope.taxonSelectors = FilterSelectorsService.createSelectors()
$scope.propertySelectors = FilterSelectorsService.createSelectors()
$scope.filtersActive = true
$scope.limit = 10
$scope.page = 1
$scope.per_page = 10
$scope.order_cycle = OrderCycle.order_cycle
# $scope.infiniteDisabled = true
$scope.supplied_taxons = null
$scope.supplied_properties = null
# All of this logic basically just replicates the functionality filtering an ng-repeat
# except that it allows us to filter a separate list before rendering, meaning that
# we can get much better performance when applying filters by resetting the limit on the
# number of products being rendered each time a filter is changed.
$rootScope.$on "orderCycleSelected", ->
$scope.update_filters()
$scope.clearAll()
$scope.$watch "Products.loading", (newValue, oldValue) ->
$scope.updateFilteredProducts()
$scope.$broadcast("loadFilterSelectors") if !newValue
$scope.update_filters = ->
order_cycle_id = OrderCycle.order_cycle.order_cycle_id
$scope.incrementLimit = ->
if $scope.limit < Products.products.length
$scope.limit += 10
$scope.updateVisibleProducts()
return unless order_cycle_id
$scope.$watch 'query', -> $scope.updateFilteredProducts()
$scope.$watchCollection 'activeTaxons', -> $scope.updateFilteredProducts()
$scope.$watchCollection 'activeProperties', -> $scope.updateFilteredProducts()
params = {
id: order_cycle_id,
distributor: currentHub.id
}
OrderCycleResource.taxons params, (data)=>
$scope.supplied_taxons = {}
data.map( (taxon) ->
$scope.supplied_taxons[taxon.id] = Taxons.taxons_by_id[taxon.id]
)
OrderCycleResource.properties params, (data)=>
$scope.supplied_properties = {}
data.map( (property) ->
$scope.supplied_properties[property.id] = Properties.properties_by_id[property.id]
)
$scope.updateFilteredProducts = ->
$scope.limit = 10
f1 = $filter('products')(Products.products, $scope.query)
f2 = $filter('taxons')(f1, $scope.activeTaxons)
$scope.filteredProducts = $filter('properties')(f2, $scope.activeProperties)
$scope.updateVisibleProducts()
$scope.loadMore = ->
if ($scope.page * $scope.per_page) <= Products.products.length
$scope.loadMoreProducts()
$scope.updateVisibleProducts = ->
$scope.visibleProducts = $filter('limitTo')($scope.filteredProducts, $scope.limit)
$scope.$watch 'query', (newValue, oldValue) -> $scope.loadProducts() if newValue != oldValue
$scope.$watchCollection 'activeTaxons', (newValue, oldValue) -> $scope.loadProducts() if newValue != oldValue
$scope.$watchCollection 'activeProperties', (newValue, oldValue) -> $scope.loadProducts() if newValue != oldValue
$scope.loadProducts = ->
$scope.page = 1
Products.update($scope.queryParams())
$scope.loadMoreProducts = ->
Products.update($scope.queryParams($scope.page + 1), true)
$scope.page += 1
$scope.queryParams = (page = null) ->
{
id: $scope.order_cycle.order_cycle_id,
page: page || $scope.page,
per_page: $scope.per_page,
'q[name_or_meta_keywords_or_supplier_name_cont]': $scope.query,
'q[properties_id_or_supplier_properties_id_in_any][]': $scope.activeProperties,
'q[primary_taxon_id_in_any][]': $scope.activeTaxons
}
$scope.searchKeypress = (e)->
code = e.keyCode || e.which

View File

@@ -0,0 +1,21 @@
Darkswarm.factory 'OrderCycleResource', ($resource) ->
$resource('/api/order_cycles/:id', {}, {
'products':
method: 'GET'
isArray: true
url: '/api/order_cycles/:id/products'
params:
id: '@id'
'taxons':
method: 'GET'
isArray: true
url: '/api/order_cycles/:id/taxons'
params:
id: '@id'
'properties':
method: 'GET'
isArray: true
url: '/api/order_cycles/:id/properties'
params:
id: '@id'
})

View File

@@ -1,26 +1,34 @@
Darkswarm.factory 'Products', ($resource, Shopfront, Dereferencer, Taxons, Properties, Cart, Variants) ->
Darkswarm.factory 'Products', (OrderCycleResource, OrderCycle, Shopfront, currentHub, Dereferencer, Taxons, Properties, Cart, Variants) ->
new class Products
constructor: ->
@update()
# TODO: don't need to scope this into object
# Already on object as far as controller scope is concerned
products: null
products: []
fetched_products: []
loading: true
update: =>
update: (params = {}, load_more = false) =>
@loading = true
@products = []
$resource("/shop/products").query (products)=>
@products = products
order_cycle_id = OrderCycle.order_cycle.order_cycle_id
if order_cycle_id == undefined
@loading = false
return
params['id'] = order_cycle_id
params['distributor'] = currentHub.id
OrderCycleResource.products params, (data)=>
@products = [] unless load_more
@fetched_products = data
@extend()
@dereference()
@registerVariants()
@products = @products.concat(@fetched_products)
@loading = false
extend: ->
for product in @products
for product in @fetched_products
if product.variants?.length > 0
prices = (v.price for v in product.variants)
product.price = Math.min.apply(null, prices)
@@ -30,7 +38,7 @@ Darkswarm.factory 'Products', ($resource, Shopfront, Dereferencer, Taxons, Prope
product.largeImage = product.images[0]?.large_url if product.images
dereference: ->
for product in @products
for product in @fetched_products
product.supplier = Shopfront.producers_by_id[product.supplier.id]
Dereferencer.dereference product.taxons, Taxons.taxons_by_id
@@ -40,7 +48,7 @@ Darkswarm.factory 'Products', ($resource, Shopfront, Dereferencer, Taxons, Prope
# May return different objects! If the variant has already been registered
# by another service, we fetch those
registerVariants: ->
for product in @products
for product in @fetched_products
if product.variants
product.variant_names = ""
product.variants = for variant in product.variants

View File

@@ -11,7 +11,7 @@
.exchange-products
-# Scope product list based on permissions the current user has to view variants in this exchange
.exchange-product{'ng-repeat' => 'product in supplied_products | filter:productSuppliedToOrderCycle | visibleProducts:exchange:order_cycle.visible_variants_for_outgoing_exchanges | orderBy:"name"' }
.exchange-product{'ng-repeat' => 'product in supplied_products | filter:productSuppliedToOrderCycle | visibleProducts:exchange:order_cycle.visible_variants_for_outgoing_exchanges' }
.exchange-product-details
%label
%img{'ng-src' => '{{ product.image_url }}'}

View File

@@ -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 }}',

View File

@@ -17,7 +17,7 @@
.small-4.medium-2.large-2.columns.variant-price
.table-cell.price
%i.ofn-i_009-close
{{ ::variant.price_with_fees | localizeCurrency }}
{{ variant.price_with_fees | localizeCurrency }}
-# Now in a template in app/assets/javascripts/templates !
%price-breakdown{"price-breakdown" => "_", variant: "variant",

View File

@@ -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;
}

View File

@@ -255,6 +255,9 @@ text-angular {
background-color: #4583bf;
}
}
a {
color: $spree-green
}
}
span.required {

View File

@@ -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

View File

@@ -1,27 +0,0 @@
require 'open_food_network/products_cache_integrity_checker'
module Admin
class CacheSettingsController < Spree::Admin::BaseController
def edit
@results = Exchange.cachable.map do |exchange|
checker = OpenFoodNetwork::ProductsCacheIntegrityChecker
.new(exchange.receiver, exchange.order_cycle)
{
distributor: exchange.receiver,
order_cycle: exchange.order_cycle,
status: checker.ok?,
diff: checker.diff
}
end
end
def update
Spree::Config.set(params[:preferences])
respond_to do |format|
format.html { redirect_to main_app.edit_admin_cache_settings_path }
end
end
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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!

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -1,16 +1,44 @@
# Base controller for OFN's API
# Includes the minimum machinery required by ActiveModelSerializers
require_dependency 'spree/api/controller_setup'
module Api
class BaseController < Spree::Api::BaseController
# Need to include these because Spree::Api::BaseContoller inherits
# from ActionController::Metal rather than ActionController::Base
# and they are required by ActiveModelSerializers
class BaseController < ActionController::Metal
include Spree::Api::ControllerSetup
include Spree::Core::ControllerHelpers::SSL
include ::ActionController::Head
respond_to :json
attr_accessor :current_api_user
before_filter :set_content_type
before_filter :authenticate_user
after_filter :set_jsonp_format
rescue_from Exception, with: :error_during_processing
rescue_from CanCan::AccessDenied, with: :unauthorized
rescue_from ActiveRecord::RecordNotFound, with: :not_found
helper Spree::Api::ApiHelpers
ssl_allowed
# Include these because we inherit from ActionController::Metal
# rather than ActionController::Base and these are required for AMS
include ActionController::Serialization
include ActionController::UrlFor
include Rails.application.routes.url_helpers
use_renderers :json
check_authorization
def set_jsonp_format
return unless params[:callback] && request.get?
self.response_body = "#{params[:callback]}(#{response_body})"
headers["Content-Type"] = 'application/javascript'
end
def respond_with_conflict(json_hash)
render json: json_hash, status: :conflict
end
@@ -19,16 +47,63 @@ module Api
# Use logged in user (spree_current_user) for API authentication (current_api_user)
def authenticate_user
@current_api_user = try_spree_current_user
super
return if @current_api_user = try_spree_current_user
if api_key.blank?
# An anonymous user
@current_api_user = Spree.user_class.new
return
end
return if @current_api_user = Spree.user_class.find_by_spree_api_key(api_key.to_s)
invalid_api_key
end
# Allows API access without authentication, but only for OFN controllers which inherit
# from Api::BaseController. @current_api_user will now initialize an empty Spree::User
# unless one is present. We now also apply devise's `check_authorization`. See here for
# details: https://github.com/CanCanCommunity/cancancan/wiki/Ensure-Authorization
def requires_authentication?
false
def set_content_type
content_type = case params[:format]
when "json"
"application/json"
when "xml"
"text/xml"
end
headers["Content-Type"] = content_type
end
def error_during_processing(exception)
render(text: { exception: exception.message }.to_json,
status: :unprocessable_entity) && return
end
def current_ability
Spree::Ability.new(current_api_user)
end
def api_key
request.headers["X-Spree-Token"] || params[:token]
end
helper_method :api_key
def invalid_resource!(resource)
@resource = resource
render(json: { error: I18n.t(:invalid_resource, scope: "spree.api"),
errors: @resource.errors },
status: :unprocessable_entity)
end
def invalid_api_key
render(json: { error: I18n.t(:invalid_api_key, key: api_key, scope: "spree.api") },
status: :unauthorized) && return
end
def unauthorized
render(json: { error: I18n.t(:unauthorized, scope: "spree.api") },
status: :unauthorized) && return
end
def not_found
render(json: { error: I18n.t(:resource_not_found, scope: "spree.api") },
status: :not_found) && return
end
end
end

View File

@@ -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

View File

@@ -0,0 +1,88 @@
module Api
class OrderCyclesController < BaseController
include EnterprisesHelper
respond_to :json
skip_authorization_check
def products
products = ProductsRenderer.new(
distributor,
order_cycle,
customer,
search_params
).products_json
render json: products
rescue ProductsRenderer::NoProducts
render status: :not_found, json: ''
end
def taxons
taxons = Spree::Taxon.
joins(:products).
where(spree_products: { id: distributed_products }).
select('DISTINCT spree_taxons.*')
render json: ActiveModel::ArraySerializer.new(taxons, each_serializer: Api::TaxonSerializer)
end
def properties
render json: ActiveModel::ArraySerializer.new(
product_properties | producer_properties, each_serializer: Api::PropertySerializer
)
end
private
def product_properties
Spree::Property.
joins(:products).
where(spree_products: { id: distributed_products }).
select('DISTINCT spree_properties.*')
end
def producer_properties
producers = Enterprise.
joins(:supplied_products).
where(spree_products: { id: distributed_products })
Spree::Property.
joins(:producer_properties).
where(producer_properties: { producer_id: producers }).
select('DISTINCT spree_properties.*')
end
def search_params
permitted_search_params = params.slice :q, :page, :per_page
if permitted_search_params.key? :q
permitted_search_params[:q].slice!(*permitted_ransack_params)
end
permitted_search_params
end
def permitted_ransack_params
[:name_or_meta_keywords_or_supplier_name_cont,
:properties_id_or_supplier_properties_id_in_any,
:primary_taxon_id_in_any]
end
def distributor
Enterprise.find_by_id(params[:distributor])
end
def order_cycle
OrderCycle.find_by_id(params[:id])
end
def customer
@current_api_user.andand.customer_of(distributor) || nil
end
def distributed_products
OrderCycleDistributedProducts.new(distributor, order_cycle, customer).products_relation
end
end
end

View File

@@ -1,5 +1,10 @@
module Api
class OrdersController < BaseController
def show
authorize! :read, order
render json: order, serializer: Api::OrderDetailedSerializer, current_order: order
end
def index
authorize! :admin, Spree::Order
@@ -19,5 +24,12 @@ module Api
each_serializer: Api::Admin::OrderSerializer
)
end
def order
@order ||= Spree::Order.
where(number: params[:id]).
includes(line_items: { variant: [:product, :stock_items, :default_price] }).
first!
end
end
end

View File

@@ -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,10 +44,9 @@ 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
# TODO: This should be named 'managed'. Is the action above used? Maybe we should remove it.
def bulk_products
product_query = OpenFoodNetwork::Permissions.new(current_api_user).
editable_products.merge(product_scope)
@@ -77,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
@@ -89,15 +88,18 @@ 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
# Copied and modified from SpreeApi::BaseController to allow
# enterprise users to access inactive products
def find_product(id)
product_scope.find_by_permalink!(id.to_s)
rescue ActiveRecord::RecordNotFound
product_scope.find(id)
end
def product_scope
# This line modified
if current_api_user.has_spree_role?("admin") || current_api_user.enterprises.present?
scope = Spree::Product
if params[:show_deleted]
@@ -107,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)
@@ -127,6 +137,9 @@ module Api
render text: {
products: serializer,
# This line is used by the PagedFetcher JS service (inventory).
pages: products.num_pages,
# This hash is used by the BulkProducts JS service.
pagination: pagination_data(products)
}.to_json
end

View File

@@ -0,0 +1,105 @@
require 'open_food_network/scope_variant_to_hub'
module Api
class ShipmentsController < Api::BaseController
respond_to :json
before_filter :find_order
before_filter :find_and_update_shipment, only: [:ship, :ready, :add, :remove]
def create
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@shipment = get_or_create_shipment(params[:stock_location_id])
@order.contents.add(variant, quantity, nil, @shipment)
@shipment.refresh_rates
@shipment.save!
render json: @shipment.reload, serializer: Api::ShipmentSerializer, status: :ok
end
def update
authorize! :read, Spree::Shipment
@shipment = @order.shipments.find_by_number!(params[:id])
params[:shipment] ||= []
unlock = params[:shipment].delete(:unlock)
if unlock == 'yes'
@shipment.adjustment.open
end
@shipment.update_attributes(params[:shipment])
if unlock == 'yes'
@shipment.adjustment.close
end
render json: @shipment.reload, serializer: Api::ShipmentSerializer, status: :ok
end
def ready
authorize! :read, Spree::Shipment
unless @shipment.ready?
if @shipment.can_ready?
@shipment.ready!
else
render(json: { error: I18n.t(:cannot_ready, scope: "spree.api.shipment") },
status: :unprocessable_entity) && return
end
end
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
end
def ship
authorize! :read, Spree::Shipment
unless @shipment.shipped?
@shipment.ship!
end
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
end
def add
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@order.contents.add(variant, quantity, nil, @shipment)
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
end
def remove
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@order.contents.remove(variant, quantity, @shipment)
@shipment.reload if @shipment.persisted?
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
end
private
def find_order
@order = Spree::Order.find_by_number!(params[:order_id])
authorize! :read, @order
end
def find_and_update_shipment
@shipment = @order.shipments.find_by_number!(params[:id])
@shipment.update_attributes(params[:shipment])
@shipment.reload
end
def scoped_variant(variant_id)
variant = Spree::Variant.find(variant_id)
OpenFoodNetwork::ScopeVariantToHub.new(@order.distributor).scope(variant)
variant
end
def get_or_create_shipment(stock_location_id)
@order.shipment || @order.shipments.create(stock_location_id: stock_location_id)
end
end
end

View File

@@ -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

View File

@@ -0,0 +1,12 @@
module Api
class TaxonomiesController < Api::BaseController
respond_to :json
skip_authorization_check only: :jstree
def jstree
@taxonomy = Spree::Taxonomy.find(params[:id])
render json: @taxonomy.root, serializer: Api::TaxonJstreeSerializer
end
end
end

View File

@@ -0,0 +1,72 @@
module Api
class TaxonsController < Api::BaseController
respond_to :json
skip_authorization_check only: [:index, :show, :jstree]
def index
if taxonomy
@taxons = taxonomy.root.children
else
if params[:ids]
@taxons = Spree::Taxon.where(id: params[:ids].split(","))
else
@taxons = Spree::Taxon.ransack(params[:q]).result
end
end
render json: @taxons, each_serializer: Api::TaxonSerializer
end
def jstree
@taxon = taxon
render json: @taxon.children, each_serializer: Api::TaxonJstreeSerializer
end
def create
authorize! :create, Spree::Taxon
@taxon = Spree::Taxon.new(params[:taxon])
@taxon.taxonomy_id = params[:taxonomy_id]
taxonomy = Spree::Taxonomy.find_by_id(params[:taxonomy_id])
if taxonomy.nil?
@taxon.errors[:taxonomy_id] = I18n.t(:invalid_taxonomy_id, scope: 'spree.api')
invalid_resource!(@taxon) && return
end
@taxon.parent_id = taxonomy.root.id unless params[:taxon][:parent_id]
if @taxon.save
render json: @taxon, serializer: Api::TaxonSerializer, status: :created
else
invalid_resource!(@taxon)
end
end
def update
authorize! :update, Spree::Taxon
if taxon.update_attributes(params[:taxon])
render json: taxon, serializer: Api::TaxonSerializer, status: :ok
else
invalid_resource!(taxon)
end
end
def destroy
authorize! :delete, Spree::Taxon
taxon.destroy
render json: taxon, serializer: Api::TaxonSerializer, status: :no_content
end
private
def taxonomy
return if params[:taxonomy_id].blank?
@taxonomy ||= Spree::Taxonomy.find(params[:taxonomy_id])
end
def taxon
@taxon ||= taxonomy.taxons.find(params[:id])
end
end
end

View File

@@ -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")

View File

@@ -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

View File

@@ -3,6 +3,10 @@ require 'open_food_network/address_finder'
class CheckoutController < Spree::CheckoutController
layout 'darkswarm'
# We need pessimistic locking to avoid race conditions.
# Otherwise we fail on duplicate indexes or end up with negative stock.
prepend_around_filter CurrentOrderLocker, only: :update
prepend_before_filter :check_hub_ready_for_checkout
prepend_before_filter :check_order_cycle_expiry
prepend_before_filter :require_order_cycle
@@ -152,7 +156,7 @@ class CheckoutController < Spree::CheckoutController
end
def update_failed
clear_ship_address
current_order.updater.shipping_address_from_distributor
RestartCheckout.new(@order).call
respond_to do |format|
@@ -165,15 +169,6 @@ class CheckoutController < Spree::CheckoutController
end
end
# When we have a pickup Shipping Method,
# we clone the distributor address into ship_address before_save
# We don't want this data in the form, so we clear it out
def clear_ship_address
unless current_order.shipping_method.andand.require_ship_address
current_order.ship_address = Spree::Address.default
end
end
def load_order
@order = current_order
redirect_to(main_app.shop_path) && return unless @order && @order.checkout_allowed?

View File

@@ -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

View File

@@ -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

View File

@@ -1,5 +1,3 @@
require 'open_food_network/cached_products_renderer'
class ShopController < BaseController
layout "darkswarm"
before_filter :require_distributor_chosen, :set_order_cycles, except: :changeable_orders_alert
@@ -9,19 +7,6 @@ class ShopController < BaseController
redirect_to main_app.enterprise_shop_path(current_distributor)
end
def products
renderer = OpenFoodNetwork::CachedProductsRenderer.new(current_distributor,
current_order_cycle)
# If we add any more filtering logic, we should probably
# move it all to a lib class like 'CachedProductsFilterer'
products_json = filter(renderer.products_json)
render json: products_json
rescue OpenFoodNetwork::CachedProductsRenderer::NoProducts
render status: :not_found, json: ''
end
def order_cycle
if request.post?
if oc = OrderCycle.with_distributor(@distributor).active.find_by_id(params[:order_cycle_id])
@@ -39,27 +24,4 @@ class ShopController < BaseController
def changeable_orders_alert
render layout: false
end
private
def filtered_json(products_json)
if applicator.rules.any?
filter(products_json)
else
products_json
end
end
def filter(products_json)
products_hash = JSON.parse(products_json)
applicator.filter!(products_hash)
JSON.unparse(products_hash)
end
def applicator
return @applicator unless @applicator.nil?
@applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor,
"FilterProducts",
current_customer.andand.tag_list)
end
end

View File

@@ -54,6 +54,7 @@ Spree::Admin::BaseController.class_eval do
if Spree.const_defined?(const_name)
return "Spree::#{const_name}".constantize
end
nil
end

View File

@@ -0,0 +1,9 @@
module Spree
module Admin
class CountriesController < ResourceController
def collection
super.order(:name)
end
end
end
end

View File

@@ -0,0 +1,37 @@
module Spree
module Admin
class GeneralSettingsController < Spree::Admin::BaseController
def edit
@preferences_general = [:site_name, :default_seo_title, :default_meta_keywords,
:default_meta_description, :site_url, :bugherd_api_key]
@preferences_security = [:allow_ssl_in_production,
:allow_ssl_in_staging, :allow_ssl_in_development_and_test,
:check_for_spree_alerts]
@preferences_currency = [:display_currency, :hide_cents]
end
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))
redirect_to edit_admin_general_settings_path
end
def dismiss_alert
return unless request.xhr? && params[:alert_id]
dismissed = Spree::Config[:dismissed_spree_alerts] || ''
Spree::Config.set(dismissed_spree_alerts: dismissed.
split(',').
push(params[:alert_id]).
join(','))
filter_dismissed_alerts
render nothing: true
end
end
end
end

View File

@@ -1,14 +0,0 @@
module Spree
module Admin
GeneralSettingsController.class_eval do
end
module GeneralSettingsEditPreferences
def edit
super
@preferences_general << :bugherd_api_key
end
end
GeneralSettingsController.prepend(GeneralSettingsEditPreferences)
end
end

View File

@@ -0,0 +1,79 @@
module Spree
module Admin
class ImageSettingsController < Spree::Admin::BaseController
def edit
@styles = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles])
@headers = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
end
def update
update_styles(params)
update_headers(params) if Spree::Config[:use_s3]
Spree::Config.set(params[:preferences])
update_paperclip_settings
respond_to do |format|
format.html {
flash[:success] = Spree.t(:image_settings_updated)
redirect_to spree.edit_admin_image_settings_path
}
end
end
private
def update_styles(params)
if params[:new_attachment_styles].present?
params[:new_attachment_styles].each do |_index, style|
params[:attachment_styles][style[:name]] = style[:value] unless style[:value].empty?
end
end
styles = params[:attachment_styles]
Spree::Config[:attachment_styles] = ActiveSupport::JSON.encode(styles) unless styles.nil?
end
def update_headers(params)
if params[:new_s3_headers].present?
params[:new_s3_headers].each do |_index, header|
params[:s3_headers][header[:name]] = header[:value] unless header[:value].empty?
end
end
headers = params[:s3_headers]
Spree::Config[:s3_headers] = ActiveSupport::JSON.encode(headers) unless headers.nil?
end
def update_paperclip_settings
if Spree::Config[:use_s3]
s3_creds = { access_key_id: Spree::Config[:s3_access_key],
secret_access_key: Spree::Config[:s3_secret],
bucket: Spree::Config[:s3_bucket] }
Spree::Image.attachment_definitions[:attachment][:storage] = :s3
Spree::Image.attachment_definitions[:attachment][:s3_credentials] = s3_creds
Spree::Image.attachment_definitions[:attachment][:s3_headers] =
ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
Spree::Image.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
else
Spree::Image.attachment_definitions[:attachment].delete :storage
end
Spree::Image.attachment_definitions[:attachment][:styles] =
ActiveSupport::JSON.decode(Spree::Config[:attachment_styles]).symbolize_keys!
Spree::Image.attachment_definitions[:attachment][:path] = Spree::Config[:attachment_path]
Spree::Image.attachment_definitions[:attachment][:default_url] =
Spree::Config[:attachment_default_url]
Spree::Image.attachment_definitions[:attachment][:default_style] =
Spree::Config[:attachment_default_style]
# Spree stores attachent definitions in JSON. This converts the style name and format to
# strings. However, when paperclip encounters these, it doesn't recognise the format.
# Here we solve that problem by converting format and style name to symbols.
Spree::Image.reformat_styles
end
end
end
end

View File

@@ -1,11 +0,0 @@
Spree::Admin::ImageSettingsController.class_eval do
# Spree stores attachent definitions in JSON. This converts the style name and format to
# strings. However, when paperclip encounters these, it doesn't recognise the format.
# Here we solve that problem by converting format and style name to symbols.
def update_paperclip_settings_with_format_styles
update_paperclip_settings_without_format_styles
Spree::Image.reformat_styles
end
alias_method_chain :update_paperclip_settings, :format_styles
end

View 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

View File

@@ -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

View File

@@ -0,0 +1,40 @@
module Spree
module Admin
class MailMethodsController < Spree::Admin::BaseController
after_filter :initialize_mail_settings
def update
if params[:smtp_password].blank?
params.delete(:smtp_password)
end
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(:mail_methods))
render :edit
end
def testmail
if TestMailer.test_email(try_spree_current_user).deliver
flash[:success] = Spree.t('admin.mail_methods.testmail.delivery_success')
else
flash[:error] = Spree.t('admin.mail_methods.testmail.delivery_error')
end
rescue StandardError => e
flash[:error] = Spree.t('admin.mail_methods.testmail.error') % { e: e }
ensure
redirect_to edit_admin_mail_method_url
end
private
def initialize_mail_settings
Spree::Core::MailSettings.init
end
end
end
end

View File

@@ -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

View File

@@ -3,7 +3,6 @@ require 'open_food_network/spree_api_key_loader'
Spree::Admin::OrdersController.class_eval do
include OpenFoodNetwork::SpreeApiKeyLoader
helper CheckoutHelper
before_filter :load_spree_api_key, only: :bulk_management
before_filter :load_order, only: %i[show edit update fire resend invoice print print_ticket]
before_filter :load_distribution_choices, only: [:new, :edit, :update]
@@ -27,6 +26,10 @@ Spree::Admin::OrdersController.class_eval do
# within the page then fetches the data it needs from Api::OrdersController
end
def bulk_management
load_spree_api_key
end
def edit
@order.shipments.map &:refresh_rates

View File

@@ -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

View File

@@ -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

View 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

View File

@@ -30,6 +30,11 @@ Spree::Admin::ProductsController.class_eval do
@show_latest_import = params[:latest_import] || false
end
def new
@object.shipping_category = DefaultShippingCategory.find_or_create
super
end
def create
delete_stock_params_and_set_after do
super
@@ -41,11 +46,12 @@ Spree::Admin::ProductsController.class_eval do
end
def update
original_supplier_id = @product.supplier_id
delete_stock_params_and_set_after do
super
ExchangeVariantDeleter.new.delete(@product) if original_supplier_id != @product.supplier_id
end
clear_variants_unit_description if @object.variant_unit == 'items'
end
def bulk_update
@@ -73,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"
@@ -141,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]
@@ -164,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
@@ -190,10 +198,4 @@ Spree::Admin::ProductsController.class_eval do
def set_product_master_variant_price_to_zero
@product.price = 0 if @product.price.nil?
end
def clear_variants_unit_description
@object.variants.each do |variant|
variant.update_attribute :unit_description, ''
end
end
end

View File

@@ -0,0 +1,6 @@
module Spree
module Admin
class PropertiesController < ResourceController
end
end
end

View File

@@ -109,7 +109,7 @@ Spree::Admin::ReportsController.class_eval do
end
def orders_and_fulfillment
params[:q] ||= {}
params[:q] ||= orders_and_fulfillment_default_filters
# -- Prepare Form Options
permissions = OpenFoodNetwork::Permissions.new(spree_current_user)
@@ -126,7 +126,8 @@ Spree::Admin::ReportsController.class_eval do
@include_blank = I18n.t(:all)
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::OrdersAndFulfillmentsReport.new spree_current_user, params, render_content?
@report = OpenFoodNetwork::OrdersAndFulfillmentsReport.new(permissions,
params, render_content?)
@table = order_grouper_table
csv_file_name = "#{params[:report_type]}_#{timestamp}.csv"
@@ -257,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
@@ -277,4 +278,10 @@ Spree::Admin::ReportsController.class_eval do
def timestamp
Time.zone.now.strftime("%Y%m%d")
end
def orders_and_fulfillment_default_filters
now = Time.zone.now
{ completed_at_gt: (now - 1.month).beginning_of_day,
completed_at_lt: (now + 1.day).beginning_of_day }
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,6 @@
module Spree
module Admin
class ShippingCategoriesController < ResourceController
end
end
end

View File

@@ -0,0 +1,86 @@
module Spree
module Admin
class ShippingMethodsController < ResourceController
before_filter :load_data, except: [:index]
before_filter :set_shipping_category, only: [:create, :update]
before_filter :set_zones, only: [:create, :update]
before_filter :load_hubs, only: [:new, :edit, :create, :update]
# Sort shipping methods by distributor name
def collection
collection = super
collection = collection.managed_by(spree_current_user).by_name
if params.key? :enterprise_id
distributor = Enterprise.find params[:enterprise_id]
collection = collection.for_distributor(distributor)
end
collection
end
def new
@object.shipping_categories = [DefaultShippingCategory.find_or_create]
super
end
def destroy
# Our reports are not adapted to soft deleted shipping_methods so here we prevent
# the deletion (even soft) of shipping_methods that are referenced in orders
if order = order_referenced_by_shipping_method
flash[:error] = I18n.t(:shipping_method_destroy_error, number: order.number)
redirect_to(collection_url) && return
end
@object.touch :deleted_at
flash[:success] = flash_message_for(@object, :successfully_removed)
respond_with(@object) do |format|
format.html { redirect_to collection_url }
end
end
private
def order_referenced_by_shipping_method
Order.joins(shipments: :shipping_rates)
.where( spree_shipping_rates: { shipping_method_id: @object } )
.first
end
def load_hubs
# rubocop:disable Style/TernaryParentheses
@hubs = Enterprise.managed_by(spree_current_user).is_distributor.sort_by! do |d|
[(@shipping_method.has_distributor? d) ? 0 : 1, d.name]
end
# rubocop:enable Style/TernaryParentheses
end
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
params[:shipping_method].delete(:shipping_categories)
end
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)
end
def location_after_save
edit_admin_shipping_method_path(@shipping_method)
end
def load_data
@available_zones = Zone.order(:name)
@calculators = ShippingMethod.calculators.sort_by(&:name)
end
end
end
end

View File

@@ -1,42 +0,0 @@
module Spree
module Admin
ShippingMethodsController.class_eval do
before_filter :do_not_destroy_referenced_shipping_methods, only: :destroy
before_filter :load_hubs, only: [:new, :edit, :create, :update]
# Sort shipping methods by distributor name
def collection
collection = super
collection = collection.managed_by(spree_current_user).by_name
if params.key? :enterprise_id
distributor = Enterprise.find params[:enterprise_id]
collection = collection.for_distributor(distributor)
end
collection
end
# Spree allows soft deletes of shipping_methods but our reports are not adapted to that
# Here we prevent the deletion (even soft) of shipping_methods that are referenced in orders
def do_not_destroy_referenced_shipping_methods
order = Order.joins(shipments: :shipping_rates)
.where( spree_shipping_rates: { shipping_method_id: @object } )
.first
return unless order
flash[:error] = I18n.t(:shipping_method_destroy_error, number: order.number)
redirect_to(collection_url) && return
end
private
def load_hubs
# rubocop:disable Style/TernaryParentheses
@hubs = Enterprise.managed_by(spree_current_user).is_distributor.sort_by! do |d|
[(@shipping_method.has_distributor? d) ? 0 : 1, d.name]
end
# rubocop:enable Style/TernaryParentheses
end
end
end
end

View File

@@ -0,0 +1,29 @@
module Spree
module Admin
class StatesController < ResourceController
belongs_to 'spree/country'
before_filter :load_data
def index
respond_with(@collection) do |format|
format.html
format.js { render partial: 'state_list' }
end
end
protected
def location_after_save
admin_country_states_url(@country)
end
def collection
super.order(:name)
end
def load_data
@countries = Country.order(:name)
end
end
end
end

View File

@@ -0,0 +1,19 @@
module Spree
module Admin
class TaxCategoriesController < ResourceController
def destroy
if @object.destroy
flash[:success] = flash_message_for(@object, :successfully_removed)
respond_with(@object) do |format|
format.html { redirect_to collection_url }
format.js { render partial: "spree/admin/shared/destroy" }
end
else
respond_with(@object) do |format|
format.html { redirect_to collection_url }
end
end
end
end
end
end

View File

@@ -0,0 +1,26 @@
module Spree
module Admin
class TaxRatesController < ResourceController
before_filter :load_data
update.after :update_after
create.after :create_after
private
def load_data
@available_zones = Zone.order(:name)
@available_categories = TaxCategory.order(:name)
@calculators = TaxRate.calculators.sort_by(&:name)
end
def update_after
Rails.cache.delete('vat_rates')
end
def create_after
Rails.cache.delete('vat_rates')
end
end
end
end

View File

@@ -0,0 +1,15 @@
module Spree
module Admin
class TaxSettingsController < Spree::Admin::BaseController
def update
Spree::Config.set(params[:preferences])
respond_to do |format|
format.html {
redirect_to edit_admin_tax_settings_path
}
end
end
end
end
end

View File

@@ -0,0 +1,21 @@
module Spree
module Admin
class TaxonomiesController < ResourceController
respond_to :json, only: [:get_children]
def get_children
@taxons = Taxon.find(params[:parent_id]).children
end
private
def location_after_save
if @taxonomy.created_at == @taxonomy.updated_at
edit_admin_taxonomy_url(@taxonomy)
else
admin_taxonomies_url
end
end
end
end
end

View File

@@ -0,0 +1,118 @@
module Spree
module Admin
class TaxonsController < Spree::Admin::BaseController
respond_to :html, :json, :js
def search
@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
@taxonomy = Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.build(params[:taxon])
if @taxon.save
respond_with(@taxon) do |format|
format.json { render json: @taxon.to_json }
end
else
flash[:error] = Spree.t('errors.messages.could_not_create_taxon')
respond_with(@taxon) do |format|
format.html do
if redirect_to @taxonomy
edit_admin_taxonomy_url(@taxonomy)
else
admin_taxonomies_url
end
end
end
end
end
def edit
@taxonomy = Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.find(params[:id])
@permalink_part = @taxon.permalink.split("/").last
end
def update
@taxonomy = Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.find(params[:id])
parent_id = params[:taxon][:parent_id]
new_position = params[:taxon][:position]
if parent_id || new_position # taxon is being moved
new_parent = parent_id.nil? ? @taxon.parent : Taxon.find(parent_id.to_i)
new_position = new_position.nil? ? -1 : new_position.to_i
# Bellow is a very complicated way of finding where in nested set we
# should actually move the taxon to achieve sane results,
# JS is giving us the desired position, which was awesome for previous setup,
# but now it's quite complicated to find where we should put it as we have
# to differenciate between moving to the same branch, up down and into
# first position.
new_siblings = new_parent.children
if new_position <= 0 && new_siblings.empty?
@taxon.move_to_child_of(new_parent)
elsif new_parent.id != @taxon.parent_id
if new_position.zero?
@taxon.move_to_left_of(new_siblings.first)
else
@taxon.move_to_right_of(new_siblings[new_position - 1])
end
elsif new_position < new_siblings.index(@taxon)
@taxon.move_to_left_of(new_siblings[new_position]) # we move up
else
@taxon.move_to_right_of(new_siblings[new_position - 1]) # we move down
end
# Reset legacy position, if any extensions still rely on it
new_parent.children.reload.each{ |t| t.update_column(:position, t.position) }
if parent_id
@taxon.reload
@taxon.set_permalink
@taxon.save!
@update_children = true
end
end
if params.key? "permalink_part"
parent_permalink = @taxon.permalink.split("/")[0...-1].join("/")
parent_permalink += "/" if parent_permalink.present?
params[:taxon][:permalink] = parent_permalink + params[:permalink_part]
end
# check if we need to rename child taxons if parent name or permalink changes
if params[:taxon][:name] != @taxon.name || params[:taxon][:permalink] != @taxon.permalink
@update_children = true
end
if @taxon.update_attributes(params[:taxon])
flash[:success] = flash_message_for(@taxon, :successfully_updated)
end
# rename child taxons
if @update_children
@taxon.descendants.each do |taxon|
taxon.reload
taxon.set_permalink
taxon.save!
end
end
respond_with(@taxon) do |format|
format.html { redirect_to edit_admin_taxonomy_url(@taxonomy) }
format.json { render json: @taxon.to_json }
end
end
def destroy
@taxon = Taxon.find(params[:id])
@taxon.destroy
respond_with(@taxon) { |format| format.json { render json: '' } }
end
end
end
end

View File

@@ -46,21 +46,26 @@ module Spree
@user.spree_roles = roles.reject(&:blank?).collect{ |r| Spree::Role.find(r) }
end
flash.now[:success] = Spree.t(:account_updated)
message = if new_email_unconfirmed?
Spree.t(:email_updated)
else
Spree.t(:account_updated)
end
flash.now[:success] = message
end
render :edit
end
def generate_api_key
if @user.generate_spree_api_key!
flash[:success] = Spree.t('api.key_generated')
flash[:success] = t('spree.api.key_generated')
end
redirect_to edit_admin_user_path(@user)
end
def clear_api_key
if @user.clear_spree_api_key!
flash[:success] = Spree.t('api.key_cleared')
flash[:success] = t('spree.api.key_cleared')
end
redirect_to edit_admin_user_path(@user)
end
@@ -69,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.
@@ -120,12 +126,17 @@ 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
def load_roles
@roles = Spree::Role.scoped
end
def new_email_unconfirmed?
params[:user][:email] != @user.email
end
end
end
end

View File

@@ -0,0 +1,26 @@
module Spree
module Admin
class ZonesController < ResourceController
before_filter :load_data, except: [:index]
def new
@zone.zone_members.build
end
protected
def collection
params[:q] ||= {}
params[:q][:s] ||= "ascend_by_name"
@search = super.ransack(params[:q])
@zones = @search.result.page(params[:page]).per(Spree::Config[:orders_per_page])
end
def load_data
@countries = Country.order(:name)
@states = State.order(:name)
@zones = Zone.order(:name)
end
end
end
end

View File

@@ -1,130 +0,0 @@
require_dependency 'spree/api/controller_setup'
module Spree
module Api
class BaseController < ActionController::Metal
include Spree::Api::ControllerSetup
include Spree::Core::ControllerHelpers::SSL
include ::ActionController::Head
self.responder = Spree::Api::Responders::AppResponder
respond_to :json
attr_accessor :current_api_user
before_filter :set_content_type
before_filter :check_for_user_or_api_key, :if => :requires_authentication?
before_filter :authenticate_user
after_filter :set_jsonp_format
rescue_from Exception, :with => :error_during_processing
rescue_from CanCan::AccessDenied, :with => :unauthorized
rescue_from ActiveRecord::RecordNotFound, :with => :not_found
helper Spree::Api::ApiHelpers
ssl_allowed
def set_jsonp_format
if params[:callback] && request.get?
self.response_body = "#{params[:callback]}(#{response_body})"
headers["Content-Type"] = 'application/javascript'
end
end
def map_nested_attributes_keys(klass, attributes)
nested_keys = klass.nested_attributes_options.keys
attributes.inject({}) do |h, (k, v)|
key = nested_keys.include?(k.to_sym) ? "#{k}_attributes" : k
h[key] = v
h
end.with_indifferent_access
end
private
def set_content_type
content_type = case params[:format]
when "json"
"application/json"
when "xml"
"text/xml"
end
headers["Content-Type"] = content_type
end
def check_for_user_or_api_key
# User is already authenticated with Spree, make request this way instead.
return true if @current_api_user = try_spree_current_user ||
!requires_authentication?
return if api_key.present?
render("spree/api/errors/must_specify_api_key", status: :unauthorized) && return
end
def authenticate_user
return if @current_api_user
if requires_authentication? || api_key.present?
unless @current_api_user = Spree.user_class.find_by_spree_api_key(api_key.to_s)
render("spree/api/errors/invalid_api_key", status: :unauthorized) && return
end
else
# An anonymous user
@current_api_user = Spree.user_class.new
end
end
def unauthorized
render("spree/api/errors/unauthorized", status: :unauthorized) && return
end
def error_during_processing(exception)
render(text: { exception: exception.message }.to_json,
status: :unprocessable_entity) && return
end
def requires_authentication?
true
end
def not_found
render("spree/api/errors/not_found", status: :not_found) && return
end
def current_ability
Spree::Ability.new(current_api_user)
end
def invalid_resource!(resource)
@resource = resource
render "spree/api/errors/invalid_resource", status: :unprocessable_entity
end
def api_key
request.headers["X-Spree-Token"] || params[:token]
end
helper_method :api_key
def find_product(id)
product_scope.find_by_permalink!(id.to_s)
rescue ActiveRecord::RecordNotFound
product_scope.find(id)
end
def product_scope
if current_api_user.has_spree_role?("admin")
scope = Product
if params[:show_deleted]
scope = scope.with_deleted
end
else
scope = Product.active
end
scope.includes(:master)
end
end
end
end

View File

@@ -1,108 +0,0 @@
require 'open_food_network/scope_variant_to_hub'
module Spree
module Api
class ShipmentsController < Spree::Api::BaseController
respond_to :json
before_filter :find_order
before_filter :find_and_update_shipment, only: [:ship, :ready, :add, :remove]
def create
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@shipment = get_or_create_shipment(params[:stock_location_id])
@order.contents.add(variant, quantity, nil, @shipment)
@shipment.refresh_rates
@shipment.save!
respond_with(@shipment.reload, default_template: :show)
end
def update
authorize! :read, Shipment
@shipment = @order.shipments.find_by_number!(params[:id])
params[:shipment] ||= []
unlock = params[:shipment].delete(:unlock)
if unlock == 'yes'
@shipment.adjustment.open
end
@shipment.update_attributes(params[:shipment])
if unlock == 'yes'
@shipment.adjustment.close
end
@shipment.reload
respond_with(@shipment, default_template: :show)
end
def ready
authorize! :read, Shipment
unless @shipment.ready?
if @shipment.can_ready?
@shipment.ready!
else
render "spree/api/shipments/cannot_ready_shipment", status: :unprocessable_entity
return
end
end
respond_with(@shipment, default_template: :show)
end
def ship
authorize! :read, Shipment
unless @shipment.shipped?
@shipment.ship!
end
respond_with(@shipment, default_template: :show)
end
def add
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@order.contents.add(variant, quantity, nil, @shipment)
respond_with(@shipment, default_template: :show)
end
def remove
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@order.contents.remove(variant, quantity, @shipment)
@shipment.reload if @shipment.persisted?
respond_with(@shipment, default_template: :show)
end
private
def find_order
@order = Spree::Order.find_by_number!(params[:order_id])
authorize! :read, @order
end
def find_and_update_shipment
@shipment = @order.shipments.find_by_number!(params[:id])
@shipment.update_attributes(params[:shipment])
@shipment.reload
end
def scoped_variant(variant_id)
variant = Spree::Variant.find(variant_id)
OpenFoodNetwork::ScopeVariantToHub.new(@order.distributor).scope(variant)
variant
end
def get_or_create_shipment(stock_location_id)
@order.shipment || @order.shipments.create(stock_location_id: stock_location_id)
end
end
end
end

View File

@@ -1,75 +0,0 @@
module Spree
module Api
class TaxonsController < Spree::Api::BaseController
respond_to :json
def index
if taxonomy
@taxons = taxonomy.root.children
else
if params[:ids]
@taxons = Taxon.where(id: params[:ids].split(","))
else
@taxons = Taxon.ransack(params[:q]).result
end
end
respond_with(@taxons)
end
def show
@taxon = taxon
respond_with(@taxon)
end
def jstree
show
end
def create
authorize! :create, Taxon
@taxon = Taxon.new(params[:taxon])
@taxon.taxonomy_id = params[:taxonomy_id]
taxonomy = Taxonomy.find_by_id(params[:taxonomy_id])
if taxonomy.nil?
@taxon.errors[:taxonomy_id] = I18n.t(:invalid_taxonomy_id, scope: 'spree.api')
invalid_resource!(@taxon) && return
end
@taxon.parent_id = taxonomy.root.id unless params[:taxon][:parent_id]
if @taxon.save
respond_with(@taxon, status: 201, default_template: :show)
else
invalid_resource!(@taxon)
end
end
def update
authorize! :update, Taxon
if taxon.update_attributes(params[:taxon])
respond_with(taxon, status: 200, default_template: :show)
else
invalid_resource!(taxon)
end
end
def destroy
authorize! :delete, Taxon
taxon.destroy
respond_with(taxon, status: 204)
end
private
def taxonomy
return if params[:taxonomy_id].blank?
@taxonomy ||= Taxonomy.find(params[:taxonomy_id])
end
def taxon
@taxon ||= taxonomy.taxons.find(params[:id])
end
end
end
end

View File

@@ -1,7 +0,0 @@
module Spree
module Api
class UsersController < Spree::Api::BaseController
respond_to :json
end
end
end

View File

@@ -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

View File

@@ -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],

View File

@@ -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

View File

@@ -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

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