Compare commits

...

560 Commits

Author SHA1 Message Date
Jean-Baptiste Bellet
8a5608435c Update all locales with the latest Transifex translations 2023-05-03 17:30:48 +02:00
Konrad
d02d0b8847 Merge pull request #10763 from openfoodfoundation/dependabot/bundler/ddtrace-1.11.0
Bump ddtrace from 1.10.1 to 1.11.0
2023-05-03 17:27:13 +02:00
Konrad
4b6ef7796e Merge pull request #10762 from mkllnk/report-encoding
Preserve encoding of stored reports
2023-05-03 17:08:44 +02:00
Konrad
b60a6fbd05 Merge pull request #10329 from thejwuscript/9861-improve-input-validation
Improve input validation on new and edit Payment Method pages
2023-05-03 16:11:21 +02:00
jibees
2e267091f6 Merge pull request #10795 from openfoodfoundation/dependabot/bundler/knapsack_pro-3.10.0
Bump knapsack_pro from 3.9.0 to 3.10.0
2023-05-03 14:31:11 +02:00
dependabot[bot]
eb3fe1b7a5 Bump knapsack_pro from 3.9.0 to 3.10.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 3.9.0 to 3.10.0.
- [Release notes](https://github.com/KnapsackPro/knapsack_pro-ruby/releases)
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.9.0...v3.10.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-03 10:06:11 +00:00
jibees
62c2d9a290 Merge pull request #10782 from openfoodfoundation/dependabot/bundler/sidekiq-7.1.0
Bump sidekiq from 7.0.9 to 7.1.0
2023-05-03 09:56:07 +02:00
jibees
a329aab007 Merge pull request #10774 from openfoodfoundation/dependabot/npm_and_yarn/babel/core-7.21.5
Bump @babel/core and @babel/preset-env from 7.21.4 to 7.21.5
2023-05-03 09:26:10 +02:00
Maikel Linke
e24198fe85 Bump @babel/preset-env from 7.21.4 to 7.21.5
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.21.4 to 7.21.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.21.5/packages/babel-preset-env)

I did this manually:

