Compare commits

...

423 Commits

Author SHA1 Message Date
Maikel Linke
ccc96c8725 Update translations from Transifex 2021-06-15 15:33:46 +10:00
Maikel Linke
4faf76794d Update translations from Transifex 2021-06-11 09:44:47 +10:00
Maikel
56570ec604 Merge pull request #7755 from openfoodfoundation/transifex
Transifex
2021-06-11 09:41:22 +10:00
Andy Brett
4047f135f7 Merge pull request #7747 from openfoodfoundation/dependabot/bundler/pdf-reader-2.5.0
Bump pdf-reader from 2.4.2 to 2.5.0
2021-06-10 14:49:35 -07:00
Matt-Yorkley
690cbe3ad3 Merge pull request #7468 from mkllnk/6328-tos-tracking
6328 tos tracking
2021-06-10 19:48:13 +02:00
Matt-Yorkley
04e76ed506 Merge pull request #7776 from openfoodfoundation/dependabot/npm_and_yarn/ssri-6.0.2
Bump ssri from 6.0.1 to 6.0.2
2021-06-10 19:45:00 +02:00
Andy Brett
d22f807084 Merge pull request #7773 from Matt-Yorkley/rspec-retries
Set Capybara retry count to 3 and remove conditional
2021-06-10 09:52:50 -07:00
Andy Brett
75440856af Merge pull request #7770 from openfoodfoundation/dependabot/bundler/rubocop-1.16.1
Bump rubocop from 1.16.0 to 1.16.1
2021-06-10 09:51:35 -07:00
dependabot[bot]
c614b92c5f Bump ssri from 6.0.1 to 6.0.2
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2.
- [Release notes](https://github.com/npm/ssri/releases)
- [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md)
- [Commits](https://github.com/npm/ssri/compare/v6.0.1...v6.0.2)

---
updated-dependencies:
- dependency-name: ssri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-10 16:51:16 +00:00
Andy Brett
84e3db30f1 Merge pull request #7772 from openfoodfoundation/dependabot/bundler/view_component-2.34.0
Bump view_component from 2.33.0 to 2.34.0
2021-06-10 09:50:42 -07:00
Matt-Yorkley
50b5fc7545 Set Capybara retry count to 3 and remove conditional
This is a slippery slope and there's perfectly reasonable arguments against doing this, but on a practical level I think retrying the occasional flaky spec (and adding an extra 10 seconds or so on to the build time) is categorically better than failing the build and having to restart the whole thing (potentially multiple times).
2021-06-10 11:39:05 +01:00
Matt-Yorkley
f36c01abf6 Merge pull request #7765 from mkllnk/7764-heartbeat-job
Avoid false alarms due to delayed HeartbeatJob
2021-06-10 11:15:42 +02:00
dependabot[bot]
d259771ce9 Bump view_component from 2.33.0 to 2.34.0
Bumps [view_component](https://github.com/github/view_component) from 2.33.0 to 2.34.0.
- [Release notes](https://github.com/github/view_component/releases)
- [Changelog](https://github.com/github/view_component/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/view_component/compare/v2.33.0...v2.34.0)

---
updated-dependencies:
- dependency-name: view_component
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-10 05:11:51 +00:00
dependabot[bot]
9fd0b096bd Bump rubocop from 1.16.0 to 1.16.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.16.0 to 1.16.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.16.0...v1.16.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-10 05:07:28 +00:00
Transifex-Openfoodnetwork
1bbc765028 Updating translations for config/locales/ru.yml 2021-06-10 05:21:49 +10:00
Transifex-Openfoodnetwork
a232722f64 Updating translations for config/locales/ru.yml 2021-06-10 05:18:45 +10:00
Andy Brett
2c1ffa929c Merge pull request #7766 from mkllnk/schema
Update schema file description
2021-06-09 08:45:06 -07:00
Andy Brett
2b66d270c0 Merge pull request #7704 from coopdevs/drop-master-variant-leftovers
Drop product.price from /api/order_cycles/:id/products
2021-06-09 08:20:44 -07:00
Transifex-Openfoodnetwork
0e19232f45 Updating translations for config/locales/ca.yml 2021-06-09 17:22:50 +10:00
Transifex-Openfoodnetwork
f4d9e8e520 Updating translations for config/locales/es.yml 2021-06-09 17:22:39 +10:00
Transifex-Openfoodnetwork
d0041334fa Updating translations for config/locales/en_FR.yml 2021-06-09 16:42:33 +10:00
Transifex-Openfoodnetwork
3b68d8a94e Updating translations for config/locales/fr.yml 2021-06-09 16:41:46 +10:00
Maikel Linke
fc8e22b82e Update schema file description
I ran `rake db:migrate` and Rails updated this section. Let's use or we
have to constantly checkout the schema after migrations or we'll have
unrelated changes in future pull requests.
2021-06-09 16:02:05 +10:00
Maikel
6caae9e886 Merge pull request #7694 from coopdevs/split-confirm-order-job
Split ConfirmOrderJob to avoid blocking DJ worker
2021-06-09 14:11:10 +10:00
Andy Brett
d145d3a8ec add create/delete specs for admin and non-admin users 2021-06-09 14:06:55 +10:00
Andy Brett
d4e9c0afdc spec TOS service object 2021-06-09 14:06:55 +10:00
Andy Brett
e0cdf4ff49 refactor to TOS service 2021-06-09 14:06:54 +10:00
Andy Brett
a4bb697787 add spec for trying to create TOS with no file 2021-06-09 14:06:54 +10:00
Maikel Linke
3e2f81d640 Add helper to view spec needing it 2021-06-09 14:06:54 +10:00
Andy Brett
768c56400c add TOS helper to application_controller.rb 2021-06-09 14:06:54 +10:00
Maikel Linke
af314cbbdf Allow fast checkout without re-accepting old terms
We did that for the shop's terms already and now do it for the platform
terms as well.
2021-06-09 14:06:54 +10:00
Maikel Linke
17a3d23d68 Handle user clicking upload button early 2021-06-09 14:06:54 +10:00
Maikel Linke
e3be519b25 Style TOS page to be usable
It's not pretty but only used by instance managers, very rarely.
2021-06-09 14:06:54 +10:00
Maikel Linke
51ad8f8065 Remove old UI to edit Terms of service
It's now completely replaced by file uploads on a separate page.
2021-06-09 14:06:54 +10:00
Maikel Linke
960b829ece Link to last uploaded Terms of service 2021-06-09 14:06:54 +10:00
Maikel Linke
23999c96bf Unify all links to platform Terms of service
DRY code and have more consistency. We always use "Terms of service" now
and not "Terms of Service" or "Terms and conditions". The latter is used
for the shop's terms, not the platform terms.
2021-06-09 14:06:54 +10:00
Maikel Linke
3b3ba70670 Safeguard deletion of ToS with alert 2021-06-09 14:06:54 +10:00
Maikel Linke
690118c2bd Add delete method to terms of service files 2021-06-09 14:06:54 +10:00
Maikel Linke
3bee9cb951 Add Rails action #new to ToS 2021-06-09 14:06:54 +10:00
Maikel Linke
abe76ccf0f Add upload of Terms of Service files
Admins can upload files and view the most recent (current) one.
2021-06-09 14:06:54 +10:00
Maikel Linke
ed4f61acd7 Add title to TOS config page 2021-06-09 14:06:53 +10:00
Maikel Linke
007b8cd888 Add new admin page for TOS files
Just the basic Rails setup without any functionality yet.
2021-06-09 14:06:53 +10:00
Maikel Linke
1f63bb15eb Remove executable bit from spec 2021-06-09 14:06:53 +10:00
Maikel Linke
9027f8b604 Add attachment to TOS record 2021-06-09 14:06:53 +10:00
Maikel Linke
c4317c5707 Add model TermsOfServiceFile
We want to enable instance managers to upload TOS files.

I also added the rails_helper which is a new convention. It can contain
more Rails specific configuration we currently have in the spec_helper.
2021-06-09 14:06:09 +10:00
Maikel Linke
a0835eae54 Avoid false alarms due to delayed HeartbeatJob
When Sidekiq was restarted, the scheduler's time was reset and jobs were
executed later. Now we trigger the HeartbeatJob straight after a Sidekiq
boot and we shouldn't see any false alarms in our monitoring.
2021-06-09 12:05:18 +10:00
Maikel
2556921110 Merge pull request #7718 from openfoodfoundation/dependabot/bundler/sidekiq-scheduler-3.1.0
Bump sidekiq-scheduler from 3.0.1 to 3.1.0
2021-06-09 12:03:31 +10:00
Andy Brett
fcbe42f080 Merge pull request #7756 from openfoodfoundation/dependabot/bundler/ddtrace-0.50.0
Bump ddtrace from 0.49.0 to 0.50.0
2021-06-08 14:59:22 -07:00
Andy Brett
b6f6407c31 Merge pull request #7660 from jibees/7499-remove-feature-toggle-for-unit-price
Remove feature toggle around unit_price
2021-06-08 10:39:32 -07:00
Andy Brett
82ec04552c Merge pull request #7693 from andrewpbrett/add-password-translation
Add translation keys for password messages
2021-06-08 10:35:41 -07:00
Andy Brett
fe62a0a2a7 Merge pull request #7697 from jibees/7689-trigger-a-change-when-hour/minute-inputs-are-modified
Datetimepicker for order cycles: add keyup event listener on hour/minute inputs
2021-06-08 10:32:07 -07:00
Andy Brett
ba6ebdee15 Merge pull request #7686 from shen-sat/7470-add-delete-action-test-to-shipping-categories-controller-spec
[7470] Add delete action test to ShippingCategoriesController spec
2021-06-08 10:31:26 -07:00
Andy Brett
ede966f2d1 Merge pull request #7640 from apricot12/closed_OC_bheaviour
Checkout made to redirect to shop front when OC closed
2021-06-08 10:30:13 -07:00
Andy Brett
74d93e324c Merge pull request #7661 from romale/products_import_date_translation
Missed import_date translation key
2021-06-08 10:26:13 -07:00
Andy Brett
37b3f7aa3f Merge pull request #7743 from openfoodfoundation/dependabot/bundler/test-unit-3.4.4
Bump test-unit from 3.4.2 to 3.4.4
2021-06-08 10:05:01 -07:00
Matt-Yorkley
9921e9c72b Merge pull request #7754 from Matt-Yorkley/stripe-issues
Stripe 3DS issues
2021-06-08 11:33:54 +02:00
dependabot[bot]
6edb80ea29 Bump ddtrace from 0.49.0 to 0.50.0
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 0.49.0 to 0.50.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.49.0...v0.50.0)

---
updated-dependencies:
- dependency-name: ddtrace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-08 05:10:49 +00:00
Matt-Yorkley
15b386bce3 Set :execute_threed option to explicitly handle 3DS responses 2021-06-07 22:48:54 +01:00
Transifex-Openfoodnetwork
225edbf745 Updating translations for config/locales/fr_CA.yml 2021-06-08 07:13:36 +10:00
Transifex-Openfoodnetwork
e8fb5d39a1 Updating translations for config/locales/en_CA.yml 2021-06-08 06:39:23 +10:00
Matt-Yorkley
3544b7de7a Remove Stripe Decorator
The method being overridden here is the same in the upstream
2021-06-07 20:44:58 +01:00
Jean-Baptiste Bellet
e3f56556cf Remove feature toggle around unit_price and enable it 2021-06-07 20:53:45 +02:00
Matt-Yorkley
8e0a84a502 Merge pull request #7729 from Matt-Yorkley/delayed-cleanup
Delayed::Cleanup
2021-06-07 19:11:37 +02:00
dependabot[bot]
90f1e3a80d Bump pdf-reader from 2.4.2 to 2.5.0
Bumps [pdf-reader](https://github.com/yob/pdf-reader) from 2.4.2 to 2.5.0.
- [Release notes](https://github.com/yob/pdf-reader/releases)
- [Changelog](https://github.com/yob/pdf-reader/blob/main/CHANGELOG)
- [Commits](https://github.com/yob/pdf-reader/compare/v2.4.2...v2.5.0)

---
updated-dependencies:
- dependency-name: pdf-reader
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-07 05:42:29 +00:00
Matt-Yorkley
82e38b0156 Merge pull request #7623 from Matt-Yorkley/order-contents
Use OrderContents to update line items
2021-06-05 17:11:45 +02:00
Andy Brett
640aa11f3b Merge pull request #7744 from luisramos0/byebug
Move byebug to test gem group so we can use it in specs
2021-06-04 13:17:43 -07:00
Luis Ramos
b939a292df Move byebug to test gem group so we can use it in specs 2021-06-04 20:59:50 +01:00
Matt-Yorkley
099ef5d358 Add more explicit tests on updating shipping fees in Api::ShipmentsController 2021-06-04 18:19:27 +01:00
dependabot[bot]
6de0682439 Bump test-unit from 3.4.2 to 3.4.4
Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.4.2 to 3.4.4.
- [Release notes](https://github.com/test-unit/test-unit/releases)
- [Commits](https://github.com/test-unit/test-unit/compare/3.4.2...3.4.4)

---
updated-dependencies:
- dependency-name: test-unit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-04 16:57:41 +00:00
Matt-Yorkley
efcf71fd2b Use OrderContents in cart spec test setups 2021-06-04 17:26:49 +01:00
Matt-Yorkley
acf7c0c4d8 Use :order_with_totals factory in CustomersController spec 2021-06-04 17:10:50 +01:00
Matt-Yorkley
443b180f32 Update order totals in :order_with_totals factory 2021-06-04 17:10:50 +01:00
Matt-Yorkley
3222d4980d Improve comment on #ensure_updated_shipments 2021-06-04 17:10:50 +01:00
Matt-Yorkley
e246eed99d Move #restart_chceckout_flow out of Order class 2021-06-04 17:10:50 +01:00
Matt-Yorkley
b69d61dd77 Remove #order_update! call from method used in order after_save callbacks
This method gets called twice every time we save a completed order, calling order_update! twice...
2021-06-04 17:10:50 +01:00
Matt-Yorkley
2d76c2730a Update shipment updating 2021-06-04 17:10:50 +01:00
Matt-Yorkley
6b364dc420 Update specs on shipping fee changes and mark as pending
The shipping fee and it's tax actually don't get updated correctly here (in master).
2021-06-04 17:10:50 +01:00
Matt-Yorkley
d5b20d5446 Add specs for Order#ensure_updated_shipments 2021-06-04 17:10:50 +01:00
Matt-Yorkley
05c001807e Add variant override specs for Stock::AvailabilityValidator 2021-06-04 17:10:50 +01:00
Matt-Yorkley
011da05712 Add more test coverage to OrderContents 2021-06-04 17:10:50 +01:00
Matt-Yorkley
2e96982e60 Refactor conditional
CartService#populate already returns the value of the #valid? method by default.
2021-06-04 17:10:50 +01:00
Matt-Yorkley
6abe0b375c Refactor stock levels check in CartController 2021-06-04 17:10:50 +01:00
Matt-Yorkley
dc6be6f06b Don't resubmit the whole cart contents for no reason.
There's a couple of places where this was causing a cart update submission where it wasn't needed, eg the items had not actually changed. The conditional here was designed to stop that from happening, but it was actually passing every time (the conditional logic was not actually catching the case it was supposed to).

This is really expensive!
2021-06-04 17:10:50 +01:00
Matt-Yorkley
47e2976fd1 Update CartService specs 2021-06-04 17:10:50 +01:00
Matt-Yorkley
38ce9eb0c4 Update line item removal in CartService when the line item doesn't exist 2021-06-04 17:10:50 +01:00
Matt-Yorkley
3b52b173e8 Delete more dead code in CartService 2021-06-04 17:10:50 +01:00
Matt-Yorkley
b8ccee5f30 Simplify use of #to_i in variant data hash 2021-06-04 17:10:50 +01:00
Matt-Yorkley
0cfe7fdc45 Move required logic into OrderContents and improve spec 2021-06-04 17:10:50 +01:00
Matt-Yorkley
42ff2307fa Update specs that use removed #add_variant and #remove_variant methods in test setup 2021-06-04 17:10:50 +01:00
Matt-Yorkley
b25e7fcb89 Delete tests for removed Order #add_variant and #remove_variant methods 2021-06-04 17:10:50 +01:00
Matt-Yorkley
79aebed40e Bring OrderContents#update_cart tests from upstream and tidy up 2021-06-04 17:10:50 +01:00
Matt-Yorkley
f5c08baabb Use OrderContents in LineItemsController and move enterprise fee updating logic 2021-06-04 17:10:50 +01:00
Matt-Yorkley
a883b2cf63 Remove dead code CartService#cart_remove 2021-06-04 17:10:50 +01:00
Matt-Yorkley
398d4b2612 Tidy up public interface of CartService
We don't need this extra hash to be passed around
2021-06-04 17:10:50 +01:00
Matt-Yorkley
4a7c0e8297 Remove variant early if we're deleting them and they're already loaded 2021-06-04 17:10:50 +01:00
Matt-Yorkley
67df6728f6 Fix Order line items association definition
Populating the cart was throwing an "Association Mismatch" error D:
2021-06-04 17:10:50 +01:00
Matt-Yorkley
0178cd7530 Adapt OrderContents to allow use with frontend cart service and updating :max_quantity
The cart service and it's surrounding logic is a bit messy, as it jumps through hoops to add extra logic for the :max_quantity attribute used with the "group buy" feature.

This is the last bit of code where an order's line items could be changed where we were not using OrderContents.
2021-06-04 17:10:50 +01:00
Matt-Yorkley
cb92231835 Clarify behavior via variable names
This is a small semantic thing to clarify that we're not adding to / incrementing the quantity here, we're setting it to the given value. In other places where we change line items on an order we are actually adding the given value to the existing quantity.
2021-06-04 17:10:50 +01:00
Matt-Yorkley
6e8fd3c3f8 Simplify CartService interface
There's only one place this method is called, and the "overwrite" argument is always explicitly true. It doesn't need to be there if it's mandatory.
2021-06-04 17:10:50 +01:00
Matt-Yorkley
6451ef173c Use OrderContents when removing line items with soft-deleted variants in CartService 2021-06-04 17:10:50 +01:00
Matt-Yorkley
7af5e8931f Adapt OrderContents for use with BulkLineItemsController#update 2021-06-04 17:10:50 +01:00
Matt-Yorkley
9045cc7d65 Use OrderContents in CartService for removing line items from cart 2021-06-04 17:10:50 +01:00
Matt-Yorkley
5ff8436c1a Adapt OrderContents#remove to allow deleting line item without passing a quantity 2021-06-04 17:10:50 +01:00
Matt-Yorkley
a5ccaf9595 Remove unnecessary code in BulkLineItemsController
This method isn't called from anywhere else
2021-06-04 17:10:50 +01:00
Matt-Yorkley
423c140670 Remove pointless currency code in Order and CartService
The currency will always be the currency of the variant, there's no need to pass this value around.
2021-06-04 17:10:50 +01:00
Matt-Yorkley
e8ef183623 Delete dead code Order#set_variant_attributes 2021-06-04 17:10:50 +01:00
Matt-Yorkley
000e2c07f8 Use OrderContents in OrdersController 2021-06-04 17:10:50 +01:00
Matt-Yorkley
c1c69b00b4 Update order explicitly in OrderSyncer 2021-06-04 17:10:50 +01:00
Matt-Yorkley
d5edf03042 Update reports_spec test setup 2021-06-04 17:10:50 +01:00
Matt-Yorkley
305ac037fe Use OrderContents in customers controller spec 2021-06-04 17:10:50 +01:00
Matt-Yorkley
23910dbab4 Use OrderContents in BulkLineItemsController
We should move towards *all* operations on an order's line items being done exclusively through this service.
2021-06-04 17:10:50 +01:00
Matt-Yorkley
632f4228f0 Bring in line item fetching refactor 2021-06-04 17:10:50 +01:00
Matt-Yorkley
1268cb565c Extract method 2021-06-04 17:10:50 +01:00
Matt-Yorkley
c55e47f6af Remove superfluous updates in OrderFeesHandler 2021-06-04 17:10:50 +01:00
Matt-Yorkley
03fc63ad14 Remove #order_update! from line item after_save callback 2021-06-04 17:10:50 +01:00
Matt-Yorkley
a124141537 Move Shipment#line_items to private 2021-06-04 17:10:50 +01:00
Matt-Yorkley
0fabb5bc2f Don't pluck variant_ids multiple times (once for each line item) 2021-06-04 17:10:50 +01:00
Matt-Yorkley
1fff81c214 Remove call to OrderInventory#verify
This already gets called in after_save and after_destroy in Spree::LineItem.
2021-06-04 17:10:50 +01:00
Matt-Yorkley
67264c047f Delete dead code #editable_by?
This is junk Spree code from 2010. 11 years old! The method that previous called this was removed long ago...
2021-06-04 17:10:50 +01:00
Matt-Yorkley
34eaf6f0f2 DRY shipment updating 2021-06-04 17:10:50 +01:00
Matt-Yorkley
8405a7672d Bring in shipment updating 2021-06-04 17:10:50 +01:00
Matt-Yorkley
66a3246a23 Move order updating 2021-06-04 17:10:50 +01:00
Matt-Yorkley
34482f6710 Bring OrderContents#update_cart from Spree 2.2 2021-06-04 17:10:50 +01:00
Matt-Yorkley
f550d1e9f3 Bring Order#ensure_updated_shipments from Spree 2.2 2021-06-04 17:10:50 +01:00
Matt-Yorkley
d99e598e7a Delete dead code in CartController
The two conditionals in #populate_variant_attributes here are never actually true, so the subsequent code paths are never reached.
2021-06-04 17:10:50 +01:00
Matt-Yorkley
eb59b691d8 Move hash parsing outside of order lock 2021-06-04 17:10:50 +01:00
Matt-Yorkley
d5d76d9b9a Move private controller methods to private 2021-06-04 17:10:50 +01:00
Andy Brett
3c933befbb Merge pull request #7607 from luisramos0/rails6_select2_upgrade
[Rails 6.1] Upgrade thor
2021-06-04 07:45:47 -07:00
Andy Brett
fc4a40ec8b Merge pull request #7668 from openfoodfoundation/dependabot/bundler/stripe-5.33.0
Bump stripe from 5.32.1 to 5.33.0
2021-06-04 07:45:02 -07:00
Andy Brett
d197b81351 Merge pull request #7606 from luisramos0/deprecation
[Rails 6.1] Fix deprecation warning in rails 6.0
2021-06-04 07:42:50 -07:00
Andy Brett
b1f619a90a Merge pull request #7715 from openfoodfoundation/dependabot/bundler/activemerchant-1.120.0
Bump activemerchant from 1.119.0 to 1.120.0
2021-06-04 07:40:24 -07:00
Andy Brett
f70c1f0644 Merge pull request #7611 from luisramos0/rails61_arel
[Rails 6.1] Adapt code to circunvent security constraint on rails 6.1
2021-06-04 07:36:23 -07:00
Andy Brett
b23530be4c Merge pull request #7736 from Matt-Yorkley/ssl-in-dev
Remove Spree::Config[:allow_ssl_in_development_and_test]
2021-06-04 07:21:05 -07:00
dependabot[bot]
1fe74c9690 Bump activemerchant from 1.119.0 to 1.120.0
Bumps [activemerchant](https://github.com/activemerchant/active_merchant) from 1.119.0 to 1.120.0.
- [Release notes](https://github.com/activemerchant/active_merchant/releases)
- [Changelog](https://github.com/activemerchant/active_merchant/blob/master/CHANGELOG)
- [Commits](https://github.com/activemerchant/active_merchant/compare/v1.119.0...v1.120.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-04 14:20:09 +00:00
Andy Brett
5d39155519 Merge pull request #7739 from openfoodfoundation/dependabot/bundler/rails-6.0.3.7
Bump rails from 6.0.3.6 to 6.0.3.7
2021-06-04 07:18:59 -07:00
Pau Perez
dfe83e5c51 Do not return master variant in api/ocs/products
`product.master` seems to always be `null` on
/api/v0/order_cycles/:id/products JSON response. That's because the
first of the underlying AR relation,
`order_cycle.variants_distributed_by(distributor)`, does not include
master variants. They are not in OC exchanges.
2021-06-04 12:10:52 +02:00
Pau Perez
e7166ba5d4 Drop product.price from /api/ocs/:id/products
Its serializer it's only used by this endpoint and
app/assets/javascripts/templates/shop_variant.html.haml doesn't rely on
the response's product.price but the variant's price.

Because our DB schema allows NULL on spree_prices.amount, a master
variant without a price can cause the shopfront not to load products.
This was the case in
https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/60adfcc31cf9740007f82fc9.
2021-06-04 12:10:52 +02:00
dependabot[bot]
b6c9d4d6a9 Bump rails from 6.0.3.6 to 6.0.3.7
Bumps [rails](https://github.com/rails/rails) from 6.0.3.6 to 6.0.3.7.
- [Release notes](https://github.com/rails/rails/releases)
- [Commits](https://github.com/rails/rails/compare/v6.0.3.6...v6.0.3.7)

---
updated-dependencies:
- dependency-name: rails
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-04 05:30:32 +00:00
Maikel
0c92a594f4 Merge pull request #7717 from coopdevs/fix-docker-jemalloc-sidekiq
Fix docker Jemalloc + Sidekiq setup
2021-06-04 13:16:53 +10:00
Maikel
4dacdb180f Merge pull request #7617 from luisramos0/layout61
[Rails 6.1] Make admin layout path relative
2021-06-04 12:26:40 +10:00
Andy Brett
c1ad4243bb Update all locales with the latest Transifex translations 2021-06-03 18:21:21 -07:00
Luis Ramos
66934af579 Upgrade to thor v1 2021-06-03 20:54:55 +01:00
Andy Brett
9f3ddfc88b Merge pull request #7735 from Matt-Yorkley/bootsnap-reloaded
Add bootsnap gem (again)
2021-06-03 12:54:22 -07:00
Luis Ramos
466f7030c6 Depend on select2-rails without the thor v0.14 requirement 2021-06-03 20:54:07 +01:00
Matt-Yorkley
7d38bec26d Remove Spree::Config[:allow_ssl_in_development_and_test]
Unconditionally disables forced https-redirects in dev and test
2021-06-03 20:52:09 +01:00
Matt-Yorkley
67d7d225cc Add bootsnap gem 2021-06-03 19:03:18 +01:00
Andy Brett
24edad15ae Merge pull request #7727 from openfoodfoundation/dependabot/bundler/view_component-2.33.0
Bump view_component from 2.32.0 to 2.33.0
2021-06-03 09:57:36 -07:00
Andy Brett
6d56a0791f Merge pull request #7728 from Matt-Yorkley/papertrail-deprecation
Remove papertrail initializer
2021-06-03 09:52:56 -07:00
dependabot[bot]
cd1d77c572 Bump view_component from 2.32.0 to 2.33.0
Bumps [view_component](https://github.com/github/view_component) from 2.32.0 to 2.33.0.
- [Release notes](https://github.com/github/view_component/releases)
- [Changelog](https://github.com/github/view_component/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/view_component/compare/v2.32.0...v2.33.0)

---
updated-dependencies:
- dependency-name: view_component
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-03 16:43:45 +00:00
dependabot[bot]
69690f1e37 Bump stripe from 5.30.0 to 5.33.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 5.30.0 to 5.33.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v5.30.0...v5.33.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-03 16:43:38 +00:00
Andy Brett
2dddd625a1 Merge pull request #7554 from luisramos0/rails6
[Rails 6.0] Upgrade to rails 6.0
2021-06-03 09:42:33 -07:00
Matt-Yorkley
d66b6f7192 Fix InvoicesController spec and change from pending to active 2021-06-03 12:51:15 +01:00
Matt-Yorkley
ba592c1ca3 Switch JobLogger to using the default Rails logger
Logging in background jobs with Sidekiq all ultimately get sent to STDOUT now anyway, which is redirected to `/log/sidekiq.log` via the Sidekiq systemd service.
2021-06-03 12:48:18 +01:00
Matt-Yorkley
0ede0acc6a Remove DelayedJob references 2021-06-03 12:45:23 +01:00
Matt-Yorkley
5b676e8f93 Remove papertrail initializer
This setting is now deprecated and triggers this message:

Association Tracking for PaperTrail has been extracted to a separate gem. To use it, please add `paper_trail-association_tracking` to your Gemfile. If you don't use it (most people don't, that's the default) and you set `track_associations = false` somewhere (probably a rails initializer) you can remove that line now.
2021-06-03 11:33:33 +01:00
Pau Perez
5d91f5f398 Document Redis as a requirement 2021-06-03 10:11:05 +02:00
Pau Pérez Fabregat
62959cc883 Merge pull request #7724 from openfoodfoundation/transifex
Transifex
2021-06-03 09:34:51 +02:00
Andy Brett
bab4b404f4 Merge pull request #7722 from openfoodfoundation/dependabot/npm_and_yarn/karma-6.3.3
Bump karma from 6.3.2 to 6.3.3
2021-06-02 15:01:46 -07:00
Andy Brett
5ecd24d66a Merge pull request #7721 from openfoodfoundation/dependabot/bundler/rubocop-1.16.0
Bump rubocop from 1.15.0 to 1.16.0
2021-06-02 15:00:55 -07:00
Transifex-Openfoodnetwork
db373a826b Updating translations for config/locales/en_IE.yml 2021-06-03 02:38:20 +10:00
Shen
80ae211b72 Use correct syntax for change matcher in spec/controllers/spree/admin/shipping_categories_controller_spec.rb
Co-authored-by: Maikel <maikel@email.org.au>
2021-06-02 13:17:49 +01:00
Shen Sat
99a4be134b Add delete action test to ShippingCategoriesController spec 2021-06-02 13:17:49 +01:00
dependabot[bot]
1ddfd2a4f7 Bump karma from 6.3.2 to 6.3.3
Bumps [karma](https://github.com/karma-runner/karma) from 6.3.2 to 6.3.3.
- [Release notes](https://github.com/karma-runner/karma/releases)
- [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma/compare/v6.3.2...v6.3.3)

---
updated-dependencies:
- dependency-name: karma
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-02 05:32:51 +00:00
dependabot[bot]
d972f6e041 Bump rubocop from 1.15.0 to 1.16.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-02 05:12:04 +00:00
Luis Ramos
cf756c5774 Added action cable to gemfile by running bundle install
After rebase Action cable was missing from Gemfile.lock
2021-06-01 22:34:04 +01:00
Luis Ramos
4252bd0bb1 For some reason report helper is not available on this view now, so we call Spree::Money directly 2021-06-01 22:34:04 +01:00
Luis Ramos
cb6e626193 Remove require rails/all, this is already done in application.rb where we are loading only the rails modules we need 2021-06-01 22:34:04 +01:00
Andy Brett
77c384633b specify payment intent ID in stripe stub 2021-06-01 22:34:04 +01:00
Luis Ramos
64de303b59 Move compass-rails back to 4.0
This must have been a mistake when managing initial conflicts in rails6 branch
2021-06-01 22:34:04 +01:00
Matt-Yorkley
88cae21ab4 Disable currently unused modules and add notes
We should migrate to ActiveStorage soon, but we're not using it yet. ActionText is cool but we also don't currently use it. ActionMailbox is not something we need at all.
2021-06-01 22:34:04 +01:00
Matt-Yorkley
66e4986944 Bring modules list from rails/all to application.rb
This is the default list in Rails 6.0
2021-06-01 22:34:04 +01:00
Andy Brett
b3e08b47b9 set Stripe api key directly instead of using allow 2021-06-01 22:33:12 +01:00
Luis Ramos
85508f45b4 Replace be_success on test_reponse with status 200
In rails 6 response.success? is not supported.
2021-06-01 22:33:12 +01:00
Luis Ramos
f07cc32be0 Remove authorization token from stripe stubs 2021-06-01 22:33:12 +01:00
Luis Ramos
2c43522bf9 change devise config to use secret_key_Base instead of secret_token as pepper 2021-06-01 22:33:12 +01:00
Luis Ramos
adf35f8e18 Fix sass-rails compass-rails compatibility problem 2021-06-01 22:33:12 +01:00
Luis Ramos
04ff4fa47c Update to rails 6.0 and resolve Gemfile conflicts 2021-06-01 22:33:12 +01:00
Matt-Yorkley
0d30e3359f Merge pull request #7081 from openfoodfoundation/dependabot/bundler/database_cleaner-2.0.1
Bump database_cleaner from 1.99.0 to 2.0.1
2021-06-01 21:59:27 +02:00
Matt-Yorkley
b1bfac5144 Update all locales with the latest Transifex translations 2021-06-01 19:10:58 +01:00
Matt-Yorkley
30e2be13f0 Update spec/lib/open_food_network/i18n_config_spec.rb 2021-06-01 18:50:04 +01:00
Luis Ramos
dc1cdf4254 Add required DB cleaner setup code 2021-06-01 18:50:04 +01:00
dependabot[bot]
c4bd9208ce Bump database_cleaner from 1.99.0 to 2.0.1
Bumps [database_cleaner](https://github.com/DatabaseCleaner/database_cleaner) from 1.99.0 to 2.0.1.
- [Release notes](https://github.com/DatabaseCleaner/database_cleaner/releases)
- [Changelog](https://github.com/DatabaseCleaner/database_cleaner/blob/main/History.rdoc)
- [Commits](https://github.com/DatabaseCleaner/database_cleaner/compare/v1.99.0...v2.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-01 18:50:04 +01:00
Pau Pérez Fabregat
01f8aff3e0 Merge pull request #7716 from coopdevs/pick-up-site-name-from-env
Allow :site_name to be picked up from ENV vars
2021-06-01 13:50:36 +02:00
Jean-Baptiste Bellet
60f3ebca62 Check whether the changes made by the keyboard are taken into account in datetimepicker
- User can change minute directly with keyboard, and without closing the datetimepicker, the modification should be catch and then a label "You have unsaved changes" with the "Save changes" button should appear
2021-06-01 12:05:03 +02:00
Jean-Baptiste Bellet
0db7df6c14 Add keyup event listener on hour/minute inputs
- To set the date (and trigger the onChange event) when the user is typing through its keyboard
2021-06-01 12:04:55 +02:00
Pau Perez
74a8b3038a Split ConfirmOrderJob to avoid blocking a worker
This unties this two email notifications so that they are picked up by
a DJ worker independently. This should avoid the blocking the worker experiences (remember we
still have a single one in all instances) when waiting between the two
deliveries. See the flamegraph:
https://app.datadoghq.com/apm/traces?end=1622015605459&paused=true&query=env%3Aproduction%20service%3Adelayed_job%20operation_name%3Adelayed_job%20resource_name%3AConfirmOrderJob%20%40duration%3A%3E%3D5s&start=1622009898303&streamTraces=true&trace=AQAAAXmngbg_woqc_QAAAABBWG1uZ2IwVkFBRHVDbWJkN25QTUVuY28&traceID=2916038355421570548&spanID=2005781139590273685.

Overall, both operations may take longer but other jobs can be processed
in between. Also, if any of the two fails, the other won't be affected.
2021-06-01 11:43:00 +02:00
dependabot[bot]
de1d4fa4eb Bump sidekiq-scheduler from 3.0.1 to 3.1.0
Bumps [sidekiq-scheduler](https://github.com/moove-it/sidekiq-scheduler) from 3.0.1 to 3.1.0.
- [Release notes](https://github.com/moove-it/sidekiq-scheduler/releases)
- [Commits](https://github.com/moove-it/sidekiq-scheduler/compare/v3.0.1...v3.1.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-01 05:31:12 +00:00
Pau Perez
07fd5cb29c Configure Sidekiq in development also 2021-05-31 17:04:14 +02:00
Pau Perez
ee7da14019 Provide Redis docker container 2021-05-31 17:04:14 +02:00
Pau Perez
e5adbf1f08 Fix jemalloc installation 2021-05-31 16:54:35 +02:00
Matt-Yorkley
7f9179193e Merge pull request #7713 from openfoodfoundation/dependabot/npm_and_yarn/ws-7.4.6
Bump ws from 7.4.4 to 7.4.6
2021-05-31 16:07:05 +02:00
Pau Perez
3be0e1c13a Allow :site_name to be picked up from ENV vars
This mimics what we did in 6377736f4. This way provisioning an instance
from scratch doesn't require configuring things from the backoffice,
which will simplify the roll out of
https://github.com/openfoodfoundation/ofn-install/pull/734.
2021-05-31 15:50:54 +02:00
Pau Pérez Fabregat
18c020535a Merge pull request #7711 from Matt-Yorkley/sidekiq
Sidekiq!
2021-05-31 15:11:45 +02:00
Matt-Yorkley
8d1fcc06fd Remove logfile config
This setting was removed in Sidekiq 6.0, logs are handled a bit differently now. The logging works though 👍
2021-05-31 10:46:43 +01:00
Matt-Yorkley
2b6a72ffb4 Remove DelayedJob web UI 2021-05-31 10:10:36 +01:00
Pau Pérez Fabregat
157d86c94f Merge pull request #7714 from openfoodfoundation/dependabot/bundler/test-unit-3.4.2
Bump test-unit from 3.4.1 to 3.4.2
2021-05-31 11:04:42 +02:00
Pau Pérez Fabregat
d41de06809 Merge pull request #7707 from openfoodfoundation/transifex
Transifex
2021-05-31 10:59:04 +02:00
Transifex-Openfoodnetwork
d730f21dc7 Updating translations for config/locales/en_GB.yml 2021-05-31 17:54:39 +10:00
dependabot[bot]
49dfaa20ab Bump test-unit from 3.4.1 to 3.4.2
Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.4.1 to 3.4.2.
- [Release notes](https://github.com/test-unit/test-unit/releases)
- [Commits](https://github.com/test-unit/test-unit/compare/3.4.1...3.4.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-31 05:38:26 +00:00
dependabot[bot]
bfeb892cab Bump ws from 7.4.4 to 7.4.6
Bumps [ws](https://github.com/websockets/ws) from 7.4.4 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.4.4...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-30 21:28:21 +00:00
Matt-Yorkley
4b56422abd Add network timeouts
In rare cases where Redis is being updated/restarted while a job is running, this should add some flexibility.
2021-05-29 21:07:36 +01:00
Matt-Yorkley
53e3e2b66d Remove outdated Job test helpers
This logic around testing jobs is already handled by integrations with ActiveJob since Rails 4.2
2021-05-29 16:37:06 +01:00
Matt-Yorkley
834140f0a2 Don't dump massive binary PDF data into the job queue
Here we were rendering an entire PDF, then passing that PDF into the job queue as an *argument* containing the entire binary of the PDF in a massive string. This means the job object itself would contain that entire PDF. That's bad queueing!

We now create the PDF *during* the job (not before it), and pass simple arguments.
2021-05-29 16:06:29 +01:00
Matt-Yorkley
0d95d83ef9 Add sidekiq-scheduler to web UI 2021-05-29 13:12:33 +01:00
Matt-Yorkley
54d373c963 Enqueue scheduled jobs with sidekick-scheduler 2021-05-29 13:12:33 +01:00
Matt-Yorkley
1dfd68c691 Add sidekiq-scheduler 2021-05-29 13:12:33 +01:00
Matt-Yorkley
df9213e812 Bump port for new caching instance 2021-05-29 13:12:33 +01:00
Matt-Yorkley
03a078a3a0 Remove namespacing in cache config 2021-05-29 13:11:59 +01:00
Matt-Yorkley
11da025247 Add Sidekiq web interface 2021-05-29 13:11:59 +01:00
Matt-Yorkley
07a9da901f Switch queue adapter to Sidekiq 2021-05-29 13:11:59 +01:00
Matt-Yorkley
4ac3853be9 Configure Sidekiq 2021-05-29 13:11:59 +01:00
Transifex-Openfoodnetwork
eae7a9978c Updating translations for config/locales/de_DE.yml 2021-05-29 18:47:49 +10:00
Transifex-Openfoodnetwork
bdd8572fbf Updating translations for config/locales/en_US.yml 2021-05-29 02:59:45 +10:00
Matt-Yorkley
07422dac29 Add sidekiq gem 2021-05-28 16:58:26 +01:00
jibees
088ae496cc Merge pull request #7664 from shen-sat/7626-fix-unknown-currency-error
7626 fix unknown currency error
2021-05-28 16:18:04 +02:00
Pau Pérez Fabregat
c83a619082 Merge pull request #7705 from openfoodfoundation/transifex
Transifex
2021-05-28 15:45:58 +02:00
Transifex-Openfoodnetwork
ca7d1b111a Updating translations for config/locales/ru.yml 2021-05-28 21:35:53 +10:00
Pau Pérez Fabregat
3c507c1727 Merge pull request #7696 from openfoodfoundation/transifex
Transifex
2021-05-28 13:28:39 +02:00
Jean-Baptiste Bellet
b111d24488 Update all locales with the latest Transifex translations 2021-05-28 09:12:42 +02:00
Andy Brett
4dc8b44e81 Merge pull request #7695 from coopdevs/fix-ruby-installation-dockerfile
Fix Rbenv and ruby-build installation to get Ruby 2.5.9
2021-05-27 11:30:31 -07:00
Andy Brett
27a9ad7bcb Merge pull request #7698 from Matt-Yorkley/remove-eventmachine
Remove eventmachine gem
2021-05-27 11:30:14 -07:00
Pau Perez
fbd4d512d5 Add libssl as required by Ruby 2.5.9
This is a more recent libssl version in Ubuntu 20. Not related to the
libssl1.0 hack required by older Ruby versions.
2021-05-27 17:50:22 +02:00
Pau Perez
0f85db6d36 Fix Rbenv and ruby-build installation to get 2.5.9
This newer Ruby version can't be found on that ruby-build's branch that
we were installing. The `docker-compose build` command works again.
2021-05-27 17:50:22 +02:00
Pau Pérez Fabregat
0f78b5b315 Merge pull request #7616 from jibees/7602-unit-price-not-displaying-when-comma-is-the-decimal-separator
Backoffice: Unit price not displaying when comma is the decimal separator
2021-05-27 17:45:19 +02:00
Matt-Yorkley
78e3bb1acd Remove eventmachine gem
This was a dependency of a dependency a long time ago...
2021-05-27 15:57:17 +01:00
Transifex-Openfoodnetwork
c5e1c057ae Updating translations for config/locales/es.yml 2021-05-28 00:17:47 +10:00
Transifex-Openfoodnetwork
f34a3c3c02 Updating translations for config/locales/ca.yml 2021-05-28 00:17:29 +10:00
Transifex-Openfoodnetwork
546a32e97a Updating translations for config/locales/en_FR.yml 2021-05-27 22:47:27 +10:00
Transifex-Openfoodnetwork
abd269949d Updating translations for config/locales/fr.yml 2021-05-27 22:47:09 +10:00
Pau Pérez Fabregat
0d5f76b19e Merge pull request #7621 from jibees/7534-upload-logo-and-promo-image-for-enterprise
Upload enterprise image (logo and promo): force content type to "text/plain"
2021-05-27 11:33:56 +02:00
Pau Pérez Fabregat
bfa77baae1 Merge pull request #7542 from jibees/6359-add-payment-method-description-to-invoice
Add payment method description to invoice
2021-05-27 11:01:07 +02:00
Pau Pérez Fabregat
a2a1aac384 Merge pull request #7604 from coopdevs/compile-with-jemalloc
Compile Ruby with jemalloc
2021-05-27 08:30:51 +02:00
Pau Perez
43ede7ba26 Remove libssl1.0 from Dockerfile
We recently removed it from production in
bd9e382fba.
2021-05-27 08:09:51 +02:00
kgericke
bb8535cb3a add translation keys for password messages 2021-05-26 08:50:16 -07:00
Andy Brett
883e9fdf62 Merge pull request #7690 from Matt-Yorkley/ruby-259
Bump Ruby to 2.5.9
2021-05-26 08:41:15 -07:00
Matt-Yorkley
c625766af1 Bump Ruby to 2.5.9 2021-05-26 09:36:28 +01:00
Andy Brett
23730ab28f Merge pull request #7683 from openfoodfoundation/dependabot/bundler/view_component-2.32.0
Bump view_component from 2.31.1 to 2.32.0
2021-05-25 07:36:25 -07:00
Jean-Baptiste Bellet
0c8bfea2f7 Add feature tests for upload images on enterprise registration
For both logo and promo images
2021-05-25 15:30:35 +02:00
Jean-Baptiste Bellet
0306732a3d Add test for enterprise logo and promo image uploading
- Add a fixture image to do the upload thanks to `fixture_file_upload`
 - Check the response status, the content type and the response body for both logo image and promo image
2021-05-25 15:30:29 +02:00
Jean-Baptiste Bellet
6842cbfda4 Force content type to "text/html"
- Force the content type to be `text/html` (instead of `application/json`)
2021-05-25 15:30:21 +02:00
Matt-Yorkley
ecb4cb31ad Merge pull request #7599 from Matt-Yorkley/cart-rendering
Move line item rendering to a collection in cart page
2021-05-25 13:37:50 +02:00
Jean-Baptiste Bellet
dd47430f19 Improve unlocalizeCurrency filter to handle many cases
- Complete the unit test to handle all these cases.
2021-05-25 13:14:53 +02:00
Matt-Yorkley
74f27544f7 Merge pull request #7647 from andrewpbrett/default-country-codes
Use correct default country code
2021-05-25 11:21:34 +02:00
Matt-Yorkley
5868765087 Merge pull request #7673 from Matt-Yorkley/spree-config-caching
Fix clashing loggers
2021-05-25 11:09:33 +02:00
Maikel
545d64a2e5 Merge pull request #7682 from openfoodfoundation/dependabot/bundler/i18n-js-3.8.3
Bump i18n-js from 3.8.2 to 3.8.3
2021-05-25 14:48:19 +10:00
Matt-Yorkley
c69dee4c96 Merge pull request #7636 from psychoslave/tip/zeus
Remove all material related to Zeus
2021-05-25 00:10:01 +02:00
Andy Brett
b367001b95 Merge pull request #7641 from luisramos0/order_path
[Rails 6.1] Fix view specs
2021-05-24 14:41:32 -07:00
Andy Brett
120fc4ca42 Merge pull request #7605 from filipefurtad0/import_item_products
Products and Inventory import: Items units
2021-05-24 14:17:43 -07:00
Andy Brett
e4756a523a Merge pull request #7678 from mkllnk/schema
Update schema syntax with Rails 5.2
2021-05-24 13:22:18 -07:00
Andy Brett
46843a5efa Merge pull request #7662 from Matt-Yorkley/enterprise-rendering
Render enterprise rows as a collection
2021-05-24 09:37:58 -07:00
Matt-Yorkley
6377736f43 Allow :site_url to be picked up from ENV vars 2021-05-24 14:58:53 +01:00
Jean-Baptiste Bellet
afe97bcc96 Add tests for creating/editing product/variant cases with decimal price 2021-05-24 10:55:05 +02:00
Jean-Baptiste Bellet
8af6fedf8a Factorize js:true as a common configuration around all tests 2021-05-24 10:55:05 +02:00
Jean-Baptiste Bellet
d8042b25e4 Add test for unlocalize currency filter
- Test that comma is well handle in both cases where comma is the default decimal separator or not.
2021-05-24 10:55:05 +02:00
Jean-Baptiste Bellet
f97e71d054 Add test for decimal price separated by point or comma 2021-05-24 10:55:05 +02:00
Jean-Baptiste Bellet
d066f0b94d Enable displayable unit price for price with comma as decimal separator
Retrieve the current decimal separator used to display price (`I18n.toCurrency()`), and check if number is formatted with only if this is `,`. If so, remplace comma by point, to pass the check `!isNaN`, and format unit price
2021-05-24 10:55:05 +02:00
dependabot[bot]
e9d389e4f1 Bump view_component from 2.31.1 to 2.32.0
Bumps [view_component](https://github.com/github/view_component) from 2.31.1 to 2.32.0.
- [Release notes](https://github.com/github/view_component/releases)
- [Changelog](https://github.com/github/view_component/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/view_component/compare/v2.31.1...v2.32.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-24 05:51:25 +00:00
dependabot[bot]
e90403dbbe Bump i18n-js from 3.8.2 to 3.8.3
Bumps [i18n-js](https://github.com/fnando/i18n-js) from 3.8.2 to 3.8.3.
- [Release notes](https://github.com/fnando/i18n-js/releases)
- [Changelog](https://github.com/fnando/i18n-js/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fnando/i18n-js/compare/v3.8.2...v3.8.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-24 05:49:51 +00:00
Matt-Yorkley
3dc3581e6b Ensure Mail configs are applied when the app starts
Previously we only set these part-way through deployment, so the values could be out of sync between our ENV vars and Spree::Config (which itself is a mix of both cached values and database-persisted values).
2021-05-23 23:05:16 +01:00
Matt-Yorkley
ff82f70e9a Remove custom logger object
This is handled already in Delayed::Command and Delayed::Worker
2021-05-23 23:05:16 +01:00
Andy Brett
560f462f7b Merge pull request #7679 from mkllnk/sample-data
Fix sample_data by filtering params for products
2021-05-22 10:37:30 -07:00
Pau Pérez Fabregat
23b2b5ba56 Merge pull request #7563 from filipefurtad0/import_products_fixture_path
Adds file and fixture path to test product import
2021-05-21 10:12:20 +02:00
Maikel Linke
11cb8cbbdc Fix sample_data by filtering params for products
We were passing too many parameters to the product creation. Rails 5.2
complained that products don't have a distributor. Filtering the
parameters helps.
2021-05-21 12:41:55 +10:00
Maikel Linke
41799b2663 Update schema syntax with Rails 5.2
The style seems to be different. This avoids a modified schema after
running rake db:migrate.
2021-05-21 11:50:34 +10:00
filipefurtad0
2f842bcbdd Adds file and fixture path to test product import
Adds file and fixture path to test product import

Reverts changes on context and it descriptions
2021-05-20 20:08:47 +01:00
Matt-Yorkley
336a8b5825 Merge pull request #7671 from Matt-Yorkley/licence
Add Spree copyright notice
2021-05-20 18:56:16 +02:00
Andy Brett
d2f54f5bd2 Merge pull request #7666 from mkllnk/codecov
Stop Codecov failing good pull requests
2021-05-20 09:18:34 -07:00
Pau Pérez Fabregat
8c81c14c8d Merge pull request #7580 from apricot12/Remove-LineItems-N+1
Removed N+1 queries while counting line_items
2021-05-20 11:42:14 +02:00
Matt-Yorkley
1f6d872fa5 Add Spree copyright notice 2021-05-20 10:25:48 +01:00
Jean-Baptiste Bellet
ae1b9b8dd5 Update all locales with the latest Transifex translations 2021-05-20 10:12:46 +02:00
Maikel
1e1706d371 Merge pull request #7280 from Matt-Yorkley/atomic
Remove atomic gem
2021-05-20 17:53:36 +10:00
Maikel Linke
5ccaa521cf Stop Codecov failing good pull requests
Something doesn't quite work with our Codecov setup. It somehow thinks
that the coverage is decreasing even though it's either not changing or
even increasing.

Until those problems are resolved, let's not mark pull requests as
failed so that we can rely on the pull's overall status report.
2021-05-20 14:18:43 +10:00
Maikel Linke
90bb9870ab Bump Codecov from 1.3.1 to 1.5.0 2021-05-20 14:17:36 +10:00
Andy Brett
70ac719725 Merge pull request #7649 from andrewpbrett/payments-when-out-of-stock
Check stock before doing anything related to admin payments
2021-05-19 14:45:38 -07:00
Andy Brett
08d540a761 Merge pull request #7648 from Matt-Yorkley/redis
Switch cache store from memcached to redis
2021-05-19 10:36:20 -07:00
Andy Brett
304a3804bc Merge pull request #7594 from luisramos0/update_attributes
[Rails 6.1] Replace AR's update_attributes! with update! (and rename order.update! and adjustment.update! in the process)
2021-05-19 10:34:12 -07:00
Luis Ramos
f7726e552a Adapt code coming from master to the new order api with update_order! 2021-05-19 10:09:42 -07:00
Luis Ramos
a1ac4e85ed Replace update_attributes with update 2021-05-19 09:54:25 -07:00
Luis Ramos
f8e5370b0b Replace update_attributes with update 2021-05-19 09:54:25 -07:00
Luis Ramos
fb560089b9 Replace usages of update_attributes! with usage of update! 2021-05-19 09:54:25 -07:00
Luis Ramos
341f6c9f62 Now that adjustment.update! has been renamed to adjustment.update_adjustment! we can use AR's update! on adjustment 2021-05-19 09:54:25 -07:00
Luis Ramos
b2e97fe1d2 Rename order.update! to order.update_order! and adjustment.update! to adjustment.update_adjustment! 2021-05-19 09:54:22 -07:00
Andy Brett
e73584fef7 remove setters from DefaultCountry service 2021-05-19 09:42:52 -07:00
Andy Brett
45ad4bbcf1 remove setting of Spree::Config country code 2021-05-19 09:33:02 -07:00
Matt-Yorkley
096847ea07 Merge pull request #7618 from openfoodfoundation/dependabot/npm_and_yarn/hosted-git-info-2.8.9
Bump hosted-git-info from 2.8.8 to 2.8.9
2021-05-19 13:51:01 +02:00
Pau Pérez Fabregat
faf6a37c9f Merge pull request #7631 from openfoodfoundation/dependabot/bundler/ddtrace-0.49.0
Bump ddtrace from 0.48.0 to 0.49.0
2021-05-19 12:32:52 +02:00
Pau Pérez Fabregat
d4ec1bda54 Merge pull request #7652 from openfoodfoundation/dependabot/bundler/webmock-3.13.0
Bump webmock from 3.12.2 to 3.13.0
2021-05-19 12:32:08 +02:00
Jean-Baptiste Bellet
325b97b683 Add tests around invoice printing in PDF
- use PDF Reader to read pdf and get its content
 - check with we print the payment description information section with the right value
2021-05-19 11:55:46 +02:00
Jean-Baptiste Bellet
7ab065e8cd Add section at the bottom of invoice: Payment Description at Checkout
- If there is any payments, we use the last one to retrieve the payment method description
Use the first completed payment to display payment description
Completed is state = "checkout" or state = "completed"
Squash w/ "Add section at the bottom of invoice: Payment Description at Checkout"

Squash w "Add section at the bottom of invoice: Payment Description a"
2021-05-19 11:55:38 +02:00
Jean-Baptiste Bellet
aea0670268 Add method payment_method to get the payment method from a payment
- Method `payment_method_name` now use `payment_method`
2021-05-19 11:55:38 +02:00
Pau Pérez Fabregat
5560a99423 Merge pull request #7663 from openfoodfoundation/transifex
Transifex
2021-05-19 11:50:02 +02:00
Matt-Yorkley
0c4e191f3b Render enterprise rows as a collection
Note: this is a bit like an N+1 query, but for rendering. If there are 30 enterprises, the partial file would be loaded and parsed 30 times; but if we render it as a collection it'll load the partial once and substantially improve the performance.
2021-05-19 08:48:25 +01:00
Shen Sat
cb914e4729 Change wording in create_admin_user to be more descriptive 2021-05-19 08:45:40 +01:00
Shen Sat
ab027d6af6 Change money initializer to use ENV vars instead of Spree::Config 2021-05-19 08:44:55 +01:00
Shen Sat
6a8ee544e8 Change readme to strong encourage running setup script 2021-05-19 08:44:10 +01:00
Andy Brett
2bb38619ea Merge pull request #7656 from openfoodfoundation/dependabot/bundler/rubocop-1.15.0
Bump rubocop from 1.14.0 to 1.15.0
2021-05-18 13:36:56 -07:00
Andy Brett
4b352da402 Merge pull request #7630 from apricot12/persistent_flash_after_reload
Persistent flash after reload
2021-05-18 12:55:37 -07:00
Transifex-Openfoodnetwork
75243b8e6a Updating translations for config/locales/en_US.yml 2021-05-19 05:54:38 +10:00
Andy Brett
7df2915fbd add DefaultCountry service 2021-05-18 12:44:53 -07:00
Matt-Yorkley
6427a3846b Merge pull request #7651 from openfoodfoundation/dependabot/bundler/activerecord-import-1.1.0
Bump activerecord-import from 1.0.8 to 1.1.0
2021-05-18 20:06:21 +02:00
Andy Brett
5169ee91ea add comment for before_action 2021-05-18 10:42:19 -07:00
Andy Brett
5917accdd2 refactor using Extract Method 2021-05-18 10:38:35 -07:00
alex
4a5cb7f628 Missed import_date translation 2021-05-18 18:30:59 +03:00
Matt-Yorkley
5dd24623f7 Merge pull request #7479 from Matt-Yorkley/payment-callbacks
Update Payment after_save callback
2021-05-18 16:19:29 +02:00
Matt-Yorkley
befb6f632f Merge pull request #7659 from openfoodfoundation/dependabot/bundler/nokogiri-1.11.4
Bump nokogiri from 1.11.3 to 1.11.4
2021-05-18 11:14:32 +02:00
dependabot[bot]
92e0f8349c Bump nokogiri from 1.11.3 to 1.11.4
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.11.3 to 1.11.4.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.11.3...v1.11.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-18 08:37:29 +00:00
dependabot[bot]
ffbba01c41 Bump rubocop from 1.14.0 to 1.15.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.14.0 to 1.15.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.14.0...v1.15.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-18 05:24:48 +00:00
Pau Pérez Fabregat
5f9679655c Merge pull request #7645 from Matt-Yorkley/stripe-payment-processing
Stripe payment processing
2021-05-17 16:17:21 +02:00
dependabot[bot]
6ded80d2c6 Bump webmock from 3.12.2 to 3.13.0
Bumps [webmock](https://github.com/bblimke/webmock) from 3.12.2 to 3.13.0.
- [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.12.2...v3.13.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 05:51:55 +00:00
dependabot[bot]
eb3c33b091 Bump activerecord-import from 1.0.8 to 1.1.0
Bumps [activerecord-import](https://github.com/zdennis/activerecord-import) from 1.0.8 to 1.1.0.
- [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.8...v1.1.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 05:51:01 +00:00
Matt-Yorkley
794216713a Ensure payment is processed if order is in completed state 2021-05-16 23:03:07 +01:00
Matt-Yorkley
a2862e604c Find relevant payment that matches the payment intent, not the last payment 2021-05-16 23:00:31 +01:00
Matt-Yorkley
8429da3d2a Remove unused argument from ProcessPaymentIntent 2021-05-16 22:19:01 +01:00
Matt-Yorkley
381b0e78d5 Improve ProcessPaymentIntent specs 2021-05-16 20:14:14 +01:00
Matt-Yorkley
2e63cd8116 Add explanatory comment on payment processing flow 2021-05-16 20:11:45 +01:00
Matt-Yorkley
52e0d84238 Reload in-memory payment before checking it's new state
The state should have changed in the database if the payment was processed successfully, and the memoized version here will not know that without a reload.
2021-05-16 20:11:45 +01:00
Matt-Yorkley
5725535715 Fix payment state checking 2021-05-16 20:11:45 +01:00
Matt-Yorkley
05ed98aa0c Use :order_with_totals in ProcessPaymentIntent
If we just use the :order factory here, it has no line items and no total, which means when we try to push it into complete state, the #requires_payment? check fails because the order total is zero, which means the call to #process_payments is ignored
2021-05-16 20:11:45 +01:00
Matt-Yorkley
fd021d4778 Refactor payment intent status checking and return "ok" if the payment has already been processed successfully in a previous request
If the page is reloaded after the payment has already gone through, we can skip the processing and give a non-error response; the payment is already completed and Stripe's response confirms it was successful.
2021-05-16 20:11:45 +01:00
Matt-Yorkley
2b9f9fce86 Fix flash session memory-effect when showing errors after payment processing
We're not doing a redirect after setting this flash message, so we need to ensure it's discarded after the current page load.
2021-05-16 20:11:45 +01:00
Matt-Yorkley
81aac442f2 Improve conditional in raise_if_not_in_capture_state 2021-05-16 20:11:45 +01:00
Matt-Yorkley
16e3af9b49 Update OrderController spec 2021-05-16 20:11:45 +01:00
Matt-Yorkley
227bdd7d4c Update ProcessPaymentIntent spec 2021-05-16 12:55:48 +01:00
Matt-Yorkley
471a7903f6 Update PaymentIntentValidator spec 2021-05-16 12:19:04 +01:00
Matt-Yorkley
37177e7207 Add test coverage to StripeSCA spec 2021-05-16 12:19:04 +01:00
Matt-Yorkley
5805104d13 Tidy up controller and add explanatory comment 2021-05-16 12:19:04 +01:00
Matt-Yorkley
e686a4f627 Move raising of errors when payment intent state != "requires_capture" out of PaymentIntentValidator service
When we're fetching the payment intent via PaymentIntentValidator in StripeSCA#purhcase (to capture it), we want it to fail loudly if it's not in "requires_capture" state. We're now also re-using the same PaymentIntentValidator service to check if payment processing was *successful*, in which case we need it *not* to fail loudly if the state == "succeeded", eg != "requires_capture".
2021-05-16 12:19:04 +01:00
Andy Brett
c7f80d86a8 Merge pull request #7638 from Matt-Yorkley/dead-code-order-distribution
Delete dead code in OrdersController#update_distribution
2021-05-15 12:40:25 -07:00
Andy Brett
19187583e1 Merge pull request #7643 from openfoodfoundation/dependabot/bundler/test-prof-1.0.5
Bump test-prof from 1.0.3 to 1.0.5
2021-05-15 12:28:22 -07:00
Andy Brett
f2c3b096a0 Merge pull request #7566 from luisramos0/erb
[Rails 6.0] Fix problem in erb template by explicitly setting format to js
2021-05-15 10:45:01 -07:00
Andy Brett
816d752dc8 Merge pull request #7439 from openfoodfoundation/dependabot/bundler/jwt-2.2.3
Bump jwt from 2.2.2 to 2.2.3
2021-05-15 10:36:13 -07:00
Andy Brett
0a880a2bf3 flip conditional order for performance 2021-05-15 07:08:07 -07:00
Matt-Yorkley
d6b3b0a3d3 Ensure a basic level of fault-tolerance on Redis connections
The default for reconnect_attempts is 0, which is not helpful! 1 is generally considered to be enough.
2021-05-15 11:36:19 +01:00
Andy Brett
ca38948e21 check stock before doing anything related to admin payments 2021-05-14 17:42:37 -07:00
Andy Brett
fe67c01e57 guard against no database, but not against .connected?
Similar to b22ce43efe
2021-05-14 12:56:24 -07:00
Matt-Yorkley
37053239c0 Switch cache store from memcached to redis 2021-05-14 20:46:13 +01:00
dependabot[bot]
2bb5a4b11f Bump test-prof from 1.0.3 to 1.0.5
Bumps [test-prof](https://github.com/test-prof/test-prof) from 1.0.3 to 1.0.5.
- [Release notes](https://github.com/test-prof/test-prof/releases)
- [Changelog](https://github.com/test-prof/test-prof/blob/master/CHANGELOG.md)
- [Commits](https://github.com/test-prof/test-prof/compare/v1.0.3...v1.0.5)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-14 05:17:23 +00:00
Maikel Linke
cea3ee4ef9 Transifex updates 2021-05-14 10:06:31 +10:00
Luis Ramos
90db52e5f5 Fix route 2021-05-14 00:14:02 +01:00
Luis Ramos
3f020ec855 Circunvent security contraint on rails 61 2021-05-14 00:13:38 +01:00
Luis Ramos
b1896733ca Fix routes 2021-05-14 00:08:20 +01:00
Luis Ramos
3d2155b60e Use Arel.sql to curcunvent security restriction on rails 6.1 2021-05-13 23:55:08 +01:00
Luis Ramos
a949422ac9 Adapt view spec stubs to rails 6 2021-05-13 23:28:35 +01:00
Luis Ramos
0243e5cbb8 Fix route in order view 2021-05-13 23:08:50 +01:00
Nihal Mohammed
0b12b398ba Update spec test for the changed redirect path 2021-05-14 03:32:14 +05:30
Nihal Mohammed
122577b11b Checkout made to redirect to shop front when OC closed 2021-05-14 02:58:41 +05:30
Andy Brett
ebdbfe0027 Merge pull request #7639 from drummer83/patch-1
Remove Ruby version from WIKI
2021-05-13 13:26:34 -07:00
Konrad
b680697af6 Remove Ruby version
Let's remove the Ruby version from the text. It changes regularly and have the link where to find it right behind it.
2021-05-13 21:16:02 +02:00
Matt-Yorkley
2e248744c0 Merge pull request #7520 from Matt-Yorkley/shipment-controller
Shipment controller: test coverage and improvements
2021-05-13 20:26:51 +02:00
Matt-Yorkley
82a6befce7 Delete dead code in OrdersController#update_distribution
I can't see any evidence that these params ever get sent to this action...
2021-05-13 15:29:53 +01:00
Mathieu Lovato Stumpf Guntz
ccef65039a Remove all material related to Zeus 2021-05-13 12:21:58 +02:00
dependabot[bot]
e4a670da5a Bump ddtrace from 0.48.0 to 0.49.0
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 0.48.0 to 0.49.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.48.0...v0.49.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-13 05:24:45 +00:00
Nihal Mohammed
c930b2ee60 Fix persistet flash after /cart page reload 2021-05-13 05:57:25 +05:30
Matt-Yorkley
4932e1dcb5 Merge pull request #7628 from viktorsmari/remove-distributer-sample-data
Remove distributer from sample_data
2021-05-12 23:53:13 +02:00
Viktor Smari
536281ec80 Remove distributer from sample_data
Closes #7625
2021-05-12 23:01:08 +02:00
Nihal Mohammed
367cee593f Move eager loading line_items to controller 2021-05-13 01:12:13 +05:30
Matt-Yorkley
99cf23df26 Merge pull request #7530 from Matt-Yorkley/email-after-commit
Email after commit
2021-05-12 21:22:55 +02:00
Matt-Yorkley
f49d4592a0 Merge pull request #7506 from guidoDutra/5546-prevent-deleting-only-item-in-confirmed-order
prevent deleting only item in confirmed order
2021-05-12 21:10:09 +02:00
Pau Pérez Fabregat
7f27544acb Merge pull request #7612 from openfoodfoundation/dependabot/bundler/actionpack-action_caching-1.2.2
Bump actionpack-action_caching from 1.2.1 to 1.2.2
2021-05-12 16:24:25 +02:00
Pau Pérez Fabregat
2aac44d95e Merge pull request #7620 from openfoodfoundation/transifex
Transifex
2021-05-12 15:50:25 +02:00
Pau Pérez Fabregat
8f921b8b08 Merge pull request #7593 from viktorsmari/add-bullet-footer
Add bullet footer
2021-05-12 15:47:54 +02:00
Transifex-Openfoodnetwork
dfe485b079 Updating translations for config/locales/ru.yml 2021-05-12 17:49:31 +10:00
dependabot[bot]
ad9096b5a8 Bump hosted-git-info from 2.8.8 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 23:49:14 +00:00
Luis Ramos
b265fbf9a0 Remove initial slash from admin layout, this fixes a problem with layouts cant be loaded from absolute paths 2021-05-11 22:34:15 +01:00
Matt-Yorkley
e60a513c88 Merge pull request #7571 from coopdevs/make-specs-accurate
Properly mock validator and extend tests
2021-05-11 22:24:01 +02:00
Pau Pérez Fabregat
1f8e731594 Merge pull request #7596 from openfoodfoundation/transifex
Transifex
2021-05-11 11:56:35 +02:00
dependabot[bot]
d69ef31bf9 Bump actionpack-action_caching from 1.2.1 to 1.2.2
Bumps [actionpack-action_caching](https://github.com/rails/actionpack-action_caching) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/rails/actionpack-action_caching/releases)
- [Changelog](https://github.com/rails/actionpack-action_caching/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/actionpack-action_caching/compare/v1.2.1...v1.2.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 05:05:32 +00:00
Andy Brett
9ae7c5efbc Merge pull request #7578 from psychoslave/master
Update things related to some package manager influencing setup process
2021-05-10 17:01:46 -07:00
Matt-Yorkley
902bbf7dc4 Merge pull request #7576 from Matt-Yorkley/bulk-line-items
Add test coverage to BulkLineItemsController actions
2021-05-11 01:47:17 +02:00
Andy Brett
d29ef0d7b1 Merge branch 'master' into make-specs-accurate 2021-05-10 16:10:33 -07:00
Luis Ramos
f29f525d90 Adapt code to circunvent security constraint on rails 6.1 2021-05-10 23:39:17 +01:00
Andy Brett
d2a3d9049f Merge pull request #7588 from andrewpbrett/enterprise-permalink-spec
[Rails 6.0] Fix enterprise permalink spec
2021-05-10 15:30:45 -07:00
Luis Ramos
d308e20871 Fix deprecation warning in rails 6.0
Warning: Class level methods will no longer inherit scoping from create in Rails 6.1
2021-05-10 21:03:24 +01:00
filipefurtad0
0cd6c53e0d Adds test-case on the inventory import for unit Items 2021-05-10 19:12:41 +01:00
filipefurtad0
5475b79cde Adds test-case on the product import unit Items 2021-05-10 19:07:05 +01:00
filipefurtad0
8e24c655b0 Adds verification of inventory import on inventory page 2021-05-10 19:01:41 +01:00
filipefurtad0
bb5452ad26 Adds verification of product import on products page 2021-05-10 18:57:47 +01:00
Pau Perez
ed6b7f1ab4 Split apt packages list into a name per line
This super long line was hard to read.
2021-05-10 19:57:24 +02:00
Matt-Yorkley
85b8e9b51f Merge pull request #7595 from openfoodfoundation/dependabot/bundler/factory_bot_rails-6.2.0
Bump factory_bot_rails from 6.1.0 to 6.2.0
2021-05-10 19:55:54 +02:00
Pau Perez
4453123944 Compile Ruby with jemalloc 2021-05-10 19:31:04 +02:00
Andy Brett
3239c893ba Merge pull request #7590 from viktorsmari/ransack-search-deprecation
Ransack.search is deprecated. Use .ransack instead
2021-05-10 08:43:09 -07:00
Andy Brett
17a0063b40 Merge pull request #7402 from filipefurtad0/products_spec_add_ons
Adds coverage for product deletion and cloning
2021-05-10 06:26:11 -07:00
Matt-Yorkley
122ba385f7 Move line item rendering to collection in cart page
Improvement from upstream Spree commit. Brings a big performance boost to rendering, especially with larger numbers of items in the cart. 50%+ reduction in rendering times reported.
2021-05-10 11:50:31 +01:00
Transifex-Openfoodnetwork
75dc7af0ed Updating translations for config/locales/en_GB.yml 2021-05-10 18:16:04 +10:00
dependabot[bot]
cb15e28cef Bump factory_bot_rails from 6.1.0 to 6.2.0
Bumps [factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails) from 6.1.0 to 6.2.0.
- [Release notes](https://github.com/thoughtbot/factory_bot_rails/releases)
- [Changelog](https://github.com/thoughtbot/factory_bot_rails/blob/master/NEWS.md)
- [Commits](https://github.com/thoughtbot/factory_bot_rails/compare/v6.1.0...v6.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-10 05:55:18 +00:00
Andy Brett
cbefa5f882 Merge pull request #7589 from andrewpbrett/order-adjustments-spec
[Rails 6.0] Fix order adjustments spec
2021-05-09 10:38:19 -07:00
Andy Brett
231f01dad2 fix order adjustments spec 2021-05-09 10:09:22 -07:00
Viktor Smari
c14ccdc21c Add bullet footer
Left corner of the page will show the bullet warnings
2021-05-09 16:49:00 +02:00
Nihal Mohammed
fcf70c242e edit item_count method to shorthand for improved readability 2021-05-09 18:31:26 +05:30
Andy Brett
a0476be2c9 Merge pull request #7568 from andrewpbrett/stripe-mock-js
[Rails 6.0] Use raw to render stripe mock js file
2021-05-08 17:46:24 -07:00
Matt-Yorkley
24a5407c8f Merge pull request #7565 from luisramos0/rails6_success
[Rails 6.0] Replace be_success on test_response with status 200
2021-05-09 02:33:49 +02:00
Andy Brett
66da72ccc2 use raw to render stripe mock js 2021-05-08 17:29:38 -07:00
Viktor Smari
6a342ae368 Ransack.search is deprecated. Use .ransack instead
https://github.com/activerecord-hackery/ransack/pull/975
2021-05-09 01:05:37 +02:00
Andy Brett
dd851edbdc fix enterprise permalink spec 2021-05-08 14:21:45 -07:00
Nihal Mohammed
e485a4a8ef Remove untested change to payments 2021-05-08 23:51:38 +05:30
Nihal Mohammed
026942dd72 Fix item_count to properly count quantity of every item 2021-05-08 23:45:41 +05:30
Nihal Mohammed
237ebd6ec4 Removed N+1 queries while counting line_items 2021-05-08 21:09:06 +05:30
Mathieu Lovato Stumpf Guntz
a4d6e69309 Replace nmp with yarn, remove newrelic 2021-05-07 21:10:55 +02:00
Mathieu Lovato Stumpf Guntz
29e04dd8c8 Merge branch 'master' of https://github.com/openfoodfoundation/openfoodnetwork 2021-05-07 16:00:08 +02:00
Mathieu Lovato Stumpf Guntz
5a8e271037 Update .node-version to last LTS and drop setup tests 2021-05-07 15:54:15 +02:00
Matt-Yorkley
43e41f4980 Add more explicit test coverage to BulkLineItemsController acitons
This spec includes taxes on line items, fees on the order and on line items, taxes on fees (inherited and non-inherited), shipping and payment fees and taxes on shipping. It checks all of these things are correctly updated after the order is changed via BOM.
2021-05-07 11:54:04 +01:00
Pau Perez
fd5e0fd60f Properly mock validator and extend tests
Tests were passing but not due to the expected reason. While at it, we
extended the assertions to be more precise.
2021-05-07 08:35:54 +02:00
Luis Ramos
de000228cf Fix problem in erb template by explicitly setting format to js while calling it 2021-05-06 23:52:16 +01:00
Luis Ramos
a2de86c23e Replace be_success on test_reponse with status 200
In rails 6 response.success? is not supported.
2021-05-06 23:51:30 +01:00
Matt-Yorkley
00c4a28d22 Extract order-updating logic to Order::Updater 2021-05-04 16:40:10 +01:00
Matt-Yorkley
8e10f7af0e Update payments controller test setup
We need to use a completed order in the test setup here or it doesn't behave correctly. `order.completed_at` is nil, for example.
2021-05-04 16:40:10 +01:00
Matt-Yorkley
135a311c05 Update void payments
Backport from Spree 2.4 stable: 4121992398
2021-05-04 16:40:10 +01:00
Matt-Yorkley
13bb5aa8dd Update Payment after_save callback
Backport from Spree 2.4 stable: 4d652a77fd
2021-05-04 16:40:09 +01:00
filipefurtad0
a476416dc4 Removes html tr tag; Clarifies it block 2021-05-03 17:03:34 +01:00
filipefurtad0
19768e1398 adds coverage for product deletion and cloning 2021-05-02 18:33:13 +01:00
Matt-Yorkley
7c2d77a3ee Fix assertion in ModelSet test
The mismatched use of hash attributes as strings and hash attributes as symbols here (attrs['name'] and attrs[:name]) meant that the conditional was not returning the expected results in the test.
2021-05-02 13:42:38 +01:00
Matt-Yorkley
2560757ea2 Change Enterprise after_create callback to after_create_commit
As a general rule, if you're triggering an email job as part of an after create/save callback, it should use after commit instead.

Why? The transaction can't finish until after the record is persisted (the data is committed) which includes the logic in all callbacks. So for example if the transaction fails after the email job has been placed it will be rolled back, but the email job will already be in the queue, and it'll be referencing a record that doesn't actually exist (due to the rollback).
2021-05-02 13:23:31 +01:00
Matt-Yorkley
e290c128bf Fix error in Api::ShipmentController#update with :unlock parameter
This is a generic issue caused by a clash between state machines trying to define (or failing to define) the #open method on adjustments as part of their state changes interface. This method is already defined in Object. For more details, see: bb42e33bf7/lib/state_machines/machine.rb (L323-L350)
2021-04-30 14:13:22 +01:00
Matt-Yorkley
95a73704a2 Add more test coverage to Api::ShipmentController#update 2021-04-30 14:09:32 +01:00
Matt-Yorkley
b843b871f6 Ensure order totals and payment/shipment states are correct when changing shipping method on a completed order.
This used to happen via an after_save callback in Shipment, which called `order.update!`. That has recently been removed. After changing a shipment's selected shipping rate (shipping method), we need to ensure the order's totals and states are updated. We don't need to update all of the order's adjustments though (see previous commit).

FYI Spree handled this issue like this: 24388485ed, but there are lots of things about that commit that are clearly awful, like: params handling in a model, duplication of Order::Updater logic across the codebase, the Shipment class having responsiblity for knowing which things need to be updated on the order, etc. The result is ultimately the same as what we're doing here though.
2021-04-30 12:57:01 +01:00
Matt-Yorkley
925676f136 Split Order::Updater#update into two methods
There are two distinct (and very important) operations happening here. The first is to update all adjustments (which can be *incredibly* expensive) and the second is to ensure the order's totals and shipping/payment states are correct. There are lots of places where we currently do both of these things where in fact we only need to do the latter (and skip the really expensive part).
2021-04-30 12:48:53 +01:00
Matt-Yorkley
d3f41f14c7 Add test coverage for Api::ShipmentsController#update 2021-04-30 12:45:49 +01:00
Matt-Yorkley
045ce73c83 Simplify shipment controller params 2021-04-30 12:20:47 +01:00
Matt-Yorkley
932d000c9d Improve shipping method factory
You can now specify an amount for the flat_rate option.
2021-04-30 12:19:43 +01:00
Guido Oliveira
84285ff985 prevent deleting only item in confirmed order 2021-04-28 17:37:28 -03:00
dependabot[bot]
8b06a735ac Bump jwt from 2.2.2 to 2.2.3
Bumps [jwt](https://github.com/jwt/ruby-jwt) from 2.2.2 to 2.2.3.
- [Release notes](https://github.com/jwt/ruby-jwt/releases)
- [Changelog](https://github.com/jwt/ruby-jwt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jwt/ruby-jwt/compare/v2.2.2...v2.2.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-20 05:21:34 +00:00
Matt-Yorkley
153ec268b7 Remove RackRequestBlocker 2021-03-30 13:24:44 +01:00
Matt-Yorkley
92eaf5fbaa Remove atomic gem
Bundler says this when installing gems:
```
Post-install message from atomic:
This gem has been deprecated and merged into Concurrent Ruby (http://concurrent-ruby.com).
```
We already have concurrent-ruby 👍
2021-03-30 12:29:48 +01:00
287 changed files with 4142 additions and 2671 deletions

5
.github/codecov.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
coverage:
status:
project:
default:
informational: true

View File

@@ -322,4 +322,4 @@ jobs:
run: bundle exec rspec --profile --pattern "engines/*/spec/{,/*/**}/*_spec.rb,spec/features/admin/*/*_spec.rb,spec/lib/{,/*/**}/*_spec.rb"
- name: Codecov
uses: codecov/codecov-action@v1.3.1
uses: codecov/codecov-action@v1.5.0

View File

@@ -1 +1 @@
5.12.0
14.16.1

View File

@@ -334,7 +334,6 @@ Layout/LineLength:
- spec/services/variant_units/option_value_namer_spec.rb
- spec/spec_helper.rb
- spec/support/cancan_helper.rb
- spec/support/delayed_job_helper.rb
- spec/support/matchers/delegate_matchers.rb
- spec/support/matchers/select2_matchers.rb
- spec/support/matchers/table_matchers.rb
@@ -549,7 +548,6 @@ Metrics/BlockLength:
- spec/models/tag_rule/discount_order_spec.rb
- spec/requests/api/orders_spec.rb
- spec/spec_helper.rb
- spec/support/delayed_job_helper.rb
- spec/support/matchers/select2_matchers.rb
- spec/support/matchers/table_matchers.rb
- spec/swagger_helper.rb

View File

@@ -781,7 +781,6 @@ Style/ClassEqualityComparison:
- 'app/controllers/spree/admin/payments_controller.rb'
- 'app/models/tag_rule/discount_order.rb'
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
- 'spec/support/delayed_job_helper.rb'
# Offense count: 3
Style/ClassVars:
@@ -1200,7 +1199,6 @@ Style/GuardClause:
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/open_food_network/rack_request_blocker.rb'
- 'lib/spree/core/controller_helpers/respond_with.rb'
- 'spec/support/delayed_job_helper.rb'
- 'spec/support/request/distribution_helper.rb'
- 'spec/support/request/shop_workflow.rb'

View File

@@ -1 +1 @@
2.5.8
2.5.9

View File

@@ -7,23 +7,39 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN echo "deb http://security.ubuntu.com/ubuntu bionic-security main" >> /etc/apt/sources.list
# Install all the requirements
RUN apt-get update && apt-get install -y curl git build-essential software-properties-common wget zlib1g-dev libssl1.0-dev libreadline-dev libyaml-dev libffi-dev libxml2-dev libxslt1-dev wait-for-it imagemagick unzip
RUN apt-get update && apt-get install -y \
curl \
git \
build-essential \
software-properties-common \
wget \
zlib1g-dev \
libreadline-dev \
libyaml-dev \
libffi-dev \
libxml2-dev \
libxslt1-dev \
wait-for-it \
imagemagick \
unzip \
libjemalloc-dev \
libssl-dev
# Setup ENV variables
ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:$PATH
ENV RBENV_ROOT /usr/local/src/rbenv
ENV CONFIGURE_OPTS --disable-install-doc
ENV BUNDLE_PATH /bundles
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so
WORKDIR /usr/src/app
COPY .ruby-version .
# Install Rbenv & Ruby
RUN git clone --depth 1 --branch v1.1.2 https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \
git clone --depth 1 --branch v20200520 https://github.com/rbenv/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build && \
${RBENV_ROOT}/plugins/ruby-build/install.sh && \
RUN git clone --depth 1 https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \
git clone --depth 1 https://github.com/rbenv/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build && \
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh && \
rbenv install $(cat .ruby-version) && \
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install $(cat .ruby-version) && \
rbenv global $(cat .ruby-version) && \
gem install bundler --version=1.17.3

View File

@@ -6,8 +6,9 @@ This is a general guide to setting up an Open Food Network **development environ
The fastest way to make it work locally is to use Docker, you only need to setup git, see the [Docker setup guide](docker/README.md).
Otherwise, for a local setup you will need:
* Ruby 2.4.4 and bundler (check current Ruby version in [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file)
* Ruby and bundler (check current Ruby version in [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file)
* PostgreSQL database
* Redis (for background jobs)
* Chrome (for testing)
The following guides will provide OS-specific step-by-step instructions to get these requirements installed:
@@ -47,7 +48,11 @@ $ sudo -u postgres psql -c "CREATE USER ofn WITH SUPERUSER CREATEDB PASSWORD 'f0
This will create the "ofn" user as superuser and allowing it to create databases. If this command fails, check the [troubleshooting section](#creating-the-database) for an alternative.
Once done, run `script/setup`. If the script succeeds you're ready to start developing. If not, take a look at the output as it should be informative enough to help you troubleshoot.
Next, it is _strongly recommended_ to run the setup script.
```sh
$ script/setup
```
If the script succeeds you're ready to start developing. If not, take a look at the output as it should be informative enough to help you troubleshoot.
Now, your dreams of spinning up a development server can be realised:
@@ -78,8 +83,6 @@ Note: If your OS is not explicitly supported in the setup guides then not all te
Note: The time zone on your machine should match the one defined in `config/application.yml`.
The project is configured to use [Zeus][zeus] to reduce the pre-test startup time while Rails loads. See the [Zeus GitHub page][zeus] for usage instructions.
Once [npm dependencies are installed][karma], AngularJS tests can be run with:
./script/karma run
@@ -119,7 +122,6 @@ If these commands succeed, you should be able to [continue the setup process](#g
[ubuntu]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-Ubuntu
[debian]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-Debian
[wiki]: https://github.com/openfoodfoundation/openfoodnetwork/wiki
[zeus]: https://github.com/burke/zeus
[rubocop]: https://rubocop.readthedocs.io/en/latest/
[karma]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Karma
[slack-dev]: https://openfoodnetwork.slack.com/messages/C2GQ45KNU

39
Gemfile
View File

@@ -1,27 +1,27 @@
# frozen_string_literal: true
source 'https://rubygems.org'
ruby "2.5.8"
ruby "2.5.9"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
gem 'rails', '~> 5.2'
gem 'rails', '~> 6.0.3.7'
gem 'activemerchant', '>= 1.78.0'
gem 'angular-rails-templates', '>= 0.3.0'
gem 'awesome_nested_set'
gem 'ransack', '2.4.1'
gem 'responders'
gem 'sass', '<= 4.7.1'
gem 'sass-rails', '< 6.0.0'
gem 'sass', '~> 3.4.0' # this restriction originates from foundation-rails's version
gem 'sass-rails', '< 5.1.0' # this restriction originates from the compass-rails's version
gem 'i18n'
gem 'i18n-js', '~> 3.8.2'
gem 'i18n-js', '~> 3.8.3'
gem 'rails-i18n'
gem 'rails_safe_tasks', '~> 1.0'
gem "activerecord-import"
gem "db2fog", github: "openfoodfoundation/db2fog", branch: "rails-5"
gem "fog-aws", ">= 0.6.0"
gem "db2fog", github: "openfoodfoundation/db2fog", branch: "rails-6"
gem "fog-aws", "~> 2.0" # db2fog does not support v3
gem "catalog", path: "./engines/catalog"
gem 'dfc_provider', path: './engines/dfc_provider'
@@ -50,10 +50,6 @@ gem 'devise-token_authenticatable'
gem 'jwt', '~> 2.2'
gem 'oauth2', '~> 1.4.7' # Used for Stripe Connect
gem 'daemons'
gem 'delayed_job_active_record'
gem 'delayed_job_web'
gem 'kaminari', '~> 1.2.1'
gem 'andand'
@@ -70,6 +66,7 @@ gem "active_model_serializers", "0.8.4"
gem 'activerecord-session_store'
gem 'acts-as-taggable-on', '~> 7.0'
gem 'angularjs-file-upload-rails', '~> 2.4.1'
gem 'bootsnap', require: false
gem 'custom_error_message', github: 'jeremydurham/custom-err-msg'
gem 'dalli'
gem 'figaro'
@@ -80,7 +77,12 @@ gem 'paper_trail', '~> 10.3.1'
gem 'paperclip', '~> 3.4.1'
gem 'rack-rewrite'
gem 'rack-ssl', require: 'rack/ssl'
gem 'roadie-rails', '~> 2.2.0'
gem 'roadie-rails'
gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
gem 'hiredis'
gem 'sidekiq'
gem 'sidekiq-scheduler'
gem 'combine_pdf'
gem 'wicked_pdf'
@@ -108,7 +110,7 @@ gem 'foundation-rails', '= 5.5.2.1'
gem 'jquery-migrate-rails'
gem 'jquery-rails', '4.4.0'
gem 'jquery-ui-rails', '~> 4.2'
gem 'select2-rails', '~> 3.4.7'
gem "select2-rails", github: "openfoodfoundation/select2-rails", branch: "v349_with_thor_v1"
gem 'ofn-qz', github: 'openfoodfoundation/ofn-qz', branch: 'ofn-rails-4'
@@ -127,12 +129,11 @@ end
group :test, :development do
# Pretty printed test output
gem 'atomic'
gem 'awesome_print'
gem 'bullet'
gem 'capybara'
gem 'database_cleaner', require: false
gem "factory_bot_rails", '6.1.0', require: false
gem "factory_bot_rails", '6.2.0', require: false
gem 'fuubar', '~> 2.5.1'
gem 'json_spec', '~> 1.1.4'
gem 'knapsack'
@@ -148,17 +149,18 @@ group :test, :development do
end
group :test do
gem 'byebug'
gem 'codecov', require: false
gem 'simplecov', require: false
gem 'test-prof'
gem 'webmock'
gem 'rails-controller-testing'
gem 'pdf-reader'
# See spec/spec_helper.rb for instructions
# gem 'perftools.rb'
end
group :development do
gem 'byebug'
gem 'debugger-linecache'
gem 'pry'
gem 'pry-byebug'
@@ -169,10 +171,5 @@ group :development do
gem "view_component_storybook", require: "view_component/storybook/engine"
# 1.0.9 fixed openssl issues on macOS https://github.com/eventmachine/eventmachine/issues/602
# While we don't require this gem directly, no dependents forced the upgrade to a version
# greater than 1.0.9, so we just required the latest available version here.
gem 'eventmachine', '>= 1.2.3'
gem 'rack-mini-profiler', '< 3.0.0'
end

View File

@@ -6,13 +6,13 @@ GIT
GIT
remote: https://github.com/openfoodfoundation/db2fog.git
revision: 8ceef362c64e6573d62d26db5ebb0c0f33cd3d61
branch: rails-5
revision: 5b63343847452f52aa42f7fc169d6ab3af57cda3
branch: rails-6
specs:
db2fog (0.9.1)
activerecord (>= 3.2.0, < 6.0)
db2fog (0.9.2)
activerecord (>= 3.2.0, < 7.0)
fog-core (~> 1.0)
rails (>= 3.2.0, < 6.0)
rails (>= 3.2.0, < 7.0)
GIT
remote: https://github.com/openfoodfoundation/ofn-qz.git
@@ -21,6 +21,15 @@ GIT
specs:
ofn-qz (0.1.0)
GIT
remote: https://github.com/openfoodfoundation/select2-rails.git
revision: fc240e85fbdf1878ff3c39d972c0cd9a312f5ed4
branch: v349_with_thor_v1
specs:
select2-rails (3.4.9)
sass-rails
thor (>= 0.14)
PATH
remote: engines/catalog
specs:
@@ -47,48 +56,61 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.6)
actionpack (= 5.2.6)
Ascii85 (1.1.0)
actioncable (6.0.3.7)
actionpack (= 6.0.3.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
actionmailbox (6.0.3.7)
actionpack (= 6.0.3.7)
activejob (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
mail (>= 2.7.1)
actionmailer (6.0.3.7)
actionpack (= 6.0.3.7)
actionview (= 6.0.3.7)
activejob (= 6.0.3.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.6)
actionview (= 5.2.6)
activesupport (= 5.2.6)
actionpack (6.0.3.7)
actionview (= 6.0.3.7)
activesupport (= 6.0.3.7)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-action_caching (1.2.1)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionpack-action_caching (1.2.2)
actionpack (>= 4.0.0)
actionview (5.2.6)
activesupport (= 5.2.6)
actiontext (6.0.3.7)
actionpack (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
nokogiri (>= 1.8.5)
actionview (6.0.3.7)
activesupport (= 6.0.3.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.8.4)
activemodel (>= 3.0)
activejob (5.2.6)
activesupport (= 5.2.6)
activejob (6.0.3.7)
activesupport (= 6.0.3.7)
globalid (>= 0.3.6)
activemerchant (1.119.0)
activemerchant (1.120.0)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
nokogiri (~> 1.4)
activemodel (5.2.6)
activesupport (= 5.2.6)
activerecord (5.2.6)
activemodel (= 5.2.6)
activesupport (= 5.2.6)
arel (>= 9.0)
activerecord-import (1.0.8)
activemodel (6.0.3.7)
activesupport (= 6.0.3.7)
activerecord (6.0.3.7)
activemodel (= 6.0.3.7)
activesupport (= 6.0.3.7)
activerecord-import (1.1.0)
activerecord (>= 3.2)
activerecord-postgresql-adapter (0.0.1)
pg
@@ -98,21 +120,24 @@ GEM
multi_json (~> 1.11, >= 1.11.2)
rack (>= 2.0.8, < 3)
railties (>= 5.2.4.1)
activestorage (5.2.6)
actionpack (= 5.2.6)
activerecord (= 5.2.6)
activestorage (6.0.3.7)
actionpack (= 6.0.3.7)
activejob (= 6.0.3.7)
activerecord (= 6.0.3.7)
marcel (~> 1.0.0)
activesupport (5.2.6)
activesupport (6.0.3.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
acts-as-taggable-on (7.0.0)
activerecord (>= 5.0, < 6.2)
acts_as_list (1.0.4)
activerecord (>= 4.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
afm (0.2.2)
andand (1.3.3)
angular-rails-templates (1.1.0)
railties (>= 4.2, < 7)
@@ -122,9 +147,7 @@ GEM
railties (>= 3, < 7)
angularjs-file-upload-rails (2.4.1)
angularjs-rails (1.5.5)
arel (9.0.0)
ast (2.4.2)
atomic (1.1.101)
awesome_nested_set (3.4.0)
activerecord (>= 4.0.0, < 7.0)
awesome_print (1.9.2)
@@ -134,6 +157,8 @@ GEM
json (~> 1.4)
nokogiri (~> 1)
bcrypt (3.1.16)
bootsnap (1.7.5)
msgpack (~> 1.0)
bugsnag (6.20.0)
concurrent-ruby (~> 1.0)
builder (3.2.4)
@@ -184,29 +209,24 @@ GEM
compass (~> 1.0.0)
sass-rails (< 5.1)
sprockets (< 4.0)
concurrent-ruby (1.1.8)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
crack (0.4.5)
rexml
crass (1.0.6)
css_parser (1.9.0)
addressable
daemons (1.4.0)
dalli (2.7.11)
database_cleaner (1.99.0)
ddtrace (0.48.0)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
ddtrace (0.50.0)
ffi (~> 1.0)
msgpack
debugger-linecache (1.2.0)
delayed_job (4.1.9)
activesupport (>= 3.0, < 6.2)
delayed_job_active_record (4.1.6)
activerecord (>= 3.0, < 6.2)
delayed_job (>= 3.0, < 5)
delayed_job_web (1.4.4)
activerecord (> 3.0.0)
delayed_job (> 2.0.3)
rack-protection (>= 1.5.5)
sinatra (>= 1.4.4)
devise (4.8.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@@ -219,22 +239,28 @@ GEM
devise (>= 4.0.0, < 5.0.0)
diff-lcs (1.4.4)
docile (1.3.5)
e2mmap (0.1.0)
erubi (1.10.0)
eventmachine (1.2.7)
excon (0.79.0)
et-orbi (1.2.4)
tzinfo
excon (0.81.0)
execjs (2.7.0)
factory_bot (6.1.0)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.1.0)
factory_bot (~> 6.1.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faraday (1.3.0)
faraday (1.4.1)
faraday-excon (~> 1.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
multipart-post (>= 1.2, < 3)
ruby2_keywords
ruby2_keywords (>= 0.0.4)
faraday-excon (1.1.0)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
ffaker (2.18.0)
ffi (1.15.0)
ffi (1.15.1)
figaro (1.2.0)
thor (>= 0.14.0, < 2)
flipper (0.20.4)
@@ -268,6 +294,9 @@ GEM
foundation-rails (5.5.2.1)
railties (>= 3.1.0)
sass (>= 3.3.0, < 3.5)
fugit (1.4.5)
et-orbi (~> 1.1, >= 1.1.8)
raabro (~> 1.4)
fuubar (2.5.1)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
@@ -284,10 +313,12 @@ GEM
temple (>= 0.8.0)
tilt
hashdiff (1.0.1)
hashery (2.1.2)
highline (2.0.3)
hiredis (0.6.3)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
i18n-js (3.8.2)
i18n-js (3.8.3)
i18n (>= 0.6.6)
immigrant (0.3.6)
activerecord (>= 3.0)
@@ -305,7 +336,7 @@ GEM
json_spec (1.1.5)
multi_json (~> 1.0)
rspec (>= 2.0, < 4.0)
jwt (2.2.2)
jwt (2.2.3)
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
@@ -321,11 +352,11 @@ GEM
kgio (2.11.3)
knapsack (1.22.0)
rake
launchy (2.4.3)
addressable (~> 2.3)
launchy (2.5.0)
addressable (~> 2.7)
letter_opener (1.7.0)
launchy (~> 2.2)
libv8-node (15.14.0.0)
libv8-node (15.14.0.1)
loofah (2.9.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
@@ -335,12 +366,12 @@ GEM
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.1104)
mime-types-data (3.2021.0225)
mimemagic (0.4.3)
nokogiri (~> 1)
rake
mini_mime (1.1.0)
mini_portile2 (2.5.1)
mini_portile2 (2.5.3)
mini_racer (0.4.0)
libv8-node (~> 15.14.0.0)
minitest (5.14.4)
@@ -352,10 +383,8 @@ GEM
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.7)
nokogiri (1.11.3)
nokogiri (1.11.7)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
oauth2 (1.4.7)
@@ -384,15 +413,22 @@ GEM
xml-simple
paypal-sdk-merchant (1.117.2)
paypal-sdk-core (~> 0.3.0)
pdf-reader (2.5.0)
Ascii85 (~> 1.0)
afm (~> 0.2.1)
hashery (~> 2.0)
ruby-rc4
ttfunk
pg (1.2.3)
power_assert (2.0.0)
pry (0.13.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
pry-byebug (3.8.0)
byebug (~> 11.0)
pry (~> 0.13.0)
pry (~> 0.10)
public_suffix (4.0.6)
raabro (1.4.0)
racc (1.5.2)
rack (2.2.3)
rack-mini-profiler (2.3.2)
@@ -404,18 +440,20 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.6)
actioncable (= 5.2.6)
actionmailer (= 5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
activemodel (= 5.2.6)
activerecord (= 5.2.6)
activestorage (= 5.2.6)
activesupport (= 5.2.6)
rails (6.0.3.7)
actioncable (= 6.0.3.7)
actionmailbox (= 6.0.3.7)
actionmailer (= 6.0.3.7)
actionpack (= 6.0.3.7)
actiontext (= 6.0.3.7)
actionview (= 6.0.3.7)
activejob (= 6.0.3.7)
activemodel (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
bundler (>= 1.3.0)
railties (= 5.2.6)
railties (= 6.0.3.7)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
@@ -426,16 +464,16 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-i18n (5.1.3)
rails-i18n (6.0.0)
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
railties (>= 6.0.0, < 7)
rails_safe_tasks (1.0.0)
railties (5.2.6)
actionpack (= 5.2.6)
activesupport (= 5.2.6)
railties (6.0.3.7)
actionpack (= 6.0.3.7)
activesupport (= 6.0.3.7)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
raindrops (0.19.1)
rake (13.0.3)
@@ -443,10 +481,11 @@ GEM
activerecord (>= 5.2.4)
activesupport (>= 5.2.4)
i18n
rb-fsevent (0.10.4)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.1)
redis (4.2.5)
regexp_parser (2.1.1)
request_store (1.5.0)
rack (>= 1.4)
@@ -499,16 +538,16 @@ GEM
rswag-ui (2.4.0)
actionpack (>= 3.1, < 7.0)
railties (>= 3.1, < 7.0)
rubocop (1.14.0)
rubocop (1.16.1)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.5.0, < 2.0)
rubocop-ast (>= 1.7.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.5.0)
rubocop-ast (1.7.0)
parser (>= 3.0.1.1)
rubocop-rails (2.10.1)
activesupport (>= 4.2.0)
@@ -516,34 +555,39 @@ GEM
rubocop (>= 1.7.0, < 2.0)
ruby-progressbar (1.11.0)
ruby-rc4 (0.1.5)
ruby2_keywords (0.0.2)
ruby2_keywords (0.0.4)
rubyzip (2.3.0)
rufus-scheduler (3.7.0)
fugit (~> 1.1, >= 1.1.6)
sass (3.4.25)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass-rails (5.0.8)
railties (>= 5.2.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
select2-rails (3.4.9)
sass-rails
thor (~> 0.14)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
sidekiq (6.2.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
sidekiq-scheduler (3.1.0)
e2mmap
redis (>= 3, < 5)
rufus-scheduler (~> 3.2)
sidekiq (>= 3)
thwait
tilt (>= 1.4.0)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
simplecov_json_formatter (0.1.3)
spring (2.1.1)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
@@ -562,15 +606,18 @@ GEM
activerecord (>= 5.1)
state_machines-activemodel (>= 0.8.0)
stringex (2.8.5)
stripe (5.30.0)
stripe (5.33.0)
temple (0.8.2)
test-prof (1.0.3)
test-unit (3.4.1)
test-prof (1.0.5)
test-unit (3.4.4)
power_assert
thor (0.20.3)
thor (1.1.0)
thread_safe (0.3.6)
thwait (0.2.0)
e2mmap
tilt (2.0.10)
timecop (0.9.4)
ttfunk (1.7.0)
tzinfo (1.2.9)
thread_safe (~> 0.1)
uglifier (4.2.0)
@@ -585,8 +632,8 @@ GEM
unicorn-worker-killer (0.4.5)
get_process_mem (~> 0)
unicorn (>= 4, < 7)
uniform_notifier (1.14.1)
view_component (2.31.1)
uniform_notifier (1.14.2)
view_component (2.34.0)
activesupport (>= 5.0.0, < 7.0)
view_component_storybook (0.8.0)
view_component (>= 2.2)
@@ -596,11 +643,11 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
webmock (3.12.2)
webmock (3.13.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.3)
websocket-driver (0.7.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
@@ -611,6 +658,7 @@ GEM
xml-simple (1.1.8)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.2)
PLATFORMS
ruby
@@ -629,10 +677,10 @@ DEPENDENCIES
angular_rails_csrf
angularjs-file-upload-rails (~> 2.4.1)
angularjs-rails (= 1.5.5)
atomic
awesome_nested_set
awesome_print
aws-sdk (= 1.67.0)
bootsnap
bugsnag
bullet
byebug
@@ -644,26 +692,22 @@ DEPENDENCIES
combine_pdf
compass-rails
custom_error_message!
daemons
dalli
database_cleaner
db2fog!
ddtrace
debugger-linecache
delayed_job_active_record
delayed_job_web
devise
devise-encryptable
devise-token_authenticatable
dfc_provider!
eventmachine (>= 1.2.3)
factory_bot_rails (= 6.1.0)
factory_bot_rails (= 6.2.0)
ffaker
figaro
flipper
flipper-active_record
flipper-ui
fog-aws (>= 0.6.0)
fog-aws (~> 2.0)
foundation-icons-sass-rails
foundation-rails (= 5.5.2.1)
fuubar (~> 2.5.1)
@@ -672,8 +716,9 @@ DEPENDENCIES
good_migrations
haml
highline (= 2.0.3)
hiredis
i18n
i18n-js (~> 3.8.2)
i18n-js (~> 3.8.3)
immigrant
jquery-migrate-rails
jquery-rails (= 4.4.0)
@@ -694,31 +739,35 @@ DEPENDENCIES
paperclip (~> 3.4.1)
paranoia (~> 2.4)
paypal-sdk-merchant (= 1.117.2)
pdf-reader
pg (~> 1.2.3)
pry
pry-byebug
rack-mini-profiler (< 3.0.0)
rack-rewrite
rack-ssl
rails (~> 5.2)
rails (~> 6.0.3.7)
rails-controller-testing
rails-i18n
rails_safe_tasks (~> 1.0)
ransack (= 2.4.1)
redcarpet
redis (>= 4.0)
responders
roadie-rails (~> 2.2.0)
roadie-rails
roo (~> 2.8.3)
rspec-rails (>= 3.5.2)
rspec-retry
rswag
rubocop
rubocop-rails
sass (<= 4.7.1)
sass-rails (< 6.0.0)
select2-rails (~> 3.4.7)
sass (~> 3.4.0)
sass-rails (< 5.1.0)
select2-rails!
selenium-webdriver
shoulda-matchers
sidekiq
sidekiq-scheduler
simplecov
spring
spring-commands-rspec
@@ -741,7 +790,7 @@ DEPENDENCIES
wkhtmltopdf-binary
RUBY VERSION
ruby 2.5.8p224
ruby 2.5.9p229
BUNDLED WITH
1.17.3

View File

@@ -3,12 +3,18 @@ angular.module('admin.orderCycles', ['ngTagsInput', 'admin.indexUtils', 'admin.e
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
$timeout ->
flatpickr(element, Object.assign({},
fp = flatpickr(element, Object.assign({},
window.FLATPICKR_DATETIME_DEFAULT, {
onOpen: (selectedDates, dateStr, instance) ->
instance.setDate(ngModel.$modelValue)
instance.input.dispatchEvent(new Event('focus', { bubbles: true }));
}));
fp.minuteElement.addEventListener "keyup", (e) ->
if !isNaN(event.target.value)
fp.setDate(fp.selectedDates[0].setMinutes(e.target.value), true)
fp.hourElement.addEventListener "keyup", (e) ->
if !isNaN(event.target.value)
fp.setDate(fp.selectedDates[0].setHours(e.target.value), true)
.directive 'ofnOnChange', ->
(scope, element, attrs) ->

View File

@@ -1,6 +1,7 @@
angular.module("admin.products").factory "UnitPrices", (VariantUnitManager, localizeCurrencyFilter) ->
angular.module("admin.products").factory "UnitPrices", (VariantUnitManager, localizeCurrencyFilter, unlocalizeCurrencyFilter) ->
class UnitPrices
@displayableUnitPrice: (price, scale, unit_type, unit_value, variant_unit_name) ->
price = unlocalizeCurrencyFilter(price)
if price && !isNaN(price) && unit_type && unit_value
value = localizeCurrencyFilter(UnitPrices.price(price, scale, unit_type, unit_value, variant_unit_name))
unit = UnitPrices.unit(scale, unit_type, variant_unit_name)
@@ -29,4 +30,4 @@ angular.module("admin.products").factory "UnitPrices", (VariantUnitManager, loca
else if unit_type == "weight"
"kg"
else if unit_type == "volume"
"L"
"L"

View File

@@ -0,0 +1,15 @@
angular.module("admin.utils").filter "unlocalizeCurrency", ()->
# Convert string to number using injected currency configuration.
(price) ->
# used decimal and thousands separators from currency configuration
decimal_separator = I18n.toCurrency(.1, {precision: 1, unit: ''}).substring(1,2)
thousands_separator = I18n.toCurrency(1000, {precision: 1, unit: ''}).substring(1,2)
if (price.length > 4)
# remove configured thousands separator if price is greater than 999
price = price.replaceAll(thousands_separator, '')
if (decimal_separator == ",")
price = price.replace(",", ".")
return parseFloat(price)

View File

@@ -3,7 +3,7 @@ Darkswarm.controller "EditBoughtOrderController", ($scope, $resource, $timeout,
$scope.removeEnabled = true
$scope.deleteLineItem = (id) ->
if Cart.has_one_line_item()
if Cart.isOnlyItemInOrder(id)
Messages.error(t 'orders_cannot_remove_the_final_item')
$scope.removeEnabled = false
$timeout (->

View File

@@ -1,9 +1,5 @@
Darkswarm.controller "ShopVariantCtrl", ($scope, $modal, Cart) ->
$scope.$watchGroup [
'variant.line_item.quantity',
'variant.line_item.max_quantity'
], (new_value, old_value) ->
return if old_value[0] == null && new_value[0] == null
$scope.updateCart = (line_item) ->
Cart.adjust($scope.variant.line_item)
$scope.variant.line_item.quantity ||= 0
@@ -44,10 +40,12 @@ Darkswarm.controller "ShopVariantCtrl", ($scope, $modal, Cart) ->
$scope.add = (quantity) ->
item = $scope.variant.line_item
item.quantity = $scope.sanitizedQuantity() + quantity
$scope.updateCart(item)
$scope.addMax = (quantity) ->
item = $scope.variant.line_item
item.max_quantity = $scope.sanitizedMaxQuantity() + quantity
$scope.updateCart(item)
$scope.canAdd = (quantity) ->
wantedQuantity = $scope.sanitizedQuantity() + quantity

View File

@@ -1,8 +0,0 @@
Darkswarm.directive "shopVariantWithUnitPrice", ->
restrict: 'E'
replace: true
templateUrl: 'shop_variant_with_unit_price.html'
scope:
variant: '='
show_unit_price: '=showunitprice'
controller: 'ShopVariantCtrl'

View File

@@ -115,8 +115,9 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo
@line_items = []
localStorageService.clearAll() # One day this will have to be moar GRANULAR
has_one_line_item: =>
@line_items_finalised.length == 1
isOnlyItemInOrder: (id) =>
deletedItem = @line_items_finalised.find((item) -> item.id == id)
@line_items_finalised.filter((item) -> item.order_id == deletedItem.order_id).length == 1
removeFinalisedLineItem: (id) =>
@line_items_finalised = @line_items_finalised.filter (item) ->

View File

@@ -10,7 +10,7 @@ Darkswarm.service "GmapsGeo", ->
# console.log "Error: #{status}"
geocode: (address, callback) ->
geocoder = new google.maps.Geocoder()
geocoder.geocode {'address': address, 'region': "<%= Spree::Country.find_by(id: Spree::Config[:default_country_id]).iso %>"}, callback
geocoder.geocode {'address': address, 'region': "<%= DefaultCountry.code %>"}, callback
distanceBetween: (src, dst) ->
google.maps.geometry.spherical.computeDistanceBetween @toLatLng(src), @toLatLng(dst)
@@ -20,4 +20,4 @@ Darkswarm.service "GmapsGeo", ->
if locatable.lat?
locatable
else
new google.maps.LatLng locatable.latitude, locatable.longitude
new google.maps.LatLng locatable.latitude, locatable.longitude

View File

@@ -8,7 +8,7 @@
.div
{{ variant.line_item.total_price | localizeCurrency }}
.unit-price{"ng-if": "show_unit_price"}
.unit-price
%question-mark-with-tooltip{"question-mark-with-tooltip": "_",
"question-mark-with-tooltip-append-to-body": "true",
"question-mark-with-tooltip-placement": "top",

View File

@@ -8,9 +8,16 @@
"price-breakdown-placement" => "bottom",
"price-breakdown-animation" => true}
{{ variant.price_with_fees | localizeCurrency }}
.unit-price.variant-unit-price
%question-mark-with-tooltip{"question-mark-with-tooltip" => "_",
"question-mark-with-tooltip-append-to-body" => "true",
"question-mark-with-tooltip-placement" => "top",
"question-mark-with-tooltip-animation" => true,
key: "'js.shopfront.unit_price_tooltip'"}
{{ variant.unit_price_price | localizeCurrency }}&nbsp;/&nbsp;{{ variant.unit_price_unit }}
.medium-2.large-2.columns.total-price
%span{"ng-class" => "{filled: variant.line_item.total_price}"}
{{ variant.line_item.total_price | localizeCurrency }}
%ng-include{src: "'partials/shop_variant_no_group_buy.html'"}
%ng-include{src: "'partials/shop_variant_with_group_buy.html'"}

View File

@@ -1,23 +0,0 @@
.variants.row
.small-4.medium-4.large-5.columns.variant-name
.inline{"ng-if" => "::variant.display_name"} {{ ::variant.display_name }}
.variant-unit {{ ::variant.unit_to_display }}
.small-3.medium-3.large-2.columns.variant-price
%price-breakdown{"price-breakdown" => "_", variant: "variant",
"price-breakdown-append-to-body" => "true",
"price-breakdown-placement" => "bottom",
"price-breakdown-animation" => true}
{{ variant.price_with_fees | localizeCurrency }}
.unit-price.variant-unit-price
%question-mark-with-tooltip{"question-mark-with-tooltip" => "_",
"question-mark-with-tooltip-append-to-body" => "true",
"question-mark-with-tooltip-placement" => "top",
"question-mark-with-tooltip-animation" => true,
key: "'js.shopfront.unit_price_tooltip'"}
{{ variant.unit_price_price | localizeCurrency }}&nbsp;/&nbsp;{{ variant.unit_price_unit }}
.medium-2.large-2.columns.total-price
%span{"ng-class" => "{filled: variant.line_item.total_price}"}
{{ variant.line_item.total_price | localizeCurrency }}
%ng-include{src: "'partials/shop_variant_no_group_buy.html'"}
%ng-include{src: "'partials/shop_variant_with_group_buy.html'"}

View File

@@ -0,0 +1,6 @@
.admin-current-terms-of-service {
border: .1em solid $spree-blue;
border-radius: .5em;
margin: 1em 0;
padding: 1em;
}

View File

@@ -32,10 +32,7 @@ module Admin
# See https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/locking/pessimistic.rb#L69
# and https://www.postgresql.org/docs/current/static/sql-select.html#SQL-FOR-UPDATE-SHARE
order.with_lock do
if @line_item.update(line_item_params)
order.update_line_item_fees! @line_item
order.update_order_fees!
order.update!
if order.contents.update_item(@line_item, line_item_params)
render body: nil, status: :no_content # No Content, does not trigger ng resource auto-update
else
render json: { errors: @line_item.errors }, status: :precondition_failed
@@ -49,7 +46,7 @@ module Admin
load_line_item
authorize! :update, order
@line_item.destroy
order.contents.remove(@line_item.variant)
render body: nil, status: :no_content # No Content, does not trigger ng resource auto-update
end
@@ -63,16 +60,9 @@ module Admin
Spree::LineItem
end
# Returns the appropriate serializer for this controller
#
# @return [Api::Admin::LineItemSerializer]
def serializer(_ams_prefix)
Api::Admin::LineItemSerializer
end
def serialized_line_items
ActiveModel::ArraySerializer.new(
@line_items, each_serializer: serializer(nil)
@line_items, each_serializer: Api::Admin::LineItemSerializer
)
end

View File

@@ -28,9 +28,7 @@ module Admin
def build_resource
enterprise_group = super
enterprise_group.address = Spree::Address.new
enterprise_group.address.country = Spree::Country.find_by(
id: Spree::Config[:default_country_id]
)
enterprise_group.address.country = DefaultCountry.country
enterprise_group
end

View File

@@ -119,7 +119,7 @@ module Admin
def build_resource
enterprise = super
enterprise.address ||= Spree::Address.new
enterprise.address.country ||= Spree::Country.find_by(id: Spree::Config[:default_country_id])
enterprise.address.country ||= DefaultCountry.country
enterprise
end

View File

@@ -0,0 +1,40 @@
# frozen_string_literal: true
module Admin
class TermsOfServiceFilesController < Spree::Admin::BaseController
def show
@current_file = TermsOfServiceFile.current
@new_file = TermsOfServiceFile.new
end
def new
show
render :show
end
def create
TermsOfServiceFile.create!(file_params)
redirect_to main_app.admin_terms_of_service_files_path
rescue ActionController::ParameterMissing
flash[:error] = t(".select_file")
redirect_to main_app.admin_terms_of_service_files_path
end
def destroy
TermsOfServiceFile.current.destroy!
redirect_to main_app.admin_terms_of_service_files_path
end
private
# Needed by Spree::Admin::BaseController#authorize_admin or it
# tries to find a Spree model.
def model_class
TermsOfServiceFile
end
def file_params
params.require(:terms_of_service_file).permit(:attachment)
end
end
end

View File

@@ -44,9 +44,9 @@ module Api
authorize! :update, @enterprise
if params[:logo] && @enterprise.update( logo: params[:logo] )
render plain: @enterprise.logo.url(:medium), status: :ok
render html: @enterprise.logo.url(:medium), status: :ok
elsif params[:promo] && @enterprise.update( promo_image: params[:promo] )
render plain: @enterprise.promo_image.url(:medium), status: :ok
render html: @enterprise.promo_image.url(:medium), status: :ok
else
invalid_resource!(@enterprise)
end

View File

@@ -31,10 +31,12 @@ module Api
unlock = params[:shipment].delete(:unlock)
if unlock == 'yes'
@shipment.fee_adjustment.open
@shipment.fee_adjustment.fire_events(:open)
end
@shipment.update(shipment_params[:shipment])
if @shipment.update(shipment_params)
@order.updater.update_totals_and_states
end
if unlock == 'yes'
@shipment.fee_adjustment.close
@@ -79,7 +81,6 @@ module Api
quantity = params[:quantity].to_i
@order.contents.remove(variant, quantity, @shipment)
@order.recreate_all_fees!
@shipment.reload if @shipment.persisted?
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
@@ -94,7 +95,7 @@ module Api
def find_and_update_shipment
@shipment = @order.shipments.find_by!(number: params[:id])
@shipment.update(shipment_params[:shipment]) if shipment_params[:shipment].present?
@shipment.update(shipment_params)
@shipment.reload
end
@@ -113,10 +114,9 @@ module Api
end
def shipment_params
params.permit(
[:id, :order_id, :variant_id, :quantity,
{ shipment: [:tracking, :selected_shipping_rate_id] }]
)
return {} unless params.has_key? :shipment
params.require(:shipment).permit(:tracking, :selected_shipping_rate_id)
end
end
end

View File

@@ -26,6 +26,7 @@ class ApplicationController < ActionController::Base
helper 'footer_links'
helper 'discourse'
helper 'checkout'
helper 'terms_and_conditions'
protect_from_forgery
@@ -153,7 +154,7 @@ class ApplicationController < ActionController::Base
current_order.empty!
current_order.set_order_cycle! nil
flash[:info] = I18n.t('order_cycle_closed')
redirect_to main_app.root_url
redirect_to main_app.shop_path
end
end

View File

@@ -3,33 +3,28 @@ class CartController < BaseController
def populate
order = current_order(true)
cart_service = CartService.new(order)
cart_service.populate(params.slice(:variants, :quantity), true)
if cart_service.valid?
if cart_service.populate(params.slice(:variants, :quantity))
order.cap_quantity_at_stock!
order.recreate_all_fees!
variant_ids = variant_ids_in(cart_service.variants_h)
render json: { error: false,
stock_levels: VariantsStockLevels.new.call(order, variant_ids) },
status: :ok
render json: { error: false, stock_levels: stock_levels(order) }, status: :ok
else
render json: { error: cart_service.errors.full_messages.join(",") },
status: :precondition_failed
end
populate_variant_attributes
end
def variant_ids_in(variants_h)
variants_h.map { |v| v[:variant_id].to_i }
end
private
def stock_levels(order)
variants_in_cart = order.line_items.pluck(:variant_id)
variants_in_request = raw_params[:variants]&.map(&:first) || []
VariantsStockLevels.new.call(order, (variants_in_cart + variants_in_request).uniq)
end
def check_authorization
session[:access_token] ||= params[:token]
order = Spree::Order.find_by(number: params[:id]) || current_order
@@ -40,26 +35,4 @@ class CartController < BaseController
authorize! :create, Spree::Order
end
end
def populate_variant_attributes
order = current_order.reload
populate_variant_attributes_from_variant(order) if params.key? :variant_attributes
populate_variant_attributes_from_product(order) if params.key? :quantity
end
def populate_variant_attributes_from_variant(order)
params[:variant_attributes].each do |variant_id, attributes|
permitted = attributes.permit(:quantity, :max_quantity).to_h.with_indifferent_access
order.set_variant_attributes(Spree::Variant.find(variant_id), permitted)
end
end
def populate_variant_attributes_from_product(order)
params[:products].each do |_product_id, variant_id|
max_quantity = params[:max_quantity].to_i
order.set_variant_attributes(Spree::Variant.find(variant_id),
max_quantity: max_quantity)
end
end
end

View File

@@ -55,7 +55,7 @@ class CheckoutController < ::BaseController
flash[:error] = I18n.t("checkout.failed")
action_failed(e)
ensure
@order.update!
@order.update_order!
end
# Clears the cached order. Required for #current_order to return a new order

View File

@@ -39,12 +39,8 @@ class LineItemsController < BaseController
def destroy_with_lock(item)
order = item.order
order.with_lock do
item.destroy
order.update_shipping_fees!
order.contents.remove(item.variant)
order.update_payment_fees!
order.update_order_fees!
order.update!
order.create_tax_charge!
end
end
end

View File

@@ -14,7 +14,7 @@ module Spree
def update_order
@order.reload
@order.update!
@order.update_order!
end
def collection

View File

@@ -12,7 +12,7 @@ module Spree
helper 'enterprise_fees'
helper 'angular_form'
layout '/spree/layouts/admin'
layout 'spree/layouts/admin'
include I18nHelper

View File

@@ -4,8 +4,7 @@ module Spree
def edit
@preferences_general = [:site_name, :default_seo_title, :default_meta_keywords,
:default_meta_description, :site_url]
@preferences_security = [:allow_ssl_in_production,
:allow_ssl_in_staging, :allow_ssl_in_development_and_test]
@preferences_security = [:allow_ssl_in_production, :allow_ssl_in_staging]
@preferences_currency = [:display_currency, :hide_cents]
end

View File

@@ -81,9 +81,7 @@ module Spree
end
def invoice
pdf = InvoiceRenderer.new.render_to_string(@order)
Spree::OrderMailer.invoice_email(@order.id, pdf).deliver_later
Spree::OrderMailer.invoice_email(@order.id).deliver_later
flash[:success] = t('admin.orders.invoice_email_sent')
respond_with(@order) { |format|

View File

@@ -9,6 +9,10 @@ module Spree
before_action :load_payment, only: [:fire, :show]
before_action :load_data
before_action :can_transition_to_payment
# We ensure that items are in stock before all screens if the order is in the Payment state.
# This way, we don't allow someone to enter credit card details for an order only to be told
# that it can't be processed.
before_action :ensure_sufficient_stock_lines
respond_to :html
@@ -142,6 +146,20 @@ module Spree
redirect_to spree.edit_admin_order_customer_url(@order)
end
def ensure_sufficient_stock_lines
return if !@order.payment? || @order.insufficient_stock_lines.blank?
flash[:error] = I18n.t("spree.orders.line_item.insufficient_stock",
on_hand: "0 #{out_of_stock_item_names}")
redirect_to spree.edit_admin_order_url(@order)
end
def out_of_stock_item_names
@order.insufficient_stock_lines.map do |line_item|
line_item.variant.name
end.join(", ")
end
def load_order
@order = Order.find_by!(number: params[:order_id])
authorize! action, @order

View File

@@ -14,7 +14,7 @@ module Spree
respond_to :html
respond_to :json
before_action :update_distribution, only: :update
before_action :set_current_order, only: :update
before_action :filter_order_params, only: :update
before_action :enable_embedded_shopfront
@@ -27,13 +27,7 @@ module Spree
def show
@order = Spree::Order.find_by!(number: params[:id])
if params.key?("payment_intent")
result = ProcessPaymentIntent.new(params["payment_intent"], @order).call!
unless result.ok?
flash[:error] = "#{I18n.t("payment_could_not_process")}. #{result.error}"
end
@order.reload
end
handle_stripe_response
end
def empty
@@ -44,17 +38,6 @@ module Spree
redirect_to main_app.cart_path
end
def check_authorization
session[:access_token] ||= params[:token]
order = Spree::Order.find_by(number: params[:id]) || current_order
if order
authorize! :edit, order, session[:access_token]
else
authorize! :create, Spree::Order
end
end
# Patching to redirect to shop if order is empty
def edit
@order = current_order(true)
@@ -68,7 +51,7 @@ module Spree
associate_user
if @order.insufficient_stock_lines.present? || @unavailable_order_variants.present?
flash[:error] = t("spree.orders.error_flash_for_unavailable_items")
flash.now[:error] = t("spree.orders.error_flash_for_unavailable_items")
end
end
end
@@ -83,14 +66,10 @@ module Spree
# This action is called either from the cart page when the order is not yet complete, or from
# the edit order page (frontoffice) if the hub allows users to update completed orders.
# This line item updating logic should probably be handled through CartService#populate.
if @order.update(order_params)
discard_empty_line_items
if @order.contents.update_cart(order_params)
@order.recreate_all_fees! # Enterprise fees on line items and on the order itself
if @order.complete?
@order.update_shipping_fees!
@order.update_payment_fees!
@order.create_tax_charge!
end
@@ -101,7 +80,7 @@ module Spree
@order.next_transition.run_callbacks if @order.cart?
redirect_to main_app.checkout_state_path(@order.checkout_steps.first)
elsif @order.complete?
redirect_to order_path(@order)
redirect_to main_app.order_path(@order)
else
redirect_to main_app.cart_path
end
@@ -115,24 +94,46 @@ module Spree
end
end
def update_distribution
@order = current_order(true)
def cancel
@order = Spree::Order.find_by!(number: params[:id])
authorize! :cancel, @order
if params[:commit] == 'Choose Hub'
distributor = Enterprise.is_distributor.find params[:order][:distributor_id]
@order.set_distributor! distributor
flash[:notice] = I18n.t(:order_choosing_hub_notice)
redirect_to request.referer
elsif params[:commit] == 'Choose Order Cycle'
@order.empty! # empty cart
order_cycle = OrderCycle.active.find params[:order][:order_cycle_id]
@order.set_order_cycle! order_cycle
flash[:notice] = I18n.t(:order_choosing_hub_notice)
redirect_to request.referer
if CustomerOrderCancellation.new(@order).call
flash[:success] = I18n.t(:orders_your_order_has_been_cancelled)
else
flash[:error] = I18n.t(:orders_could_not_cancel)
end
redirect_to request.referer || main_app.order_path(@order)
end
private
def set_current_order
@order = current_order(true)
end
def check_authorization
session[:access_token] ||= params[:token]
order = Spree::Order.find_by(number: params[:id]) || current_order
if order
authorize! :edit, order, session[:access_token]
else
authorize! :create, Spree::Order
end
end
# Stripe can redirect here after a payment is processed in the backoffice.
# We verify if it was successful here and persist the changes.
def handle_stripe_response
return unless params.key?("payment_intent")
result = ProcessPaymentIntent.new(params["payment_intent"], @order).call!
unless result.ok?
flash.now[:error] = "#{I18n.t("payment_could_not_process")}. #{result.error}"
end
@order.reload
end
def filter_order_params
@@ -148,20 +149,6 @@ module Spree
end
end
def cancel
@order = Spree::Order.find_by!(number: params[:id])
authorize! :cancel, @order
if CustomerOrderCancellation.new(@order).call
flash[:success] = I18n.t(:orders_your_order_has_been_cancelled)
else
flash[:error] = I18n.t(:orders_could_not_cancel)
end
redirect_to request.referer || order_path(@order)
end
private
def discard_empty_line_items
@order.line_items = @order.line_items.select { |li| li.quantity > 0 }
end
@@ -197,7 +184,7 @@ module Spree
if items.empty?
flash[:error] = I18n.t(:orders_cannot_remove_the_final_item)
redirect_to order_path(order_to_update)
redirect_to main_app.order_path(order_to_update)
end
end

View File

@@ -14,7 +14,7 @@ module Spree
def show
@payments_requiring_action = PaymentsRequiringAction.new(spree_current_user).query
@orders = orders_collection
@orders = orders_collection.includes(:line_items)
customers = spree_current_user.customers
@shops = Enterprise

View File

@@ -1,9 +1,13 @@
module Spree
module PaymentMethodsHelper
def payment_method_name(payment)
def payment_method(payment)
# hack to allow us to retrieve the name of a "deleted" payment method
id = payment.payment_method_id
Spree::PaymentMethod.find_with_destroyed(id).name
Spree::PaymentMethod.find_with_destroyed(id)
end
def payment_method_name(payment)
payment_method(payment).name
end
end
end

View File

@@ -1,6 +1,10 @@
# frozen_string_literal: true
module TermsAndConditionsHelper
def link_to_platform_terms
link_to(t("terms_of_service"), TermsOfServiceFile.current_url, target: "_blank")
end
def render_terms_and_conditions
if platform_terms_required? && terms_and_conditions_activated?
render("checkout/all_terms_and_conditions")
@@ -19,12 +23,18 @@ module TermsAndConditionsHelper
current_order.distributor.terms_and_conditions.file?
end
def terms_and_conditions_already_accepted?
customer_terms_and_conditions_accepted_at = spree_current_user&.
customer_of(current_order.distributor)&.terms_and_conditions_accepted_at
def all_terms_and_conditions_already_accepted?
platform_tos_already_accepted? && terms_and_conditions_already_accepted?
end
customer_terms_and_conditions_accepted_at.present? &&
(customer_terms_and_conditions_accepted_at >
current_order.distributor.terms_and_conditions_updated_at)
def platform_tos_already_accepted?
TermsOfService.tos_accepted?(spree_current_user&.customer_of(current_order.distributor))
end
def terms_and_conditions_already_accepted?
TermsOfService.tos_accepted?(
spree_current_user&.customer_of(current_order.distributor),
current_order.distributor
)
end
end

View File

@@ -1,8 +0,0 @@
# frozen_string_literal: true
class ConfirmOrderJob < ActiveJob::Base
def perform(order_id)
Spree::OrderMailer.confirm_email_for_customer(order_id).deliver_now
Spree::OrderMailer.confirm_email_for_shop(order_id).deliver_now
end
end

View File

@@ -10,7 +10,7 @@ module JobLogger
def self.logger
@logger ||= begin
logger = Delayed::Worker.logger.clone
logger = Rails.logger.clone
logger.formatter = Formatter.new
logger
end

View File

@@ -90,13 +90,13 @@ class SubscriptionConfirmJob < ActiveJob::Base
end
def send_confirmation_email(order)
order.update!
order.update_order!
record_success(order)
SubscriptionMailer.confirmation_email(order).deliver_now
end
def send_failed_payment_email(order, error_message = nil)
order.update!
order.update_order!
record_and_log_error(:failed_payment, order, error_message)
SubscriptionMailer.failed_payment_email(order).deliver_now
rescue StandardError => e

View File

@@ -77,7 +77,7 @@ class SubscriptionPlacementJob < ActiveJob::Base
def handle_empty_order(order, changes)
order.reload.all_adjustments.destroy_all
order.update!
order.update_order!
send_empty_email(order, changes)
end

View File

@@ -5,6 +5,8 @@ module Spree
# Inline stylesheets
include Roadie::Rails::Automatic
helper TermsAndConditionsHelper
layout 'mailer'
def from_address

View File

@@ -49,8 +49,10 @@ module Spree
end
end
def invoice_email(order_or_order_id, pdf)
def invoice_email(order_or_order_id)
@order = find_order(order_or_order_id)
pdf = InvoiceRenderer.new.render_to_string(@order)
attach_file("invoice-#{@order.number}.pdf", pdf)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.email,

View File

@@ -105,7 +105,7 @@ class Enterprise < ApplicationRecord
after_touch :touch_distributors
after_create :set_default_contact
after_create :relate_to_owners_enterprises
after_create :send_welcome_email
after_create_commit :send_welcome_email
after_rollback :restore_permalink
@@ -121,7 +121,7 @@ class Enterprise < ApplicationRecord
scope :not_ready_for_checkout, lambda {
# When ready_for_checkout is empty, return all rows when there are no enterprises ready for
# checkout.
ready_enterprises = Enterprise.ready_for_checkout.
ready_enterprises = Enterprise.default_scoped.ready_for_checkout.
except(:select).
select('DISTINCT enterprises.id')

View File

@@ -56,7 +56,7 @@ class Exchange < ApplicationRecord
scope :by_enterprise_name, -> {
joins('INNER JOIN enterprises AS sender ON (sender.id = exchanges.sender_id)').
joins('INNER JOIN enterprises AS receiver ON (receiver.id = exchanges.receiver_id)').
order("CASE WHEN exchanges.incoming='t' THEN sender.name ELSE receiver.name END")
order(Arel.sql("CASE WHEN exchanges.incoming='t' THEN sender.name ELSE receiver.name END"))
}
# Exchanges on order cycles that are dated and are upcoming or open are cached

View File

@@ -24,7 +24,7 @@ module Spree
def self.default
country = begin
Spree::Country.find(Spree::Config[:default_country_id])
DefaultCountry.country
rescue StandardError
Spree::Country.first
end

View File

@@ -96,7 +96,7 @@ module Spree
# more than on line items at once via accepted_nested_attributes the order
# object on the association would be in a old state and therefore the
# adjustment calculations would not performed on proper values
def update!(calculable = nil, force: false)
def update_adjustment!(calculable = nil, force: false)
return amount if immutable? && !force
if originator.present?
@@ -127,11 +127,7 @@ module Spree
end
def set_absolute_included_tax!(tax)
# This rubocop issue can now fixed by renaming Adjustment#update! to something else,
# then AR's update! can be used instead of update_attributes!
# rubocop:disable Rails/ActiveRecordAliases
update_attributes! included_tax: tax.round(2)
# rubocop:enable Rails/ActiveRecordAliases
update! included_tax: tax.round(2)
end
def display_included_tax

View File

@@ -33,7 +33,6 @@ module Spree
preference :allow_backorder_shipping, :boolean, default: false
preference :allow_checkout_on_gateway_error, :boolean, default: false
preference :allow_guest_checkout, :boolean, default: true
preference :allow_ssl_in_development_and_test, :boolean, default: false
preference :allow_ssl_in_production, :boolean, default: true
preference :allow_ssl_in_staging, :boolean, default: true
# Replace with the name of a zone if you would like to limit the countries

View File

@@ -87,7 +87,7 @@ module Spree
)
refund_transaction_response = provider.refund_transaction(refund_transaction)
if refund_transaction_response.success?
payment.source.update_attributes(
payment.source.update(
refunded_at: Time.now,
refund_transaction_id: refund_transaction_response.RefundTransactionID,
state: "refunded",

View File

@@ -5,7 +5,6 @@ require 'stripe/credit_card_cloner'
require 'stripe/authorize_response_patcher'
require 'stripe/payment_intent_validator'
require 'active_merchant/billing/gateways/stripe_payment_intents'
require 'active_merchant/billing/gateways/stripe_decorator'
module Spree
class Gateway
@@ -112,6 +111,7 @@ module Spree
options[:description] = "Spree Order ID: #{gateway_options[:order_id]}"
options[:currency] = gateway_options[:currency]
options[:stripe_account] = stripe_account_id
options[:execute_threed] = true # Handle 3DS responses
options
end
@@ -129,7 +129,19 @@ module Spree
payment = fetch_payment(creditcard, gateway_options)
raise Stripe::StripeError, I18n.t(:no_pending_payments) unless payment&.response_code
Stripe::PaymentIntentValidator.new.call(payment.response_code, stripe_account_id)
payment_intent_response = Stripe::PaymentIntentValidator.new.
call(payment.response_code, stripe_account_id)
raise_if_not_in_capture_state(payment_intent_response)
payment.response_code
end
def raise_if_not_in_capture_state(payment_intent_response)
state = payment_intent_response.status
return if state == 'requires_capture'
raise Stripe::StripeError, I18n.t(:invalid_payment_state, state: state)
end
def fetch_payment(creditcard, gateway_options)

View File

@@ -66,7 +66,7 @@ module Spree
end
def update_order
order.update!
order.update_order!
end
end
end

View File

@@ -17,9 +17,9 @@ module Spree
end
def update_adjustments
adjustment_total = adjustments.additional.map(&:update!).compact.sum
included_tax_total = tax_adjustments.inclusive.reload.map(&:update!).compact.sum
additional_tax_total = tax_adjustments.additional.reload.map(&:update!).compact.sum
adjustment_total = adjustments.additional.map(&:update_adjustment!).compact.sum
included_tax_total = tax_adjustments.inclusive.reload.map(&:update_adjustment!).compact.sum
additional_tax_total = tax_adjustments.additional.reload.map(&:update_adjustment!).compact.sum
item.update_columns(
included_tax_total: included_tax_total,

View File

@@ -65,10 +65,10 @@ module Spree
# Find line items that are from order sorted by variant name and unit value
scope :sorted_by_name_and_unit_value, -> {
joins(variant: :product).
reorder("
reorder(Arel.sql("
lower(spree_products.name) asc,
lower(spree_variants.display_name) asc,
spree_variants.unit_value asc")
spree_variants.unit_value asc"))
}
scope :from_order_cycle, lambda { |order_cycle|
@@ -230,7 +230,6 @@ module Spree
# update the order totals, etc.
order.create_tax_charge!
order.update!
end
def update_inventory_before_destroy

View File

@@ -35,7 +35,7 @@ module Spree
alias_attribute :shipping_address, :ship_address
has_many :state_changes, as: :stateful
has_many :line_items, -> { order('created_at ASC') }, dependent: :destroy
has_many :line_items, -> { order('created_at ASC') }, class_name: "Spree::LineItem", dependent: :destroy
has_many :payments, dependent: :destroy
has_many :return_authorizations, dependent: :destroy, inverse_of: :order
has_many :adjustments, -> { order "#{Spree::Adjustment.table_name}.created_at ASC" },
@@ -212,7 +212,7 @@ module Spree
@updater ||= OrderManagement::Order::Updater.new(self)
end
def update!
def update_order!
updater.update
end
@@ -243,63 +243,11 @@ module Spree
return_authorizations.any?(&:authorized?)
end
# This is currently used when adding a variant to an order in the BackOffice.
# Spree::OrderContents#add is equivalent but slightly different from add_variant below.
# OrderContents should always be used when modifying an order's line items
def contents
@contents ||= Spree::OrderContents.new(self)
end
# This is currently used when adding a variant to an order in the FrontOffice.
# This add_variant is equivalent but slightly different from Spree::OrderContents#add above.
# Spree::OrderContents#add is the more modern version in Spree history
# but this add_variant has been customized for OFN FrontOffice.
def add_variant(variant, quantity = 1, max_quantity = nil, currency = nil)
line_items.reload
current_item = find_line_item_by_variant(variant)
# Notify bugsnag if we get line items with a quantity of zero
if quantity == 0
Bugsnag.notify(RuntimeError.new("Zero Quantity Line Item"),
current_item: current_item.as_json,
line_items: line_items.map(&:id),
variant: variant.as_json)
end
if current_item
current_item.quantity = quantity
current_item.max_quantity = max_quantity
current_item.currency = currency unless currency.nil?
current_item.save
else
current_item = Spree::LineItem.new(quantity: quantity, max_quantity: max_quantity)
current_item.variant = variant
if currency
current_item.currency = currency unless currency.nil?
current_item.price = variant.price_in(currency).amount
else
current_item.price = variant.price
end
line_items << current_item
end
reload
current_item
end
def set_variant_attributes(variant, attributes)
line_item = find_line_item_by_variant(variant)
return unless line_item
if attributes.key?(:max_quantity) && attributes[:max_quantity].to_i < line_item.quantity
attributes[:max_quantity] = line_item.quantity
end
line_item.assign_attributes(attributes)
line_item.save!
end
# Associates the specified user with the order.
def associate_user!(user)
self.user = user
@@ -395,7 +343,8 @@ module Spree
def deliver_order_confirmation_email
return if subscription.present?
ConfirmOrderJob.perform_later(id)
Spree::OrderMailer.confirm_email_for_customer(id).deliver_later
Spree::OrderMailer.confirm_email_for_shop(id).deliver_later
end
# Helper methods for checkout steps
@@ -517,6 +466,16 @@ module Spree
shipments
end
# Clear shipments and move order back to address state unless compete. This is relevant where
# an order is part-way through checkout and the user changes items in the cart; in that case
# we need to reset the checkout flow to ensure the order is processed correctly.
def ensure_updated_shipments
if !self.completed? && shipments.any?
shipments.destroy_all
restart_checkout_flow
end
end
def refresh_shipment_rates
shipments.map(&:refresh_rates)
end
@@ -580,12 +539,6 @@ module Spree
save!
end
def remove_variant(variant)
line_items.reload
current_item = find_line_item_by_variant(variant)
current_item.andand.destroy
end
def cap_quantity_at_stock!
line_items.includes(variant: :stock_items).find_each(&:cap_quantity_at_stock!)
end
@@ -748,8 +701,8 @@ module Spree
def update_adjustment!(adjustment)
return if adjustment.finalized?
adjustment.update!(force: true)
update!
adjustment.update_adjustment!(force: true)
updater.update_totals_and_states
end
# object_params sets the payment amount to the order total, but it does this

View File

@@ -130,6 +130,13 @@ module Spree
steps << "complete" unless steps.include?("complete")
steps
end
def restart_checkout_flow
update_columns(
state: checkout_steps.first,
updated_at: Time.zone.now,
)
end
end
end
end

View File

@@ -11,25 +11,79 @@ module Spree
# Get current line item for variant if exists
# Add variant qty to line_item
def add(variant, quantity = 1, shipment = nil)
line_item = order.find_line_item_by_variant(variant)
add_to_line_item(line_item, variant, quantity, shipment)
line_item = add_to_line_item(variant, quantity, shipment)
update_shipment(shipment)
update_order
line_item
end
# Get current line item for variant
# Remove variant qty from line_item
def remove(variant, quantity = 1, shipment = nil)
line_item = order.find_line_item_by_variant(variant)
def remove(variant, quantity = nil, shipment = nil)
line_item = remove_from_line_item(variant, quantity, shipment)
update_shipment(shipment)
order.update_order_fees! if order.completed?
update_order
line_item
end
unless line_item
raise ActiveRecord::RecordNotFound, "Line item not found for variant #{variant.sku}"
def update_or_create(variant, attributes)
line_item = find_line_item_by_variant(variant)
if line_item
line_item.update(attributes)
else
line_item = Spree::LineItem.new(attributes)
line_item.variant = variant
line_item.price = variant.price
order.line_items << line_item
end
remove_from_line_item(line_item, variant, quantity, shipment)
order.reload
line_item
end
def update_cart(params)
if order.update_attributes(params)
discard_empty_line_items
update_shipment
update_order
true
else
false
end
end
def update_item(line_item, params)
if line_item.update_attributes(params)
discard_empty_line_items
order.update_line_item_fees! line_item
order.update_order_fees! if order.completed?
update_shipment
update_order
true
else
false
end
end
private
def add_to_line_item(line_item, variant, quantity, shipment = nil)
def discard_empty_line_items
order.line_items = order.line_items.select {|li| li.quantity.positive? }
end
def update_shipment(target_shipment = nil)
if order.completed? || target_shipment.present?
order.update_shipping_fees!
else
order.ensure_updated_shipments
end
end
def add_to_line_item(variant, quantity, shipment = nil)
line_item = find_line_item_by_variant(variant)
if line_item
line_item.target_shipment = shipment
line_item.quantity += quantity.to_i
@@ -40,23 +94,37 @@ module Spree
end
line_item.save
order.reload
line_item
end
def remove_from_line_item(line_item, _variant, quantity, shipment = nil)
line_item.quantity += -quantity
def remove_from_line_item(variant, quantity, shipment = nil)
line_item = find_line_item_by_variant(variant, true)
quantity.present? ? line_item.quantity += -quantity : line_item.quantity = 0
line_item.target_shipment = shipment
if line_item.quantity == 0
Spree::OrderInventory.new(order).verify(line_item, shipment)
line_item.destroy
else
line_item.save!
end
order.reload
line_item
end
def find_line_item_by_variant(variant, raise_error = false)
line_item = order.find_line_item_by_variant(variant)
if !line_item.present? && raise_error
raise ActiveRecord::RecordNotFound, "Line item not found for variant #{variant.sku}"
end
line_item
end
def update_order
order.update_order!
order.reload
end
end
end

View File

@@ -50,6 +50,7 @@ module Spree
scope :failed, -> { with_state('failed') }
scope :valid, -> { where('state NOT IN (?)', %w(failed invalid)) }
scope :authorization_action_required, -> { where.not(cvv_response_message: nil) }
scope :with_payment_intent, ->(code) { where(response_code: code) }
# order state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
state_machine initial: :checkout do
@@ -205,7 +206,7 @@ module Spree
end
def update_order
order.update!
OrderManagement::Order::Updater.new(order).after_payment_update(self)
end
# Necessary because some payment gateways will refuse payments with

View File

@@ -66,7 +66,7 @@ module Spree
order.shipped_shipments.collect{ |s| s.inventory_units.to_a }.flatten
end
# Used when Adjustment#update! wants to update the related adjustment
# Used when Adjustment#update_adjustment! wants to update the related adjustment
def compute_amount(*_args)
-amount.abs
end
@@ -105,7 +105,7 @@ module Spree
)
order.return if inventory_units.all?(&:returned?)
order.update!
order.update_order!
end
def allow_receive?

View File

@@ -160,10 +160,6 @@ module Spree
Spree::Money.new(item_cost, currency: currency)
end
def editable_by?(_user)
!shipped?
end
def update_amounts
return unless fee_adjustment&.amount != cost
@@ -187,14 +183,6 @@ module Spree
@scoper ||= OpenFoodNetwork::ScopeVariantToHub.new(order.distributor)
end
def line_items
if order.complete?
order.line_items.select { |li| inventory_units.pluck(:variant_id).include?(li.variant_id) }
else
order.line_items
end
end
def finalize!
InventoryUnit.finalize_units!(inventory_units)
manifest.each { |item| manifest_unstock(item) }
@@ -295,6 +283,15 @@ module Spree
private
def line_items
if order.complete?
inventory_unit_ids = inventory_units.pluck(:variant_id)
order.line_items.select { |li| inventory_unit_ids.include?(li.variant_id) }
else
order.line_items
end
end
def manifest_unstock(item)
stock_location.unstock item.variant, item.quantity, self
end
@@ -309,7 +306,7 @@ module Spree
record = true
while record
random = "H#{Array.new(11) { rand(9) }.join}"
record = self.class.find_by(number: random)
record = self.class.default_scoped.find_by(number: random)
end
self.number = random
end

View File

@@ -50,7 +50,7 @@ module Spree
category = TaxCategory.includes(:tax_rates).find_by(is_default: true)
return 0 unless category
address ||= Address.new(country_id: Spree::Config[:default_country_id])
address ||= Address.new(country_id: DefaultCountry.id)
rate = category.tax_rates.detect { |tax_rate| tax_rate.zone.include? address }.try(:amount)
rate || 0

View File

@@ -0,0 +1,22 @@
# frozen_string_literal: true
class TermsOfServiceFile < ApplicationRecord
has_attached_file :attachment
validates :attachment, presence: true
# The most recently uploaded file is the current one.
def self.current
order(:id).last
end
def self.current_url
current&.attachment&.url || Spree::Config.footer_tos_url
end
# If no file has been uploaded, we don't know when the old terms have
# been updated last. So we return the most recent possible update time.
def self.updated_at
current&.updated_at || Time.zone.now
end
end

View File

@@ -1,5 +1,5 @@
class Api::LineItemSerializer < ActiveModel::Serializer
attributes :id, :quantity, :max_quantity, :price
attributes :id, :quantity, :max_quantity, :price, :order_id
has_one :variant, serializer: Api::VariantSerializer
end

View File

@@ -22,7 +22,7 @@ module Api
end
def item_count
object.line_items.sum(:quantity)
object.line_items.sum(&:quantity)
end
def completed_at

View File

@@ -3,10 +3,9 @@ require "open_food_network/scope_variant_to_hub"
class Api::ProductSerializer < ActiveModel::Serializer
attributes :id, :name, :permalink, :meta_keywords
attributes :group_buy, :notes, :description, :description_html
attributes :properties_with_values, :price
attributes :properties_with_values
has_many :variants, serializer: Api::VariantSerializer
has_one :master, serializer: Api::VariantSerializer
has_one :primary_taxon, serializer: Api::TaxonSerializer
has_many :taxons, serializer: Api::IdSerializer
@@ -32,18 +31,6 @@ class Api::ProductSerializer < ActiveModel::Serializer
options[:variants][object.id] || []
end
def master
options[:master_variants][object.id].andand.first
end
def price
if options[:enterprise_fee_calculator]
object.master.price + options[:enterprise_fee_calculator].indexed_fees_for(object.master)
else
object.master.price_with_fees(options[:current_distributor], options[:current_order_cycle])
end
end
private
def sanitizer

View File

@@ -3,23 +3,22 @@ require 'open_food_network/scope_variant_to_hub'
# Previously Spree::OrderPopulator. Modified to work with max_quantity and variant overrides.
class CartService
attr_accessor :order, :currency
attr_reader :variants_h
attr_accessor :order
attr_reader :errors
def initialize(order)
@order = order
@currency = order.currency
@errors = ActiveModel::Errors.new(self)
end
def populate(from_hash, overwrite = false)
def populate(from_hash)
@distributor, @order_cycle = distributor_and_order_cycle
variants_data = read_variants_hash(from_hash)
@order.with_lock do
variants_data = read_variants from_hash
attempt_cart_add_variants variants_data
overwrite_variants variants_data if overwrite
overwrite_variants variants_data
end
valid?
end
@@ -34,10 +33,10 @@ class CartService
loaded_variants = indexed_variants(variants_data)
variants_data.each do |variant_data|
loaded_variant = loaded_variants[variant_data[:variant_id].to_i]
loaded_variant = loaded_variants[variant_data[:variant_id]]
if loaded_variant.deleted?
remove_deleted_variant(loaded_variant)
if loaded_variant.deleted? || !variant_data[:quantity].positive?
cart_remove(loaded_variant)
next
end
@@ -57,15 +56,7 @@ class CartService
end
end
def remove_deleted_variant(variant)
line_item_for_variant(variant).andand.destroy
end
def attempt_cart_add(variant, quantity, max_quantity = nil)
quantity = quantity.to_i
max_quantity = max_quantity.to_i if max_quantity
return unless quantity > 0
scoper.scope(variant)
return unless valid_variant?(variant)
@@ -73,27 +64,37 @@ class CartService
end
def cart_add(variant, quantity, max_quantity)
quantity_to_add, max_quantity_to_add = quantities_to_add(variant, quantity, max_quantity)
if quantity_to_add > 0
@order.add_variant(variant, quantity_to_add, max_quantity_to_add, currency)
attributes = final_quantities(variant, quantity, max_quantity)
if attributes[:quantity].positive?
@order.contents.update_or_create(variant, attributes)
else
@order.remove_variant variant
cart_remove(variant)
end
end
def quantities_to_add(variant, quantity, max_quantity)
def cart_remove(variant)
begin
order.contents.remove(variant)
rescue ActiveRecord::RecordNotFound
# Nothing to remove; no line items for this variant were found.
end
end
def final_quantities(variant, quantity, max_quantity)
# If not enough stock is available, add as much as we can to the cart
on_hand = variant.on_hand
on_hand = [quantity, max_quantity].compact.max if variant.on_demand
quantity_to_add = [quantity, on_hand].min
max_quantity_to_add = max_quantity # max_quantity is not capped
final_quantity = [quantity, on_hand].min
final_max_quantity = max_quantity # max_quantity is not capped
[quantity_to_add, max_quantity_to_add]
{ quantity: final_quantity, max_quantity: final_max_quantity }
end
def overwrite_variants(variants)
variants_removed(variants).each do |id|
cart_remove(id)
variants_removed(variants).each do |variant_id|
variant = Spree::Variant.with_deleted.find(variant_id)
cart_remove(variant)
end
end
@@ -101,27 +102,25 @@ class CartService
@scoper ||= OpenFoodNetwork::ScopeVariantToHub.new(@distributor)
end
def read_variants(data)
@variants_h = read_variants_hash(data)
end
def read_variants_hash(data)
variants_array = []
(data[:variants] || []).each do |variant_id, quantity|
if quantity.is_a?(ActionController::Parameters)
variants_array.push({ variant_id: variant_id, quantity: quantity[:quantity], max_quantity: quantity[:max_quantity] })
variants_array.push({
variant_id: variant_id.to_i,
quantity: quantity[:quantity].to_i,
max_quantity: quantity[:max_quantity].to_i
})
else
variants_array.push({ variant_id: variant_id, quantity: quantity })
variants_array.push({
variant_id: variant_id.to_i,
quantity: quantity.to_i
})
end
end
variants_array
end
def cart_remove(variant_id)
variant = Spree::Variant.find(variant_id)
@order.remove_variant(variant)
end
def distributor_and_order_cycle
[@order.distributor, @order.order_cycle]
end
@@ -131,7 +130,7 @@ class CartService
li = line_item_for_variant loaded_variant
li_added = li.nil? && (variant_data[:quantity].to_i > 0 || variant_data[:max_quantity].to_i > 0)
li_quantity_changed = li.present? && li.quantity.to_i != variant_data[:quantity].to_i
li_quantity_changed = li.present? && li.quantity != variant_data[:quantity].to_i
li_max_quantity_changed = li.present? && li.max_quantity.to_i != variant_data[:max_quantity].to_i
li_added || li_quantity_changed || li_max_quantity_changed

View File

@@ -0,0 +1,13 @@
class DefaultCountry
def self.id
country.id
end
def self.code
country.iso
end
def self.country
Spree::Country.find_by(iso: ENV["DEFAULT_COUNTRY_CODE"]) || Spree::Country.first
end
end

View File

@@ -2,9 +2,8 @@
# by setting entries on the Spree Config
# and initializing Spree:MailSettings that uses the Spree::Config.
class MailConfiguration
# @param entries [Hash] Spree Config entries
def self.entries=(entries)
entries.each do |name, value|
def self.apply!
configuration.each do |name, value|
Spree::Config[name] = value
end
apply_mail_settings
@@ -12,6 +11,21 @@ class MailConfiguration
private
def self.configuration
{
mail_host: ENV.fetch('MAIL_HOST'),
mail_domain: ENV.fetch('MAIL_DOMAIN'),
mail_port: ENV.fetch('MAIL_PORT'),
mail_auth_type: ENV.fetch('MAIL_AUTH_TYPE', 'login'),
smtp_username: ENV.fetch('SMTP_USERNAME'),
smtp_password: ENV.fetch('SMTP_PASSWORD'),
secure_connection_type: ENV.fetch('MAIL_SECURE_CONNECTION', 'None'),
mails_from: ENV.fetch('MAILS_FROM', "no-reply@#{ENV.fetch('MAIL_DOMAIN')}"),
mail_bcc: ENV.fetch('MAIL_BCC', ''),
intercept_email: ''
}
end
def self.apply_mail_settings
Spree::Core::MailSettings.init
end

View File

@@ -13,7 +13,7 @@ class OrderCheckoutRestart
clear_shipments
clear_payments
order.reload.update!
order.reload.update_order!
end
private

View File

@@ -19,12 +19,9 @@ class OrderFeesHandler
create_line_item_fees!
create_order_fees!
order.updater.update_totals
order.updater.persist_totals
end
order.update!
order.update_order!
end
def create_line_item_fees!
@@ -43,13 +40,13 @@ class OrderFeesHandler
def update_line_item_fees!(line_item)
line_item.adjustments.enterprise_fee.each do |fee|
fee.update!(line_item, force: true)
fee.update_adjustment!(line_item, force: true)
end
end
def update_order_fees!
order.adjustments.enterprise_fee.where(adjustable_type: 'Spree::Order').each do |fee|
fee.update!(order, force: true)
fee.update_adjustment!(order, force: true)
end
end

View File

@@ -15,6 +15,7 @@ class OrderSyncer
distributor_id: shop_id)
update_associations_for(order)
line_item_syncer.sync!(order)
order.update_order!
order.save
end
end

View File

@@ -44,7 +44,7 @@ module Permissions
def filtered_orders(orders)
return orders unless filter_orders?
orders.complete.not_state(:canceled).search(search_params).result
orders.complete.not_state(:canceled).ransack(search_params).result
end
def filter_orders?

View File

@@ -23,21 +23,20 @@ class ProcessPaymentIntent
end
end
def initialize(payment_intent, order, last_payment = nil)
def initialize(payment_intent, order)
@payment_intent = payment_intent
@order = order
@last_payment = last_payment.presence || OrderPaymentFinder.new(order).last_payment
@payment = order.payments.pending.with_payment_intent(payment_intent).first
end
def call!
validate_intent!
return Result.new(ok: false) unless valid?
return Result.new(ok: false) unless payment.present? && ready_for_capture?
return Result.new(ok: true) if already_processed?
OrderWorkflow.new(order).next
process_payment
if last_payment.can_complete?
last_payment.complete!
last_payment.mark_as_processed
if payment.reload.completed?
payment.mark_as_processed
Result.new(ok: true)
else
@@ -50,18 +49,29 @@ class ProcessPaymentIntent
private
attr_reader :order, :payment_intent, :last_payment
attr_reader :order, :payment_intent, :payment
def valid?
order.present? && matches_last_payment?
def process_payment
if order.state == "payment"
# Moves the order to completed, which calls #process_payments!
OrderWorkflow.new(order).next
else
order.process_payments!
end
end
def validate_intent!
Stripe::PaymentIntentValidator.new.call(payment_intent, stripe_account_id)
def ready_for_capture?
payment_intent_status == 'requires_capture'
end
def matches_last_payment?
last_payment&.state == "pending" && last_payment&.response_code == payment_intent
def already_processed?
payment_intent_status == 'succeeded'
end
def payment_intent_status
@payment_intent_status ||= Stripe::PaymentIntentValidator.new.
call(payment_intent, stripe_account_id).
status
end
def stripe_account_id
@@ -69,6 +79,6 @@ class ProcessPaymentIntent
end
def preferred_enterprise_id
last_payment.payment_method.preferred_enterprise_id
payment.payment_method.preferred_enterprise_id
end
end

View File

@@ -19,7 +19,6 @@ class ProductsRenderer
current_order_cycle: order_cycle,
current_distributor: distributor,
variants: variants_for_shop_by_id,
master_variants: master_variants_for_shop_by_id,
enterprise_fee_calculator: enterprise_fee_calculator).to_json
end
@@ -31,7 +30,9 @@ class ProductsRenderer
return unless order_cycle
@products ||= begin
results = distributed_products.products_relation.order(taxon_order)
results = distributed_products.
products_relation.
order(Arel.sql(taxon_order))
filter_and_paginate(results).
each { |product| product_scoper.scope(product) } # Scope results with variant_overrides
@@ -84,10 +85,6 @@ class ProductsRenderer
index_by_product_id variants_for_shop.reject(&:is_master)
end
def master_variants_for_shop_by_id
index_by_product_id variants_for_shop.select(&:is_master)
end
def index_by_product_id(variants)
variants.each_with_object({}) do |v, vs|
vs[v.product_id] ||= []

View File

@@ -77,6 +77,6 @@ class TaxRateFinder
approximation = (included_tax / (amount - included_tax))
return [] if approximation.infinite? || approximation.zero? || approximation.nan?
[Spree::TaxRate.order("ABS(amount - #{approximation})").first]
[Spree::TaxRate.order(Arel.sql("ABS(amount - #{approximation})")).first]
end
end

View File

@@ -0,0 +1,11 @@
class TermsOfService
def self.tos_accepted?(customer, distributor = nil)
return false unless accepted_at = customer&.terms_and_conditions_accepted_at
if distributor
accepted_at > distributor.terms_and_conditions_updated_at
else
accepted_at > TermsOfServiceFile.updated_at
end
end
end

View File

@@ -10,7 +10,7 @@
= "admin.enterprises"
= admin_inject_available_countries(module: 'admin.enterprises')
= admin_inject_json "admin.enterprises", "defaultCountryID", Spree::Config[:default_country_id]
= admin_inject_json "admin.enterprises", "defaultCountryID", DefaultCountry.id
-# Form

View File

@@ -0,0 +1,16 @@
- content_for :page_title do
= t(".title")
.admin-current-terms-of-service
- if @current_file
%p= t(".current_terms_html", tos_link: link_to(t(".terms_of_service"), @current_file.attachment.url), datetime: @current_file.updated_at)
%p= link_to t(".delete"), main_app.admin_terms_of_service_files_path, method: "delete", data: { confirm: t(".confirm_delete") }
- else
%p
= t(".no_files")
= t(".using_default_terms_html", tos_link: link_to_platform_terms)
= form_for [main_app, :admin, @new_file] do |f|
= f.label :attachment
= f.file_field :attachment
= f.submit

View File

@@ -1,4 +1,4 @@
%p
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted=false" } }
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted = #{all_terms_and_conditions_already_accepted?}" } }
%label.small{for: "accept_terms"}
= t('.message_html', terms_and_conditions_link: link_to( t(".terms_and_conditions"), current_order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to(t(".terms_of_service"), Spree::Config.footer_tos_url, target: "_blank"))
= t('.message_html', terms_and_conditions_link: link_to( t(".terms_and_conditions"), current_order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to_platform_terms)

View File

@@ -38,7 +38,7 @@
= validated_input t(:postcode), "order.bill_address.zipcode"
.small-6.columns.right
= validated_select t(:country), "order.bill_address.country_id", {}, {"ng-init" => "order.bill_address.country_id = order.bill_address.country_id || #{Spree::Config[:default_country_id]}", "ng-options" => "c.id as c.name for c in countries"}
= validated_select t(:country), "order.bill_address.country_id", {}, {"ng-init" => "order.bill_address.country_id = order.bill_address.country_id || #{DefaultCountry.id}", "ng-options" => "c.id as c.name for c in countries"}
.row
.small-12.columns.text-right

View File

@@ -1,4 +1,4 @@
%p
%input{ type: "checkbox", id: "platform_tos_accepted", ng: { model: "platform_tos_accepted", init: "platform_tos_accepted = false" } }
%input{ type: "checkbox", id: "platform_tos_accepted", ng: { model: "platform_tos_accepted", init: "platform_tos_accepted = #{platform_tos_already_accepted?}" } }
%label.small{for: "platform_tos_accepted"}
= t(".message_html", tos_link: link_to(t(".terms_of_service"), Spree::Config.footer_tos_url, target: "_blank"))
= t(".message_html", tos_link: link_to_platform_terms)

View File

@@ -22,7 +22,7 @@
.small-6.columns
= validated_input t(:postcode), "order.ship_address.zipcode"
.small-6.columns.right
= validated_select t(:country), "order.ship_address.country_id", {}, {"ng-init" => "order.ship_address.country_id = order.ship_address.country_id || #{Spree::Config[:default_country_id]}", "ng-options" => "c.id as c.name for c in countries"}
= validated_select t(:country), "order.ship_address.country_id", {}, {"ng-init" => "order.ship_address.country_id = order.ship_address.country_id || #{DefaultCountry.id}", "ng-options" => "c.id as c.name for c in countries"}
.row
.small-6.columns
= validated_input t(:phone), "order.ship_address.phone"

View File

@@ -42,8 +42,7 @@
%tr
%td{:align => "center"}
%p
%a{:href => "#{ URI.join(main_app.root_url, Spree::Config.footer_tos_url).to_s }", :target => "_blank"}
= t :terms_of_service
= link_to_platform_terms
|
%a{:href => "#{ main_app.root_url }"}
= Spree::Config[:site_name]

View File

@@ -53,7 +53,7 @@
.small-12.medium-8.large-8.columns
.field
%label{ for: 'enterprise_country' }= t(".country_field")
%select.chunky{ id: 'enterprise_country', name: 'country', required: true, ng: { init: "setDefaultCountry(#{Spree::Config[:default_country_id]})", model: 'enterprise.country', options: 'c as c.name for c in countries' } }
%select.chunky{ id: 'enterprise_country', name: 'country', required: true, ng: { init: "setDefaultCountry(#{DefaultCountry.id})", model: 'enterprise.country', options: 'c as c.name for c in countries' } }
%span.error{ ng: { show: "details.country.$error.required && submitted" } }
= t(".country_field_error")

View File

@@ -42,7 +42,7 @@
.small-12.medium-6.columns{'ng-hide' => '!tos_required' }
%p.tos-message
#{t(:enterprise_tos_message)}
%a{href: Spree::Config.footer_tos_url, target: "_blank" } #{t(:enterprise_tos_link_text)}
= link_to_platform_terms
%p.tos-checkbox
%input{ type: 'checkbox', name: 'accept_terms', id: 'accept_terms', ng: { model: "tos_accepted" } }
%label{for: "accept_terms"} #{t(:enterprise_tos_agree)}

View File

@@ -100,8 +100,7 @@
.small-12.medium-5.columns.text-left
%p.text-small
= t '.footer_legal_call'
%a{href: Spree::Config.footer_tos_url, target: "_blank"}
= t '.footer_legal_tos'
= link_to_platform_terms
&#124;
= t '.footer_legal_visit'
%a{href:"https://github.com/openfoodfoundation/openfoodnetwork", target: "_blank"} GitHub

View File

@@ -1,5 +1,5 @@
- if Rails.env.test?
%script{type: "text/javascript"}
= render file: "spec/support/fixtures/stripejs-mock.js"
= raw render file: "spec/support/fixtures/stripejs-mock.js"
- else
%script{src: "https://js.stripe.com/v3/", type: "text/javascript"}

View File

@@ -23,17 +23,16 @@
%span.quantity {{ line_item.quantity }}
%td
.total-price.text-right {{ line_item.total_price | localizeCurrency }}
- if feature? :unit_price, spree_current_user
.unit-price
%div{:style => "margin-right: 5px"}
%question-mark-with-tooltip{"question-mark-with-tooltip" => "_",
"question-mark-with-tooltip-append-to-body" => "true",
"question-mark-with-tooltip-placement" => "top",
"question-mark-with-tooltip-animation" => true,
key: "'js.shopfront.unit_price_tooltip'",
context: "'cart-sidebar'"}
.options-text
{{ line_item.variant.unit_price_price | localizeCurrency }}&nbsp;/&nbsp;{{ line_item.variant.unit_price_unit }}
.unit-price
%div{:style => "margin-right: 5px"}
%question-mark-with-tooltip{"question-mark-with-tooltip" => "_",
"question-mark-with-tooltip-append-to-body" => "true",
"question-mark-with-tooltip-placement" => "top",
"question-mark-with-tooltip-animation" => true,
key: "'js.shopfront.unit_price_tooltip'",
context: "'cart-sidebar'"}
.options-text
{{ line_item.variant.unit_price_price | localizeCurrency }}&nbsp;/&nbsp;{{ line_item.variant.unit_price_unit }}
.cart-empty{"ng-show" => "Cart.line_items.length == 0"}
%p

View File

@@ -13,10 +13,7 @@
%product.animate-repeat{"ng-controller" => "ProductNodeCtrl", "ng-repeat" => "product in Products.products track by product.id", "id" => "product-{{ product.id }}"}
= render "shop/products/summary"
.shop-variants
- if feature? :unit_price, spree_current_user
%shop-variant-with-unit-price{showunitprice: 'true', variant: 'variant', "ng-repeat" => "variant in product.variants | orderBy: ['name_to_display','unit_value'] track by variant.id", "id" => "variant-{{ variant.id }}", "ng-class" => "{'out-of-stock': !variant.on_demand && variant.on_hand == 0}"}
- else
%shop-variant{variant: 'variant', "ng-repeat" => "variant in product.variants | orderBy: ['name_to_display','unit_value'] track by variant.id", "id" => "variant-{{ variant.id }}", "ng-class" => "{'out-of-stock': !variant.on_demand && variant.on_hand == 0}"}
%shop-variant{variant: 'variant', "ng-repeat" => "variant in product.variants | orderBy: ['name_to_display','unit_value'] track by variant.id", "id" => "variant-{{ variant.id }}", "ng-class" => "{'out-of-stock': !variant.on_demand && variant.on_hand == 0}"}
%product{"ng-show" => "Products.loading"}
.summary
.small-12.columns.text-center

View File

@@ -26,9 +26,6 @@
= label_tag(key, Spree.t(key)) + tag(:br) if type == :boolean
%fieldset.legal.no-border-bottom
%legend{:align => "center"}= t('.legal_settings')
.field
= label_tag(:footer_tos_url, t('.footer_tos_url')) + tag(:br)
= preference_field_tag(:footer_tos_url, Spree::Config[:footer_tos_url], type: Spree::Config.preference_type(:footer_tos_url))
.field
= preference_field_tag(:enterprises_require_tos, Spree::Config[:enterprises_require_tos], :type => Spree::Config.preference_type(:enterprises_require_tos))
= label_tag(:enterprises_require_tos, t('.enterprises_require_tos')) + tag(:br)

View File

@@ -26,4 +26,4 @@
var shipments = [];
- @order.shipments.each do |shipment|
shipments.push(#{shipment.to_json(:root => false, :include => [:inventory_units, :stock_location]).html_safe});
= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:erb]
= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:erb], :formats => [:js]

View File

@@ -152,7 +152,7 @@
%th.final_weight_volume{ 'ng-show' => 'columns.final_weight_volume.visible' }
= t("admin.orders.bulk_management.weight_volume")
%th.price{ 'ng-show' => 'columns.price.visible' }
= "#{t('admin.price')} (#{currency_symbol})"
= "#{t('admin.price')} (#{Spree::Money.currency_symbol})"
%th.actions
%th.actions
= t("admin.orders.bulk_management.ask")

View File

@@ -25,8 +25,7 @@
%span.centered.three.columns
= t "spree_admin_enterprises_fees"
%div.sixteen.columns.alpha.list
- @enterprises.each do |enterprise|
= render 'enterprise_row', { enterprise: enterprise }
= render partial: 'enterprise_row', collection: @enterprises, as: :enterprise
%a.sixteen.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_enterprises_path}" }
= t "spree_admin_overview_enterprises_footer"

View File

@@ -16,7 +16,7 @@
%br
%select.fullwidth{ id: 'category_filter', 'ofn-select2-min-search' => 5, ng: {model: 'q.categoryFilter', options: 'taxon.id as taxon.name for taxon in taxons'} }
.filter_select.three.columns
%label{ for: 'import_filter' } Import Date
%label{ for: 'import_filter' }= t 'import_date'
%br
%select.fullwidth{ id: 'import_date_filter', 'ofn-select2-min-search' => 5, ng: {model: 'q.importDateFilter', init: "importDates = #{@import_dates}; showLatestImport = #{@show_latest_import}", options: 'date.id as date.name for date in importDates'} }

View File

@@ -52,20 +52,19 @@
%br/
= f.text_field :price, { "class" => "fullwidth", "ng-model" => "product.price" }
= f.error_message_on :price
- if feature? :unit_price, spree_current_user
.four.columns{ ng: { app: 'ofn.admin'}}
= f.field_container :unit_price do
%div{style: "display: flex"}
= f.label :unit_price, t(".unit_price")
%question-mark-with-tooltip{"question-mark-with-tooltip" => "_",
"question-mark-with-tooltip-append-to-body" => "true",
"question-mark-with-tooltip-placement" => "top",
"question-mark-with-tooltip-animation" => true,
key: "'js.admin.unit_price_tooltip'"}
%input{ "type" => "text", "id" => "product_unit_price", "name" => "product[unit_price]",
"class" => 'fullwidth', "disabled" => true, "ng-model" => "unit_price"}
%div{style: "color: black"}
= t(".unit_price_legend")
.four.columns{ ng: { app: 'ofn.admin'}}
= f.field_container :unit_price do
%div{style: "display: flex"}
= f.label :unit_price, t(".unit_price")
%question-mark-with-tooltip{"question-mark-with-tooltip" => "_",
"question-mark-with-tooltip-append-to-body" => "true",
"question-mark-with-tooltip-placement" => "top",
"question-mark-with-tooltip-animation" => true,
key: "'js.admin.unit_price_tooltip'"}
%input{ "type" => "text", "id" => "product_unit_price", "name" => "product[unit_price]",
"class" => 'fullwidth', "disabled" => true, "ng-model" => "unit_price"}
%div{style: "color: black"}
= t(".unit_price_legend")
.sixteen.columns.alpha
.three.columns
- if Spree::TaxCategory.any?

View File

@@ -5,14 +5,15 @@
%nav.menu
%ul.sidebar
= configurations_sidebar_menu_item Spree.t(:general_settings), edit_admin_general_settings_path
= configurations_sidebar_menu_item t(".terms_of_service"), main_app.admin_terms_of_service_files_path
= configurations_sidebar_menu_item Spree.t(:mail_method_settings), edit_admin_mail_methods_path
= configurations_sidebar_menu_item Spree.t(:tax_categories), admin_tax_categories_path
= configurations_sidebar_menu_item Spree.t(:tax_rates), admin_tax_rates_path
= configurations_sidebar_menu_item Spree.t(:tax_settings), edit_admin_tax_settings_path
= configurations_sidebar_menu_item Spree.t(:zones), admin_zones_path
= configurations_sidebar_menu_item Spree.t(:countries), admin_countries_path
- if Spree::Config[:default_country_id]
= configurations_sidebar_menu_item Spree.t(:states), admin_country_states_path(Spree::Config[:default_country_id])
- if DefaultCountry.id
= configurations_sidebar_menu_item Spree.t(:states), admin_country_states_path(DefaultCountry.id)
= configurations_sidebar_menu_item Spree.t(:payment_methods), admin_payment_methods_path
= configurations_sidebar_menu_item Spree.t(:taxonomies), admin_taxonomies_path
= configurations_sidebar_menu_item Spree.t(:shipping_methods), admin_shipping_methods_path

View File

@@ -34,22 +34,21 @@
.field
= f.label :price, t('.price')
= f.text_field :price, class: 'fullwidth', "ng-model" => "variant.price", "ng-init" => "variant.price = '#{number_to_currency(@variant.price, unit: '')}'"
- if feature? :unit_price, spree_current_user
.field
= hidden_field_tag 'product_variant_unit', @product.variant_unit
= hidden_field_tag 'product_variant_unit_name', @product.variant_unit_name
= f.field_container :unit_price do
%div{style: "display: flex"}
= f.label :unit_price, t(".unit_price"), {style: "display: inline-block"}
%question-mark-with-tooltip{"question-mark-with-tooltip" => "_",
"question-mark-with-tooltip-append-to-body" => "true",
"question-mark-with-tooltip-placement" => "top",
"question-mark-with-tooltip-animation" => true,
key: "'js.admin.unit_price_tooltip'"}
%input{ "type" => "text", "id" => "variant_unit_price", "name" => "variant[unit_price]",
"class" => 'fullwidth', "disabled" => true, "ng-model" => "unit_price"}
%div{style: "color: black"}
= t("spree.admin.products.new.unit_price_legend")
.field
= hidden_field_tag 'product_variant_unit', @product.variant_unit
= hidden_field_tag 'product_variant_unit_name', @product.variant_unit_name
= f.field_container :unit_price do
%div{style: "display: flex"}
= f.label :unit_price, t(".unit_price"), {style: "display: inline-block"}
%question-mark-with-tooltip{"question-mark-with-tooltip" => "_",
"question-mark-with-tooltip-append-to-body" => "true",
"question-mark-with-tooltip-placement" => "top",
"question-mark-with-tooltip-animation" => true,
key: "'js.admin.unit_price_tooltip'"}
%input{ "type" => "text", "id" => "variant_unit_price", "name" => "variant[unit_price]",
"class" => 'fullwidth', "disabled" => true, "ng-model" => "unit_price"}
%div{style: "color: black"}
= t("spree.admin.products.new.unit_price_legend")
%div{ 'set-on-demand' => '' }
.field.checkbox
%label

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