```
$ yarn upgrade "@babel/preset-env"
yarn upgrade v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > stimulus_reflex@3.5.0-rc2" has unmet peer dependency "@hotwired/stimulus@>= 3.0".
[4/4] Rebuilding all packages...
success Saved lockfile.
success Saved 35 new dependencies.
info Direct dependencies
└─ @babel/preset-env@7.21.5
info All dependencies
├─ @babel/code-frame@7.21.4
├─ @babel/helper-builder-binary-assignment-operator-visitor@7.21.5
├─ @babel/helper-function-name@7.21.0
├─ @babel/helper-module-imports@7.21.4
├─ @babel/helper-replace-supers@7.21.5
├─ @babel/helper-string-parser@7.21.5
├─ @babel/helper-wrap-function@7.20.5
├─ @babel/highlight@7.18.6
├─ @babel/parser@7.21.5
├─ @babel/plugin-transform-arrow-functions@7.21.5
├─ @babel/plugin-transform-computed-properties@7.21.5
├─ @babel/plugin-transform-for-of@7.21.5
├─ @babel/plugin-transform-modules-commonjs@7.21.5
├─ @babel/plugin-transform-regenerator@7.21.5
├─ @babel/plugin-transform-unicode-escapes@7.21.5
├─ @babel/preset-env@7.21.5
├─ @babel/regjsgen@0.8.0
├─ @babel/template@7.20.7
├─ @babel/traverse@7.21.5
├─ @jridgewell/resolve-uri@3.1.0
├─ color-convert@1.9.3
├─ escape-string-regexp@1.0.5
├─ is-core-module@2.12.0
├─ js-tokens@4.0.0
├─ jsesc@2.5.2
├─ ms@2.1.2
├─ regenerate-unicode-properties@10.1.0
├─ regenerator-runtime@0.13.11
├─ regexpu-core@5.3.2
├─ regjsparser@0.9.1
├─ to-fast-properties@2.0.0
├─ unicode-canonical-property-names-ecmascript@2.0.0
├─ unicode-match-property-ecmascript@2.0.0
├─ unicode-match-property-value-ecmascript@2.1.0
└─ unicode-property-aliases-ecmascript@2.1.0
Done in 16.54s.
```
2023-05-03 15:33:57 +10:00
dependabot[bot]
a9bf7a2498 Bump @babel/core from 7.21.4 to 7.21.5
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.21.4 to 7.21.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.21.5/packages/babel-core)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-03 12:18:41 +10:00
Konrad
21a0017352 Merge pull request #10756 from jibees/10743-admin-add-unregistered-users-modal-some-html-is-rendered-as-plain-text-instead-of-being
Admin, Add unregistered user: Fix a reflex-morph issue that lead to a HTML escaping error
2023-05-02 19:28:48 +02:00
Konrad
d115c4ce2c Merge pull request #10733 from jibees/9782-shops-list-overlapping-and-overflowing-texts-on-mobile2
Shops list: fix some overlapping and overflowing texts on mobile
2023-05-02 12:15:19 +02:00
dependabot[bot]
b05d46c3e3 Bump sidekiq from 7.0.9 to 7.1.0
Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.0.9 to 7.1.0.
- [Release notes](https://github.com/sidekiq/sidekiq/releases)
- [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md)
- [Commits](https://github.com/sidekiq/sidekiq/compare/v7.0.9...v7.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-02 09:57:28 +00:00
jibees
aae0fc59fb Merge pull request #10768 from Matt-Yorkley/query-logs
Improve query logging in development
2023-05-02 11:44:19 +02:00
Gaetan Craig-Riou
d1f7cc1b2a Merge pull request #10764 from Matt-Yorkley/remove-data-hooks
Remove `data-hook` attributes
2023-05-02 16:35:46 +10:00
Gaetan Craig-Riou
964481f188 Merge pull request #10765 from Matt-Yorkley/update-webpack-packages
Update webpack packages
2023-05-02 15:19:37 +10:00
Maikel
9bca22ae3b Merge pull request #10775 from openfoodfoundation/dependabot/bundler/mini_portile2-2.8.2
Bump mini_portile2 from 2.8.1 to 2.8.2
2023-05-02 11:54:37 +10:00
dependabot[bot]
064c843c90 Bump mini_portile2 from 2.8.1 to 2.8.2
Bumps [mini_portile2](https://github.com/flavorjones/mini_portile) from 2.8.1 to 2.8.2.
- [Release notes](https://github.com/flavorjones/mini_portile/releases)
- [Changelog](https://github.com/flavorjones/mini_portile/blob/main/CHANGELOG.md)
- [Commits](https://github.com/flavorjones/mini_portile/compare/v2.8.1...v2.8.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-01 10:02:13 +00:00
Maikel
482d438ec9 Merge pull request #10766 from filipefurtad0/remove_asertion_on_js_element_loading_orders
Removes assertions on transient JS element - "Loading orders"
2023-05-01 13:36:44 +10:00
Konrad
1176ea2a5f Merge pull request #9941 from basilawwad/conditionally-send-cancellation-email
Conditionally send cancellation email when cancelling order.
2023-04-28 21:54:42 +02:00
Matt-Yorkley
f42a9e3a66 Add query_count gem in development
A very simple gem that counts the total number of queries triggered by each request and displays a little number in the log. Nice.
2023-04-28 15:02:02 +01:00
Matt-Yorkley
8d9a8d8db5 Enable verbose query logs in development
This is a new feature in Rails 7. Whenever a query is triggered it not only show you the query (as before), but also tells you (directly in the logs) exactly which line of code was responsible for triggering the query. It's unbelievably useful for debugging and performance work.
2023-04-28 14:35:16 +01:00
Matt-Yorkley
b9431cd121 Remove data-hook attributes 2023-04-28 13:03:13 +01:00
filipefurtad0
74d18fb6ff Removes assertions on transient JS element 2023-04-28 12:48:59 +01:00
Matt-Yorkley
5e26e49764 Update webpack packages
`webpack-cli` is a dependency of `@rails/webpacker` but needs to be at version 3.x, we can just cut it from the explicit dependecy list and the correct version will be installed.

`webpack-dev-server` version 3.x corresponds (unhelpfully) to `webpacker` 4.x, and needs to be left that way. Dependabot tries to change it occasionally, but it should not be updated to 4.x
2023-04-28 12:48:21 +01:00
dependabot[bot]
c9dada4215 Bump ddtrace from 1.10.1 to 1.11.0
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 1.10.1 to 1.11.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/v1.10.1...v1.11.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-28 10:00:28 +00:00
Maikel Linke
630169f8bb Preserve encoding of stored reports
Active Storage reads stored strings as ASCII and that can clash with
Rails' default UTF-8 encoding when special characters are present.
2023-04-28 16:38:06 +10:00
Gaetan Craig-Riou
152af5e105 Merge pull request #10751 from mkllnk/mail-config
Remove unused feature to intercept emails
2023-04-28 16:28:41 +10:00
David Cook
918425fd93 Remove customised error message
We're now handling these values on the frontend, so can keep this simple.

fixes up:
 Add numericality validation for *
 Add translation for Active Record error message
2023-04-28 14:02:12 +10:00
David Cook
a46eef291c Remove localized number logic from calculators
The browser is now responsible for dealing with the decimal separator, for all numeric preferences (as input[type=number]; see Spree::Admin::BaseHelper::preference_field_tag). Calculators are the only place that numeric preferences are used.

It will enforce that only one comma or dot (depending on user's locale) is entered, thus avoiding any ambiguity, and mis-interpretation (eg 100,001 could be interpreted as more than 100 thousand or 100 with a decimal place).
2023-04-28 13:54:16 +10:00
David Cook
d2fbb0bde2 Update translations
js: admin: orders: order_state: confirmation
2023-04-27 14:49:28 +10:00
David Cook
c42dfdde10 Merge pull request #10748 from openfoodfoundation/dependabot/bundler/view_component-3.0.0
Bump view_component from 2.82.0 to 3.0.0
2023-04-27 14:46:09 +10:00
Jean-Baptiste Bellet
959dcb82e1 Morph the form itself instead of morphing a parent DOM element
This seems to avoid HTML parsing error
2023-04-26 17:41:28 +02:00
jibees
51d5817665 Merge pull request #10755 from openfoodfoundation/dependabot/bundler/i18n-1.13.0
Bump i18n from 1.12.0 to 1.13.0
2023-04-26 15:45:59 +02:00
jibees
a8384b3155 Merge pull request #10754 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.2.7
Bump @floating-ui/dom from 1.2.6 to 1.2.7
2023-04-26 15:44:04 +02:00
Konrad
394bfd00d8 Merge pull request #10586 from jibees/10563-allow-custom-url-on-logo-click
White Label: can link an URL to the white label logo
2023-04-26 13:52:10 +02:00
dependabot[bot]
bda1a527d3 Bump i18n from 1.12.0 to 1.13.0
Bumps [i18n](https://github.com/ruby-i18n/i18n) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/ruby-i18n/i18n/releases)
- [Changelog](https://github.com/ruby-i18n/i18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ruby-i18n/i18n/compare/v1.12.0...v1.13.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 09:57:48 +00:00
dependabot[bot]
77bd832dd6 Bump @floating-ui/dom from 1.2.6 to 1.2.7
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.2.6 to 1.2.7.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.2.7/packages/dom)

---
updated-dependencies:
- dependency-name: "@floating-ui/dom"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 09:57:09 +00:00
Jean-Baptiste Bellet
b1de28eeea When there is a white_label_logo_link pref. use it!
+ update spec as well

 + use an an helper to get the main logo link for a shopfront

Co-Authored-By: Maikel <maikel@email.org.au>
2023-04-26 11:04:47 +02:00
Jean-Baptiste Bellet
679fcc0114 When removing the logo, also delete white_label_logo_link preference
since it has no sense without the logo
2023-04-26 11:04:47 +02:00
Jean-Baptiste Bellet
35778ecf1d If enterprise has a white_label_logo attached, then can edit its link 2023-04-26 11:04:47 +02:00
Jean-Baptiste Bellet
70a6e9f44b Add a white_label_logo_link attribute to enterprise model 2023-04-26 11:04:47 +02:00
Jean-Baptiste Bellet
30ba29382a Avoid name collision by renaming some classes with a prefix flex-
This classes should only be used with `.flex`
2023-04-26 09:52:24 +02:00
Jean-Baptiste Bellet
9584205a8e Use .flex class in utilities.scss file
No need to have multiple definition as already included
2023-04-26 09:51:28 +02:00
Jean-Baptiste Bellet
3644dbc0fd Small fix of a prettier formatter error 2023-04-26 09:51:17 +02:00
Jean-Baptiste Bellet
05a7276c9c Create an utilities.scss file that contains some utility classes
Finally Tailwind is coming? ;)
2023-04-26 09:47:23 +02:00
David Cook
1fc60d498a Merge pull request #10746 from openfoodfoundation/dependabot/bundler/rswag-specs-2.9.0
Bump rswag-specs from 2.8.0 to 2.9.0
2023-04-26 14:08:30 +10:00
Maikel Linke
dae8703b02 Remove unused feature to intercept emails
This option came from Spree and we never used it. The config input field
is disabled in the admin interface and I checked our managed databases.

I don't think that we will want this feature in the future either.
Staging sends unmodified emails which is more realistic and we haven't
had a use case to intercept those emails. There's still the BCC option
if we need additional access.
2023-04-26 13:50:31 +10:00
Maikel
3078c599f9 Merge pull request #10747 from openfoodfoundation/dependabot/bundler/rswag-ui-2.9.0
Bump rswag-ui from 2.8.0 to 2.9.0
2023-04-26 12:04:09 +10:00
dependabot[bot]
5d91ac217d Bump rswag-specs from 2.8.0 to 2.9.0
Bumps [rswag-specs](https://github.com/rswag/rswag) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/rswag/rswag/releases)
- [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rswag/rswag/compare/2.8.0...2.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 02:03:53 +00:00
Maikel
f2edb6d404 Merge pull request #10745 from openfoodfoundation/dependabot/bundler/rswag-api-2.9.0
Bump rswag-api from 2.8.0 to 2.9.0
2023-04-26 12:02:38 +10:00
David Cook
7cd1b5d5db Update link
The old project was closed in favour of a new one.
2023-04-26 09:44:58 +10:00
dependabot[bot]
ad82f66173 Bump rswag-api from 2.8.0 to 2.9.0
Bumps [rswag-api](https://github.com/rswag/rswag) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/rswag/rswag/releases)
- [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rswag/rswag/compare/2.8.0...2.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-25 10:10:17 +00:00
dependabot[bot]
62bfa9e04c Bump view_component from 2.82.0 to 3.0.0
Bumps [view_component](https://github.com/viewcomponent/view_component) from 2.82.0 to 3.0.0.
- [Release notes](https://github.com/viewcomponent/view_component/releases)
- [Changelog](https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/viewcomponent/view_component/compare/v2.82.0...v3.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-25 09:38:51 +00:00
dependabot[bot]
28c9d72342 Bump rswag-ui from 2.8.0 to 2.9.0
Bumps [rswag-ui](https://github.com/rswag/rswag) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/rswag/rswag/releases)
- [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rswag/rswag/compare/2.8.0...2.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-25 09:38:22 +00:00
jibees
7317d6ca34 Merge pull request #10742 from filipefurtad0/fix_broken_build
Considers recent changes on login test helpers
2023-04-25 11:36:56 +02:00
filipefurtad0
edb8da4b4d Considers recent changes on login test helpers
PR #10696 introduced changes on the login helpers which were not considered, when merging a recent PR; This broke the build
2023-04-24 18:35:10 +01:00
Konrad
00d5bd9165 Merge pull request #10684 from MadisonBowron/master
Fix admin product variants form to close issues #10579 & Wishlist: 430
2023-04-24 18:18:01 +02:00
Jean-Baptiste Bellet
1730c9eb60 Fix one warning: Modal window with text has been opened, ...
```
Modal window with text `An invoice for this order will be sent to the customer. Are you sure you want to continue?` has been opened, but you didn't wrap your code into (`accept_prompt` | `dismiss_prompt` | `accept_confirm` | `dismiss_confirm` | `accept_alert`), accepting by default
```
2023-04-24 15:18:35 +02:00
Jean-Baptiste Bellet
5b9815f4a3 Test that restock has been called or not, depending on checkbox checked 2023-04-24 15:03:14 +02:00
jibees
445eb45ad7 Merge pull request #10737 from openfoodfoundation/dependabot/npm_and_yarn/prettier-2.8.8
Bump prettier from 2.8.7 to 2.8.8
2023-04-24 14:43:20 +02:00
jibees
8770471ada Merge pull request #10738 from openfoodfoundation/dependabot/npm_and_yarn/karma-6.4.2
Bump karma from 6.4.1 to 6.4.2
2023-04-24 14:43:07 +02:00
dependabot[bot]
6d45940ca4 Bump karma from 6.4.1 to 6.4.2
Bumps [karma](https://github.com/karma-runner/karma) from 6.4.1 to 6.4.2.
- [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.4.1...v6.4.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-24 09:58:22 +00:00
dependabot[bot]
69383ac621 Bump prettier from 2.8.7 to 2.8.8
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.7 to 2.8.8.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.7...2.8.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-24 09:58:05 +00:00
Maikel
945cb84127 Merge pull request #10683 from filipefurtad0/update-the-build-env-to-ubuntu-2204
Updates build environment to Ubuntu 22.04
2023-04-24 15:27:05 +10:00
Maikel
343a2db1bf Merge pull request #10722 from mkllnk/rubocop-autocorrect-script
Add script for bulk autocorrect with Rubocop
2023-04-24 10:58:43 +10:00
Maikel Linke
de8f5e13b3 Explain gotcha in case it breaks one day 2023-04-24 09:39:21 +10:00
Konrad
75b5d1fd6f Merge pull request #10712 from jibees/6133-backoffice-orders-endless-spinner-and-error-500-after-skipping-oc-selector
Admin, create new order: distributor and order cycle are now mandatory on step 1 (aka the set_distribution step)
2023-04-22 16:04:15 +02:00
Konrad
0c1606e50c Merge pull request #10728 from jibees/10718-missing-translation-confirmation-order-state
Admin, `/orders`: adds translation for order in `confirmation` state
2023-04-22 11:56:23 +02:00
jibees
fa05554f15 Merge pull request #10734 from openfoodfoundation/dependabot/npm_and_yarn/karma-chrome-launcher-3.2.0
Bump karma-chrome-launcher from 3.1.1 to 3.2.0
2023-04-21 14:13:19 +02:00
Jean-Baptiste Bellet
2cc509de15 Do not check Metrics/BlockLength for shared_examples_for block
They can contains a lot of `it` tests
2023-04-21 11:59:24 +02:00
dependabot[bot]
41afad73e4 Bump karma-chrome-launcher from 3.1.1 to 3.2.0
Bumps [karma-chrome-launcher](https://github.com/karma-runner/karma-chrome-launcher) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/karma-runner/karma-chrome-launcher/releases)
- [Changelog](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma-chrome-launcher/compare/v3.1.1...v3.2.0)

---
updated-dependencies:
- dependency-name: karma-chrome-launcher
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-21 09:57:29 +00:00
Jean-Baptiste Bellet
b17b25516f Use a UTF-8 character 2023-04-21 10:37:20 +02:00
Jean-Baptiste Bellet
8444fca19a Fix syntax error 2023-04-21 10:36:47 +02:00
Jean-Baptiste Bellet
18d90114fe Be more responsive: use flex, ellipsis, less columns 2023-04-21 10:36:21 +02:00
Gaetan Craig-Riou
2f17a02974 Merge pull request #10726 from mkllnk/spec-email-helper
Remove useless email test setup
2023-04-21 15:43:19 +10:00
Gaetan Craig-Riou
135bc7e2f8 Removing env variable $runs_on
Seting "env" under "jobs" doesn't work it gets picked up as a job. I moved
runs_on to the top level env. but I couldn't fine a way to get it to work.
I tried all syntax I could think of: $runs_on, ${{ runs_on }}  env.runs_on,
${{ env.runs_on }} and their capitalized versions.
2023-04-21 15:14:20 +10:00
Gaetan Craig-Riou
3810d79cad Merge pull request #10695 from macanudo527/rename_inversables
Rename Inversable Method Names
2023-04-21 11:38:58 +10:00
Maikel Linke
4960402643 Update translations 2023-04-21 09:45:45 +10:00
jibees
3557c10cd6 Merge pull request #10730 from openfoodfoundation/dependabot/bundler/stringex-2.8.6
Bump stringex from 2.8.5 to 2.8.6
2023-04-20 15:50:19 +02:00
jibees
45dd421f1f Merge pull request #10729 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.121.0
Bump aws-sdk-s3 from 1.120.1 to 1.121.0
2023-04-20 15:48:46 +02:00
Jean-Baptiste Bellet
81606e841a Canceling an order: clicking on cancel btn or cancel action in dropdown 2023-04-20 14:38:59 +02:00
basilawwad
e633670e01 Use a shared_examples for the order cancellation tests 2023-04-20 14:38:59 +02:00
Filipe
11653c9430 Merge pull request #10575 from jibees/10559-allow-upload-of-custom-header-logo
White Label: can upload a custom header logo
2023-04-20 13:27:52 +01:00
dependabot[bot]
d068094044 Bump stringex from 2.8.5 to 2.8.6
Bumps [stringex](https://github.com/rsl/stringex) from 2.8.5 to 2.8.6.
- [Release notes](https://github.com/rsl/stringex/releases)
- [Commits](https://github.com/rsl/stringex/compare/v2.8.5...v2.8.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-20 10:06:33 +00:00
dependabot[bot]
b892bf726e Bump aws-sdk-s3 from 1.120.1 to 1.121.0
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.120.1 to 1.121.0.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-s3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-20 10:00:05 +00:00
basilawwad
fa373518fb applied modal function
Update variant_autocomplete.js.erb

Applied modal function

refactored function

fix indentation and removed old function
2023-04-20 11:46:02 +02:00
Jean-Baptiste Bellet
76357789a3 Avoid line break between state wording and its little colored circle 2023-04-20 09:09:29 +02:00
Jean-Baptiste Bellet
5dd7246b85 Rename confirm to use confirmation
`confirmation` is the state used by order model
2023-04-20 09:07:01 +02:00
Jean-Baptiste Bellet
ba45dd84dd Solves rubocop linter errors 2023-04-20 08:46:19 +02:00
Jean-Baptiste Bellet
92e2a83e0e Use Rails7 command for image variant syntax 2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
f42f513f8c Display white_label_logo image when hide_ofn_navigation is set to true
for both desktop and mobile view
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
54342254b6 Do not show white label logo is hide_ofn_navigation is not checked
They are both strongly linked
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
470761da86 Add a simple CheckboxDisplay controller that show/hide content
depending on the checkbox state (checked or not)
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
6fdf9fa038 Add/Remove white label logo in enterprise preferences panel 2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
bbec01a9cb Create a concern for reflexes that handle Enterprise update 2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
e3001cc8c4 Add white_label_logo to enterprise model as attachment
Co-Authored-By: Maikel <maikel@email.org.au>
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
ad0d0e393e ConfirmModalComponent is ready to receive data-reflex
And not only `data-action`
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
2690ff5eb5 Add comment, which links these two files together 2023-04-20 08:45:03 +02:00
jibees
2594382488 Merge pull request #10723 from openfoodfoundation/dependabot/bundler/sidekiq-7.0.9
Bump sidekiq from 7.0.8 to 7.0.9
2023-04-20 08:31:46 +02:00
Maikel Linke
9b3cfe80ff Remove useless clearing of test emails
They are cleared by the test environment anyway.
2023-04-20 13:35:40 +10:00
Maikel Linke
04d33adaf2 Remove duplicate declaration of test mail delivery
Our test environment sets the mail delivery method already. We don't
have to do it in individual spec files.
2023-04-20 13:28:59 +10:00
Maikel Linke
915bd19d7b Remove useless email test setup
We always deliver emails these days.
2023-04-20 12:18:04 +10:00
Maikel Linke
9998025687 Remove useless test header setup for emails
Once upon a time we needed a helper to set the `from` header of emails.
This is now set in the ApplicationMailer and not necessary any more.
2023-04-20 12:15:34 +10:00
Maikel
89cb3b7c14 Merge pull request #10707 from mkllnk/mailer-previews
Fix ShipmentMailer preview autoload path
2023-04-20 11:30:25 +10:00
Maikel Linke
1955a6719c Fix commit message formatting
Git needs a blank line between the summary and the longer description.
And `echo` doesn't interpret `\n` by default.
2023-04-20 11:19:32 +10:00
Maikel Linke
f71e5ee43c Limit number of rubocop autocorrect runs
The typical use case is to create a small number of commits for a pull
request to ease the review. And you can still run it for all cops with
`-n 999` or `-n -0`.
2023-04-20 11:19:32 +10:00
Maikel Linke
0ac2358f2c Regenerate Rubocop's TODO file without timestamp 2023-04-20 10:34:35 +10:00
Filipe
3e0b358370 Merge pull request #10461 from vviekk/9978
Updating price, on_hand, on_demand validations for product import
2023-04-19 16:09:49 +01:00
Filipe
f206b7ed9e Merge pull request #10661 from mkllnk/report-download
[Hidden] Provide download link for reports generated in the background
2023-04-19 11:53:14 +01:00
dependabot[bot]
946b69242c Bump sidekiq from 7.0.8 to 7.0.9
Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.0.8 to 7.0.9.
- [Release notes](https://github.com/sidekiq/sidekiq/releases)
- [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md)
- [Commits](https://github.com/sidekiq/sidekiq/compare/v7.0.8...v7.0.9)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-19 09:58:13 +00:00
Filipe
a409d3b97e Merge pull request #10201 from saunmanoj888/fix-invalid-image-upload
Fix corrupt and invalid image upload issue
2023-04-19 10:45:04 +01:00
Jean-Baptiste Bellet
a27b64a66b Add confirmation state translation 2023-04-19 11:32:51 +02:00
Jean-Baptiste Bellet
0f54d3950d Save can have a context: simplify then 2023-04-19 10:15:35 +02:00
Jean-Baptiste Bellet
7e306693a8 Use Rails standard naming: same name for the route and the method 2023-04-19 10:15:35 +02:00
Maikel
1f661c1e69 Merge pull request #10716 from jibees/10048-stimulusreflex-caching-warning
Adds caching by default in development environment to avoid StimulusReflex warning
2023-04-19 16:22:37 +10:00
saunmanoj888
97f51d24b8 Validate image on creating product from products/new 2023-04-19 16:11:46 +10:00
saunmanoj888
c3d274c84f Fix corrupt and invalid image upload issue 2023-04-19 16:11:46 +10:00
Maikel Linke
213fb42a05 Safely autocorrect Gemspec/RequireMFA
Inspecting 1404 files
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................W.....................W....................................W...........................W.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

engines/catalog/catalog.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |s| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/catalog/catalog.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
s.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/dfc_provider/dfc_provider.gemspec:9:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |spec| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/dfc_provider/dfc_provider.gemspec:21:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
spec.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/order_management/order_management.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |s| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/order_management/order_management.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
s.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/web/web.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |s| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/web/web.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
s.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1404 files inspected, 8 offenses detected, 8 offenses corrected
2023-04-19 15:35:30 +10:00
Maikel Linke
bde46fa1e9 Safely autocorrect Gemspec/DeprecatedAttributeAssignment
Inspecting 1404 files
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................W.....................W....................................W...........................W.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

engines/catalog/catalog.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec.
  s.test_files = Dir["test/**/*"]
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/dfc_provider/dfc_provider.gemspec:17:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec.
  spec.test_files = Dir['spec/**/*']
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/order_management/order_management.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec.
  s.test_files = Dir["spec/**/*"]
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/web/web.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec.
  s.test_files = Dir["test/**/*"]
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1404 files inspected, 4 offenses detected, 4 offenses corrected
2023-04-19 15:35:29 +10:00
Maikel Linke
dc560d3793 Safely autocorrect Bundler/OrderedGems
Inspecting 1404 files
.C..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

Gemfile:18:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem angular-rails-templates should appear before rexml.
gem 'angular-rails-templates', '>= 0.3.0'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:19:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem awesome_nested_set should appear before rexml.
gem 'awesome_nested_set'
^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:20:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem ransack should appear before rexml.
gem 'ransack', '~> 2.6.0'
^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:21:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem responders should appear before rexml.
gem 'responders'
^^^^^^^^^^^^^^^^
Gemfile:74:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem omniauth-rails_csrf_protection should appear before openid_connect.
gem 'omniauth-rails_csrf_protection'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:154:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before factory_bot_rails.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:155:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before fuubar.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:156:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before json_spec.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:157:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before knapsack_pro.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:158:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before letter_opener.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:159:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rspec-rails.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:160:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rspec-retry.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:161:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rswag-specs.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:162:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before shoulda-matchers.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:163:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before timecop.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:179:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem foreman should appear before rails-erd.
  gem 'foreman'
  ^^^^^^^^^^^^^
Gemfile:180:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem listen should appear before rails-erd.
  gem 'listen'
  ^^^^^^^^^^^^
Gemfile:181:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem pry should appear before rails-erd.
  gem 'pry', '~> 0.13.0'
  ^^^^^^^^^^^^^^^^^^^^^^

1404 files inspected, 18 offenses detected, 18 offenses corrected
2023-04-19 15:35:29 +10:00
Maikel Linke
52f134fc9e Regenerate Rubocop's TODO file 2023-04-19 15:35:29 +10:00
Maikel Linke
c08e264afa Add script for bulk autocorrect with Rubocop
We also had an old script which wasn't used and needed manual steps.
2023-04-19 15:35:29 +10:00
Maikel
0b03152f3b Merge pull request #10697 from mkllnk/rubocop-config-update
Update Rubocop config and replace deprecated TimeWithZone#to_s with argument
2023-04-19 11:23:34 +10:00
Maikel
6f492d868c Merge pull request #10688 from mkllnk/application-mailer
Apply Rails standard to base mailer class
2023-04-19 10:29:16 +10:00
jibees
dab2a4af75 Merge pull request #10693 from jibees/10658-move-all-managed-instances-to-fully-enabled-split_checkout-toggle
Activate `split_checkout` feature by default
2023-04-18 17:33:48 +02:00
Jean-Baptiste Bellet
f7935bde34 Enable caching dy default, to avoid StimulusReflex warning
```
Heads up! 🔥

👉 StimulusReflex requires caching to be enabled. Caching allows the session to be modified during ActionCable requests.

To enable caching in development, run:

rails dev:cache
```

Documentation: https://docs.stimulusreflex.com/hello-world/setup.html#manual-configuration
2023-04-18 16:02:02 +02:00
Jean-Baptiste Bellet
61850f7e92 Remove duplicate line
Probably due to a bad merge conflict resolution

Line is already on line `#25`
2023-04-18 16:01:04 +02:00
Neal Chambers
4e32bfd70b Rename Inversable Method Names 2023-04-18 22:58:06 +09:00
jibees
7df456c1e3 Merge pull request #10715 from openfoodfoundation/dependabot/bundler/puma-6.2.2
Bump puma from 6.2.1 to 6.2.2
2023-04-18 15:04:17 +02:00
Konrad
2fa86492d1 Merge pull request #10653 from openfoodfoundation/10645-pagination-in-bom-not-aggregating-results-when-clicking-a-productvariant
BOM: When selecting a specific variant, trigger a new search that avoid pagination issues
2023-04-18 14:49:14 +02:00
Jean-Baptiste Bellet
722c660697 Do not show any links to other steps when no distribution set
distribution means tuple: distributor + order cycle
2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
ac666a6fce Validate presence of distributor and order_cycle in set_distribution step 2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
ba1d985932 update the set_distribution form on the same path
and use the same method `OrdersController#set_distribution`
2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
0f28d318ac Fix rubocop error and prefer using a return clause 2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
6172d1f2e5 Extract method on_update that will be used elsewhere 2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
05a040b4c3 No need to ensure if the distribution is set on new action
This will be handled by validation on set_distribution action
2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
73a81310f8 Create a new url /orders/ORDER_ID/distribution
That handles the step when distributor and order_cycle must be selected
2023-04-18 14:21:23 +02:00
dependabot[bot]
85860692ae Bump puma from 6.2.1 to 6.2.2
Bumps [puma](https://github.com/puma/puma) from 6.2.1 to 6.2.2.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v6.2.1...v6.2.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 09:59:41 +00:00
jibees
8ad4d2cc2e Merge pull request #10708 from openfoodfoundation/dependabot/npm_and_yarn/webpack-dev-server-4.13.3
Bump webpack-dev-server from 4.13.2 to 4.13.3
2023-04-18 10:15:01 +02:00
David Cook
c967eca9c4 Merge pull request #10713 from openfoodfoundation/dependabot/npm_and_yarn/ansi-regex-4.1.1
Bump ansi-regex from 4.1.0 to 4.1.1 (security patch)
2023-04-18 15:34:24 +10:00
David Cook
7fff82eec3 Merge pull request #10710 from openfoodfoundation/dependabot/bundler/rubocop-1.50.2
Bump rubocop from 1.50.1 to 1.50.2
2023-04-18 15:24:40 +10:00
dependabot[bot]
c30ed0f7c8 Bump rubocop from 1.50.1 to 1.50.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.50.1 to 1.50.2.
- [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.50.1...v1.50.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 04:51:38 +00:00
David Cook
cde420716b Merge pull request #10709 from openfoodfoundation/dependabot/bundler/rubocop-rails-2.19.1
Bump rubocop-rails from 2.19.0 to 2.19.1
2023-04-18 14:50:11 +10:00
David Cook
ee37c5d4a3 Merge pull request #10699 from dacook/sass-deprecations
Sass deprecations
2023-04-18 11:48:56 +10:00
dependabot[bot]
e9d236f761 Bump ansi-regex from 4.1.0 to 4.1.1
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 00:05:00 +00:00
Gaetan Craig-Riou
8b78c28feb Merge pull request #10702 from openfoodfoundation/dependabot/npm_and_yarn/cable_ready-5.0.0
Bump cable_ready from 5.0.0-rc2 to 5.0.0
2023-04-18 10:02:59 +10:00
David Cook
43e51cb592 Simplify login spec helpers, avoid long lines
Follow on from 5c6d9a092e
2023-04-18 10:01:23 +10:00
David Cook
6570891349 Fix linter issues
Although I don't think the size was an issue here, small hashes can easily fit on one line.
2023-04-18 09:50:08 +10:00
David Cook
0f3e2ae572 Use browser validation for calculator values
They're all numbers, so we can reliably validate in the browser, removing the need for additional validation logic.
They will still be validated server-side, and in the unlikely even that there is an error, the generic 'Calculator is invalid' message will appear, with the relevant fields highlighted red. I think that's fine.
2023-04-18 09:50:08 +10:00
David Cook
f0110d20a2 Move config to base helper
This config is relevant for all specs, including system specs.
2023-04-18 09:50:08 +10:00
David Cook
353acfd6ae Validate associated calculator with built in error handling
Except that pesky generic message was appearing. I still don't know how to control that so just deleted it.
2023-04-18 09:39:39 +10:00
David Cook
e43a018dc7 [wip] Copy each calculator error
But we still have the duplicate problem.
Wait a minute, it copies them in the same format that I am copying them. So.. I don't need to copy them at all!

Now I see that we just needed the right format in the translation file.
2023-04-18 09:39:39 +10:00
David Cook
f6fac018ea [wip] Use a custom message format for associated errors
This is much simpler. Multiple messages get combined onto one line though, which is not perfect.

And.. it still seems to duplicate the errors. Weird, it's fine on my frontend though.
2023-04-18 09:39:39 +10:00
David Cook
ce1bd12760 Consolidate specs
It takes time to set up this test case. Given that there's no interactions in the expectations, we should save time to generate it only once.
2023-04-18 09:39:39 +10:00
David Cook
364ccc2146 Add comment 2023-04-18 09:39:39 +10:00
James Wu
2a7cb50fa9 Keep and display submitted data on new payment method page 2023-04-18 09:39:39 +10:00
James Wu
29ddc68d20 Fix duplicate validation error message 2023-04-18 09:39:39 +10:00
James Wu
d40f3414ea fixup! Add translation for Active Record error message 2023-04-18 09:39:39 +10:00
James Wu
f5e2edb028 fixup! Modify Calculator validation error messages [wip]
DC: the error message has now become "Amount Invalid input".
2023-04-18 09:39:39 +10:00
James Wu
7af26e6579 Add errors for invalid input with number localization enabled 2023-04-18 09:39:39 +10:00
James Wu
824d4adf21 Rename spec file 2023-04-18 09:39:39 +10:00
James Wu
00cc8da2fc Fix rubocop class length error 2023-04-18 09:39:39 +10:00
James Wu
ae5f2cc19d Fix error saving data on new Calculator 2023-04-18 09:39:39 +10:00
James Wu
41ce4fbc16 Fix cache issue with invalid form data 2023-04-18 09:39:39 +10:00
James Wu
48753df5f0 Improve input validation and error notification 2023-04-18 09:39:39 +10:00
James Wu
1f3e66316b Modify Calculator validation error messages 2023-04-18 09:39:39 +10:00
James Wu
6b1426d0c6 Add numericality validation for PriceSack 2023-04-18 09:39:39 +10:00
James Wu
c68987c0f2 Add numericality validation for PerItem 2023-04-18 09:39:39 +10:00
James Wu
2cb25e6366 Add numericality validation for FlexiRate 2023-04-18 09:39:39 +10:00
James Wu
073f46e590 Add numericality validation for FlatRate 2023-04-18 09:39:39 +10:00
James Wu
23beea8a13 Add numericality validation for FlatPercentPerItem 2023-04-18 09:39:39 +10:00
James Wu
096e388fdf Add numericality validation for FlatPercentItemTotal 2023-04-18 09:39:39 +10:00
James Wu
3dfaf882a3 Add translation for Active Record error message 2023-04-18 09:39:39 +10:00
James Wu
7b51f45b4d Fix spelling in test description 2023-04-18 09:39:39 +10:00
James Wu
b9b2fa7c94 Fix error converting String to BigDecimal 2023-04-18 09:39:39 +10:00
James Wu
ee30d3d139 Fix PaymentMethodFactory creating extra Calculator 2023-04-18 09:39:39 +10:00
Filipe
871b2f8816 Merge pull request #10696 from mkllnk/login-as-admin
Simplify login test helpers
2023-04-17 12:14:06 +01:00
dependabot[bot]
214bdc6fbe Bump rubocop-rails from 2.19.0 to 2.19.1
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.19.0 to 2.19.1.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.19.0...v2.19.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-17 10:01:45 +00:00
dependabot[bot]
d2fce053a7 Bump webpack-dev-server from 4.13.2 to 4.13.3
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.13.2 to 4.13.3.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.13.2...v4.13.3)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-17 09:57:50 +00:00
Jean-Baptiste Bellet
11a7aa9f96 When clicking on "Clear Filters" button, to not reset variant selection
+ add some specs to cover that particular case
2023-04-17 11:08:17 +02:00
Jean-Baptiste Bellet
c0203e7091 Refactor by putting two specs into a shared_example
"It's a Surprise Tool That Will Help Us Later"
2023-04-17 11:06:23 +02:00
Maikel
44cc5cc665 Merge pull request #10677 from mkllnk/spec-helpers
Simplify spec helpers
2023-04-17 16:16:29 +10:00
Maikel Linke
6c8e383ab8 Fix ShipmentMailer preview autoload path
The Zeitwerk autoloader requires class names and file names to match. In
this case, the class had a Spree namespace without being in a spree
folder. The preview couldn't be displayed. Now it can be displayed.
2023-04-17 15:18:22 +10:00
Maikel Linke
5c6d9a092e Simplify login spec helpers, avoid long lines
The `login_as_admin_and_visit` helper was used a lot but isn't really
shorter than:

    login_as_admin
    visit path_visit

Calling those methods separately reduces line length. It also removes
the potential impression that it may be more efficient to use the
helper. Now we have less indirection if one of the calls fails and see
the failing spec line straight away.
2023-04-17 11:08:32 +10:00
Maikel Linke
8d500a2c27 Remove superflouous login test helper
It was often used with a `visit` statement after which resulted in
unnecessary page loads. There was only one case where a `visit` was
expected but it wasn't needed either.
2023-04-17 10:56:51 +10:00
Maikel Linke
425674c4e5 Remove unused return value of admin login helper
Well, there was one use of the return helper. But I don't think that
it's a very intuitive method.
2023-04-17 10:56:51 +10:00
Konrad
e91e827f29 Merge pull request #10664 from abdellani/fix-remove-duplicated-cusomter-from-mailing-list-report
Fix Repeated customer entries on Mailing List Report
2023-04-16 21:17:33 +02:00
Konrad
8f201c830a Merge pull request #10665 from abdellani/fix-remove-duplicated-cusomter-from-addresses-list-report
Fix Repeated customer entries on Addresses List Report
2023-04-16 20:40:56 +02:00
Konrad
1b536d9265 Merge pull request #10601 from abdellani/fix-v1-customers-endpoint-should-only-return-managed-enterprise-customers
fix: v1/customers endpoint should load customers of managed enterprises only
2023-04-16 16:22:02 +02:00
Mohamed ABDELLANI
1b8a9244a6 test when user is a non-persisted object 2023-04-15 06:16:40 +01:00
dependabot[bot]
a40e883d17 Bump cable_ready from 5.0.0-rc2 to 5.0.0
Bumps [cable_ready](https://github.com/stimulusreflex/cable_ready) from 5.0.0-rc2 to 5.0.0.
- [Release notes](https://github.com/stimulusreflex/cable_ready/releases)
- [Changelog](https://github.com/stimulusreflex/cable_ready/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stimulusreflex/cable_ready/commits/v5.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-14 09:57:54 +00:00
Jean-Baptiste Bellet
6bf21d2abd SASS loader: Do not print warnings from dependencies 2023-04-14 11:09:39 +02:00
David Cook
29b9777a96 Replace deprecated sass division operator
https://sass-lang.com/documentation/breaking-changes/slash-div
> Sass currently treats / as a division operation in some contexts and a separator in others. This makes it difficult for Sass users to tell what any given / will mean, and makes it hard to work with new CSS features that use / as a separator.

There's a handy migrator:

    npm install -g sass-migrator
    sass-migrator division **/*.scss

And it cleverly avoids the need for the ugly division method in most cases.
2023-04-14 17:59:01 +10:00
David Cook
283dd84ad6 Add expected whitespace
The migrator refused to proceed until I fixed this.
2023-04-14 17:56:24 +10:00
Maikel Linke
03828c5608 Style Rails/ToSWithArgument 2023-04-14 16:34:51 +10:00
Maikel Linke
dad4061ff9 Style Rails/ToFormattedS 2023-04-14 16:32:39 +10:00
Maikel Linke
b19df0dfbf Enable new Rubocop cops
This detects an additional 639 offenses which I added to the todo file.
From now on, when Dependabot bumps rubocop the build may fail due to new
cops. But that's a great opportunity to utilise those new cops and fix
violations straight away. Otherwise we'll never get to them and lose out
on useful autocorrection, for example for updating deprecated syntax.
2023-04-14 16:28:20 +10:00
Maikel Linke
efb2ae6843 Style Rails/Pick - rubocop passes completely 2023-04-14 16:22:46 +10:00
Maikel Linke
407fca17cb Style Rails/IndexWith 2023-04-14 16:19:21 +10:00
Maikel Linke
33409725a5 Run rubocop-rails with current Rails version 7.0
This adds three new issues I will address in the next commits.

```
Offenses:

app/json_schemas/json_api_schema.rb:40:7: C: [Correctable] Rails/IndexWith: Prefer index_with over to_h { ... }.
      relationships.to_h { |name| [name, relationship_schema(name)] }
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/base.rb:18:11: C: [Correctable] Rails/IndexWith: Prefer index_with over map { ... }.to_h.
          data_attributes.map { |attr| [attr, I18n.t("header.#{attr}", scope: i18n_scope)] }.to_h
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/sales_tax/sales_tax_totals_by_order.rb:140:14: C: [Correctable] Rails/Pick: Prefer pick('sum(amount)') over pluck('sum(amount)').first.
            .pluck('sum(amount)').first || 0
             ^^^^^^^^^^^^^^^^^^^^^^^^^^

1404 files inspected, 3 offenses detected, 3 offenses autocorrectable
```
2023-04-14 16:15:13 +10:00
Maikel Linke
c70a694111 Style line length - rubocop passes completely 2023-04-14 16:12:14 +10:00
Maikel Linke
9c88c77066 Style empty lines 2023-04-14 16:05:50 +10:00
Maikel Linke
42585bb074 Remove redundant cop disable directive 2023-04-14 16:04:57 +10:00
MadisonBowron
697f2795d4 Remove arbitrary comments 2023-04-14 01:25:14 -04:00
Maikel
b0211d0930 Merge pull request #10686 from filipefurtad0/truncates_product_description
Sets too long line truncation spec as pending
2023-04-14 15:11:31 +10:00
Maikel
0675422509 Merge pull request #10678 from dacook/show-commit-in-ci
Show commit in CI
2023-04-14 14:43:44 +10:00
Maikel
5ff1b0d358 Merge pull request #10676 from filipefurtad0/fix_spec_ts_and_cs
Adds pending test for default ToS
2023-04-14 14:00:32 +10:00
Maikel Linke
43cbac7d17 Simplify report filename generation 2023-04-14 11:29:36 +10:00
Maikel Linke
98e4f867b4 Provide download link for generated reports 2023-04-14 11:29:35 +10:00
Maikel Linke
ebb15781d5 Store report's filename within the blob
For future downloads outside the ReportsController.
2023-04-14 11:29:35 +10:00
Maikel Linke
028c4f4281 Simplify ReportJob by extracting model for result
This makes the code heaps simpler.
2023-04-14 11:29:35 +10:00
Maikel Linke
ef7dfa3b4f Store reports with Active Storage
This will enable us to offer download links and clean them up
automatically.
2023-04-14 11:29:35 +10:00
Maikel Linke
71f9415d21 Use ApplicationJob as it's a Rails default 2023-04-14 11:29:35 +10:00
Maikel Linke
12848acf21 Fix typo 2023-04-14 11:29:35 +10:00
Maikel Linke
4f751c2711 Leverage test helpers for enqueued jobs
The production code calls `perform_later` and it's better to do the same
in specs. Handy test helper allow us to control the execution.

Credit to https://github.com/cyrillefr.
2023-04-14 11:29:35 +10:00
jibees
920e2564a4 Merge pull request #10692 from openfoodfoundation/dependabot/bundler/rubocop-1.50.1
Bump rubocop from 1.50.0 to 1.50.1
2023-04-13 13:45:28 +02:00
Jean-Baptiste Bellet
6b4e150e2a Active split_checkout feature by default 2023-04-13 13:21:23 +02:00
dependabot[bot]
2d43e32688 Bump rubocop from 1.50.0 to 1.50.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.50.0 to 1.50.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.50.0...v1.50.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-13 09:57:38 +00:00
David Cook
a6cd393c57 Update all locales with the latest Transifex translations 2023-04-13 16:45:38 +10:00
Filipe
b1060bf1c9 Merge pull request #10640 from openfoodfoundation/dependabot/bundler/stripe-8.5.0
Bump stripe from 8.3.0 to 8.5.0
2023-04-12 19:27:18 +01:00
Filipe
1bf5fbaf3a Merge pull request #10449 from macanudo527/fix_ER
Update OCs after ER Permissions are Revoked
2023-04-12 18:59:20 +01:00
Konrad
2ace3afd67 Merge pull request #10606 from thejwuscript/10116-improve-bom-sorting
Sort orders by last name
2023-04-12 16:36:45 +02:00
Konrad
0bfceb877d Merge pull request #10666 from jibees/9723-admin-missing-translation-in-payment-report
Admin, Payment reports: add missing translation for payment state
2023-04-12 15:47:23 +02:00
Filipe
c1d28b2e8f Merge pull request #10119 from binarygit/donot-hide-producers-name-in-products
Display producer's name in products inspite of hide all refs option
2023-04-12 13:07:52 +01:00
Jean-Baptiste Bellet
2841b42296 Specify truncate parameter as we don't always truncate description
Only when too long.
2023-04-12 10:34:30 +02:00
jibees
98e44e7a40 Merge pull request #10687 from openfoodfoundation/dependabot/bundler/nokogiri-1.14.3
Bump nokogiri from 1.14.2 to 1.14.3
2023-04-12 10:25:56 +02:00
jibees
51c6c19f80 Merge pull request #10669 from openfoodfoundation/dependabot/bundler/sidekiq-7.0.8
Bump sidekiq from 7.0.7 to 7.0.8
2023-04-12 10:24:59 +02:00
filipefurtad0
26947a64c0 Adds test to check pagination upon line-item selection 2023-04-12 09:58:01 +02:00
Jean-Baptiste Bellet
df5c21048a Clear on bulk submenu should reset some filters + refresh data as well 2023-04-12 09:58:01 +02:00
Jean-Baptiste Bellet
8a124fb6be BOM: once variant has been selected, refresh data with a new search
- Remove variant_filter
 - instantiate a new search to avoid pagination issues
2023-04-12 09:58:00 +02:00
filipefurtad0
7d51979c06 Updates build environment to Ubuntu 22.04
Creates environment variable to set OS version
2023-04-12 09:19:14 +02:00
Maikel Linke
ced49e0217 Apply Rails standard to base mailer class
It has the advantage that `rails generate mailer` works out of the box
and we comply with rubocop rules.
2023-04-12 16:39:20 +10:00
dependabot[bot]
75b7a1864b Bump nokogiri from 1.14.2 to 1.14.3
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.14.2 to 1.14.3.
- [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.14.2...v1.14.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-12 06:24:59 +00:00
Maikel Linke
281d0eb417 Simplify mailers with Rails default "from" setting 2023-04-12 16:15:51 +10:00
Maikel Linke
496f5199c9 Use DatabaseCleaner recommendation of late cleaning
https://github.com/DatabaseCleaner/database_cleaner#rspec-with-capybara-example
2023-04-12 14:24:07 +10:00
Maikel Linke
f13c0e1dca Bring all Rspec config for database cleaning together 2023-04-12 14:23:09 +10:00
David Cook
f801d4a4cb Move single-used variables to their own example
They were created three times each, but only used once.
2023-04-12 11:05:11 +10:00
David Cook
d94da8df1e Update comment 2023-04-12 11:04:00 +10:00
MadisonBowron
8c6e0a841c Fix rubocop extra blank line error 2023-04-11 15:35:37 -04:00
filipefurtad0
70d9cfa08e Sets too long line truncation spec as pending 2023-04-11 19:46:11 +01:00
jibees
193ae7936e Merge pull request #10681 from openfoodfoundation/dependabot/bundler/rubocop-1.50.0
Bump rubocop from 1.49.0 to 1.50.0
2023-04-11 20:40:55 +02:00
Filipe
0971e8d9b5 Merge pull request #10644 from mkllnk/report-timeout-message
[Hidden] Display a friendly message when a background report times out
2023-04-11 19:40:42 +01:00
Jean-Baptiste Bellet
e78b44b9ca Do not shows <a /> if producers is hidden
Different style as it does not open any modal
2023-04-11 14:27:57 +02:00
binarygit
c5779eff81 Do not open modal for producer's who are 'hidden' 2023-04-11 14:27:57 +02:00
Jean-Baptiste Bellet
b616c14f63 Don't hide producer's name in products despite hide all refs opt selected 2023-04-11 14:26:47 +02:00
Mohamed ABDELLANI
03cb14c926 define manage_by scope on customer model 2023-04-11 12:18:15 +01:00
Mohamed ABDELLANI
da78e06a39 load customers of managed enterprises only 2023-04-11 12:10:07 +01:00
dependabot[bot]
f4c351febf Bump rubocop from 1.49.0 to 1.50.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.49.0 to 1.50.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.49.0...v1.50.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-11 10:05:30 +00:00
Maikel Linke
30184ac6aa Background reports time out earlier than nginx
This allows us to display a friendly message before nginx displays its
default error.
2023-04-11 16:44:13 +10:00
David Cook
a123d45eca Fix spec
It's worth noting that this page hasn't been updated by this PR.
I honestly don't know why it broke, but don't care anymore. It seems the extra `login_as_admin_and_visit` was causing a race condition on one spec. It's not necessary so I've removed this context.

Best viewed with whitespace ignored.
2023-04-11 16:38:49 +10:00
James Wu
a75f16e23c Implement full_name_for_sorting 2023-04-11 15:25:20 +10:00
James Wu
546e90b286 Sort orders by last names 2023-04-11 15:25:20 +10:00
David Cook
bf9f47a000 Show commit in CI
actions/checkout@v3 actually creates a merge commit into master, to ensure you're testing the latest as close to master as possible.
That's all well and good, but quite confusing when you see errors in CI that aren't present in the actual PR branch. Hopefully this will be a clue when such confusions arise.
2023-04-11 15:22:19 +10:00
David Cook
3da6e6b5ed Link to CI page 2023-04-11 15:22:12 +10:00
Maikel Linke
111705f6f2 Clarify DatabaseCleaner use only for concurrency
Otherwise we use transactions.
2023-04-11 14:07:27 +10:00
Maikel Linke
68d5327b12 Load all spec helpers in one place
These helpers are loaded depending on the spec type. We don't need to
separate them into different files.
2023-04-11 12:56:28 +10:00
Maikel Linke
688285c374 Remove loading of unused spec helpers
We have only one feature spec left and it's loading the
system_helper instead of the spec_helper. These lines were dead code.
2023-04-11 12:14:02 +10:00
MadisonBowron
9d0a69cceb Fix admin product variants form to close issues #10579 & #430 2023-04-10 18:53:01 -04:00
Konrad
15058299d8 Merge pull request #10641 from openfoodfoundation/dependabot/npm_and_yarn/babel/preset-env-7.21.4
Bump @babel/preset-env from 7.18.2 to 7.21.4
2023-04-10 20:00:06 +02:00
filipefurtad0
4e92f33b1c DRYes spec; adds pending test for default ToS 2023-04-10 12:08:35 +01:00
Jean-Baptiste Bellet
c7cb982c9a Update browser list
```
npx update-browserslist-db@latest
```
2023-04-10 11:20:19 +02:00
Jean-Baptiste Bellet
34e9112c0a Fix dependencies warning: adds core and `plugin-transform-runtime 2023-04-10 11:20:19 +02:00
dependabot[bot]
28eb11bda5 Bump @babel/preset-env from 7.20.2 to 7.21.4
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.20.2 to 7.21.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.21.4/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 11:20:19 +02:00
jibees
d8e82d9c88 Merge pull request #10668 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.120.1
Bump aws-sdk-s3 from 1.120.0 to 1.120.1
2023-04-10 11:12:45 +02:00
Mohamed ABDELLANI
061fc321b4 group records before rending the report 2023-04-07 18:44:19 +01:00
Mohamed ABDELLANI
5201e54f82 group orders before rendering the report 2023-04-07 18:16:12 +01:00
jibees
5192a08082 Merge pull request #10673 from openfoodfoundation/dependabot/bundler/rubocop-rails-2.19.0
Bump rubocop-rails from 2.18.0 to 2.19.0
2023-04-07 14:33:31 +02:00
jibees
94d3f136e2 Merge pull request #10672 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.2.6
Bump @floating-ui/dom from 1.2.5 to 1.2.6
2023-04-07 14:32:45 +02:00
dependabot[bot]
db3a923ea7 Bump rubocop-rails from 2.18.0 to 2.19.0
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.18.0 to 2.19.0.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.18.0...v2.19.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-07 09:59:34 +00:00
dependabot[bot]
619eb43c57 Bump @floating-ui/dom from 1.2.5 to 1.2.6
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.2.6/packages/dom)

---
updated-dependencies:
- dependency-name: "@floating-ui/dom"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-07 09:58:01 +00:00
filipefurtad0
680b6a7122 Update all locales with the latest Transifex translations 2023-04-07 10:17:13 +01:00
Filipe
d9e9add78b Merge pull request #10527 from vviekk/10456
Fixing 'unsaved' alert behaviour for order cycle edit forms
2023-04-06 17:05:49 +01:00
Filipe
8893824b06 Merge pull request #10635 from jibees/fix-content-security-policy-for-local-images
Fix content security policy: authorize `ENV["SITE_URL"]` as trusted domain for images
2023-04-06 11:25:05 +01:00
dependabot[bot]
5c221621d3 Bump sidekiq from 7.0.7 to 7.0.8
Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.0.7 to 7.0.8.
- [Release notes](https://github.com/sidekiq/sidekiq/releases)
- [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md)
- [Commits](https://github.com/sidekiq/sidekiq/compare/v7.0.7...v7.0.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-06 09:58:23 +00:00
dependabot[bot]
60d7ed5036 Bump aws-sdk-s3 from 1.120.0 to 1.120.1
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.120.0 to 1.120.1.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-s3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-06 09:57:53 +00:00
Filipe
e71a747925 Merge pull request #10667 from jibees/10662-flaky-specqueriescustomers_with_balance_specrb26
Flaky: Avoid flaky spec by sorting array before comparing on `spec/queries/customers_with_balance_spec.rb:26`
2023-04-06 10:47:32 +01:00
Jean-Baptiste Bellet
eedd421055 Avoid flaky spec by sorting array before comparing 2023-04-06 10:41:42 +02:00
Jean-Baptiste Bellet
e74328f1d7 Add i18n for payment state key
+ update spec
2023-04-06 10:28:44 +02:00
Jean-Baptiste Bellet
bb502c2e65 Authorize localhost:3000 as trusted domain for images 2023-04-06 10:10:44 +02:00
Jean-Baptiste Bellet
6abd652251 Factorize into inherited method from Base: payment_state(order) 2023-04-06 09:50:50 +02:00
Filipe
2f6b730ed4 Merge pull request #10614 from cillian/business-address-country-state-placeholders
Add placeholders to business address country and state select fields
2023-04-05 19:55:07 +01:00
dependabot[bot]
3821eede51 Bump stripe from 8.3.0 to 8.5.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 8.3.0 to 8.5.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/v8.3.0...v8.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-05 16:38:33 +00:00
Filipe
2ff464321c Merge pull request #10619 from openfoodfoundation/dependabot/npm_and_yarn/stimulus_reflex-3.5.0-rc1
Bump stimulus_reflex and cable_ready from 3.5.0-preX to 3.5.0-rc2
2023-04-05 17:37:15 +01:00
Filipe
fc8d9252d5 Merge pull request #10605 from abdellani/fix-impossible-to-reach-OCs-older-than-6-months
Fix load order cycles by date ranges
2023-04-05 17:33:51 +01:00
Rachel Arnould
3e5becf70a Merge pull request #10538 from jibees/10537-shopfront-product-description-is-too-long
Shopfront: Force product description to be on one line
2023-04-05 17:42:18 +02:00
Maikel
ef841b161f Merge pull request #10660 from MadisonBowron/master
Fix bug #10596, missing translation for editing shipping category
2023-04-05 16:12:20 +10:00
Maikel
c11dd2c1fb Merge pull request #10642 from macanudo527/fix_rubocop_errors
Fix Rubocop Layout/LineLength
2023-04-05 16:11:08 +10:00
Maikel Linke
8bbc545e39 Cover untranslated text by spec 2023-04-05 15:03:42 +10:00
Maikel
fc08913152 Merge pull request #10648 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.120.0
Bump aws-sdk-s3 from 1.119.2 to 1.120.0
2023-04-05 14:44:22 +10:00
Maikel
19ae3651fa Merge pull request #10643 from dacook/update-node-docker
Update node for docker
2023-04-05 14:43:24 +10:00
Jean-Baptiste Bellet
66307c9277 cable_ready changed its Content-Type ; update the mrujs one as well
Thanks @marcoroth for the great debugging session! 🙏
2023-04-05 14:19:34 +10:00
Jean-Baptiste Bellet
65084422cb cable_ready is already imported in app/webpacker/controllers/index.js 2023-04-05 14:19:34 +10:00
Jean-Baptiste Bellet
6f8ab56d2e Replace deprecated call render operations:
```
DEPRECATED: CableReady's `render operations:` call has been renamed to `render cable_ready:`. Please update your render call.
```
2023-04-05 14:19:34 +10:00
dependabot[bot]
ab6cdd4c78 Bump stimulus_reflex from 3.5.0-pre9 to 3.5.0-rc2
Updating JS and Ruby libraries. This commit was started by Dependabot
for 3.5.0-rc1. Then we updated to rc2.

Old Dependabot message about rc1:
Bumps [stimulus_reflex](https://github.com/stimulusreflex/stimulus_reflex) from 3.5.0-pre9 to 3.5.0-rc1.
- [Release notes](https://github.com/stimulusreflex/stimulus_reflex/releases)
- [Changelog](https://github.com/stimulusreflex/stimulus_reflex/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stimulusreflex/stimulus_reflex/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>

Bump cable_ready from 5.0.0-pre10 to 5.0.0-rc1

Bumps [cable_ready](https://github.com/stimulusreflex/cable_ready) from 5.0.0-pre10 to 5.0.0-rc1.
- [Release notes](https://github.com/stimulusreflex/cable_ready/releases)
- [Changelog](https://github.com/stimulusreflex/cable_ready/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stimulusreflex/cable_ready/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-05 14:19:16 +10:00
David Cook
865d81d28f Apply suggestions from code review 2023-04-05 14:05:26 +10:00
Maikel Linke
020af0c0e4 Explain report timeout better to user 2023-04-05 09:59:02 +10:00
emiliecm
5abda22831 Fix bug #10596, missing translation for editing shipping category 2023-04-04 19:48:16 -04:00
Cillian O'Ruanaidh
89dac47aa6 Add placeholders to business address country and state select fields 2023-04-04 19:22:22 +01:00
jibees
e18d973047 Merge pull request #10655 from filipefurtad0/fix_flaky_oc_form_spec
Sorts plucked shipping/payment methods
2023-04-04 15:34:39 +02:00
jibees
afeeaf0a9b Merge pull request #10657 from openfoodfoundation/dependabot/bundler/combine_pdf-1.0.23
Bump combine_pdf from 1.0.22 to 1.0.23
2023-04-04 14:31:06 +02:00
jibees
3010717ece Merge pull request #10656 from openfoodfoundation/dependabot/bundler/devise-4.9.2
Bump devise from 4.9.1 to 4.9.2
2023-04-04 14:30:11 +02:00
dependabot[bot]
0c48dbe0d5 Bump combine_pdf from 1.0.22 to 1.0.23
Bumps [combine_pdf](https://github.com/boazsegev/combine_pdf) from 1.0.22 to 1.0.23.
- [Release notes](https://github.com/boazsegev/combine_pdf/releases)
- [Changelog](https://github.com/boazsegev/combine_pdf/blob/master/CHANGELOG.md)
- [Commits](https://github.com/boazsegev/combine_pdf/compare/v1.0.22...v1.0.23)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-04 10:04:31 +00:00
dependabot[bot]
f7b215b7ac Bump devise from 4.9.1 to 4.9.2
Bumps [devise](https://github.com/heartcombo/devise) from 4.9.1 to 4.9.2.
- [Release notes](https://github.com/heartcombo/devise/releases)
- [Changelog](https://github.com/heartcombo/devise/blob/main/CHANGELOG.md)
- [Commits](https://github.com/heartcombo/devise/compare/v4.9.1...v4.9.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-04 09:58:37 +00:00
filipefurtad0
29520542db Sorts plucked shipping/payment methods 2023-04-04 09:30:36 +01:00
Maikel Linke
00a3976905 Display a friendly message when a report times out
Once we get a download link for a report, we can display this message
sooner. But for now we just use the existing request timeout.
2023-04-04 11:08:20 +10:00
Maikel Linke
3bd8e430f9 Use Rack::Timeout for more realistic tests
The closer the test environment is to the production environment the
more realistic the tests will be, and the more code we test.

We are now able to test the app behaviour on timeouts which I want to do
for reports. We can also catch incompatibilities with the rack-timeout
gem during testing.
2023-04-04 11:08:20 +10:00
Neal Chambers
940f806e5f Fix Rubocop Layout/LineLength 2023-04-04 09:44:15 +09:00
Neal Chambers
77733169fc Update OCs after ERs Permissions are Revoked 2023-04-04 09:37:13 +09:00
David Cook
c34ced2f65 Merge pull request #10639 from openfoodfoundation/dependabot/bundler/puma-6.2.1
Bump puma from 6.1.1 to 6.2.1
2023-04-04 10:08:57 +10:00
Filipe
2051d811cf Merge pull request #10567 from jibees/10557-allow-hide-of-ofn-main-navigation
White Label: Allow enterprise to hide ofn main navigation on `/shop`, `/cart`, `/checkout`, `/orders` pages
2023-04-03 20:29:37 +01:00
jibees
0335cf2441 Merge pull request #10647 from openfoodfoundation/dependabot/npm_and_yarn/webpack-dev-server-4.13.2
Bump webpack-dev-server from 4.13.1 to 4.13.2
2023-04-03 16:47:02 +02:00
jibees
d3ddc8a221 Merge pull request #10650 from openfoodfoundation/dependabot/bundler/devise-4.9.1
Bump devise from 4.9.0 to 4.9.1
2023-04-03 16:44:46 +02:00
jibees
25e00d5210 Merge pull request #10649 from openfoodfoundation/dependabot/bundler/capybara-3.39.0
Bump capybara from 3.38.0 to 3.39.0
2023-04-03 16:42:53 +02:00
jibees
2a556ab329 Merge pull request #10651 from openfoodfoundation/dependabot/bundler/rubocop-1.49.0
Bump rubocop from 1.48.1 to 1.49.0
2023-04-03 16:42:08 +02:00
dependabot[bot]
80a94011b8 Bump rubocop from 1.48.1 to 1.49.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.48.1 to 1.49.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.48.1...v1.49.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 10:06:36 +00:00
dependabot[bot]
d4f2704213 Bump devise from 4.9.0 to 4.9.1
Bumps [devise](https://github.com/heartcombo/devise) from 4.9.0 to 4.9.1.
- [Release notes](https://github.com/heartcombo/devise/releases)
- [Changelog](https://github.com/heartcombo/devise/blob/main/CHANGELOG.md)
- [Commits](https://github.com/heartcombo/devise/compare/v4.9.0...v4.9.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 10:02:14 +00:00
dependabot[bot]
91bf3c67cd Bump capybara from 3.38.0 to 3.39.0
Bumps [capybara](https://github.com/teamcapybara/capybara) from 3.38.0 to 3.39.0.
- [Release notes](https://github.com/teamcapybara/capybara/releases)
- [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md)
- [Commits](https://github.com/teamcapybara/capybara/compare/3.38.0...3.39.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 10:01:25 +00:00
dependabot[bot]
307a9effb0 Bump aws-sdk-s3 from 1.119.2 to 1.120.0
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.119.2 to 1.120.0.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-s3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 10:00:03 +00:00
dependabot[bot]
56e8f7b0c6 Bump webpack-dev-server from 4.13.1 to 4.13.2
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.13.1 to 4.13.2.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.13.1...v4.13.2)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 09:58:14 +00:00
Maikel
de58aa1187 Merge pull request #10529 from mkllnk/setup
Update setup script with newest template and merge with old script
2023-04-03 15:44:29 +10:00
Maikel Linke
da0ef8531b Install our used bundler version 2023-04-03 14:37:31 +10:00
Maikel Linke
08f2254a0e Leverage bin/setup within script/setup
And remove duplicate output. `bin/setup` is the Rails default for
updating your environment after code updates and `script/setup` is our
convenience script for the initial setup and starting with sample data.
2023-04-03 14:37:31 +10:00
Maikel Linke
477524039f Update bundler version when necessary
Not just when it's missing.
2023-04-03 14:37:31 +10:00
Maikel Linke
e5e5bf8c17 Install ruby automatically if rbenv is available
People may use other ways to provide the right Ruby version but if they
use rbenv then we can use it automatically.
2023-04-03 14:37:30 +10:00
Maikel Linke
4999e231bc Avoid permission warning when running sudo as root
The command is switching to an unprivileged user which can't access
/root and therefore there was a warning when executing. Adding `--login`
to the sudo command switches to that user properly and avoids the
warning.
2023-04-03 14:36:07 +10:00
Maikel Linke
6b857a5683 Make code examples easier to copy without $ sign
The $ sign used to indicate shell commands. But with markdown it's
obvious that we are entering commands.

Github has a quick copy button for all code examples which used to copy
the $ sign as well. Removing it allows to copy and paste easier with
that button.
2023-04-03 14:35:52 +10:00
Maikel Linke
f12ee186ee Speed up setup script when restarting rails 2023-04-03 14:33:39 +10:00
Maikel Linke
93ef95f58e Update JS dependencies with setup script 2023-04-03 14:33:39 +10:00
Maikel Linke
49dd1dd1fa Update setup script with newest template
I used the script from a new Rails 7 project.
2023-04-03 14:32:22 +10:00
David Cook
04d2f3f50d Install nodenv to use correct Node version
Copying what we do for rbenv, using the same plugins that we use in https://github.com/openfoodfoundation/ofn-install/blob/master/roles/node/tasks/main.yml
2023-04-03 14:11:28 +10:00
David Cook
f43bdec0f4 Update to latest node v17
Really this should install nodenv though..
2023-04-03 11:41:54 +10:00
Jean-Baptiste Bellet
b79bd8ef05 Removes empty <p> tags from product description 2023-03-31 11:37:30 +02:00
Jean-Baptiste Bellet
4dfc56954c Force .product-description to be one line
and make it as a `div`
2023-03-31 10:41:27 +02:00
dependabot[bot]
8c08827d35 Bump puma from 6.1.1 to 6.2.1
Bumps [puma](https://github.com/puma/puma) from 6.1.1 to 6.2.1.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v6.1.1...v6.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-31 08:13:31 +00:00
Maikel Linke
a56081ad5b Update translations 2023-03-31 14:59:16 +11:00
jibees
996c6d35f3 Merge pull request #10633 from openfoodfoundation/dependabot/bundler/debug-1.7.2
Bump debug from 1.7.1 to 1.7.2
2023-03-30 14:08:13 +02:00
Jean-Baptiste Bellet
89036db666 Do not use a preference, but create a new column for hide_ofn_navigation 2023-03-30 09:19:17 +11:00
Jean-Baptiste Bellet
dd9fec58a4 Instead of parsing URLs pass order through method for Orders Ctrl
Use methods for before_actions

Maybe we should for hide_of_navigation too, but a name 'hide_ofn_navigation_for_order_distributor' seemed unhelpful..
2023-03-30 09:19:17 +11:00
Jean-Baptiste Bellet
4fa44e6c64 Put the white label behind a feature toggle white_label
+ update specs as well

+ for admin section also
2023-03-30 09:19:17 +11:00
Jean-Baptiste Bellet
4ad2a1a723 Prefer a concern that set a variable instead of a global helper
Therefor, for the right controllers, simply implements:

```
include WhiteLabel

before_action :hide_ofn_navigation, only: [:show, :edit]
```

This is mort robust, since we're working in a controller level, not parsing URLs...
2023-03-30 09:17:57 +11:00
Jean-Baptiste Bellet
5279be4dc6 Improve spec: visiting order confirmation with distributor
Two cases:
 - the current distributor is the same than the order of the order confirmation page
 - the current distributor *is not* the same than the order of the order confirmation page (and has not set `hide_ofn_navigation` preference to `true`)
2023-03-30 09:17:57 +11:00
Jean-Baptiste Bellet
348c1ff7da Hide the OFN navigation menu when distributor as set its preference
Hide, when preference is true, for page:
 - shop
 - cart
 - checkout
 - order confirmation
2023-03-30 09:17:57 +11:00
Jean-Baptiste Bellet
c20ae0de1e Edit hide_ofn_navigation in 'white label' panel for an enterprise 2023-03-30 09:17:57 +11:00
Jean-Baptiste Bellet
3452864503 Add "white label" panel in enterprise settings page 2023-03-30 09:17:57 +11:00
Jean-Baptiste Bellet
d2f29b7d73 Some refactoring to avoid rubocop class too long warning 2023-03-30 09:13:35 +11:00
Filipe
62cdda2ce2 Merge pull request #10523 from rioug/10431-voucher-minimum-backend
Voucher bare minimum backoffice
2023-03-29 20:21:57 +01:00
Filipe
e6123969d2 Merge pull request #10607 from mkllnk/zone-spec
Sort zones by name again, in the admin panel
2023-03-29 17:57:50 +01:00
Filipe
90ce52612d Merge pull request #10615 from mkllnk/background-report-job
Run background reports with Sidekiq, not fork
2023-03-29 17:38:48 +01:00
jibees
7e6d40f370 Merge pull request #10621 from openfoodfoundation/dependabot/bundler/valid_email2-4.0.6
Bump valid_email2 from 4.0.5 to 4.0.6
2023-03-29 17:13:34 +02:00
Filipe
b6e4ff908f Merge pull request #10566 from mkllnk/products-meta-description
Remove unused product meta description
2023-03-29 15:58:31 +01:00
Filipe
c16c1a5e62 Merge pull request #10544 from filipefurtad0/test_pdf_reports
Adds pdf comparison; removes csv, xlsx, pdf file fixtures
2023-03-29 14:03:25 +01:00
dependabot[bot]
3f5aceff99 Bump debug from 1.7.1 to 1.7.2
Bumps [debug](https://github.com/ruby/debug) from 1.7.1 to 1.7.2.
- [Release notes](https://github.com/ruby/debug/releases)
- [Commits](https://github.com/ruby/debug/compare/v1.7.1...v1.7.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-29 10:00:12 +00:00
dependabot[bot]
b8e9925601 Bump valid_email2 from 4.0.5 to 4.0.6
Bumps [valid_email2](https://github.com/micke/valid_email2) from 4.0.5 to 4.0.6.
- [Release notes](https://github.com/micke/valid_email2/releases)
- [Changelog](https://github.com/micke/valid_email2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micke/valid_email2/compare/v4.0.5...v4.0.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-29 07:51:47 +00:00
Maikel
667a514ed2 Merge pull request #10623 from jibees/10622-flaky-specservicesorder_cycle_form_specrb403
Flaky: Sort array to avoid flaky spec when comparing values
2023-03-29 16:32:44 +11:00
filipefurtad0
25108f4c70 Removes all fixture files; asserts on downloaded file
Changes helper method to assert there is one file only

load_file_txt will be useful in other spec files too, and could probably be moved to spec/support/file_helper.rb
2023-03-29 16:24:21 +11:00
Maikel Linke
6f83607aa8 Remove unused product meta description from DB 2023-03-29 14:35:16 +11:00
Maikel Linke
70aff98581 Remove unused product meta description from UI 2023-03-29 14:33:42 +11:00
Maikel
812fb974dd Merge pull request #10584 from openfoodfoundation/dependabot/bundler/devise-i18n-1.11.0
Bump devise-i18n from 1.10.3 to 1.11.0
2023-03-29 13:08:35 +11:00
filipefurtad0
0a91f3d392 Sorts all shipiping method arrays 2023-03-28 15:46:41 +02:00
Gaetan Craig-Riou
c7c19e47de Add feature toggle description 2023-03-28 13:46:51 +11:00
Gaetan Craig-Riou
e1845dddac Fix TabsAndPanelsController now that #! are removed from url
This PR https://github.com/openfoodfoundation/openfoodnetwork/pull/9729
remove #! from url. But unfortunately, AngularJs rewrite "example.com#panel"
as "example.com#/panel" thus breaking the original implementation.
2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
2e10336a47 Add ability to manage voucher for enterprise user
Update spec accordingly
2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
37d3c025e9 Make sure New voucher page can be accessed from voucher panel
Co-authored-by: David Cook <david@redcliffs.net>
2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
6eb52aa540 TabsAndPanelsController specs, add missinrg panel scenario 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
6809198c96 Vouchers specs, remove obsolete step
Vouchers tabs now shows when returning from new voucher page,
no need to manually click on the 'vouchers' link in the menu
2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
3b7aebd6da Enable vouchers feature toggle when running vouchers specs 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
7dc5bc87d1 Fix rubocop warnings 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
0c43d0f16a Put vouchers admin screen behind 'vouchers' feature toggle 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
fb1ad4c65f Remove non needed collumn from voucher list 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
04748b6e0e Move voucher value to the model
Use Spree::Money to display amount with currency
2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
094fc039e9 Update tabs_and_panels to display tab and panel based on the url anchor
For Vouchers, this means the voucher tab and panel are displayed when
you come back to entreprise edit screen from the new vourcher page
2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
e4f40d14b8 Fix enterprise voucher tab
Add harcoded voucher amount
Add missing translation
2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
4085aa22dc Add create voucher action and system test 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
a4add889a8 Add form on the new voucher page 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
f9f6793d10 Add template and basic controller for backoffice voucher pages 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
a62687b1a7 Fix warning : The implicit block expectation syntax is deprecated 2023-03-28 13:39:29 +11:00
Gaetan Craig-Riou
a48fd0828c Add Voucher model
A voucher belongs to an enterprise and an enterprise can have many
vouchers
2023-03-28 13:39:29 +11:00
Maikel
6cfb86e578 Link to merged feature toggle wiki page 2023-03-28 12:25:21 +11:00
Maikel
a168126cfa Merge pull request #10600 from mkllnk/features
Add all feature toggles with descriptions at boot
2023-03-28 10:58:40 +11:00
Jean-Baptiste Bellet
88c833ec83 Sort array to avoid flaky spec when comparing values 2023-03-27 15:57:46 +02:00
Konrad
c887efee54 Merge pull request #10519 from vviekk/viv/10515
Removing 'none' from shipping categories from product edit page
2023-03-27 14:01:11 +02:00
jibees
86abff224e Merge pull request #10616 from mkllnk/rails-7-schema
Update DB schema to Rails 7.0
2023-03-27 10:56:14 +02:00
vviekk
9a10c8c25a Removing none from shipping categories from product edit page 2023-03-27 11:56:10 +05:30
Maikel Linke
4461b33491 Sort zones by name again
Zones were intended to be sorted by name. But I guess that the syntax of
Ransack changed one day and we didn't notice because the spec was
creating entries in the right order already (which often reflects the
query result order without parameters). So the spec is fixed to fail if
the sorting doesn't happen and Ransack is configured to sort correctly.
The previous sort value was ignored.
2023-03-27 16:36:04 +11:00
Maikel Linke
5ae9016f09 Speed up spec by skipping additional page load
The login_as_admin helper has to load a page to log in. Providing the
page we want to go to avoids going to the default page first.
2023-03-27 16:36:04 +11:00
Maikel Linke
67ab8f63e0 Remove superfluous test setup
There are no zones at the start of the test. This is probably a
left-over from old times when specs were not encapsulated in
transactions.
2023-03-27 16:36:04 +11:00
Maikel Linke
40e64acd37 Update DB schema to Rails 7.0
This is the result of: `./bin/rails db:migrate`
2023-03-27 16:18:02 +11:00
Maikel Linke
78fea7c7f2 Run background reports with Sidekiq, not fork
Forking worked in theory but crashed the browser in system specs. It
also came with many other hurdles and isn't well known solution in the
Rails community. Sidekiq can give us better control over execution
limits as well.
2023-03-27 13:27:49 +11:00
Konrad
4c61666fc7 Merge pull request #10547 from vviekk/10419
Enable invoices config only controls Print bulk action
2023-03-26 13:53:20 +02:00
Konrad
0c6a12a6f0 Merge pull request #10241 from binarygit/provide-err-msg-when-using-text-in-var-field
Admin, edit variant: only allow numerical values for weight, height, width and depth fields
2023-03-26 13:03:20 +02:00
jibees
0da245f912 Merge pull request #10595 from jibees/10592-flaky-specservicesorder_cycle_form_specrb282
Flaky spec: Sort each array to ensure the order
2023-03-24 16:11:49 +01:00
jibees
eba0c9c4f7 Merge pull request #10609 from openfoodfoundation/dependabot/npm_and_yarn/prettier-2.8.7
Bump prettier from 2.8.6 to 2.8.7
2023-03-24 11:22:07 +01:00
dependabot[bot]
25618c009e Bump prettier from 2.8.6 to 2.8.7
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.6 to 2.8.7.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.6...2.8.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-24 09:58:19 +00:00
jibees
068ac40a76 Merge pull request #10589 from openfoodfoundation/dependabot/npm_and_yarn/webpack-dev-server-4.13.1
Bump webpack-dev-server from 4.12.0 to 4.13.1
2023-03-24 10:52:01 +01:00
dependabot[bot]
5868fd1b7c Bump webpack-dev-server from 4.12.0 to 4.13.1
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.12.0 to 4.13.1.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.12.0...v4.13.1)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-24 09:36:40 +00:00
jibees
540129854e Merge pull request #10603 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.119.2
Bump aws-sdk-s3 from 1.119.1 to 1.119.2
2023-03-24 10:29:26 +01:00
jibees
f747ab568a Merge pull request #10604 from openfoodfoundation/dependabot/bundler/knapsack_pro-3.9.0
Bump knapsack_pro from 3.8.0 to 3.9.0
2023-03-24 10:23:01 +01:00
Jean-Baptiste Bellet
f9f619c036 Update all locales with the latest Transifex translations 2023-03-24 09:29:45 +01:00
Filipe
31ffeab4cd Merge pull request #10440 from mkllnk/rails7
Upgrade to Rails 7.0
2023-03-23 12:04:11 +00:00
Filipe
1673a18eb6 Merge pull request #9729 from binarygit/remove-angular-from-users
Admin, Enterprise Settings, Users tabs: remove tooltips directives + use reflex to invite user to be managers
2023-03-23 11:52:18 +00:00
Mohamed ABDELLANI
d3a25282de fix load order cycles by date ranges 2023-03-23 12:02:17 +01:00
Jean-Baptiste Bellet
29cdadd563 Avoid using exception but simply errors attribute contained in object
Co-Authored-By: Maikel <maikel@email.org.au>
2023-03-23 11:21:15 +01:00
Jean-Baptiste Bellet
8dffb38bf5 Sort each array to ensure the order
and then expect the right values.
2023-03-23 11:21:05 +01:00
binarygit
ecd5033efa Replace angular for when adding a new unregistered manager to an enterprise
Co-Authored-By: David Cook <david@redcliffs.net>
2023-03-23 11:21:05 +01:00
Jean-Baptiste Bellet
a13227defa Add I18N to all reflexes 2023-03-23 11:21:05 +01:00
Jean-Baptiste Bellet
465a295dfa Delete manager invitation controller 2023-03-23 11:21:05 +01:00
Jean-Baptiste Bellet
9c84a6936a Create a concern for manager invitations
Can be used elsewhere

Update manager_invitations.rb
2023-03-23 11:21:05 +01:00
dependabot[bot]
f3d687cbea Bump knapsack_pro from 3.8.0 to 3.9.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 3.8.0 to 3.9.0.
- [Release notes](https://github.com/KnapsackPro/knapsack_pro-ruby/releases)
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.8.0...v3.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-23 10:05:23 +00:00
dependabot[bot]
6894cb5dd7 Bump aws-sdk-s3 from 1.119.1 to 1.119.2
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.119.1 to 1.119.2.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-s3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-23 10:04:05 +00:00
Filipe
809a57dbdb Merge pull request #10437 from openfoodfoundation/10436-the-cookie-policy-modal-does-not-appear-to-use-the-language-selected-by-the-user
Translate cookie policy into languages selected by the user
2023-03-23 10:00:38 +00:00
Filipe
6b30a654a6 Merge pull request #10516 from macanudo527/fix_taxonomy
Fix Sorting entries in a taxonomy is broken
2023-03-23 09:23:16 +00:00
Filipe
9b749ee2e0 Merge pull request #10466 from dacook/report-summaries
Report summaries in JSON (API) output
2023-03-22 23:34:48 +00:00
David Cook
c27974c5a3 Add marker for summary rows
This can be enabled in the reports API with the hidden parameter `fields_to_show[]=report_row_type` to help with parsing summary row output.
2023-03-22 11:47:26 +00:00
David Cook
6f41a4168d Allow headers and footers for JSON format
You wouldn't want it by default, but it can be enabled with a parameter like display_summary_row=true
2023-03-22 11:47:26 +00:00
David Cook
db7ac904e9 Allow column formatting and header/footer stripping to be specified independently
This will allow us to change the options in the following commit.
2023-03-22 11:47:26 +00:00
David Cook
96eaec908d Remove unused mock in specs
It looks like it was expected that the price and amount columns would be formatted, but this is not currently the case. So I cleaned this up to be less ambiguous.

If any of these columns were to be configured for formatting, this line could be added back to test for unformatted output.
2023-03-22 11:47:26 +00:00
Maikel Linke
e0fd180edd DRY Flipper UI config 2023-03-22 15:45:26 +11:00
Maikel Linke
fd68cbf56d Remove on-the-fly adding of feature toggle entries
We now have a new source of truth. You shouldn't use a feature toggle
without adding it to OpenFoodNetwork::FeatureToggle first. All toggles
are added at boot time already.
2023-03-22 15:36:08 +11:00
Maikel Linke
9a1b1498bf Add all feature toggles with descriptions at boot
So you can easily inspect and activate new features without trying to
use them first. It brings more visibility and will enable us to easily
remove retired features as well.
2023-03-22 15:36:08 +11:00
Filipe
12de3ae584 Merge pull request #10509 from mkllnk/filter-shipping-methods-by-category
Filter shipping methods by category
2023-03-21 17:47:22 +00:00
Rachel Arnould
75c3bf8b56 Merge pull request #9630 from binarygit/remove-angular-from-business-details
Remove angular from business details
2023-03-21 18:31:40 +01:00
Rachel Arnould
52c12ea896 Merge pull request #10554 from mkllnk/dfc-variants
Ignore master variants exporting to DFC
2023-03-21 18:30:05 +01:00
jibees
2e4bbb7740 Merge pull request #10590 from openfoodfoundation/dependabot/npm_and_yarn/prettier-2.8.6
Bump prettier from 2.8.5 to 2.8.6
2023-03-21 15:32:45 +01:00
dependabot[bot]
1b0880e7df Bump prettier from 2.8.5 to 2.8.6
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.5 to 2.8.6.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.5...2.8.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-21 14:12:05 +00:00
Filipe
84f319894a Merge pull request #10594 from jibees/10593-deployment-failed-on-master
Move `webpack-*` as dependency (not devDependencies)
2023-03-21 14:09:52 +00:00
Jean-Baptiste Bellet
2a9b6f8e8c Sort each array to ensure the order
and then expect the right values.
2023-03-21 14:52:05 +01:00
Jean-Baptiste Bellet
c4e58eab3c Move webpack-* as dependency (not devDependencies) 2023-03-21 14:35:57 +01:00
Neal Chambers
920e9e65bd Merge remote-tracking branch 'origin/fix_taxonomy' into fix_taxonomy 2023-03-21 21:39:02 +09:00
David Cook
78b978efba Merge pull request #10458 from dacook/838-node-install-scripts
Node install script
2023-03-21 15:02:08 +11:00
Maikel Linke
31db35675b Add feature toggle for filtering shipping methods 2023-03-21 14:49:47 +11:00
Maikel Linke
6b25c36476 Filter ship methods by required shipping category
The products in an order may require several shipping categories like
refrigeration or express. We now filter the categories according to
their support of shipping categories.
2023-03-21 14:30:45 +11:00
Maikel Linke
73fa6295ec Simplify shipping method selection code 2023-03-21 14:30:44 +11:00
Maikel Linke
b5f43b3c1c Rename method because it's not changing the input
A common Ruby convention is to to use the bang naming `!` to mark method
which change the given parameter instead of returning a copy.
2023-03-21 14:30:44 +11:00
Maikel Linke
fcc68a0a19 Return new filtered list instead of modifying
This makes a clear distinction between the unfiltered and filtered list.
There may also be some gotchas when modifying the array of an
ActiveRecord relation. It also allows us to write shorter code without
storing a separate variable.
2023-03-21 14:30:44 +11:00
Maikel Linke
4c2d7c0d1c Rename confusing test variable
The "subject" is usually the code under test. In this spec it would be
the TagRuleApplicator and not the parameter given to it. So I renamed it
to avoid confusion here.
2023-03-21 14:30:44 +11:00
Maikel Linke
eee5e8eee7 Remove unnecessary tag rule code
The applicator converts the input to an array, even `nil` becomes an
empty array. Iterating over an empty array doesn't do anything either,
the result is the same.
2023-03-21 14:30:44 +11:00
Maikel Linke
e227cb912b Simplify tag rule spec
We don't need to know the internals. We want to know that the applicator
is not raising an error when we give `nil` or an empty collection.
2023-03-21 14:30:44 +11:00
Maikel Linke
6f3a0e8812 De-duplicate early for better performance 2023-03-21 14:30:44 +11:00
Maikel Linke
d7e4962fba Add method for easier reading 2023-03-21 14:30:44 +11:00
David Cook
7ad5181026 Merge pull request #10568 from openfoodfoundation/dependabot/npm_and_yarn/webpack-dev-server-4.12.0
Bump webpack-cli and webpack-dev-server from v3 to v4
2023-03-21 11:47:16 +11:00
jibees
c2133c8fa5 Merge pull request #10583 from openfoodfoundation/dependabot/bundler/flipper-active_record-0.26.2
Bump flipper-active_record from 0.26.0 to 0.26.2
2023-03-20 14:48:10 +01:00
dependabot[bot]
de5264138d Bump flipper-active_record from 0.26.0 to 0.26.2
Bumps [flipper-active_record](https://github.com/jnunemaker/flipper) from 0.26.0 to 0.26.2.
- [Release notes](https://github.com/jnunemaker/flipper/releases)
- [Changelog](https://github.com/jnunemaker/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/jnunemaker/flipper/compare/v0.26.0...v0.26.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 13:30:57 +00:00
Jean-Baptiste Bellet
bfbcdba98c Modify configuration to match new version of webpacker
Error was:
```
ERROR in chunk admin [entry]
js/[name]-[contenthash].js
Cannot use [chunkhash] or [contenthash] for chunk in 'js/[name]-[contenthash].js' (use [hash] instead)
```
2023-03-20 11:34:57 +01:00
David Cook
0632553a4a Remove @webpack-cli/serve
This now gets included as a dependency of webpack-cli v4. If webpack-cli had been upgraded earlier, we never would have needed to specify this.
2023-03-20 11:34:57 +01:00
David Cook
a97d416bfd Bump webpack-cli from 3.3.12 to 4.10.0
I don't know why, but Dependabot decided not to: https://github.com/openfoodfoundation/openfoodnetwork/pull/9798#issuecomment-1288583629

This is required for webpack-dev-server v4.
2023-03-20 11:34:56 +01:00
dependabot[bot]
b306539163 Bump webpack-dev-server from 3.11.3 to 4.12.0
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 3.11.3 to 4.12.0.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v3.11.3...v4.12.0)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 11:33:31 +01:00
jibees
caea53ab91 Merge pull request #10582 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.2.5
Bump @floating-ui/dom from 1.2.4 to 1.2.5
2023-03-20 11:23:56 +01:00
jibees
d7ee0ca434 Merge pull request #10580 from openfoodfoundation/dependabot/bundler/flipper-ui-0.26.2
Bump flipper-ui from 0.26.0 to 0.26.2
2023-03-20 11:20:11 +01:00
jibees
7fa4aa62f9 Merge pull request #10581 from openfoodfoundation/dependabot/npm_and_yarn/prettier-2.8.5
Bump prettier from 2.8.4 to 2.8.5
2023-03-20 11:17:14 +01:00
dependabot[bot]
ca97adb724 Bump devise-i18n from 1.10.3 to 1.11.0
Bumps [devise-i18n](https://github.com/tigrish/devise-i18n) from 1.10.3 to 1.11.0.
- [Release notes](https://github.com/tigrish/devise-i18n/releases)
- [Changelog](https://github.com/tigrish/devise-i18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tigrish/devise-i18n/compare/v1.10.3...v1.11.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 09:59:49 +00:00
dependabot[bot]
6295ecc7cf Bump @floating-ui/dom from 1.2.4 to 1.2.5
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.2.4 to 1.2.5.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.2.5/packages/dom)

---
updated-dependencies:
- dependency-name: "@floating-ui/dom"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 09:58:48 +00:00
dependabot[bot]
b207d3e7fd Bump prettier from 2.8.4 to 2.8.5
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.4 to 2.8.5.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.4...2.8.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 09:58:31 +00:00
dependabot[bot]
b4f3655fae Bump flipper-ui from 0.26.0 to 0.26.2
Bumps [flipper-ui](https://github.com/jnunemaker/flipper) from 0.26.0 to 0.26.2.
- [Release notes](https://github.com/jnunemaker/flipper/releases)
- [Changelog](https://github.com/jnunemaker/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/jnunemaker/flipper/compare/v0.26.0...v0.26.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 09:58:17 +00:00
Jean-Baptiste Bellet
918e220557 Move $locationProvider configuration to another file
Actually the `config()` method of `admin_ofn` file did not run on `/admin/enterprises/*` pages for an unknown reason

Now those two files have the same configuration
2023-03-20 08:37:47 +01:00
binarygit
a397ba1ca9 Replace what's this tooltips
There are tooltips here that don't have a what's this?
There are many angular directives/methods being used that I haven't
looked into
Every select box is using select2
2023-03-20 08:37:47 +01:00
Maikel Linke
7cd235c84d Translate AngularJS templates in the browser
AngularJS templates are compiled as assets on deploy. Any translatable
text can't be translated in Ruby during compilation because it's static
text. It needs to be translated with an AngularJS filter in the browser.
2023-03-20 17:02:10 +11:00
Jean-Baptiste Bellet
e97cd0a1fd That particular spec is actually failing ; this must be solved 2023-03-20 16:59:19 +11:00
Jean-Baptiste Bellet
a56f061663 Prepare the spec to be factorized and to be used in different context 2023-03-20 16:59:19 +11:00
Maikel
512cb44df5 Merge pull request #10330 from mickenorlen/8909-add-balance-to-api-v1-customer-endpoint
Add balance to api v1 customers endpoint
2023-03-20 15:47:41 +11:00
Maikel
0ab8e62749 Merge pull request #10405 from jibees/upgrade-node-version
Upgrade node version
2023-03-20 10:55:41 +11:00
Mohamed ABDELLANI
008b12a75d remove "/" from the partial path to load sub-report filters 2023-03-20 10:41:28 +11:00
Maikel Linke
2e51d9be4a Include Rails version in db schema
So Rails knows which defaults to apply.
https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#rails-version-is-now-included-in-the-active-record-schema-dump
2023-03-20 10:41:28 +11:00
Maikel Linke
bd20e299f3 Support old cookie encryption
https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#key-generator-digest-class-changing-to-use-sha256
2023-03-20 10:41:28 +11:00
Maikel Linke
90a92421f4 Remove obsolete setting of Zeitwerk
It's the default now.
https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#the-setter-config-autoloader-has-been-deleted
2023-03-20 10:41:28 +11:00
Maikel Linke
84daa046ca Update I18n spec to Rails 7 2023-03-20 10:41:28 +11:00
Maikel Linke
61259bcfc2 Bump rails from 6.1.7 to 7.0.4
Result of:

    bundle update --conservative rails railties\
     actioncable actionmailbox actionmailer actionpack actiontext\
     actionview activejob activemodel activerecord activestorage activesupport
2023-03-20 10:41:15 +11:00
Maikel Linke
4f44d50943 Omit Rails version restriction 2023-03-20 10:38:57 +11:00
Konrad
2e426c701e Merge pull request #10232 from binarygit/show-correct-error-when-user-inputs-url-as-ig-acc
[Enterprise->Create] Show correct error message when user inputs url in instagram field
2023-03-19 21:57:02 +01:00
Konrad
99b3701e17 Merge pull request #10463 from openfoodfoundation/dependabot/bundler/devise-4.9.0
Bump devise from 4.8.1 to 4.9.0
2023-03-17 18:41:03 +01:00
Filipe
8bef0f9a43 Merge pull request #10337 from jibees/9419-send-invoices-per-email-in-bulk-from-the-admin-orders-page
Admin, orders list page: send invoices per email in bulk
2023-03-17 10:58:26 +00:00
jibees
d69aa04435 Merge pull request #10577 from openfoodfoundation/dependabot/bundler/flipper-0.26.2
Bump flipper from 0.26.0 to 0.26.2
2023-03-17 11:42:23 +01:00
dependabot[bot]
0b4a243d8e Bump flipper from 0.26.0 to 0.26.2
Bumps [flipper](https://github.com/jnunemaker/flipper) from 0.26.0 to 0.26.2.
- [Release notes](https://github.com/jnunemaker/flipper/releases)
- [Changelog](https://github.com/jnunemaker/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/jnunemaker/flipper/compare/v0.26.0...v0.26.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-17 10:01:35 +00:00
David Cook
ced9784fb8 Merge pull request #10576 from openfoodfoundation/revert-10474-fix-customer-can-checkout-non-matching-shipping-and-product-categories
Revert "Fix: Customers can checkout with non-matching shipping and product categories"
2023-03-17 15:41:04 +11:00
David Cook
788457618f Check ship address required based on all available methods
This check was implemented based on 'allowed' shipping methods, but we need to revert that logic. So for now, we can check all 'available' shipping methods.

This could potentially result in the same query being run twice, because load_shipping_methods also loads it. I opted to keep things simple and not try to optimise here.
2023-03-17 13:06:45 +11:00
David Cook
ef607da2c1 Revert "Fix: Customers can checkout with non-matching shipping and product categories" 2023-03-17 10:40:53 +11:00
Filipe
9ea6fa5c44 Merge pull request #9687 from dacook/9616-order-cycle-open-webhook
Add webhook triggered on Order Cycle Open
2023-03-16 17:24:22 +00:00
Konrad
a945f8f72f Merge pull request #10522 from mkllnk/flipper-upgrade
Bump flipper* from 0.20.4 to 0.26.0
2023-03-16 17:24:33 +01:00
jibees
0c3ee2e8fc Merge pull request #10574 from openfoodfoundation/dependabot/npm_and_yarn/jasmine-core-4.6.0
Bump jasmine-core from 4.5.0 to 4.6.0
2023-03-16 14:59:33 +01:00
vviekk
54d5d0ed80 Accepting 0<unit values<1 in product import validations 2023-03-16 16:26:43 +05:30
dependabot[bot]
f6458e91c2 Bump jasmine-core from 4.5.0 to 4.6.0
Bumps [jasmine-core](https://github.com/jasmine/jasmine) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/jasmine/jasmine/releases)
- [Changelog](https://github.com/jasmine/jasmine/blob/main/RELEASE.md)
- [Commits](https://github.com/jasmine/jasmine/compare/v4.5.0...v4.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-16 09:59:04 +00:00
vviekk
ac5cbcf19e Merge branch 'openfoodfoundation:master' into 9978 2023-03-16 14:30:26 +05:30
David Cook
4757b82a80 Update all locales with the latest Transifex translations 2023-03-16 14:15:04 +11:00
David Cook
ad9e82e973 Merge pull request #10569 from openfoodfoundation/dependabot/bundler/sidekiq-7.0.7
Bump sidekiq from 7.0.6 to 7.0.7
2023-03-16 11:47:55 +11:00
Filipe
e8430eae6d Merge pull request #10460 from jibees/10400-pagination-in-bom-not-aggregating-results-from-quick-search-field
BOM: Add a search input that search for items with pagination
2023-03-15 16:31:32 +00:00
dependabot[bot]
584b013a49 Bump sidekiq from 7.0.6 to 7.0.7
Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.0.6 to 7.0.7.
- [Release notes](https://github.com/sidekiq/sidekiq/releases)
- [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md)
- [Commits](https://github.com/sidekiq/sidekiq/compare/v7.0.6...v7.0.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-15 10:05:08 +00:00
Maikel
f15cb01f2a Merge pull request #10520 from mkllnk/return-auth-controller-spec
Correctly include order id in return auth spec for Rails 7 compatibility
2023-03-15 14:08:16 +11:00
Maikel Linke
f1a5c46685 Remove unnecessary Flipper memoizer config
Auto-config, yay.
2023-03-15 12:54:03 +11:00
Maikel Linke
00f2f92ce0 Remove unnecessary Flipper active_record config
This is now done automatically when including flipper-active_record in
the Gemfile.
2023-03-15 12:54:03 +11:00
Maikel Linke
fdd71cff51 Remove now unnecessary flipper_id method
Flipper does it for us.
2023-03-15 12:54:02 +11:00
Maikel Linke
c9ca020f05 Bump flipper* from 0.20.4 to 0.26.0 2023-03-15 12:54:02 +11:00
David Cook
d59074dabd Tidy up spec
The best way to check if something changed or not, is with 'change' of course.
2023-03-15 12:18:17 +11:00
jibees
6a874b9527 Merge pull request #10562 from openfoodfoundation/dependabot/bundler/rails-6.1.7.3
Bump rails from 6.1.7.2 to 6.1.7.3
2023-03-14 15:02:49 +01:00
dependabot[bot]
1f08da207f Bump rails from 6.1.7.2 to 6.1.7.3
Bumps [rails](https://github.com/rails/rails) from 6.1.7.2 to 6.1.7.3.
- [Release notes](https://github.com/rails/rails/releases)
- [Commits](https://github.com/rails/rails/compare/v6.1.7.2...v6.1.7.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-14 09:59:50 +00:00
Maikel Linke
9c3bdc6b9b Remove unnecessary table join
And use Rails syntax for clarity and future extensions.
2023-03-14 14:38:25 +11:00
Maikel Linke
2105c0d0ea Ignore master variants exporting to DFC 2023-03-14 14:38:24 +11:00
Maikel Linke
6e514acc77 Spec too many variants exported to DFC 2023-03-14 14:38:24 +11:00
Maikel Linke
b8338fb9af Removing engine namespace from services
Services are usually not namespaced because they are part of the app.
This engine has an isolated namespace which means that we don't need to
separate with out own namespacing here.
2023-03-14 13:49:21 +11:00
jibees
687d4593fb Merge pull request #10550 from openfoodfoundation/dependabot/bundler/database_cleaner-2.0.2
Bump database_cleaner from 2.0.1 to 2.0.2
2023-03-13 21:12:42 +01:00
dependabot[bot]
b62f88512f Bump database_cleaner from 2.0.1 to 2.0.2
Bumps [database_cleaner](https://github.com/DatabaseCleaner/database_cleaner) from 2.0.1 to 2.0.2.
- [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/v2.0.1...v2.0.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-13 15:24:41 +00:00
vviekk
2674df026a Fixing 'unsaved' alert behaviour for order cycle edit forms 2023-03-13 17:50:00 +05:30
vviekk
c1c0eca7c4 Enable invoices config only controls Print bulk action 2023-03-13 11:39:21 +05:30
vviekk
e10ea4b686 Merge branch 'openfoodfoundation:master' into 9978 2023-03-11 11:00:03 +05:30
David Cook
8f67e9839d Apply code suggestion
Avoids an error:
./script/nodenv-install.sh: line 13: brew: command not found

Co-authored-by: Maikel <maikel@email.org.au>
2023-03-10 13:38:59 +11:00
David Cook
fdeeab5750 Test twitter with (almost) real world example
I discovered that twitter doesn't have 'www' in the url anymore, no '@' symbol and interestingly no trailing slash. I added back the '@' just so we can test that still.

Using a regex group we can cater for optional www in a single regex.
2023-03-09 11:22:04 +11:00
David Cook
9e7e176cf9 Accept full URLs
It looks like the intention was there, so I made it work.
I've included a real world example, but added capitalisation to complete the test.
2023-03-09 11:21:52 +11:00
Jean-Baptiste Bellet
40a0d8e08c Improve design: make delete not a button but a link + close to file name 2023-03-08 10:38:28 +01:00
Jean-Baptiste Bellet
5cbec5521c Simplify ability
Co-Authored-By: David Cook <david@redcliffs.net>
2023-03-08 10:38:28 +01:00
binarygit
8f6fdf3e31 [Admin, Enterprise Settings] Remove Angular from Business Details tab 2023-03-08 10:26:05 +01:00
David Cook
9d5ca2255b Apply suggestions from code review
Co-authored-by: Maikel <maikel@email.org.au>
2023-03-07 15:38:50 +11:00
David Cook
00a823b2fc 6. Add webhook endpoints to user developer settings screen
Allowing creation and deleting via the user association.
It probably won't be much effort to allow editing and multiple records, but I cut it down to the minimum needed to avoid any further delays.

I couldn't find a way to test a failure in the destroy method, but decided to keep the condition because I thought it was worth having.
2023-03-07 15:38:50 +11:00
David Cook
3d81a6e280 Prevent creating duplicate webhook notifications [migration]
Using the clever concurrency testing borrowed from SubscriptionPlacementJob, but I thought a shorter pause time (just 100ms) would be sufficient.

I considered doing this with a new 'state' field (upcoming/open/close), but decided to keep it simple.
2023-03-07 15:38:50 +11:00
David Cook
739df4be01 4. OrderCycleOpenedJob triggers webhook 2023-03-07 15:38:50 +11:00
David Cook
b91cabc510 Also send webhook payloads for distributor owners
But not supplier owners.
2023-03-07 15:38:50 +11:00
David Cook
ba152f12ee 3. Add OrderCycleWebhookService to create webhook payloads for an order cycle event 2023-03-07 15:38:50 +11:00
David Cook
778baba118 User may have many WebhookEndpoints [migration]
Although we won't be allowing multiple in the this PR, we certainly plan to in the future.

The migration helper add_reference couldn't handle the custom column name, so I had to put it together manually.
2023-03-07 15:38:50 +11:00
David Cook
85c98c6d3e 2. Add model WebhookEndpoint [migration]
This will store the URL for each user that wants a notification.

We probably don't need URL validation (it's not done on Enterprise for example). It could be validated by browser input, and anyway will be validated if the webhook actually works or not.

Inspired by Keygen: https://keygen.sh/blog/how-to-build-a-webhook-system-in-rails-using-sidekiq/
2023-03-07 15:38:50 +11:00
David Cook
de9546587a Prevent webhooks to private addresses (SSRF) [add gem]
Best reviewed with whitespace hidden.

Unfortunately the spec isn't allowed in CI. But it worked on my environment, I promise.
I chose `xit` so that it doesn't run unnecessarily. Perhaps we could use `pending` instead, which would execute, and notify us if it suddenly started working one day. But I doubt it.
2023-03-07 15:38:50 +11:00
David Cook
9741935955 Raise error on server error
And thus retry later.
I tried to test that it actually retries, or ensuring the job remained in the queue to be retried, but couldn't get it to work.
2023-03-07 15:38:50 +11:00
David Cook
9d19f37fec 1. Add WebhookDeliveryJob
This job is responsible for delivering a payload for one webhook event only. It allows the action to run asynchronously (and not slow down the calling process).
2023-03-07 15:38:50 +11:00
David Cook
718ac0ab80 Add Faraday for making HTTP requests [add gem]
It's the most popular and flexible option, so should be able to cater for our future needs best.
2023-03-07 15:38:47 +11:00
Neal Chambers
d95c5ff8a8 Use Spree Taxon Controller instead of API Taxon Controller
Add tests for reordering taxons
2023-03-07 13:22:59 +11:00
Maikel Linke
797b98d686 Remove Rails 5.0 controller spec workaround
We added a method to work around a bug. But that's not needed any more.
2023-03-07 08:46:36 +11:00
Maikel Linke
3dc3ebe584 Correctly include order id in return auth spec
The route to update a return authorization must include the order number
as id:

    /admin/orders/:order_id/return_authorizations/:id(.:format)

The spec only worked because the controller's ivars were not reset
between requests and the order was already set. But Rails 7 will reset
the ivars and it failed finding the order without a given id.
2023-03-07 08:46:36 +11:00
filipefurtad0
6d05d57846 Fixes spec when introducing invalid instagram link
It seems that only the slash at the end of the address is making it invalid, which does not correspond to the error message. This is a separate issue.
2023-03-06 15:02:49 +01:00
Jean-Baptiste Bellet
ac739108a2 Improve readability by generating search string for ransack 2023-03-06 11:31:36 +01:00
Neal Chambers
3f3ae97a40 Add tests for reordering taxons 2023-03-06 18:57:02 +09:00
binarygit
ae166ae220 Fix: User does not get stuck when going backwards while creating new ent 2023-03-06 09:29:04 +01:00
binarygit
533f7048bf [Enterprise->Create] Show correct error message when user inputs url in instagram field 2023-03-06 09:29:04 +01:00
Neal Chambers
e399e27a7d Merge remote-tracking branch 'origin/fix_taxonomy' into fix_taxonomy 2023-03-06 15:09:13 +09:00
Neal Chambers
63ba3defec Use Spree Taxon Controller instead of API Taxon Controller 2023-03-06 15:07:52 +09:00
dependabot[bot]
fb01a6e244 Bump devise from 4.8.1 to 4.9.0
Bumps [devise](https://github.com/heartcombo/devise) from 4.8.1 to 4.9.0.
- [Release notes](https://github.com/heartcombo/devise/releases)
- [Changelog](https://github.com/heartcombo/devise/blob/main/CHANGELOG.md)
- [Commits](https://github.com/heartcombo/devise/compare/v4.8.1...v4.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-02 14:47:11 +00:00
binarygit
fd81429f39 Specify weight, height, width and depth as numeric field 2023-03-01 16:32:18 +01:00
Jean-Baptiste Bellet
50bc48c96f Introduce some specs around searching in BOM 2023-03-01 14:54:46 +01:00
Jean-Baptiste Bellet
8ad532c41a Can search bill_address:phone, firstname, lastname and distributor:name 2023-03-01 14:54:46 +01:00
Jean-Baptiste Bellet
ebd5d706c2 Add search input
Actually this only search for `order_email` or `order_number` or `product_name` or `supplier_name`

+ Improve display by reduce each columns width
2023-03-01 14:40:12 +01:00
Jean-Baptiste Bellet
8658b1a743 Remove quick filter that search only on displayed line items
+ remove specs as well
2023-02-28 15:39:31 +01:00
Jean-Baptiste Bellet
5208094f05 Do not bulk send invoices if order is not 'complete' or 'resumed'
+ update specs as well
2023-02-27 14:30:59 +01:00
Jean-Baptiste Bellet
8926a3f08d Having a cleaner syntax a prefer using map() instead of forEach() 2023-02-27 14:30:59 +01:00
Jean-Baptiste Bellet
58ea3a10e8 Invert condition on can send invoice 2023-02-27 14:30:59 +01:00
Jean-Baptiste Bellet
5ca5c32da4 Factorize what could be into two methods: success and orders 2023-02-27 14:30:59 +01:00
Jean-Baptiste Bellet
7a1a1286d2 Factorize two reflexes into one: BulkActionsInOrdersListReflex 2023-02-27 14:30:59 +01:00
Jean-Baptiste Bellet
5e61aa8a77 Create the bulk send invoice action in order list
using the same pattern than SendConfirmationEmail action

Co-Authored-By: David Cook <david@redcliffs.net>
2023-02-27 14:30:59 +01:00
Jean-Baptiste Bellet
af92b9f464 Reorganize spec by dividing into two contexts: 'admin' and 'hub manager' 2023-02-27 14:30:59 +01:00
Jean-Baptiste Bellet
ffaf4a837f Extract common behavior to BulkActionsController 2023-02-27 14:30:58 +01:00
vviekk
913f8bbad0 Addressing comments 2023-02-26 15:50:34 +05:30
vviekk
fc951e92ac Updating price, on_hand, on_demand validations for product import 2023-02-18 13:52:35 +05:30
David Cook
d377300f32 Support installations with homebrew (macOS)
The officially recommended installation for Mac is via Homebrew.
2023-02-17 10:36:10 +11:00
David Cook
b7a3f7263b Add script to install current node version
The API is conveniently exactly the same as rbenv.
2023-02-17 10:17:48 +11:00
Mikael Norlén
f645f8fc79 Improve schema method get_extra_fields
Use double-splat for passing options and improve examples
2023-02-15 11:14:28 +01:00
Mikael Norlén
3d06b75892 Simplify customers_with_balance spec
Improve variable names and use multiple expectations
2023-02-15 11:14:28 +01:00
Mikael Norlén
af23375b04 Separate Structure from JsonApiSchema
Class was getting too long
2023-02-15 11:14:28 +01:00
Mikael Norlén
f15a4cc943 Add autogenerated whitespaces to swagger.yml
These whitespaces were generated by
bundle exec rails rswag.

Might be related to a new version of rswag or
developers' trim trailing whitespace settings.
2023-02-15 11:14:28 +01:00
Mikael Norlén
e95d08cae8 Add balance to api v1 customers endpoint
- customers#show: Add balance (data_type: double) to customer attributes.
- customers#index: Add balance only if specified in extra_fields
query parameter: extra_fields[customer]=balance
2023-02-15 11:14:27 +01:00
Mikael Norlén
3989843a21 Add support for extra fields in JsonApiSchemas
As we are now supporting optional extra fields,
We need to be able to construct schemas where
extra fields are optionally included.
2023-02-15 11:14:27 +01:00
Mikael Norlén
22b1dd3232 Add support for extra_fields query parameter
Api now supports optional fields.
These are included with the extra_fields query param.

Syntax: extra_fields[type]=field1,field2
2023-02-15 11:14:27 +01:00
Mikael Norlén
96c0057b03 Use Customers as argument for CustomersWithBalance
Change argument for CustomersWithBalance from
enterprise_id to Customers collection.

We have the need to calculate balance for customers in general,
not just for customers in a given enterprise.
2023-02-15 11:14:27 +01:00
Jean-Baptiste Bellet
1fb4e27064 Upgrade to latest 17.* node version 2023-02-09 14:00:19 +01:00
Jean-Baptiste Bellet
9f2a17c3e9 Upgrade to node 17 which requires a --openssl-legacy-provider option
Node 17 moved to OpenSSL3, see https://nodejs.org/en/blog/release/v17.0.0/#openssl-3-0 for more.
2023-02-09 12:54:11 +01:00
Jean-Baptiste Bellet
ac639fa283 Upgrade node to the next LTS version
(which is in maintenance mode, but let's be incremental to test)
2023-02-09 10:56:28 +01:00
533 changed files with 10310 additions and 4538 deletions

View File

@@ -5,9 +5,17 @@
#
# cp .env.development .env.local
VERBOSE_QUERY_LOGS=true
SECRET_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
OFN_REDIS_URL="redis://localhost:6379/1"
OFN_REDIS_JOBS_URL="redis://localhost:6379/2"
SITE_URL="0.0.0.0:3000"
# Deactivate rack-timeout in development.
# https://github.com/zombocom/rack-timeout#configuring
RACK_TIMEOUT_SERVICE_TIMEOUT="0"
RACK_TIMEOUT_WAIT_TIMEOUT="0"
RACK_TIMEOUT_WAIT_OVERTIME="0"

View File

@@ -41,6 +41,7 @@ jobs:
- name: Scan
continue-on-error: true
run: |
git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
brakeman -f sarif -o output.sarif.json .
# Upload the SARIF file generated in the previous step

View File

@@ -18,7 +18,7 @@ permissions:
jobs:
knapsack_rspec_controllers:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -68,7 +68,6 @@ jobs:
bundle exec rake db:schema:load
- name: Run tests
env:
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: 864ef557d85ea8e603e086c0387d5154
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
@@ -82,12 +81,12 @@ jobs:
# https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it
#KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/controllers/**/*_spec.rb}"
run: |
git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
bundle exec rake knapsack_pro:rspec
knapsack_rspec_models:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -156,7 +155,7 @@ jobs:
bundle exec rake knapsack_pro:rspec
knapsack_rspec_system_admin:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -234,7 +233,7 @@ jobs:
if-no-files-found: ignore
knapsack_rspec_system_consumer:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -312,7 +311,7 @@ jobs:
if-no-files-found: ignore
knapsack_rspec_engines:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -390,7 +389,7 @@ jobs:
if-no-files-found: ignore
knapsack_rspec_test_the_rest:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -460,7 +459,7 @@ jobs:
bundle exec rake knapsack_pro:rspec
non_knapsack_jest_karma:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10

View File

@@ -9,7 +9,11 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v1
- uses: ruby/setup-ruby@v1
- run: git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
- name: rubocop
uses: reviewdog/action-rubocop@v2
with:
@@ -32,6 +36,8 @@ jobs:
- name: Install JS dependencies
run: yarn install --frozen-lockfile
- run: git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
- name: prettier
uses: EPMatt/reviewdog-action-prettier@v1
with:

View File

@@ -1 +1 @@
14.21.2
17.9.1

View File

@@ -2,9 +2,8 @@
#
# These are the rules we agreed upon and we work towards.
AllCops:
NewCops: disable
NewCops: enable
SuggestExtensions: false
TargetRailsVersion: 5.0
Exclude:
- 'bin/**/*'
- 'db/**/*'
@@ -41,6 +40,7 @@ Metrics/BlockLength:
"resources",
"scenario",
"shared_examples",
"shared_examples_for",
"xdescribe",
]

File diff suppressed because it is too large Load Diff

View File

@@ -57,6 +57,7 @@ TL;DR:
* Maintain a clean commit history
* Use a style consistent with the rest of the codebase
* Before submitting, [rebase your work][rebase] on the current master branch
* After submitting, be sure to check the [CI test results](ci). Click on a ❌ result to view the logged results and investigate.
From here, your pull request will progress through the [Review, Test, Merge & Deploy process][process].
@@ -70,4 +71,5 @@ From here, your pull request will progress through the [Review, Test, Merge & De
[slack-dev]: https://openfoodnetwork.slack.com/messages/C2GQ45KNU
[ofn-transifex]: https://www.transifex.com/open-food-foundation/open-food-network/
[i18n]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Internationalisation-%28i18n%29
[welcome-dev]: https://github.com/orgs/openfoodfoundation/projects/2
[welcome-dev]: https://github.com/orgs/openfoodfoundation/projects/5
[ci]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Continuous-Integration

View File

@@ -28,8 +28,9 @@ RUN apt-get update && apt-get install -y \
gnupg
# Setup ENV variables
ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:$PATH
ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:/usr/local/src/nodenv/shims:/usr/local/src/nodenv/bin:$PATH
ENV RBENV_ROOT /usr/local/src/rbenv
ENV NODENV_ROOT /usr/local/src/nodenv
ENV CONFIGURE_OPTS --disable-install-doc
ENV BUNDLE_PATH /bundles
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so
@@ -53,10 +54,19 @@ RUN sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-
apt-get update && \
apt-get install -yqq --no-install-recommends postgresql-client-10 libpq-dev
# Install NodeJs and yarn
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install --no-install-recommends -y nodejs \
&& npm install -g yarn
# trim spaces and line return from .node-version file
COPY .node-version .node-version.raw
RUN cat .node-version.raw | tr -d '\r\t ' > .node-version
# Install Node and Yarn with Nodenv
RUN git clone --depth 1 https://github.com/nodenv/nodenv.git ${NODENV_ROOT} && \
git clone --depth 1 https://github.com/nodenv/node-build.git ${NODENV_ROOT}/plugins/node-build && \
git clone --depth 1 https://github.com/pine/nodenv-yarn-install.git ${NODENV_ROOT}/plugins/nodenv-yarn-install && \
git clone --depth 1 https://github.com/nodenv/nodenv-package-rehash.git ${NODENV_ROOT}/plugins/nodenv-package-rehash && \
echo 'eval "$(nodenv init -)"' >> /etc/profile.d/nodenv.sh && \
nodenv install $(cat .node-version) && \
nodenv global $(cat .node-version)
# Install Chrome
RUN wget --quiet -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \

View File

@@ -48,14 +48,14 @@ Fetch the latest version of `master` from `upstream` (ie. the main repo):
First, you need to create the database user the app will use by manually typing the following in your terminal:
```sh
$ sudo -u postgres psql -c "CREATE USER ofn WITH SUPERUSER CREATEDB PASSWORD 'f00d'"
sudo --login --user=postgres psql -c "CREATE USER ofn WITH SUPERUSER CREATEDB PASSWORD 'f00d'"
```
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.
Next, it is _strongly recommended_ to run the setup script.
```sh
$ script/setup
./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.
@@ -114,13 +114,13 @@ Below are fixes to potential issues that can happen during the installation proc
#### Creating the database
If the ```$ sudo -u postgres psql -c "CREATE USER ofn WITH SUPERUSER CREATEDB PASSWORD 'f00d'"``` command doesn't work, you can run the following commands instead:
If the `sudo -u postgres psql -c "CREATE USER ofn WITH SUPERUSER CREATEDB PASSWORD 'f00d'"` command doesn't work, you can run the following commands instead:
```
$ createuser --superuser --pwprompt ofn
Enter password for new role: f00d
Enter it again: f00d
$ createdb open_food_network_dev --owner=ofn
$ createdb open_food_network_test --owner=ofn
createuser --superuser --pwprompt ofn
# Enter password for new role: f00d
# Enter it again: f00d
createdb open_food_network_dev --owner=ofn
createdb open_food_network_test --owner=ofn
```
If these commands succeed, you should be able to [continue the setup process](#get-it-running).

22
Gemfile
View File

@@ -6,7 +6,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
gem 'dotenv-rails', require: 'dotenv/rails-now' # Load ENV vars before other gems
gem 'rails', '>= 6.1.4'
gem 'rails'
# Active Storage
gem "active_storage_validations"
@@ -14,11 +14,11 @@ gem "aws-sdk-s3", require: false
gem "image_processing"
gem 'activemerchant', '>= 1.78.0'
gem 'rexml'
gem 'angular-rails-templates', '>= 0.3.0'
gem 'awesome_nested_set'
gem 'ransack', '~> 2.6.0'
gem 'responders'
gem 'rexml'
gem 'webpacker', '~> 5'
gem 'i18n'
@@ -27,7 +27,7 @@ gem 'rails-i18n'
gem 'rails_safe_tasks', '~> 1.0'
gem "activerecord-import"
gem "db2fog", github: "openfoodfoundation/db2fog", branch: "rails-6"
gem "db2fog", github: "openfoodfoundation/db2fog", branch: "rails-7"
gem "fog-aws", "~> 2.0" # db2fog does not support v3
gem "mime-types" # required by fog
@@ -70,8 +70,8 @@ gem 'rswag-api'
gem 'rswag-ui'
gem 'omniauth_openid_connect'
gem 'openid_connect', '~> 1.3'
gem 'omniauth-rails_csrf_protection'
gem 'openid_connect', '~> 1.3'
gem 'angularjs-rails', '1.8.0'
gem 'bugsnag'
@@ -92,6 +92,7 @@ gem 'gmaps4rails'
gem 'mimemagic', '> 0.3.5'
gem 'paper_trail', '~> 12.1'
gem 'rack-rewrite'
gem 'rack-timeout'
gem 'roadie-rails'
gem 'hiredis'
@@ -100,8 +101,8 @@ gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
gem 'sidekiq'
gem 'sidekiq-scheduler'
gem "cable_ready", "5.0.0.pre9"
gem "stimulus_reflex", "3.5.0.pre9"
gem "cable_ready", "5.0.0.rc2"
gem "stimulus_reflex", "3.5.0.rc2"
gem 'combine_pdf'
gem 'wicked_pdf'
@@ -136,9 +137,11 @@ gem 'view_component_reflex', '3.1.14.pre9'
gem 'mini_portile2', '~> 2.8'
gem "faraday"
gem "private_address_check"
group :production, :staging do
gem 'ddtrace'
gem 'rack-timeout'
gem 'sd_notify' # For better Systemd process management. Used by Puma.
end
@@ -147,6 +150,7 @@ group :test, :development do
gem 'capybara'
gem 'cuprite'
gem 'database_cleaner', require: false
gem 'debug', '>= 1.0.0'
gem "factory_bot_rails", '6.2.0', require: false
gem 'fuubar', '~> 2.5.1'
gem 'json_spec', '~> 1.1.4'
@@ -157,7 +161,6 @@ group :test, :development do
gem 'rswag-specs'
gem 'shoulda-matchers'
gem 'timecop'
gem 'debug', '>= 1.0.0'
end
group :test do
@@ -172,10 +175,11 @@ end
group :development do
gem 'debugger-linecache'
gem 'rails-erd'
gem 'foreman'
gem 'listen'
gem 'pry', '~> 0.13.0'
gem 'query_count'
gem 'rails-erd'
gem 'rubocop'
gem 'rubocop-rails'
gem 'spring'

View File

@@ -1,12 +1,12 @@
GIT
remote: https://github.com/openfoodfoundation/db2fog.git
revision: 5b63343847452f52aa42f7fc169d6ab3af57cda3
branch: rails-6
revision: 6e88c0ab9eeb23d7ad9964b27becb1c04a83141f
branch: rails-7
specs:
db2fog (0.9.2)
activerecord (>= 3.2.0, < 7.0)
activerecord (>= 3.2.0)
fog-core (~> 1.0)
rails (>= 3.2.0, < 7.0)
rails (>= 3.2.0)
GIT
remote: https://github.com/openfoodfoundation/select2-rails.git
@@ -44,42 +44,49 @@ GEM
remote: https://rubygems.org/
specs:
Ascii85 (1.1.0)
actioncable (6.1.7.2)
actionpack (= 6.1.7.2)
activesupport (= 6.1.7.2)
actioncable (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.7.2)
actionpack (= 6.1.7.2)
activejob (= 6.1.7.2)
activerecord (= 6.1.7.2)
activestorage (= 6.1.7.2)
activesupport (= 6.1.7.2)
actionmailbox (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
mail (>= 2.7.1)
actionmailer (6.1.7.2)
actionpack (= 6.1.7.2)
actionview (= 6.1.7.2)
activejob (= 6.1.7.2)
activesupport (= 6.1.7.2)
net-imap
net-pop
net-smtp
actionmailer (7.0.4.3)
actionpack (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activesupport (= 7.0.4.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (6.1.7.2)
actionview (= 6.1.7.2)
activesupport (= 6.1.7.2)
rack (~> 2.0, >= 2.0.9)
actionpack (7.0.4.3)
actionview (= 7.0.4.3)
activesupport (= 7.0.4.3)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionpack-action_caching (1.2.2)
actionpack (>= 4.0.0)
actiontext (6.1.7.2)
actionpack (= 6.1.7.2)
activerecord (= 6.1.7.2)
activestorage (= 6.1.7.2)
activesupport (= 6.1.7.2)
actiontext (7.0.4.3)
actionpack (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (6.1.7.2)
activesupport (= 6.1.7.2)
actionview (7.0.4.3)
activesupport (= 7.0.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
@@ -91,19 +98,19 @@ GEM
activemodel (>= 5.2.0)
activestorage (>= 5.2.0)
activesupport (>= 5.2.0)
activejob (6.1.7.2)
activesupport (= 6.1.7.2)
activejob (7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.3.6)
activemerchant (1.123.0)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
nokogiri (~> 1.4)
activemodel (6.1.7.2)
activesupport (= 6.1.7.2)
activerecord (6.1.7.2)
activemodel (= 6.1.7.2)
activesupport (= 6.1.7.2)
activemodel (7.0.4.3)
activesupport (= 7.0.4.3)
activerecord (7.0.4.3)
activemodel (= 7.0.4.3)
activesupport (= 7.0.4.3)
activerecord-import (1.4.1)
activerecord (>= 4.2)
activerecord-postgresql-adapter (0.0.1)
@@ -114,24 +121,23 @@ GEM
multi_json (~> 1.11, >= 1.11.2)
rack (>= 2.0.8, < 3)
railties (>= 5.2.4.1)
activestorage (6.1.7.2)
actionpack (= 6.1.7.2)
activejob (= 6.1.7.2)
activerecord (= 6.1.7.2)
activesupport (= 6.1.7.2)
activestorage (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activesupport (= 7.0.4.3)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.2)
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
acts-as-taggable-on (9.0.1)
activerecord (>= 6.0, < 7.1)
acts_as_list (1.0.4)
activerecord (>= 4.2)
addressable (2.8.1)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0)
afm (0.2.2)
@@ -151,16 +157,16 @@ GEM
awesome_nested_set (3.5.0)
activerecord (>= 4.0.0, < 7.1)
aws-eventstream (1.2.0)
aws-partitions (1.711.0)
aws-sdk-core (3.170.0)
aws-partitions (1.750.0)
aws-sdk-core (3.171.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.62.0)
aws-sdk-kms (1.63.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.119.1)
aws-sdk-s3 (1.121.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
@@ -178,16 +184,14 @@ GEM
bullet (7.0.7)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
cable_ready (5.0.0.pre9)
actioncable (>= 5.2)
cable_ready (5.0.0.rc2)
actionpack (>= 5.2)
actionview (>= 5.2)
activerecord (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
thread-local (>= 1.1.0)
cancancan (1.15.0)
capybara (3.38.0)
capybara (3.39.0)
addressable
matrix
mini_mime (>= 0.1.3)
@@ -211,11 +215,11 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
combine_pdf (1.0.22)
combine_pdf (1.0.23)
matrix
ruby-rc4 (>= 0.1.5)
concurrent-ruby (1.2.2)
connection_pool (2.3.0)
connection_pool (2.4.0)
crack (0.4.5)
rexml
crass (1.0.6)
@@ -224,24 +228,24 @@ GEM
cuprite (0.14.3)
capybara (~> 3.0)
ferrum (~> 0.13.0)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.0)
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.1.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.3)
ddtrace (1.10.1)
ddtrace (1.11.0)
debase-ruby_core_source (>= 0.10.16, <= 3.2.0)
libdatadog (~> 2.0.0.1.0)
libddwaf (~> 1.6.2.0.0)
libddwaf (~> 1.8.2.0.0)
msgpack
debase-ruby_core_source (3.2.0)
debug (1.7.1)
debug (1.7.2)
irb (>= 1.5.0)
reline (>= 0.3.1)
debugger-linecache (1.2.0)
devise (4.8.1)
devise (4.9.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
@@ -249,8 +253,8 @@ GEM
warden (~> 1.2.3)
devise-encryptable (0.2.0)
devise (>= 2.1.0)
devise-i18n (1.10.3)
devise (>= 4.8.0)
devise-i18n (1.11.0)
devise (>= 4.9.0)
devise-token_authenticatable (1.1.0)
devise (>= 4.0.0, < 5.0.0)
diff-lcs (1.5.0)
@@ -283,15 +287,17 @@ GEM
websocket-driver (>= 0.6, < 0.8)
ffaker (2.21.0)
ffi (1.15.5)
flipper (0.20.4)
flipper-active_record (0.20.4)
activerecord (>= 5.0, < 7)
flipper (~> 0.20.4)
flipper-ui (0.20.4)
flipper (0.26.2)
concurrent-ruby (< 2)
flipper-active_record (0.26.2)
activerecord (>= 4.2, < 8)
flipper (~> 0.26.2)
flipper-ui (0.26.2)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 0.20.4)
flipper (~> 0.26.2)
rack (>= 1.4, < 3)
rack-protection (>= 1.5.3, < 2.2.0)
rack-protection (>= 1.5.3, <= 4.0.0)
sanitize (< 7)
fog-aws (2.0.1)
fog-core (~> 1.38)
fog-json (~> 1.0)
@@ -332,7 +338,7 @@ GEM
hiredis (0.6.3)
htmlentities (4.3.4)
httpclient (2.8.3)
i18n (1.12.0)
i18n (1.13.0)
concurrent-ruby (~> 1.0)
i18n-js (3.9.2)
i18n (>= 0.6.6)
@@ -343,7 +349,7 @@ GEM
activerecord (>= 3.0)
io-console (0.6.0)
ipaddress (0.8.3)
irb (1.6.2)
irb (1.6.3)
reline (>= 0.3.0)
jmespath (1.6.2)
jquery-rails (4.4.0)
@@ -367,20 +373,20 @@ GEM
jsonapi-serializer (2.2.0)
activesupport (>= 4.2)
jwt (2.7.0)
knapsack_pro (3.8.0)
knapsack_pro (3.10.0)
rake
launchy (2.5.0)
addressable (~> 2.7)
letter_opener (1.8.1)
launchy (>= 2.2, < 3)
libdatadog (2.0.0.1.0)
libddwaf (1.6.2.0.0)
libddwaf (1.8.2.0.0)
ffi (~> 1.0)
libv8-node (16.10.0.0)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.19.1)
loofah (2.20.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.8.1)
@@ -399,15 +405,15 @@ GEM
rake
mini_magick (4.11.0)
mini_mime (1.1.2)
mini_portile2 (2.8.1)
mini_portile2 (2.8.2)
mini_racer (0.6.3)
libv8-node (~> 16.10.0.0)
minitest (5.17.0)
minitest (5.18.0)
monetize (1.12.0)
money (~> 6.12)
money (6.16.0)
i18n (>= 0.6.4, <= 2)
msgpack (1.6.1)
msgpack (1.7.0)
multi_json (1.15.0)
multi_xml (0.6.0)
net-imap (0.3.4)
@@ -419,8 +425,8 @@ GEM
timeout
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.14.2)
nio4r (2.5.9)
nokogiri (1.14.3)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
oauth2 (1.4.11)
@@ -459,7 +465,7 @@ GEM
parallel (1.22.1)
paranoia (2.6.1)
activerecord (>= 5.1, < 7.1)
parser (3.2.1.1)
parser (3.2.2.0)
ast (~> 2.4.1)
paypal-sdk-core (0.3.4)
multi_json (~> 1.0)
@@ -474,15 +480,19 @@ GEM
ttfunk
pg (1.2.3)
power_assert (2.0.2)
private_address_check (0.5.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.1)
puma (6.1.1)
puma (6.2.2)
nio4r (~> 2.0)
query_count (1.1.1)
activerecord (>= 4.2)
railties (>= 4.2)
raabro (1.4.0)
racc (1.6.2)
rack (2.2.6.3)
rack (2.2.7)
rack-mini-profiler (2.3.4)
rack (>= 1.2.0)
rack-oauth2 (1.21.3)
@@ -491,29 +501,28 @@ GEM
httpclient
json-jwt (>= 1.11.0)
rack (>= 2.1.0)
rack-protection (2.1.0)
rack-protection (3.0.5)
rack
rack-proxy (0.7.6)
rack
rack-rewrite (1.5.1)
rack-test (2.0.2)
rack-test (2.1.0)
rack (>= 1.3)
rack-timeout (0.6.3)
rails (6.1.7.2)
actioncable (= 6.1.7.2)
actionmailbox (= 6.1.7.2)
actionmailer (= 6.1.7.2)
actionpack (= 6.1.7.2)
actiontext (= 6.1.7.2)
actionview (= 6.1.7.2)
activejob (= 6.1.7.2)
activemodel (= 6.1.7.2)
activerecord (= 6.1.7.2)
activestorage (= 6.1.7.2)
activesupport (= 6.1.7.2)
rails (7.0.4.3)
actioncable (= 7.0.4.3)
actionmailbox (= 7.0.4.3)
actionmailer (= 7.0.4.3)
actionpack (= 7.0.4.3)
actiontext (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activemodel (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
bundler (>= 1.15.0)
railties (= 6.1.7.2)
sprockets-rails (>= 2.0.0)
railties (= 7.0.4.3)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
@@ -532,12 +541,13 @@ GEM
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
rails_safe_tasks (1.0.0)
railties (6.1.7.2)
actionpack (= 6.1.7.2)
activesupport (= 6.1.7.2)
railties (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
ransack (2.6.0)
@@ -549,10 +559,10 @@ GEM
ffi (~> 1.0)
redcarpet (3.6.0)
redis (4.8.1)
redis-client (0.13.0)
redis-client (0.14.1)
connection_pool
regexp_parser (2.7.0)
reline (0.3.2)
regexp_parser (2.8.0)
reline (0.3.3)
io-console (~> 0.5)
request_store (1.5.1)
rack (>= 1.4)
@@ -576,7 +586,7 @@ GEM
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.1)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
diff-lcs (>= 1.2.0, < 2.0)
@@ -595,29 +605,29 @@ GEM
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.12.0)
rswag-api (2.8.0)
rswag-api (2.9.0)
railties (>= 3.1, < 7.1)
rswag-specs (2.8.0)
rswag-specs (2.9.0)
activesupport (>= 3.1, < 7.1)
json-schema (>= 2.2, < 4.0)
railties (>= 3.1, < 7.1)
rspec-core (>= 2.14)
rswag-ui (2.8.0)
rswag-ui (2.9.0)
actionpack (>= 3.1, < 7.1)
railties (>= 3.1, < 7.1)
rubocop (1.48.1)
rubocop (1.50.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.26.0, < 2.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.27.0)
rubocop-ast (1.28.0)
parser (>= 3.2.1.0)
rubocop-rails (2.18.0)
rubocop-rails (2.19.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
@@ -631,6 +641,9 @@ GEM
rubyzip (2.3.2)
rufus-scheduler (3.8.2)
fugit (~> 1.1, >= 1.1.6)
sanitize (6.0.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
sass (3.4.25)
sass-rails (5.0.8)
railties (>= 5.2.0)
@@ -642,11 +655,11 @@ GEM
semantic_range (3.0.0)
shoulda-matchers (5.3.0)
activesupport (>= 5.2.0)
sidekiq (7.0.6)
sidekiq (7.1.0)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.11.0)
redis-client (>= 0.14.0)
sidekiq-scheduler (5.0.2)
rufus-scheduler (~> 3.2)
sidekiq (>= 6, < 8)
@@ -677,18 +690,18 @@ GEM
state_machines-activerecord (0.8.0)
activerecord (>= 5.1)
state_machines-activemodel (>= 0.8.0)
stimulus_reflex (3.5.0.pre9)
actioncable (>= 5.2)
actionpack (>= 5.2)
actionview (>= 5.2)
activesupport (>= 5.2)
cable_ready (>= 5.0.0.pre9)
nokogiri
rack
railties (>= 5.2)
redis
stringex (2.8.5)
stripe (8.3.0)
stimulus_reflex (3.5.0.rc2)
actioncable (>= 5.2, < 8)
actionpack (>= 5.2, < 8)
actionview (>= 5.2, < 8)
activesupport (>= 5.2, < 8)
cable_ready (>= 5.0.0.rc2)
nokogiri (~> 1.0)
rack (>= 2, < 4)
railties (>= 5.2, < 8)
redis (>= 4.0, < 6.0)
stringex (2.8.6)
stripe (8.5.0)
swd (1.3.0)
activesupport (>= 3)
attr_required (>= 0.0.5)
@@ -706,7 +719,7 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
uniform_notifier (1.16.0)
valid_email2 (4.0.5)
valid_email2 (4.0.6)
activemodel (>= 3.2)
mail (~> 2.5)
validate_email (0.1.6)
@@ -716,7 +729,7 @@ GEM
activemodel (>= 3.0.0)
public_suffix
vcr (6.1.0)
view_component (2.82.0)
view_component (3.0.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
@@ -781,7 +794,7 @@ DEPENDENCIES
bootsnap
bugsnag
bullet
cable_ready (= 5.0.0.pre9)
cable_ready (= 5.0.0.rc2)
cancancan (~> 1.15.0)
capybara
catalog!
@@ -801,6 +814,7 @@ DEPENDENCIES
digest
dotenv-rails
factory_bot_rails (= 6.2.0)
faraday
ffaker
flipper
flipper-active_record
@@ -843,12 +857,14 @@ DEPENDENCIES
paypal-sdk-merchant (= 1.117.2)
pdf-reader
pg (~> 1.2.3)
private_address_check
pry (~> 0.13.0)
puma
query_count
rack-mini-profiler (< 3.0.0)
rack-rewrite
rack-timeout
rails (>= 6.1.4)
rails
rails-controller-testing
rails-erd
rails-i18n
@@ -877,7 +893,7 @@ DEPENDENCIES
spring
spring-commands-rspec
state_machines-activerecord
stimulus_reflex (= 3.5.0.pre9)
stimulus_reflex (= 3.5.0.rc2)
stringex (~> 2.8.5)
stripe
test-unit (~> 3.5)

View File

@@ -1,5 +1,5 @@
# Foreman Procfile. Start all dev server processes with: `foreman start`
rails: bundle exec rails s -p 3000
rails: DEV_CACHING=true bundle exec rails s -p 3000
webpack: ./bin/webpack-dev-server
sidekiq: bundle exec sidekiq -q mailers -q default
sidekiq: DEV_CACHING=true bundle exec sidekiq -q mailers -q default

View File

@@ -12,5 +12,6 @@ angular.module("ofn.admin", [
"admin.orders"
]).config ($httpProvider, $locationProvider, $qProvider) ->
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"
# for the next line, you should also probably check file: app/assets/javascripts/admin/utils/utils.js.coffee
$locationProvider.hashPrefix('')
$qProvider.errorOnUnhandledRejections(false)

View File

@@ -55,28 +55,12 @@ angular.module("admin.enterprises")
else
alert ("#{manager.email}" + " " + t("is_already_manager"))
$scope.inviteManager = ->
$scope.invite_errors = $scope.invite_success = null
email = $scope.newUser
$http.post("/admin/manager_invitations", {email: email, enterprise_id: $scope.Enterprise.id}).then (response)->
$scope.addManager({id: response.data.user, email: email})
$scope.invite_success = t('user_invited', email: email)
.catch (response) ->
$scope.invite_errors = response.data.errors
$scope.resetModal = ->
$scope.newUser = $scope.invite_errors = $scope.invite_success = null
$scope.removeLogo = ->
$scope.performEnterpriseAction("removeLogo", "immediate_logo_removal_warning", "removed_logo_successfully")
$scope.removePromoImage = ->
$scope.performEnterpriseAction("removePromoImage", "immediate_promo_image_removal_warning", "removed_promo_image_successfully")
$scope.removeTermsAndConditions = ->
$scope.performEnterpriseAction("removeTermsAndConditions", "immediate_terms_and_conditions_removal_warning", "removed_terms_and_conditions_successfully")
$scope.performEnterpriseAction = (enterpriseActionName, warning_message_key, success_message_key) ->
return unless confirm($scope.translation(warning_message_key))

View File

@@ -1,32 +0,0 @@
angular.module("admin.enterprises").directive 'termsAndConditionsWarning', ($rootScope, $compile, $templateCache, DialogDefaults, $timeout) ->
restrict: 'A'
scope: true
link: (scope, element, attr) ->
# This file input click handler will hold the browser file input dialog and show a warning modal
scope.hold_file_input_and_show_warning_modal = (event) ->
event.preventDefault()
scope.template = $compile($templateCache.get('admin/modals/terms_and_conditions_warning.html'))(scope)
if scope.template.dialog
scope.template.dialog(DialogDefaults)
scope.template.dialog('open')
$rootScope.$evalAsync()
element.bind 'click', scope.hold_file_input_and_show_warning_modal
# When the user presses continue in the warning modal, we open the browser file input dialog
scope.continue = ->
scope.template.dialog('close')
$rootScope.$evalAsync()
# unbind warning modal handler and click file input again to open the browser file input dialog
element.unbind('click').trigger('click')
# afterwards, bind warning modal handler again so that the warning is shown the next time
$timeout ->
element.bind 'click', scope.hold_file_input_and_show_warning_modal
return
scope.close = ->
scope.template.dialog('close')
$rootScope.$evalAsync()
return

View File

@@ -11,5 +11,6 @@ angular.module("admin.indexUtils").factory 'SortOptions', ->
sortingExpr
toggle: (predicate) ->
@reverse = (@predicate == predicate) && !@reverse
# predicate is a string or an array of strings
@reverse = (JSON.stringify(@predicate) == JSON.stringify(predicate)) && !@reverse
@predicate = predicate

View File

@@ -17,7 +17,15 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
]
$scope.page = 1
$scope.per_page = $scope.per_page_options[0].id
$scope.filterByVariantId = null
searchThrough = ["order_distributor_name",
"order_bill_address_phone",
"order_bill_address_firstname",
"order_bill_address_lastname",
"variant_product_supplier_name",
"order_email",
"order_number",
"product_name"].join("_or_") + "_cont"
$scope.confirmRefresh = ->
LineItems.allSaved() || confirm(t("unsaved_changes_warning"))
@@ -26,7 +34,7 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.distributorFilter = ''
$scope.supplierFilter = ''
$scope.orderCycleFilter = ''
$scope.quickSearch = ''
$scope.query = ''
$scope.startDate = undefined
$scope.endDate = undefined
event = new CustomEvent('flatpickr:clear')
@@ -60,6 +68,8 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
[formattedStartDate, formattedEndDate] = $scope.formatDates($scope.startDate, $scope.endDate)
RequestMonitor.load LineItems.index(
"q[#{searchThrough}]": $scope.query,
"q[variant_id_eq]": $scope.filterByVariantId if $scope.filterByVariantId,
"q[order_state_not_eq]": "canceled",
"q[order_shipment_state_not_eq]": "shipped",
"q[order_completed_at_not_null]": "true",
@@ -168,6 +178,17 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.setSelectedUnitsVariant = (unitsProduct,unitsVariant) ->
$scope.selectedUnitsProduct = unitsProduct
$scope.selectedUnitsVariant = unitsVariant
$scope.filterByVariantId = unitsVariant.id
$scope.page = 1
$scope.refreshData()
$scope.resetSelectedUnitsVariant = ->
$scope.selectedUnitsProduct = { }
$scope.selectedUnitsVariant = { }
$scope.filterByVariantId = null
$scope.sharedResource = false
$scope.page = 1
$scope.refreshData()
$scope.getLineItemScale = (lineItem) ->
if lineItem.units_product && lineItem.units_variant && (lineItem.units_product.variant_unit == "weight" || lineItem.units_product.variant_unit == "volume")

View File

@@ -1,6 +0,0 @@
angular.module("admin.lineItems").filter "variantFilter", ->
return (lineItems,selectedUnitsProduct,selectedUnitsVariant,sharedResource) ->
filtered = []
filtered.push lineItem for lineItem in lineItems when (angular.equals(selectedUnitsProduct,{}) ||
(lineItem.units_product.id == selectedUnitsProduct.id && (sharedResource || lineItem.units_variant.id == selectedUnitsVariant.id ) ) )
filtered

View File

@@ -18,7 +18,6 @@ angular.module('admin.orderCycles')
$scope.submit = ($event, destination) ->
$event.preventDefault()
NavigationCheck.clear()
StatusMessage.display 'progress', t('js.saving')
OrderCycle.update(destination, $scope.order_cycle_form)

View File

@@ -33,9 +33,11 @@ angular.module("admin.orderCycles").controller "OrderCyclesCtrl", ($scope, $q, C
StatusMessage.display 'notice', "You have unsaved changes" if newVal
$scope.showMore = (days) ->
orderCycles = OrderCycles.index(ams_prefix: "index",
"q[orders_close_at_gt]": "#{daysFromToday($scope.ordersCloseAtLimit - days)}",
"q[orders_close_at_lteq]": "#{daysFromToday($scope.ordersCloseAtLimit)}"
)
$scope.ordersCloseAtLimit -= days
existingIDs = Object.keys(OrderCycles.byID)
orderCycles = OrderCycles.index(ams_prefix: "index", "q[orders_close_at_gt]": "#{daysFromToday($scope.ordersCloseAtLimit)}", "q[id_not_in][]": existingIDs)
orderCycles.$promise.then ->
$scope.orderCycles.push(orderCycle) for orderCycle in orderCycles
compileData()

View File

@@ -14,7 +14,4 @@ angular.module("admin.resources").factory 'EnterpriseResource', ($resource) ->
'removePromoImage':
url: '/api/v0/enterprises/:id/promo_image.json'
method: 'DELETE'
'removeTermsAndConditions':
url: '/api/v0/enterprises/:id/terms_and_conditions.json'
method: 'DELETE'
})

View File

@@ -63,4 +63,3 @@ angular.module("admin.resources").factory 'Enterprises', ($q, $filter, Enterpris
removeLogo: performActionOnEnterpriseResource(EnterpriseResource.removeLogo)
removePromoImage: performActionOnEnterpriseResource(EnterpriseResource.removePromoImage)
removeTermsAndConditions: performActionOnEnterpriseResource(EnterpriseResource.removeTermsAndConditions)

View File

@@ -15,7 +15,7 @@ $(document).ready(function() {
console.log(msg);
});
}
$('[data-hook=admin_order_edit_form] a.ship').click(handle_ship_click);
$('.admin-order-edit-form a.ship').click(handle_ship_click);
//handle shipping method edit click
$('a.edit-method').click(toggleMethodEdit);
@@ -37,7 +37,7 @@ $(document).ready(function() {
console.log(msg);
});
}
$('[data-hook=admin_order_edit_form] a.save-method').click(handle_shipping_method_save);
$('.admin-order-edit-form a.save-method').click(handle_shipping_method_save);
//handle tracking info edit/delete
@@ -64,8 +64,8 @@ $(document).ready(function() {
return Spree.url( Spree.routes.orders_api + "/" + order_number + "/shipments/" + shipmentNumber + ".json");
}
$('[data-hook=admin_order_edit_form] a.save-tracking').click(saveTrackingInfo);
$('[data-hook=admin_order_edit_form] a.delete-tracking').click(deleteTrackingInfo);
$('.admin-order-edit-form a.save-tracking').click(saveTrackingInfo);
$('.admin-order-edit-form a.delete-tracking').click(deleteTrackingInfo);
// handle note edit/delete
@@ -96,8 +96,8 @@ $(document).ready(function() {
});
}
$('[data-hook=admin_order_edit_form] a.save-note').click(saveNote);
$('[data-hook=admin_order_edit_form] a.delete-note').click(deleteNote);
$('.admin-order-edit-form a.save-note').click(saveNote);
$('.admin-order-edit-form a.delete-note').click(deleteNote);
// Makes API call for notes/tracking info
makeApiCall = function(url, params) {

View File

@@ -4,7 +4,8 @@ $(document).ready(function() {
initAlert()
initConfirm()
initCancelOrder()
initButtonCancel()
initLinkCancel()
if ($('#variant_autocomplete_template').length > 0) {
window.variantTemplate = Handlebars.compile($('#variant_autocomplete_template').text());
@@ -276,17 +277,23 @@ ofnConfirm = function(callback) {
$('#custom-confirm').show();
}
initCancelOrder = function() {
$('#cancel_order_form').submit(function(e){
ofnCancelOrderAlert((confirm, sendEmailCancellation, restock_items) => {
if (confirm) {
var redirectTo = new URL(Spree.routes.cancel_order.toString());
redirectTo.searchParams.append("send_cancellation_email", sendEmailCancellation);
redirectTo.searchParams.append("restock_items", restock_items);
window.location.href = redirectTo.toString();
}
});
e.preventDefault();
return false;
initCancelAction = function(e){
ofnCancelOrderAlert((confirm, sendEmailCancellation, restock_items) => {
if (confirm) {
var redirectTo = new URL(Spree.routes.cancel_order.toString());
redirectTo.searchParams.append("send_cancellation_email", sendEmailCancellation);
redirectTo.searchParams.append("restock_items", restock_items);
window.location.href = redirectTo.toString();
}
});
e.preventDefault();
return false;
};
initButtonCancel = function() {
$('#cancel_order_form').submit(initCancelAction)
}
initLinkCancel = function() {
$('#links-dropdown a[href$="cancel"]').click(initCancelAction);
}

View File

@@ -8,7 +8,7 @@ handle_move = (e, data) ->
node = data.rslt.o
new_parent = data.rslt.np
url = new URL(base_url)
url = new URL(Spree.routes.admin_taxonomy_taxons)
url.pathname = url.pathname + '/' + node.attr("id")
data = {
_method: "put",

View File

@@ -1,2 +1,4 @@
angular.module("admin.utils", ["templates", "ngSanitize"]).config ($httpProvider) ->
angular.module("admin.utils", ["templates", "ngSanitize"]).config ($httpProvider, $locationProvider) ->
# for the next line, you should also probably check file: app/assets/javascripts/admin/admin_ofn.js.coffee
$locationProvider.hashPrefix('')
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"

View File

@@ -2,6 +2,7 @@ angular.module('Darkswarm').factory "EnterpriseModal", ($modal, $rootScope, $htt
# Build a modal popup for an enterprise.
new class EnterpriseModal
open: (enterprise)->
return if enterprise.visible == 'hidden'
scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise
scope.embedded_layout = window.location.search.indexOf("embedded_shopfront=true") != -1

View File

@@ -55,6 +55,10 @@ angular.module('Darkswarm').factory "EnterpriseRegistrationService", ($http, Reg
).catch((response) ->
Loading.clear()
alert(t('failed_to_update_enterprise_unknown'))
if response.data.errors.instagram
igErr = document.querySelector("#instagram-error")
igErr.style.display = 'block'
igErr.textContent = response.data.errors.instagram[0]
)
prepare: =>

View File

@@ -1,14 +0,0 @@
%div
.margin-bottom-30.text-center
.text-big
{{ 'js.admin.modals.terms_and_conditions_warning.title' | t }}
.margin-bottom-30
%p
{{ 'js.admin.modals.terms_and_conditions_warning.message_1' | t }}
.margin-bottom-30
%p
{{ 'js.admin.modals.terms_and_conditions_warning.message_2' | t }}
.text-center
%input.button.red{ type: 'button', value: t('js.admin.modals.close'), ng: { click: 'close()' } }
%input.button.red{ type: 'button', value: t('js.admin.modals.continue'), ng: { click: 'continue()' } }

View File

@@ -1,9 +1,10 @@
# frozen_string_literal: true
class ConfirmModalComponent < ModalComponent
def initialize(id:, confirm_actions: nil, controllers: nil, message: nil)
def initialize(id:, confirm_actions: nil, controllers: nil, message: nil, confirm_reflexes: nil)
super(id: id, close_button: true)
@confirm_actions = confirm_actions
@confirm_reflexes = confirm_reflexes
@controllers = controllers
@message = message
end

View File

@@ -7,4 +7,4 @@
.modal-actions
%input{ class: "button icon-plus #{close_button_class}", type: 'button', value: t('js.admin.modals.cancel'), "data-action": "click->modal#close" }
%input{ class: "button icon-plus primary", type: 'button', value: t('js.admin.modals.confirm'), "data-action": @confirm_actions }
%input{ class: "button icon-plus primary", type: 'button', value: t('js.admin.modals.confirm'), "data-action": @confirm_actions, "data-reflex": @confirm_reflexes }

View File

@@ -2,6 +2,7 @@
require 'open_food_network/address_finder'
# rubocop:disable Metrics/ClassLength
module Admin
class CustomersController < Admin::ResourceController
before_action :load_managed_shops, only: :index, if: :html_request?
@@ -67,7 +68,7 @@ module Admin
def collection
if json_request? && params[:enterprise_id].present?
CustomersWithBalance.new(managed_enterprise_id).query.
CustomersWithBalance.new(customers).query.
includes(
:enterprise,
{ bill_address: [:state, :country] },
@@ -79,6 +80,15 @@ module Admin
end
end
def customers
return @customers if @customers.present?
@customers = Customer.managed_by(spree_current_user)
return @customers if params[:enterprise_id].blank?
@customers = @customers.where(enterprise_id: params[:enterprise_id])
end
def managed_enterprise_id
@managed_enterprise_id ||= Enterprise.managed_by(spree_current_user).
select('enterprises.id').find_by(id: params[:enterprise_id])
@@ -120,3 +130,4 @@ module Admin
end
end
end
# rubocop:enable Metrics/ClassLength

View File

@@ -50,7 +50,7 @@ module Admin
if params[:stimulus]
@enterprise.is_primary_producer = params[:is_primary_producer]
@enterprise.sells = params[:enterprise_sells]
render operations: cable_car.morph("#side_menu", partial("admin/shared/side_menu"))
render cable_ready: cable_car.morph("#side_menu", partial("admin/shared/side_menu"))
.morph("#permalink", partial("admin/enterprises/form/permalink"))
end
end

View File

@@ -1,47 +0,0 @@
# frozen_string_literal: true
module Admin
class ManagerInvitationsController < Spree::Admin::BaseController
authorize_resource class: false
def create
@email = params[:email]
@enterprise = Enterprise.find(params[:enterprise_id])
authorize! :edit, @enterprise
existing_user = Spree::User.find_by(email: @email)
if existing_user
render json: { errors: t('admin.enterprises.invite_manager.user_already_exists') },
status: :unprocessable_entity
return
end
new_user = create_new_manager
if new_user
render json: { user: new_user.id }, status: :ok
else
render json: { errors: t('admin.enterprises.invite_manager.error') },
status: :internal_server_error
end
end
private
def create_new_manager
password = Devise.friendly_token
new_user = Spree::User.create(email: @email, unconfirmed_email: @email, password: password)
new_user.reset_password_token = Devise.friendly_token
# Same time as used in Devise's lib/devise/models/recoverable.rb.
new_user.reset_password_sent_at = Time.now.utc
new_user.save!
@enterprise.users << new_user
EnterpriseMailer.manager_invitation(@enterprise, new_user).deliver_later
new_user
end
end
end

View File

@@ -2,6 +2,7 @@
module Admin
class ReportsController < Spree::Admin::BaseController
include ActiveStorage::SetCurrent
include ReportsActions
helper ReportsHelper
@@ -21,11 +22,13 @@ module Admin
def show
@report = report_class.new(spree_current_user, params, render: render_data?)
if report_format.present?
if params[:report_format].present?
export_report
else
show_report
end
rescue Timeout::Error
render_timeout_error
end
private
@@ -36,6 +39,7 @@ module Admin
def show_report
assign_view_data
@table = render_report_as(:html) if render_data?
render "show"
end
@@ -45,7 +49,6 @@ module Admin
@report_subtype = report_subtype
@report_title = report_title
@rendering_options = rendering_options
@table = render_report_as(:html) if render_data?
@data = Reporting::FrontendData.new(spree_current_user)
end
@@ -55,17 +58,43 @@ module Admin
def render_report_as(format)
if OpenFoodNetwork::FeatureToggle.enabled?(:background_reports, spree_current_user)
job = ReportJob.new
JobProcessor.perform_forked(
job,
report_class, spree_current_user, params, format
@blob = ReportBlob.create_for_upload_later!(report_filename)
ReportJob.perform_later(
report_class, spree_current_user, params, format, @blob
)
Timeout.timeout(max_wait_time) do
sleep 1 until @blob.content_stored?
end
# This result has been rendered by Rails in safe mode already.
job.result.html_safe # rubocop:disable Rails/OutputSafety
@blob.result.html_safe # rubocop:disable Rails/OutputSafety
else
@report.render_as(format)
end
end
def render_timeout_error
assign_view_data
if @blob
@error = ".report_taking_longer_html"
@error_url = @blob.url
else
@error = ".report_taking_longer"
@error_url = ""
end
render "show"
end
def max_wait_time
# This value is used by rack-timeout and nginx, usually 30 seconds in
# staging and production:
server_timeout = ENV.fetch("RACK_TIMEOUT_SERVICE_TIMEOUT", "15").to_f
# Zero disables the timeout:
return 0 if server_timeout.zero?
# We want to time out earlier than nginx:
server_timeout - 2.seconds
end
end
end

View File

@@ -16,7 +16,8 @@ module Admin
respond_to do |format|
format.html do
if view_context.subscriptions_setup_complete?(@shops)
@order_cycles = OrderCycle.joins(:schedules).managed_by(spree_current_user).includes([:distributors, :cached_incoming_exchanges])
@order_cycles = OrderCycle.joins(:schedules).managed_by(spree_current_user)
.includes([:distributors, :cached_incoming_exchanges])
@payment_methods = Spree::PaymentMethod.managed_by(spree_current_user).includes(:taggings)
@payment_method_tags = payment_method_tags_by_id
@shipping_methods = Spree::ShippingMethod.managed_by(spree_current_user)
@@ -25,7 +26,10 @@ module Admin
render :setup_explanation
end
end
format.json { render_as_json @collection, ams_prefix: params[:ams_prefix], payment_method_tags: payment_method_tags_by_id }
format.json {
render_as_json @collection, ams_prefix: params[:ams_prefix],
payment_method_tags: payment_method_tags_by_id
}
end
end

View File

@@ -63,7 +63,7 @@ module Admin
options = [{ id: '0', name: 'All' }]
import_dates.collect(&:import_date).map { |i|
options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long))
options.push(id: i.to_date, name: i.to_date.to_fs(:long))
}
options

View File

@@ -0,0 +1,36 @@
# frozen_string_literal: true
module Admin
class VouchersController < ResourceController
before_action :load_enterprise
def new
@voucher = Voucher.new
end
def create
voucher_params = permitted_resource_params.merge(enterprise: @enterprise)
@voucher = Voucher.create(voucher_params)
if @voucher.save
redirect_to(
"#{edit_admin_enterprise_path(@enterprise)}#vouchers_panel",
flash: { success: flash_message_for(@voucher, :successfully_created) }
)
else
flash[:error] = @voucher.errors.full_messages.to_sentence
render :new
end
end
private
def load_enterprise
@enterprise = Enterprise.find_by permalink: params[:enterprise_id]
end
def permitted_resource_params
params.require(:voucher).permit(:code)
end
end
end

View File

@@ -106,7 +106,9 @@ module Api
end
def json_api_error(message, **options)
{ errors: [{ detail: message }] }.merge(options)
error_options = options.delete(:error_options) || {}
{ errors: [{ detail: message }.merge(error_options)] }.merge(options)
end
def json_api_invalid(message, errors)

View File

@@ -6,11 +6,17 @@ module Api
module V1
class CustomersController < Api::V1::BaseController
include AddressTransformation
include ExtraFields
skip_authorization_check only: :index
before_action :authorize_action, only: [:show, :update, :destroy]
# Query parameters
before_action only: [:index] do
@extra_customer_fields = extra_fields :customer, [:balance]
end
def index
@pagy, customers = pagy(search_customers, pagy_options)
@@ -51,7 +57,11 @@ module Api
private
def customer
@customer ||= Customer.find(params[:id])
@customer ||= if action_name == "show"
CustomersWithBalance.new(Customer.where(id: params[:id])).query.first!
else
Customer.find(params[:id])
end
end
def authorize_action
@@ -61,13 +71,16 @@ module Api
def search_customers
customers = visible_customers.includes(:bill_address, :ship_address)
customers = customers.where(enterprise_id: params[:enterprise_id]) if params[:enterprise_id]
if @extra_customer_fields.include?(:balance)
customers = CustomersWithBalance.new(customers).query
end
customers.ransack(params[:q]).result.order(:id)
end
def visible_customers
current_api_user.customers.or(
Customer.where(enterprise_id: editable_enterprises)
)
Customer.managed_by(current_api_user)
end
def customer_params
@@ -91,10 +104,6 @@ module Api
attributes
end
def editable_enterprises
OpenFoodNetwork::Permissions.new(current_api_user).editable_enterprises.select(:id)
end
def include_options
fields = [params.fetch(:include, [])].flatten

View File

@@ -5,6 +5,7 @@ require 'open_food_network/address_finder'
class CheckoutController < ::BaseController
include OrderStockCheck
include OrderCompletion
include WhiteLabel
layout 'darkswarm'
@@ -27,6 +28,8 @@ class CheckoutController < ::BaseController
before_action :associate_user
before_action :check_authorization
before_action :hide_ofn_navigation, only: :edit
helper 'spree/orders'
def edit; end

View File

@@ -15,9 +15,7 @@ module CheckoutCallbacks
prepend_before_action :require_distributor_chosen
before_action :load_order, :associate_user, :load_saved_addresses, :load_saved_credit_cards
before_action :allowed_shipping_methods, if: -> {
params[:step] == "details"
}
before_action :load_shipping_methods, if: -> { params[:step] == "details" }
before_action :ensure_order_not_completed
before_action :ensure_checkout_allowed
@@ -48,22 +46,8 @@ module CheckoutCallbacks
@selected_card = nil
end
def allowed_shipping_methods
@allowed_shipping_methods ||= sorted_available_shipping_methods.filter(
&method(:supports_all_products_shipping_categories?)
)
end
def sorted_available_shipping_methods
available_shipping_methods.sort { |a, b| a.name.casecmp(b.name) }
end
def supports_all_products_shipping_categories?(shipping_method)
(products_shipping_categories - shipping_method.shipping_categories.pluck(:id)).empty?
end
def products_shipping_categories
@products_shipping_categories ||= @order.products.pluck(:shipping_category_id).uniq
def load_shipping_methods
@shipping_methods = available_shipping_methods.sort { |a, b| a.name.casecmp(b.name) }
end
def redirect_to_shop?

View File

@@ -0,0 +1,32 @@
# frozen_string_literal: true
# To be included in api controllers for handeling query params
module ExtraFields
extend ActiveSupport::Concern
def invalid_query_param(name, status, msg)
render status: status, json: json_api_error(msg, error_options:
{
title: I18n.t("api.query_param.error.title"),
source: { parameter: name },
status: status,
code: Rack::Utils::SYMBOL_TO_STATUS_CODE[status]
})
end
def extra_fields(type, available_fields)
fields = params.dig(:extra_fields, type)&.split(',')&.compact&.map(&:to_sym)
return [] if fields.blank?
unknown_fields = fields - available_fields
if unknown_fields.present?
invalid_query_param(
"extra_fields[#{type}]", :unprocessable_entity,
I18n.t("api.query_param.error.extra_fields", fields: unknown_fields.join(', '))
)
end
fields
end
end

View File

@@ -0,0 +1,19 @@
# frozen_string_literal: true
module ManagerInvitations
extend ActiveSupport::Concern
def create_new_manager(email, enterprise)
password = Devise.friendly_token
new_user = Spree::User.create(email: email, unconfirmed_email: email, password: password)
new_user.reset_password_token = Devise.friendly_token
# Same time as used in Devise's lib/devise/models/recoverable.rb.
new_user.reset_password_sent_at = Time.now.utc
if new_user.save
enterprise.users << new_user
EnterpriseMailer.manager_invitation(enterprise, new_user).deliver_later
end
new_user
end
end

View File

@@ -31,7 +31,7 @@ module OrderStockCheck
flash[:info] = I18n.t('order_cycle_closed')
respond_to do |format|
format.cable_ready {
render status: :see_other, operations: cable_car.redirect_to(url: main_app.shop_path)
render status: :see_other, cable_ready: cable_car.redirect_to(url: main_app.shop_path)
}
format.json { render json: { path: main_app.shop_path }, status: :see_other }
format.html { redirect_to main_app.shop_path, status: :see_other }

View File

@@ -56,7 +56,7 @@ module ReportsActions
end
def report_format
params[:report_format]
params[:report_format].presence || "html"
end
def report_filename

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
module WhiteLabel
extend ActiveSupport::Concern
include EnterprisesHelper
def hide_ofn_navigation(distributor = current_distributor)
return false unless OpenFoodNetwork::FeatureToggle.enabled?(:white_label)
# if the distributor has the hide_ofn_navigation preference set to true
# then we should hide the OFN navigation
@hide_ofn_navigation = distributor.hide_ofn_navigation
# if the distributor has the hide_ofn_navigation preference
# set to false, there is no need to check the white_label_logo preference
return unless @hide_ofn_navigation
@white_label_logo = distributor.white_label_logo
@white_label_distributor = distributor
end
end

View File

@@ -7,6 +7,7 @@ class EnterprisesController < BaseController
helper Spree::ProductsHelper
include OrderCyclesHelper
include SerializerHelper
include WhiteLabel
protect_from_forgery except: :check_permalink
@@ -14,6 +15,7 @@ class EnterprisesController < BaseController
prepend_before_action :set_order_cycles, :require_distributor_chosen, :reset_order, only: :shop
before_action :clean_permalink, only: :check_permalink
before_action :hide_ofn_navigation, only: :shop
respond_to :js, only: :permalink_checker

View File

@@ -10,6 +10,7 @@ class SplitCheckoutController < ::BaseController
include CheckoutCallbacks
include OrderCompletion
include CablecarResponses
include WhiteLabel
helper 'terms_and_conditions'
helper 'checkout'
@@ -18,13 +19,14 @@ class SplitCheckoutController < ::BaseController
helper OrderHelper
before_action :set_checkout_redirect
before_action :hide_ofn_navigation, only: [:edit, :update]
def edit
redirect_to_step_based_on_order unless params[:step]
check_step if params[:step]
recalculate_tax if params[:step] == "summary"
flash_error_when_no_shipping_method_available if allowed_shipping_methods.none?
flash_error_when_no_shipping_method_available if available_shipping_methods.none?
end
def update
@@ -41,7 +43,7 @@ class SplitCheckoutController < ::BaseController
rescue Spree::Core::GatewayError => e
flash[:error] = I18n.t(:spree_gateway_error_flash_for_checkout, error: e.message)
@order.update_column(:state, "payment")
render operations: cable_car.redirect_to(url: checkout_step_path(:payment))
render cable_ready: cable_car.redirect_to(url: checkout_step_path(:payment))
end
private
@@ -52,7 +54,7 @@ class SplitCheckoutController < ::BaseController
messages: order_error_messages
)
render status: :unprocessable_entity, operations: cable_car.
render status: :unprocessable_entity, cable_ready: cable_car.
replace("#checkout", partial("split_checkout/checkout")).
replace("#flashes", partial("shared/flashes", locals: { flashes: flash }))
end
@@ -130,7 +132,7 @@ class SplitCheckoutController < ::BaseController
return unless selected_payment_method&.external_gateway?
return unless (redirect_url = selected_payment_method.external_payment_url(order: @order))
render operations: cable_car.redirect_to(url: redirect_url)
render cable_ready: cable_car.redirect_to(url: redirect_url)
true
end
@@ -168,7 +170,7 @@ class SplitCheckoutController < ::BaseController
end
def shipping_method_ship_address_not_required?
selected_shipping_method = allowed_shipping_methods&.select do |sm|
selected_shipping_method = available_shipping_methods&.select do |sm|
sm.id.to_s == params[:shipping_method_id]
end

View File

@@ -9,11 +9,9 @@ module Spree
helper CheckoutHelper
before_action :load_order, only: [:edit, :update, :fire, :resend,
:invoice, :print]
before_action :load_distribution_choices, only: [:new, :edit, :update]
:invoice, :print, :distribution]
before_action :load_distribution_choices, only: [:new, :edit, :update, :distribution]
# Ensure that the distributor is set for an order when
before_action :ensure_distribution, only: :new
before_action :require_distributor_abn, only: :invoice
respond_to :html, :json
@@ -21,8 +19,20 @@ module Spree
def new
@order = Order.create
@order.created_by = spree_current_user
@order.generate_order_number
@order.save
redirect_to spree.edit_admin_order_url(@order)
redirect_to spree.distribution_admin_order_path(@order)
end
def distribution
return if order_params.blank?
on_update
@order.assign_attributes(order_params)
return unless @order.save(context: :set_distribution_step)
redirect_to spree.admin_order_customer_path(@order)
end
def edit
@@ -33,12 +43,7 @@ module Spree
end
def update
@order.recreate_all_fees!
unless @order.cart?
@order.create_tax_charge!
@order.update_order!
end
on_update
if params[:set_distribution_step] && @order.update(order_params)
return redirect_to spree.admin_order_customer_path(@order)
@@ -105,6 +110,15 @@ module Spree
private
def on_update
@order.recreate_all_fees!
return if @order.cart?
@order.create_tax_charge!
@order.update_order!
end
def order_params
return params[:order] if params[:order].blank?
@@ -142,17 +156,6 @@ module Spree
ocs.closed +
ocs.undated
end
def ensure_distribution
unless @order
@order = Spree::Order.new
@order.generate_order_number
@order.save!
end
return if @order.distribution_set?
render 'set_distribution', locals: { order: @order }
end
end
end
end

View File

@@ -7,7 +7,6 @@ module Spree
before_action :load_data
before_action :validate_payment_method_provider, only: [:create]
before_action :load_hubs, only: [:new, :edit, :update]
before_action :validate_calculator_preferred_value, only: [:update]
respond_to :html
@@ -17,6 +16,10 @@ module Spree
@payment_method = payment_method_class.constantize.new(base_params)
@object = @payment_method
if !base_params["calculator_type"] && gateway_params["calculator_type"]
@payment_method.calculator_type = gateway_params["calculator_type"]
end
load_hubs
if @payment_method.save
@@ -44,6 +47,7 @@ module Spree
redirect_to spree.edit_admin_payment_method_path(@payment_method)
else
respond_with(@payment_method)
clear_preference_cache
end
end
@@ -182,33 +186,23 @@ module Spree
end
end
# Ensure the calculator to be updated is the correct type
if params_for_update["calculator_type"] && params_for_update["calculator_attributes"]
add_type_to_calculator_attributes(params_for_update)
end
params_for_update
end
end
def validate_calculator_preferred_value
return if calculator_preferred_values.all? do |value|
preferred_value_from_params = gateway_params.dig(:calculator_attributes, value)
preferred_value_from_params.nil? || Float(preferred_value_from_params,
exception: false)
def clear_preference_cache
@payment_method.calculator.preferences.each_key do |key|
Rails.cache.delete(@payment_method.calculator.preference_cache_key(key))
end
flash[:error] = I18n.t(:calculator_preferred_value_error)
redirect_to spree.edit_admin_payment_method_path(@payment_method)
end
def calculator_preferred_values
[
:preferred_amount,
:preferred_flat_percent,
:preferred_flat_percent,
:preferred_first_item,
:preferred_additional_item,
:preferred_max_items,
:preferred_normal_amount,
:preferred_discount_amount,
:preferred_minimal_amount
]
def add_type_to_calculator_attributes(hash)
hash["calculator_attributes"]["type"] = hash["calculator_type"]
end
end
end

View File

@@ -177,7 +177,7 @@ module Spree
def product_import_dates
options = [{ id: '0', name: '' }]
product_import_dates_query.collect(&:import_date).
map { |i| options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) }
map { |i| options.push(id: i.to_date, name: i.to_date.to_fs(:long)) }
options
end

View File

@@ -13,7 +13,7 @@ module Spree
def collection
params[:q] ||= {}
params[:q][:s] ||= "ascend_by_name"
params[:q][:s] ||= "name asc"
@search = super.ransack(params[:q])
@pagy, @zones = pagy(@search.result, items: Spree::Config[:orders_per_page])
@zones

View File

@@ -5,6 +5,7 @@ module Spree
include OrderCyclesHelper
include Rails.application.routes.url_helpers
include CablecarResponses
include WhiteLabel
layout 'darkswarm'
@@ -14,7 +15,8 @@ module Spree
respond_to :html, :json
before_action :check_authorization
before_action :set_current_order, only: :update
before_action :set_order_from_params, only: :show
before_action :set_current_order, only: [:edit, :update]
before_action :filter_order_params, only: :update
prepend_before_action :require_order_authentication, only: :show
@@ -23,10 +25,12 @@ module Spree
before_action :check_hub_ready_for_checkout, only: :edit
before_action :check_at_least_one_line_item, only: :update
def show
@order = Spree::Order.find_by!(number: params[:id])
before_action only: [:show, :edit] do
hide_ofn_navigation(@order.distributor)
end
def show; end
def empty
if @order = current_order
@order.empty!
@@ -37,7 +41,6 @@ module Spree
# Patching to redirect to shop if order is empty
def edit
@order = current_order(true)
@insufficient_stock_lines = @order.insufficient_stock_lines
@unavailable_order_variants = OrderCycleDistributedVariants.
new(current_order_cycle, current_distributor).unavailable_order_variants(@order)
@@ -101,11 +104,15 @@ module Spree
flash[:error] = I18n.t(:orders_could_not_cancel)
end
render status: :found,
operations: cable_car.redirect_to(url: request.referer || main_app.order_path(@order))
cable_ready: cable_car.redirect_to(url: request.referer || main_app.order_path(@order))
end
private
def set_order_from_params
@order = Spree::Order.find_by!(number: params[:id])
end
def set_current_order
@order = current_order(true)
end

View File

@@ -24,11 +24,11 @@ module Spree
if spree_user_signed_in?
flash[:success] = t('devise.success.logged_in_succesfully')
render operations: cable_car.redirect_to(
render cable_ready: cable_car.redirect_to(
url: return_url_or_default(after_sign_in_path_for(spree_current_user))
)
else
render status: :unauthorized, operations: cable_car.inner_html(
render status: :unauthorized, cable_ready: cable_car.inner_html(
"#login-feedback",
partial("layouts/alert", locals: { type: "alert", message: t('devise.failure.invalid') })
)
@@ -60,7 +60,7 @@ module Spree
end
def render_unconfirmed_response
render status: :unprocessable_entity, operations: cable_car.inner_html(
render status: :unprocessable_entity, cable_ready: cable_car.inner_html(
"#login-feedback",
partial("layouts/alert", locals: { type: "alert", message: t(:email_unconfirmed),
unconfirmed: true, tab: "login" })

View File

@@ -30,10 +30,11 @@ module Spree
registered = Spree::User.find_by(email: params[:email]).present?
if registered
render status: :ok, operations: cable_car.
render status: :ok, cable_ready: cable_car.
inner_html(
"#login-feedback",
partial("layouts/alert", locals: { type: "alert", message: t('devise.failure.already_registered') })
partial("layouts/alert",
locals: { type: "alert", message: t('devise.failure.already_registered') })
).
dispatch_event(name: "login:modal:open")
else
@@ -45,12 +46,14 @@ module Spree
@user = Spree::User.new(user_params)
if @user.save
render operations: cable_car.inner_html(
render cable_ready: cable_car.inner_html(
"#signup-feedback",
partial("layouts/alert", locals: { type: "success", message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') })
partial("layouts/alert",
locals: { type: "success",
message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') })
)
else
render status: :unprocessable_entity, operations: cable_car.morph(
render status: :unprocessable_entity, cable_ready: cable_car.morph(
"#signup-tab",
partial("layouts/signup_tab", locals: { signup_form_user: @user })
)

View File

@@ -22,9 +22,10 @@ class UserConfirmationsController < DeviseController
set_flash_message(:error, :confirmation_not_sent)
end
else
render operations: cable_car.inner_html(
render cable_ready: cable_car.inner_html(
"##{params[:tab] || 'forgot'}-feedback",
partial("layouts/alert", locals: { type: "success", message: t("devise.confirmations.send_instructions") })
partial("layouts/alert",
locals: { type: "success", message: t("devise.confirmations.send_instructions") })
)
return
end

View File

@@ -11,12 +11,12 @@ class UserPasswordsController < Spree::UserPasswordsController
self.resource = resource_class.send_reset_password_instructions(raw_params[resource_name])
if resource.errors.empty?
render operations: cable_car.inner_html(
render cable_ready: cable_car.inner_html(
"#forgot-feedback",
partial("layouts/alert", locals: { type: "success", message: t(:password_reset_sent) })
)
else
render status: :not_found, operations: cable_car.inner_html(
render status: :not_found, cable_ready: cable_car.inner_html(
"#forgot-feedback",
partial("layouts/alert", locals: { type: "alert", message: t(:email_not_found) })
)
@@ -26,7 +26,7 @@ class UserPasswordsController < Spree::UserPasswordsController
private
def render_unconfirmed_response
render status: :unprocessable_entity, operations: cable_car.inner_html(
render status: :unprocessable_entity, cable_ready: cable_car.inner_html(
"#forgot-feedback",
partial("layouts/alert",
locals: { type: "alert", message: t(:email_unconfirmed),

View File

@@ -0,0 +1,47 @@
# frozen_string_literal: true
class WebhookEndpointsController < ::BaseController
before_action :load_resource, only: :destroy
def create
webhook_endpoint = spree_current_user.webhook_endpoints.new(webhook_endpoint_params)
if webhook_endpoint.save
flash[:success] = t('.success')
else
flash[:error] = t('.error')
end
redirect_to redirect_path
end
def destroy
if @webhook_endpoint.destroy
flash[:success] = t('.success')
else
flash[:error] = t('.error')
end
redirect_to redirect_path
end
def load_resource
@webhook_endpoint = spree_current_user.webhook_endpoints.find(params[:id])
end
def webhook_endpoint_params
params.require(:webhook_endpoint).permit(:url)
end
def redirect_path
if request.referer.blank? || request.referer.include?(spree.account_path)
developer_settings_path
else
request.referer
end
end
def developer_settings_path
"#{spree.account_path}#/developer_settings"
end
end

View File

@@ -22,6 +22,14 @@ module Admin
show_enterprise_fees = can?(:manage_enterprise_fees,
enterprise) && (is_shop || enterprise.is_primary_producer)
build_enterprise_side_menu_items(is_shop, show_properties, show_shipping_methods,
show_payment_methods, show_enterprise_fees)
end
private
def build_enterprise_side_menu_items(is_shop, show_properties, show_shipping_methods,
show_payment_methods, show_enterprise_fees)
[
{ name: 'primary_details', icon_class: "icon-home", show: true, selected: 'selected' },
{ name: 'address', icon_class: "icon-map-marker", show: true },
@@ -34,13 +42,20 @@ module Admin
{ name: 'shipping_methods', icon_class: "icon-truck", show: show_shipping_methods },
{ name: 'payment_methods', icon_class: "icon-money", show: show_payment_methods },
{ name: 'enterprise_fees', icon_class: "icon-tasks", show: show_enterprise_fees },
{ name: 'vouchers', icon_class: "icon-ticket", show: true },
{ name: 'enterprise_permissions', icon_class: "icon-plug", show: true,
href: admin_enterprise_relationships_path },
{ name: 'inventory_settings', icon_class: "icon-list-ol", show: is_shop },
{ name: 'tag_rules', icon_class: "icon-random", show: is_shop },
{ name: 'shop_preferences', icon_class: "icon-shopping-cart", show: is_shop },
{ name: 'users', icon_class: "icon-user", show: true }
]
{ name: 'users', icon_class: "icon-user", show: true },
] + [add_white_label_if_feature_activated].compact
end
def add_white_label_if_feature_activated
return nil unless OpenFoodNetwork::FeatureToggle.enabled?(:white_label)
{ name: 'white_label', icon_class: "icon-leaf", show: true }
end
end
end

View File

@@ -29,7 +29,8 @@ class AngularFormBuilder < ActionView::Helpers::FormBuilder
@template.ng_options_for_select(choices, angular_field), options
end
def ng_collection_select(method, collection, value_method, text_method, angular_field, options = {})
def ng_collection_select(method, collection, value_method,
text_method, angular_field, options = {})
options.reverse_merge!('id' => angular_id(method), 'ng-model' => angular_model(method).to_s)
@template.select_tag angular_name(method),

View File

@@ -139,8 +139,8 @@ module CheckoutHelper
def stripe_card_options(cards)
cards.map do |cc|
[
"#{cc.brand} #{cc.last_digits} #{I18n.t(:card_expiry_abbreviation)}:#{cc.month.to_s.rjust(2, '0')}/#{cc.year}",
cc.id
"#{cc.brand} #{cc.last_digits} #{I18n.t(:card_expiry_abbreviation)}:"\
"#{cc.month.to_s.rjust(2, '0')}/#{cc.year}", cc.id
]
end
end

View File

@@ -87,4 +87,10 @@ module EnterprisesHelper
main_app.producers_url
end
end
def main_logo_link(enterprise)
return enterprise.white_label_logo_link if enterprise&.white_label_logo_link.present?
main_app.root_path
end
end

View File

@@ -3,8 +3,8 @@
module ReportsHelper
def report_order_cycle_options(order_cycles)
order_cycles.map do |oc|
orders_open_at = oc.orders_open_at&.to_s(:short) || 'NA'
orders_close_at = oc.orders_close_at&.to_s(:short) || 'NA'
orders_open_at = oc.orders_open_at&.to_fs(:short) || 'NA'
orders_close_at = oc.orders_close_at&.to_fs(:short) || 'NA'
["#{oc.name} &nbsp; (#{orders_open_at} - #{orders_close_at})".html_safe, oc.id]
end
end

View File

@@ -29,8 +29,8 @@ module Spree
def preference_field_tag(name, value, options)
case options[:type]
when :integer
text_field_tag(name, value, preference_field_options(options))
when :integer, :decimal
number_field_tag(name, value, preference_field_options(options))
when :boolean
hidden_field_tag(name, 0) +
check_box_tag(name, 1, value, preference_field_options(options))
@@ -49,8 +49,8 @@ module Spree
def preference_field_for(form, field, options, object)
case options[:type]
when :integer
form.text_field(field, preference_field_options(options))
when :integer, :decimal
form.number_field(field, preference_field_options(options))
when :boolean
form.check_box(field, preference_field_options(options))
when :string
@@ -80,26 +80,24 @@ module Spree
end
def preference_field_options(options)
field_options = case options[:type]
when :integer
{ size: 10,
class: 'input_integer' }
when :boolean
{}
when :string
{ size: 10,
class: 'input_string fullwidth' }
when :password
{ size: 10,
class: 'password_string fullwidth' }
when :text
{ rows: 15,
cols: 85,
class: 'fullwidth' }
else
{ size: 10,
class: 'input_string fullwidth' }
end
field_options =
case options[:type]
when :integer
{ size: 10, class: 'input_integer', step: 1 }
when :decimal
# Allow any number of decimal places
{ size: 10, class: 'input_integer', step: :any }
when :boolean
{}
when :string
{ size: 10, class: 'input_string fullwidth' }
when :password
{ size: 10, class: 'password_string fullwidth' }
when :text
{ rows: 15, cols: 85, class: 'fullwidth' }
else
{ size: 10, class: 'input_string fullwidth' }
end
field_options.merge!(
readonly: options[:readonly],

View File

@@ -105,8 +105,7 @@ module Spree
def cancel_order_link
{ name: t(:cancel_order),
url: spree.fire_admin_order_path(@order.number, e: 'cancel'),
icon: 'icon-trash',
confirm: t(:are_you_sure) }
icon: 'icon-trash' }
end
def cancel_event_link

View File

@@ -0,0 +1,27 @@
# frozen_string_literal: true
# Trigger jobs for any order cycles that recently opened
class OrderCycleOpenedJob < ApplicationJob
def perform
ActiveRecord::Base.transaction do
recently_opened_order_cycles.find_each do |order_cycle|
OrderCycleWebhookService.create_webhook_job(order_cycle, 'order_cycle.opened')
end
mark_as_opened(recently_opened_order_cycles)
end
end
private
def recently_opened_order_cycles
@recently_opened_order_cycles ||= OrderCycle
.where(opened_at: nil)
.where(orders_open_at: 1.hour.ago..Time.zone.now)
.lock.order(:id)
end
def mark_as_opened(order_cycles)
now = Time.zone.now
order_cycles.update_all(opened_at: now, updated_at: now)
end
end

View File

@@ -1,34 +1,10 @@
# frozen_string_literal: true
# Renders a report and saves it to a temporary file.
class ReportJob < ActiveJob::Base
def perform(report_class, user, params, format)
# Renders a report and stores it in a given blob.
class ReportJob < ApplicationJob
def perform(report_class, user, params, format, blob)
report = report_class.new(user, params, render: true)
result = report.render_as(format)
write(result)
end
def done?
@done ||= File.file?(filename)
end
def result
@result ||= read_result
end
private
def write(result)
File.write(filename, result, mode: "wb")
end
def read_result
File.read(filename)
ensure
File.unlink(filename)
end
def filename
Rails.root.join("tmp/report-#{job_id}")
blob.store(result)
end
end

View File

@@ -0,0 +1,50 @@
# frozen_string_literal: true
require "faraday"
require "private_address_check"
require "private_address_check/tcpsocket_ext"
# Deliver a webhook payload
# As a delayed job, it can run asynchronously and handle retries.
class WebhookDeliveryJob < ApplicationJob
# General failed request error that we're going to use to signal
# the job runner to retry our webhook worker.
class FailedWebhookRequestError < StandardError; end
queue_as :default
def perform(url, event, payload)
body = {
id: job_id,
at: Time.zone.now.to_s,
event: event,
data: payload,
}
# Request user-submitted url, preventing any private connections being made
# (SSRF).
# This method may allow the socket to open, but is necessary in order to
# protect from TOC/TOU.
# Note that private_address_check provides some methods for pre-validating,
# but they're not as comprehensive and so unnecessary here. Simply
# momentarily opening sockets probably can't cause DoS or other damage.
PrivateAddressCheck.only_public_connections do
notify_endpoint(url, body)
end
end
def notify_endpoint(url, body)
connection = Faraday.new(
request: { timeout: 30 },
headers: {
'User-Agent' => 'openfoodnetwork_webhook/1.0',
'Content-Type' => 'application/json',
}
)
response = connection.post(url, body.to_json)
# Raise a failed request error and let job runner handle retrying.
# In theory, only 5xx errors should be retried, but who knows.
raise FailedWebhookRequestError, response.status.to_s unless response.success?
end
end

View File

@@ -61,4 +61,9 @@ class CustomerSchema < JsonApiSchema
def self.relationships
[:enterprise]
end
# Optional attributes included with eg: CustomerSchema.schema(extra_fields: :balance)
def self.balance
{ balance: { type: :number, format: :double } }
end
end

View File

@@ -19,84 +19,77 @@ class JsonApiSchema
end
def schema(options = {})
{
type: :object,
properties: {
data: {
type: :object,
properties: data_properties(**options)
},
meta: { type: :object },
links: { type: :object }
},
required: [:data]
}
Structure.schema(data_properties(**options))
end
def collection(options)
{
type: :object,
properties: {
data: {
type: :array,
items: {
type: :object,
properties: data_properties(**options)
}
},
meta: {
type: :object,
properties: {
pagination: {
type: :object,
properties: {
results: { type: :integer, example: 250 },
pages: { type: :integer, example: 5 },
page: { type: :integer, example: 2 },
per_page: { type: :integer, example: 50 },
}
}
},
required: [:pagination]
},
links: {
type: :object,
properties: {
self: { type: :string },
first: { type: :string },
prev: { type: :string, nullable: true },
next: { type: :string, nullable: true },
last: { type: :string }
}
}
},
required: [:data, :meta, :links]
}
Structure.collection(data_properties(**options))
end
private
def data_properties(require_all: false)
def data_properties(require_all: false, extra_fields: nil)
extra_fields_result = get_extra_fields(extra_fields)
attributes = get_attributes(extra_fields_result)
required = get_required(require_all, extra_fields, extra_fields_result)
Structure.data_properties(object_name, attributes, required, relationship_properties)
end
def relationship_properties
relationships.index_with { |name| relationship_schema(name) }
end
# Example
# MySchema.schema(extra_fields: :my_method)
# => extra_fields_result = MySchema.my_method
# => attributes = attributes.merge(extra_fields_result)
#
# MySchema.schema(extra_fields: {name: :my_method, required: true, opts: {method_opt: true}})
# => extra_fields_result = MySchema.my_method(method_opt: true)
# => attributes = attributes.merge(extra_fields_result)
# => required += extra_fields_result.keys
#
# MySchema.schema(extra_fields: [:my_method, :another_method])
# => extra_fields_result = MySchema.my_method.merge(another_method)
# => attributes = attribtues.merge(extra_fields_result)
#
# To test use eg:
# MySchema.schema(extra_fields: :my_method)
# .dig(:properties, :data, :properties, :attributes)
def get_extra_fields(extra_fields)
case extra_fields
when Symbol
public_send(extra_fields)
when Hash
public_send(extra_fields[:name], **extra_fields[:opts].to_h)
when Array
obj = {}
extra_fields.each do |w|
obj.merge!(get_extra_fields(w))
end
obj
end
end
def get_required(require_all, extra_fields, extra_fields_result)
required = require_all ? all_attributes : required_attributes
{
id: { type: :string, example: "1" },
type: { type: :string, example: object_name },
attributes: {
type: :object,
properties: attributes,
required: required
},
relationships: {
type: :object,
properties: relationships.to_h do |name|
[
name,
relationship_schema(name)
]
end
}
}
if extra_fields.is_a?(Hash) && extra_fields[:required] == true && extra_fields_result.present?
required += extra_fields_result.keys
end
required
end
def get_attributes(extra_fields_result)
if [extra_fields_result, attributes].all?{ |obj| obj.respond_to?(:merge) }
attributes.merge(extra_fields_result)
else
attributes
end
end
def relationship_schema(name)

View File

@@ -0,0 +1,83 @@
# frozen_string_literal: true
# rubocop:disable Metrics/MethodLength
class JsonApiSchema
module Structure
extend self
def schema(data_properties)
{
type: :object,
properties: {
data: {
type: :object,
properties: data_properties
},
meta: { type: :object },
links: { type: :object }
},
required: [:data]
}
end
def collection(data_properties)
{
type: :object,
properties: {
data: {
type: :array,
items: {
type: :object,
properties: data_properties
}
},
meta: {
type: :object,
properties: {
pagination: {
type: :object,
properties: {
results: { type: :integer, example: 250 },
pages: { type: :integer, example: 5 },
page: { type: :integer, example: 2 },
per_page: { type: :integer, example: 50 },
}
}
},
required: [:pagination]
},
links: {
type: :object,
properties: {
self: { type: :string },
first: { type: :string },
prev: { type: :string, nullable: true },
next: { type: :string, nullable: true },
last: { type: :string }
}
}
},
required: [:data, :meta, :links]
}
end
def data_properties(object_name, attributes, required, relationship_properties)
{
id: { type: :string, example: "1" },
type: { type: :string, example: object_name },
attributes: {
type: :object,
properties: attributes,
required: required
},
relationships: {
type: :object,
properties: relationship_properties
}
}
end
end
end
# rubocop:enable Metrics/MethodLength

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base
# Inline stylesheets
include Roadie::Rails::Automatic
helper TermsAndConditionsHelper
default from: -> { Spree::Config[:mails_from] }
layout 'mailer'
def money(amount)
Spree::Money.new(amount).to_s
end
helper_method :money
protected
def roadie_options
# This lets us specify assets using relative paths in email templates
super.merge(url_options: { host: URI(main_app.root_url).host })
end
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'devise/mailers/helpers'
class EnterpriseMailer < Spree::BaseMailer
class EnterpriseMailer < ApplicationMailer
include Devise::Mailers::Helpers
include I18nHelper
@@ -12,7 +12,6 @@ class EnterpriseMailer < Spree::BaseMailer
enterprise: @enterprise.name,
sitename: Spree::Config[:site_name])
mail(to: enterprise.contact.email,
from: from_address,
subject: subject)
end
end
@@ -20,12 +19,10 @@ class EnterpriseMailer < Spree::BaseMailer
def manager_invitation(enterprise, user)
@enterprise = enterprise
@instance = Spree::Config[:site_name]
@instance_email = from_address
I18n.with_locale valid_locale(@enterprise.owner) do
subject = t('enterprise_mailer.invite_manager.subject', enterprise: @enterprise.name)
mail(to: user.email,
from: from_address,
subject: subject)
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class PaymentMailer < Spree::BaseMailer
class PaymentMailer < ApplicationMailer
include I18nHelper
def authorize_payment(payment)
@@ -8,7 +8,7 @@ class PaymentMailer < Spree::BaseMailer
subject = I18n.t('spree.payment_mailer.authorize_payment.subject',
distributor: @payment.order.distributor.name)
I18n.with_locale valid_locale(@payment.order.user) do
mail(to: payment.order.email, from: from_address, subject: subject)
mail(to: payment.order.email, subject: subject)
end
end
@@ -19,7 +19,6 @@ class PaymentMailer < Spree::BaseMailer
order: @payment.order)
I18n.with_locale valid_locale(shop_owner) do
mail(to: shop_owner.email,
from: from_address,
subject: subject)
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class ProducerMailer < Spree::BaseMailer
class ProducerMailer < ApplicationMailer
include I18nHelper
def order_cycle_report(producer, order_cycle)
@@ -14,7 +14,6 @@ class ProducerMailer < Spree::BaseMailer
mail(
to: @producer.contact.email,
from: from_address,
subject: subject,
reply_to: @coordinator.contact.email,
cc: @coordinator.contact.email

View File

@@ -1,28 +0,0 @@
# frozen_string_literal: true
module Spree
class BaseMailer < ActionMailer::Base
# Inline stylesheets
include Roadie::Rails::Automatic
helper TermsAndConditionsHelper
layout 'mailer'
def from_address
Spree::Config[:mails_from]
end
def money(amount)
Spree::Money.new(amount).to_s
end
helper_method :money
protected
def roadie_options
# This lets us specify assets using relative paths in email templates
super.merge(url_options: { host: URI(main_app.root_url).host })
end
end
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
module Spree
class OrderMailer < BaseMailer
class OrderMailer < ApplicationMailer
helper 'checkout'
helper SpreeCurrencyHelper
helper Spree::PaymentMethodsHelper
@@ -13,7 +13,6 @@ module Spree
@order = find_order(order_or_order_id)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.email,
from: from_address,
subject: mail_subject(t('spree.order_mailer.cancel_email.subject'), resend))
end
end
@@ -23,7 +22,6 @@ module Spree
I18n.with_locale valid_locale(@order.distributor.owner) do
subject = I18n.t('spree.order_mailer.cancel_email_for_shop.subject')
mail(to: @order.distributor.contact.email,
from: from_address,
subject: subject)
end
end
@@ -33,7 +31,6 @@ module Spree
I18n.with_locale valid_locale(@order.user) do
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
mail(to: @order.email,
from: from_address,
subject: subject,
reply_to: @order.distributor.contact.email)
end
@@ -44,7 +41,6 @@ module Spree
I18n.with_locale valid_locale(@order.user) do
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
mail(to: @order.distributor.contact.email,
from: from_address,
subject: subject)
end
end
@@ -56,7 +52,6 @@ module Spree
attach_file("invoice-#{@order.number}.pdf", pdf)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.email,
from: from_address,
subject: mail_subject(t(:invoice), false),
reply_to: @order.distributor.contact.email)
end

View File

@@ -1,12 +1,12 @@
# frozen_string_literal: true
module Spree
class ShipmentMailer < BaseMailer
class ShipmentMailer < ApplicationMailer
def shipped_email(shipment, delivery:)
@shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment)
@delivery = delivery
subject = base_subject
mail(to: @shipment.order.email, from: from_address, subject: subject)
mail(to: @shipment.order.email, subject: subject)
end
private

View File

@@ -1,11 +1,11 @@
# frozen_string_literal: true
module Spree
class TestMailer < BaseMailer
class TestMailer < ApplicationMailer
def test_email(user)
recipient = user.respond_to?(:id) ? user : Spree::User.find(user)
subject = "#{Spree::Config[:site_name]} #{t('spree.test_mailer.test_email.subject')}"
mail(to: recipient.email, from: from_address, subject: subject)
mail(to: recipient.email, subject: subject)
end
end
end

View File

@@ -3,7 +3,7 @@
# This mailer is configured to be the Devise mailer
# Some methods here override Devise::Mailer methods
module Spree
class UserMailer < BaseMailer
class UserMailer < ApplicationMailer
include I18nHelper
helper MailerHelper
@@ -16,7 +16,7 @@ module Spree
"#{I18n.t('spree.user_mailer.reset_password_instructions.subject')}"
I18n.with_locale valid_locale(user) do
mail(to: user.email, from: from_address, subject: subject)
mail(to: user.email, subject: subject)
end
end
@@ -24,7 +24,7 @@ module Spree
def signup_confirmation(user)
@user = user
I18n.with_locale valid_locale(@user) do
mail(to: user.email, from: from_address,
mail(to: user.email,
subject: t(:welcome_to) + ' ' + Spree::Config[:site_name])
end
end
@@ -39,7 +39,6 @@ module Spree
I18n.with_locale valid_locale(@user) do
subject = t('spree.user_mailer.confirmation_instructions.subject')
mail(to: confirmation_email_address,
from: from_address,
subject: subject)
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class SubscriptionMailer < Spree::BaseMailer
class SubscriptionMailer < ApplicationMailer
helper 'checkout'
helper MailerHelper
helper ShopMailHelper
@@ -37,7 +37,6 @@ class SubscriptionMailer < Spree::BaseMailer
@shop = Enterprise.find(summary.shop_id)
@summary = summary
mail(to: @shop.contact.email,
from: from_address,
subject: "#{Spree::Config[:site_name]} #{t('subscription_mailer.placement_summary_email.subject')}")
end
@@ -45,7 +44,6 @@ class SubscriptionMailer < Spree::BaseMailer
@shop = Enterprise.find(summary.shop_id)
@summary = summary
mail(to: @shop.contact.email,
from: from_address,
subject: "#{Spree::Config[:site_name]} #{t('subscription_mailer.confirmation_summary_email.subject')}")
end
@@ -56,7 +54,6 @@ class SubscriptionMailer < Spree::BaseMailer
confirm_email_subject = t('spree.order_mailer.confirm_email.subject')
subject = "#{Spree::Config[:site_name]} #{confirm_email_subject} ##{order.number}"
mail(to: order.email,
from: from_address,
subject: subject,
reply_to: order.distributor.contact.email)
end

View File

@@ -1,14 +1,11 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class FlatPercentItemTotal < Spree::Calculator
extend Spree::LocalizedNumber
preference :flat_percent, :decimal, default: 0
localize_number :preferred_flat_percent
validates :preferred_flat_percent,
numericality: true
def self.description
Spree.t(:flat_percent)

View File

@@ -1,18 +1,15 @@
# frozen_string_literal: true
require 'spree/localized_number'
class Calculator::FlatPercentPerItem < Spree::Calculator
# Spree's FlatPercentItemTotal calculator sums all amounts, and then calculates a percentage
# on them.
# In the cart, we display line item individual amounts rounded, so to have consistent
# calculations we do the same internally. Here, we round adjustments at the individual
# item level first, then multiply by the item quantity.
extend Spree::LocalizedNumber
preference :flat_percent, :decimal, default: 0
localize_number :preferred_flat_percent
validates :preferred_flat_percent,
numericality: true
def self.description
I18n.t(:flat_percent_per_item)

View File

@@ -1,14 +1,11 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class FlatRate < Spree::Calculator
extend Spree::LocalizedNumber
preference :amount, :decimal, default: 0
localize_number :preferred_amount
validates :preferred_amount,
numericality: true
def self.description
I18n.t(:flat_rate_per_order)

View File

@@ -1,17 +1,14 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class FlexiRate < Spree::Calculator
extend Spree::LocalizedNumber
preference :first_item, :decimal, default: 0.0
preference :additional_item, :decimal, default: 0.0
preference :max_items, :integer, default: 0
localize_number :preferred_first_item,
:preferred_additional_item
validates :preferred_first_item,
:preferred_additional_item,
numericality: true
def self.description
I18n.t(:flexible_rate)

View File

@@ -1,14 +1,11 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class PerItem < Spree::Calculator
extend Spree::LocalizedNumber
preference :amount, :decimal, default: 0
localize_number :preferred_amount
validates :preferred_amount,
numericality: true
def self.description
I18n.t(:flat_rate_per_item)

View File

@@ -1,18 +1,15 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class PriceSack < Spree::Calculator
extend Spree::LocalizedNumber
preference :minimal_amount, :decimal, default: 0
preference :normal_amount, :decimal, default: 0
preference :discount_amount, :decimal, default: 0
localize_number :preferred_minimal_amount,
:preferred_normal_amount,
:preferred_discount_amount
validates :preferred_minimal_amount,
:preferred_normal_amount,
:preferred_discount_amount,
numericality: true
def self.description
I18n.t(:price_sack)

View File

@@ -4,4 +4,8 @@ module AddressDisplay
def full_name_reverse
[lastname, firstname].reject(&:blank?).join(" ")
end
def full_name_for_sorting
[last_name, first_name].reject(&:blank?).join(", ")
end
end

View File

@@ -35,6 +35,7 @@ class Customer < ApplicationRecord
uniqueness: { scope: :enterprise_id, message: I18n.t('validation_msg_is_associated_with_an_exising_customer') }
scope :of, ->(enterprise) { where(enterprise_id: enterprise) }
scope :managed_by, ->(user) { user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none }
before_create :associate_user

View File

@@ -15,9 +15,13 @@ class Enterprise < ApplicationRecord
medium: { resize_to_fill: [720, 156] },
large: { resize_to_fill: [1200, 260] },
}.freeze
WHITE_LABEL_LOGO_SIZES = {
default: { gravity: "Center", resize_to_fill: [217, 44] },
mobile: { gravity: "Center", resize_to_fill: [75, 26] },
}.freeze
VALID_INSTAGRAM_REGEX = %r{\A[a-zA-Z0-9._]{1,30}([^/-]*)\z}
searchable_attributes :sells, :is_primary_producer
searchable_attributes :sells, :is_primary_producer, :name
searchable_associations :properties
searchable_scopes :is_primary_producer, :is_distributor, :is_hub, :activated, :visible,
:ready_for_checkout, :not_ready_for_checkout
@@ -65,6 +69,7 @@ class Enterprise < ApplicationRecord
has_many :inventory_items
has_many :tag_rules
has_one :stripe_account, dependent: :destroy
has_many :vouchers
delegate :latitude, :longitude, :city, :state_name, to: :address
@@ -83,9 +88,14 @@ class Enterprise < ApplicationRecord
has_one_attached :logo
has_one_attached :promo_image
has_one_attached :terms_and_conditions
has_one_attached :white_label_logo
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :logo,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :terms_and_conditions, content_type: {
in: "application/pdf",
message: I18n.t(:enterprise_terms_and_conditions_type_error),
@@ -100,7 +110,11 @@ class Enterprise < ApplicationRecord
validate :shopfront_taxons
validate :shopfront_producers
validate :enforce_ownership_limit, if: lambda { owner_id_changed? && !owner_id.nil? }
validates :instagram, format: { with: VALID_INSTAGRAM_REGEX, message: Spree.t('errors.messages.invalid_instagram_url') }, allow_blank: true
validates :instagram,
format: {
with: VALID_INSTAGRAM_REGEX,
message: Spree.t('errors.messages.invalid_instagram_url')
}, allow_blank: true
before_validation :initialize_permalink, if: lambda { permalink.nil? }
before_validation :set_unused_address_fields
@@ -262,7 +276,7 @@ class Enterprise < ApplicationRecord
def plus_parents_and_order_cycle_producers(order_cycles)
oc_producer_ids = Exchange.in_order_cycle(order_cycles).incoming.pluck :sender_id
Enterprise.not_hidden.is_primary_producer.parents_of_one_union_others(id, oc_producer_ids | [id])
Enterprise.is_primary_producer.parents_of_one_union_others(id, oc_producer_ids | [id])
end
def relatives_including_self
@@ -293,6 +307,14 @@ class Enterprise < ApplicationRecord
)
end
def white_label_logo_url(name = :default)
return unless white_label_logo.variable?
Rails.application.routes.url_helpers.url_for(
white_label_logo.variant(WHITE_LABEL_LOGO_SIZES[name])
)
end
def website
strip_url self[:website]
end
@@ -450,7 +472,8 @@ class Enterprise < ApplicationRecord
end
def strip_url(url)
url&.sub(%r{(https?://)?}, '')
# Strip protocol and trailing slash
url&.sub(%r{(https?://)?}, '')&.sub(%r{/\z}, '')
end
def correct_whatsapp_url(phone_number)
@@ -458,11 +481,11 @@ class Enterprise < ApplicationRecord
end
def correct_instagram_url(url)
url && strip_url(url.downcase).sub(%r{www.instagram.com/}, '').sub(%r{instagram.com/}, '').delete("@")
url && strip_url(url.downcase).sub(%r{(www\.)?instagram.com/}, '').delete("@")
end
def correct_twitter_url(url)
url && strip_url(url).sub(%r{www.twitter.com/}, '').delete("@")
url && strip_url(url).sub(%r{(www\.)?twitter.com/}, '').delete("@")
end
def set_unused_address_fields

View File

@@ -28,8 +28,12 @@ class EnterpriseGroup < ApplicationRecord
has_one_attached :logo
has_one_attached :promo_image
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :logo,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
scope :by_position, -> { order('position ASC') }
scope :on_front_page, -> { where(on_front_page: true) }

View File

@@ -13,6 +13,7 @@ class EnterpriseRelationship < ApplicationRecord
after_save :update_permissions_of_child_variant_overrides
before_destroy :revoke_all_child_variant_overrides
before_destroy :destroy_related_exchanges
scope :with_enterprises, -> {
joins("
@@ -102,6 +103,10 @@ class EnterpriseRelationship < ApplicationRecord
child_variant_overrides.update_all(permission_revoked_at: Time.zone.now)
end
def destroy_related_exchanges
Exchange.where(sender: parent, receiver: child, incoming: true).destroy_all
end
def child_variant_overrides
VariantOverride.unscoped.for_hubs(child)
.joins(variant: :product).where("spree_products.supplier_id IN (?)", parent)

View File

@@ -1,5 +1,15 @@
# frozen_string_literal: true
class EnterpriseRelationshipPermission < ApplicationRecord
belongs_to :enterprise_relationship
default_scope { order('name') }
before_destroy :destroy_related_exchanges
def destroy_related_exchanges
return if name != "add_to_order_cycle"
Exchange
.where(sender: enterprise_relationship.parent,
receiver: enterprise_relationship.child, incoming: true).destroy_all
end
end

View File

@@ -3,4 +3,9 @@
class ExchangeVariant < ApplicationRecord
belongs_to :exchange
belongs_to :variant, class_name: 'Spree::Variant'
after_destroy :destroy_related_outgoing_variants
def destroy_related_outgoing_variants
VariantDeleter.new.destroy_related_outgoing_variants(variant_id, exchange.order_cycle)
end
end

View File

@@ -34,6 +34,7 @@ class OrderCycle < ApplicationRecord
attr_accessor :incoming_exchanges, :outgoing_exchanges
before_update :reset_opened_at, if: :will_save_change_to_orders_open_at?
before_update :reset_processed_at, if: :will_save_change_to_orders_close_at?
after_save :sync_subscriptions, if: :opening?
@@ -333,6 +334,14 @@ class OrderCycle < ApplicationRecord
errors.add(:orders_close_at, :after_orders_open_at)
end
def reset_opened_at
# Reset only if order cycle is opening again at a later date
return unless orders_open_at.present? && orders_open_at_was.present?
return unless orders_open_at > orders_open_at_was
self.opened_at = nil
end
def reset_processed_at
return unless orders_close_at.present? && orders_close_at_was.present?
return unless orders_close_at > orders_close_at_was

View File

@@ -10,7 +10,8 @@ module ProductImport
:variants_created, :variants_updated, :enterprise_products,
:total_enterprise_products, :products_reset_count
def initialize(importer, validator, import_settings, spreadsheet_data, editable_enterprises, import_time, updated_ids)
def initialize(importer, validator, import_settings, spreadsheet_data,
editable_enterprises, import_time, updated_ids)
@importer = importer
@validator = validator
@settings = Settings.new(import_settings)

View File

@@ -39,6 +39,8 @@ module ProductImport
enterprise_validation(entry)
unit_fields_validation(entry)
variant_of_product_validation(entry)
price_validation(entry)
on_hand_on_demand_validation(entry)
next if entry.enterprise_id.blank?
@@ -170,6 +172,11 @@ module ProductImport
error: I18n.t('admin.product_import.model.blank'))
end
unless is_numeric(entry.units) && entry.units.to_f > 0
mark_as_invalid(entry, attribute: 'units',
error: I18n.t('admin.product_import.model.incorrect_value'))
end
return if import_into_inventory?
# unit_type must be valid type
@@ -189,6 +196,42 @@ module ProductImport
error: I18n.t('admin.product_import.model.conditional_blank'))
end
def is_numeric(value)
return true unless Float(value, exception: false).nil?
end
def price_validation(entry)
return if is_numeric(entry.price)
error_string = if empty_or_placeholder_value(entry.price)
'admin.product_import.model.blank'
else
'admin.product_import.model.incorrect_value'
end
mark_as_invalid(entry, attribute: 'price', error: I18n.t(error_string))
end
def on_hand_on_demand_validation(entry)
on_hand_present_numeric = !empty_or_placeholder_value(entry.on_hand) &&
is_numeric(entry.on_hand)
on_hand_value = entry.on_hand&.to_i
on_demand_present_numeric = !empty_or_placeholder_value(entry.on_demand) &&
is_numeric(entry.on_demand)
on_demand_value = entry.on_demand&.to_i
return if (on_hand_present_numeric && on_hand_value >= 0) ||
(on_demand_present_numeric && on_demand_value == 1)
mark_as_invalid(entry, attribute: 'on_hand',
error: I18n.t('admin.product_import.model.incorrect_value'))
mark_as_invalid(entry, attribute: 'on_demand',
error: I18n.t('admin.product_import.model.incorrect_value'))
end
def empty_or_placeholder_value(value)
value.blank? || value.to_s.strip == "-"
end
def variant_of_product_validation(entry)
return if entry.producer.blank? || entry.name.blank?
@@ -293,8 +336,7 @@ module ProductImport
entry.primary_taxon_id = @spreadsheet_data.categories_index[category_name]
else
mark_as_invalid(entry, attribute: "category",
error: I18n.t(:error_not_found_in_database,
name: category_name))
error: I18n.t('admin.product_import.model.category_not_found'))
end
end

36
app/models/report_blob.rb Normal file
View File

@@ -0,0 +1,36 @@
# frozen_string_literal: true
# Stores a generated report.
class ReportBlob < ActiveStorage::Blob
def self.create_for_upload_later!(filename)
# ActiveStorage discourages modifying a blob later but we need a blob
# before we know anything about the report file. It enables us to use the
# same blob in the controller to read the result.
create_before_direct_upload!(
filename: filename,
byte_size: 0,
checksum: "0",
content_type: content_type(filename),
).tap do |blob|
ActiveStorage::PurgeJob.set(wait: 1.month).perform_later(blob)
end
end
def self.content_type(filename)
MIME::Types.of(filename).first&.to_s || "application/octet-stream"
end
def store(content)
io = StringIO.new(content)
upload(io, identify: false)
save!
end
def content_stored?
@content_stored ||= reload.checksum != "0"
end
def result
@result ||= download.force_encoding(Encoding::UTF_8)
end
end

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