mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-14 18:56:49 +00:00
Compare commits
337 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2be3f7b86d | ||
|
|
2d975c5534 | ||
|
|
86c91143b7 | ||
|
|
cde757efbd | ||
|
|
260e7ba817 | ||
|
|
bda506528f | ||
|
|
e429cb7198 | ||
|
|
a838ef4a21 | ||
|
|
f0b6403c1d | ||
|
|
71ca292c92 | ||
|
|
adf0340153 | ||
|
|
664f324db6 | ||
|
|
c609107379 | ||
|
|
6f2c5b5f7f | ||
|
|
e5b7f89b32 | ||
|
|
b7c34ced26 | ||
|
|
f5baa42bfc | ||
|
|
86238cc0ee | ||
|
|
61aa02b3c3 | ||
|
|
4b2099625c | ||
|
|
f8bd0a1cc7 | ||
|
|
09de223c93 | ||
|
|
74c80c9fff | ||
|
|
11f3bbc566 | ||
|
|
e5ee398f26 | ||
|
|
99c098f567 | ||
|
|
4b1d7d8a41 | ||
|
|
1e3c18f3f6 | ||
|
|
63a1b390e2 | ||
|
|
6eb5986c68 | ||
|
|
4d9f396f40 | ||
|
|
ac3730096f | ||
|
|
662467a1a4 | ||
|
|
af07358914 | ||
|
|
8e7e5fc20f | ||
|
|
3c613f80a3 | ||
|
|
83b6f58100 | ||
|
|
17c32ae09a | ||
|
|
0474c591de | ||
|
|
196956140e | ||
|
|
91f2ca9286 | ||
|
|
3015beab99 | ||
|
|
da0660c119 | ||
|
|
852dd41f89 | ||
|
|
48993232d1 | ||
|
|
0002b2e019 | ||
|
|
84a2e6c24d | ||
|
|
be4e0a259e | ||
|
|
c362e8dd0d | ||
|
|
1550ca5da0 | ||
|
|
f474afaceb | ||
|
|
8c71760556 | ||
|
|
37ab832b86 | ||
|
|
a11873559b | ||
|
|
51b3770188 | ||
|
|
989a6d57e0 | ||
|
|
495634b60c | ||
|
|
49fd1dc4a6 | ||
|
|
e31e45b875 | ||
|
|
61fec653cf | ||
|
|
eece738865 | ||
|
|
2465780c1c | ||
|
|
21b7e6e567 | ||
|
|
9f43244312 | ||
|
|
66f080232f | ||
|
|
7f62b49da5 | ||
|
|
070b93c531 | ||
|
|
fb96f8f936 | ||
|
|
4303f0e974 | ||
|
|
2eec4c73bf | ||
|
|
5ef85aef3e | ||
|
|
283db8f9d0 | ||
|
|
95e620a78b | ||
|
|
c948efd9ce | ||
|
|
95bc0cc679 | ||
|
|
efe2b724e6 | ||
|
|
14c32c0d2e | ||
|
|
8f4f873ba0 | ||
|
|
c0ae2ede2c | ||
|
|
3ec53a7d71 | ||
|
|
3849db7c48 | ||
|
|
7b286ea31d | ||
|
|
3e0eb8708e | ||
|
|
c7fa3ff819 | ||
|
|
f839452df9 | ||
|
|
a7a38890f4 | ||
|
|
caa6d284f0 | ||
|
|
827e37cada | ||
|
|
6c6927af84 | ||
|
|
439f0cac64 | ||
|
|
98966f6b89 | ||
|
|
260e4f7b00 | ||
|
|
099da3fc6c | ||
|
|
7078c4ef03 | ||
|
|
318790d207 | ||
|
|
2be8ef96be | ||
|
|
f6e4b107b0 | ||
|
|
a5d17b4da9 | ||
|
|
83ab9594f6 | ||
|
|
562a24524b | ||
|
|
2809194b42 | ||
|
|
7d3eff2abb | ||
|
|
c0a49df150 | ||
|
|
f8bb33a9e8 | ||
|
|
24a25d31a0 | ||
|
|
4822a9ebcd | ||
|
|
68fa903d61 | ||
|
|
c2e0c94f2e | ||
|
|
296997d558 | ||
|
|
a9ad6a2851 | ||
|
|
1078e7cd36 | ||
|
|
40c4d38e45 | ||
|
|
a25937321a | ||
|
|
a8db288425 | ||
|
|
a106eb10b6 | ||
|
|
a6d71f8dd1 | ||
|
|
5c300d6d41 | ||
|
|
bb4ff5adc2 | ||
|
|
be548c506d | ||
|
|
955f8ba5ae | ||
|
|
ad94da975a | ||
|
|
f33eb23909 | ||
|
|
9d5806b858 | ||
|
|
35f9c420fd | ||
|
|
052e3b6380 | ||
|
|
1545708d4e | ||
|
|
2a4d275f4b | ||
|
|
9ead14b8a0 | ||
|
|
38721d9f36 | ||
|
|
3f6aaa74cc | ||
|
|
c08683412c | ||
|
|
4a38d7ef57 | ||
|
|
243a4a55b4 | ||
|
|
5be53a40a9 | ||
|
|
76fdf3725a | ||
|
|
67f037280a | ||
|
|
776b9fcdab | ||
|
|
7e84d41e8c | ||
|
|
68491559f3 | ||
|
|
f8d3467d46 | ||
|
|
1580d539df | ||
|
|
e2aac8ca1d | ||
|
|
15a2513815 | ||
|
|
00768f6ba0 | ||
|
|
908caa984b | ||
|
|
6993750757 | ||
|
|
379e5acfe5 | ||
|
|
5bf6bdf7f0 | ||
|
|
8de7c304fe | ||
|
|
b6695ba9a2 | ||
|
|
e8de76dc46 | ||
|
|
55733555bf | ||
|
|
f59ee96011 | ||
|
|
2b74bbd45d | ||
|
|
d56ab9257b | ||
|
|
f24a4edc68 | ||
|
|
27dd5def57 | ||
|
|
561f4648d2 | ||
|
|
64d3091db9 | ||
|
|
0a9b858f2a | ||
|
|
4756ab47c2 | ||
|
|
0a04342712 | ||
|
|
556539d1b1 | ||
|
|
b7aaab204c | ||
|
|
632184b0a8 | ||
|
|
8500f6c198 | ||
|
|
ec4dba71c2 | ||
|
|
6117d70fae | ||
|
|
2e5c526170 | ||
|
|
32e32117e3 | ||
|
|
2a1d494301 | ||
|
|
fd45dea9f7 | ||
|
|
9073f0e5a8 | ||
|
|
c4f2c1c3ca | ||
|
|
a23bbf8537 | ||
|
|
6fac32b446 | ||
|
|
cf21c03619 | ||
|
|
0f7f1130f1 | ||
|
|
009d033e4c | ||
|
|
983addff0d | ||
|
|
d061fe8ad9 | ||
|
|
53286c22ba | ||
|
|
0cf8f079e4 | ||
|
|
f2163a42c4 | ||
|
|
05b25c78bb | ||
|
|
cc3181c820 | ||
|
|
9cd39d5c91 | ||
|
|
7d2f3bfa2f | ||
|
|
6df0b24bcf | ||
|
|
cf5e182cf7 | ||
|
|
74bbc7c3c0 | ||
|
|
4773d1c82e | ||
|
|
fde18ebf24 | ||
|
|
fd2cbb67db | ||
|
|
3f1d99d77c | ||
|
|
9cfcab4f02 | ||
|
|
703ad26773 | ||
|
|
627c9eede2 | ||
|
|
f9a76342f8 | ||
|
|
d52134dad8 | ||
|
|
1016656781 | ||
|
|
bd1611630f | ||
|
|
ce28c10c7e | ||
|
|
4342d3b912 | ||
|
|
af3aed827a | ||
|
|
f73be6447e | ||
|
|
98eabc9d0f | ||
|
|
169cbbe1a1 | ||
|
|
72a503c3c1 | ||
|
|
afc4c1e967 | ||
|
|
d76c4bddb0 | ||
|
|
ae993784d8 | ||
|
|
d1abe22c32 | ||
|
|
2817b8891e | ||
|
|
ab87610d91 | ||
|
|
54252f5444 | ||
|
|
7b6b0dbb78 | ||
|
|
b2e15f52cf | ||
|
|
5d18c48b6c | ||
|
|
0c2dcbc50d | ||
|
|
4a028b2238 | ||
|
|
43a366005c | ||
|
|
64470e977a | ||
|
|
a696c66857 | ||
|
|
cfeb0afbd4 | ||
|
|
4968e3dc8d | ||
|
|
5324747f89 | ||
|
|
ef2856d169 | ||
|
|
d9c79ee49c | ||
|
|
d1f9b0855d | ||
|
|
b82726e7ba | ||
|
|
7e7ab2e36d | ||
|
|
e35a5179bb | ||
|
|
85385a1989 | ||
|
|
a816814819 | ||
|
|
60afa4d465 | ||
|
|
dd5175558e | ||
|
|
94b98867d8 | ||
|
|
35ef1b9c7f | ||
|
|
8badfb2505 | ||
|
|
d61acd2cc1 | ||
|
|
7417cee20a | ||
|
|
98951161b1 | ||
|
|
a745249f3b | ||
|
|
63c62cae08 | ||
|
|
d489c77efe | ||
|
|
e2423ad612 | ||
|
|
8b036113d9 | ||
|
|
7f09044ae1 | ||
|
|
e9c7e1778c | ||
|
|
32cd14ef54 | ||
|
|
ad585f1eab | ||
|
|
d9368c1bfc | ||
|
|
b6bfb4e866 | ||
|
|
4d222c61c6 | ||
|
|
d599cf77a2 | ||
|
|
8f7505d53d | ||
|
|
867e17301f | ||
|
|
95135ca526 | ||
|
|
de063fecb1 | ||
|
|
ef9ca33913 | ||
|
|
2710eafc33 | ||
|
|
4718fdb0be | ||
|
|
ce6ae04147 | ||
|
|
1621f97fdb | ||
|
|
96f9894f41 | ||
|
|
66b519bd1c | ||
|
|
1b8e256e8a | ||
|
|
b73e529bfc | ||
|
|
25b1620707 | ||
|
|
5f9b14df9f | ||
|
|
922b853e3a | ||
|
|
8d747a2508 | ||
|
|
a50be52cde | ||
|
|
d62d002bc5 | ||
|
|
0c7448ba43 | ||
|
|
24afd40414 | ||
|
|
524aec7868 | ||
|
|
f2eb4b05f4 | ||
|
|
ffaf1b4ea0 | ||
|
|
eb547f4861 | ||
|
|
c9daca22d5 | ||
|
|
7b22740289 | ||
|
|
66c8a5c424 | ||
|
|
cfeac651b6 | ||
|
|
05315ff8e0 | ||
|
|
c4ee6b14ff | ||
|
|
a78f46259c | ||
|
|
1e79fde236 | ||
|
|
a9fe52a4ff | ||
|
|
075f5499f8 | ||
|
|
ed61f7e7bc | ||
|
|
bd6019036e | ||
|
|
0bbc3d2758 | ||
|
|
ae6182579b | ||
|
|
1e05811917 | ||
|
|
5f86a26f42 | ||
|
|
3f1b907ef2 | ||
|
|
08ab405893 | ||
|
|
ae2e92f09d | ||
|
|
b174080e29 | ||
|
|
a2c3ac2f60 | ||
|
|
429e2b0a86 | ||
|
|
70ca03173c | ||
|
|
7961ff7976 | ||
|
|
2d6ffc0ca1 | ||
|
|
d9c296cdb3 | ||
|
|
23aa762be2 | ||
|
|
61f2954973 | ||
|
|
d354317c73 | ||
|
|
19ef047193 | ||
|
|
037eb456c0 | ||
|
|
aed78f3138 | ||
|
|
c31416c536 | ||
|
|
f154de66f9 | ||
|
|
4a30493716 | ||
|
|
f325857e1f | ||
|
|
58872a7017 | ||
|
|
7392079d4d | ||
|
|
506126c1d3 | ||
|
|
fa004d0897 | ||
|
|
db7add88fe | ||
|
|
f21aca234c | ||
|
|
93a6ff4b50 | ||
|
|
97a72dfde7 | ||
|
|
a6d3909e95 | ||
|
|
5ca7f40a4e | ||
|
|
a2f4df191a | ||
|
|
b49da46842 | ||
|
|
2d24593403 | ||
|
|
2201d2e8c2 | ||
|
|
b6c407971d | ||
|
|
cd8dc41b15 | ||
|
|
a1887bdc76 | ||
|
|
e9f89362f4 | ||
|
|
675b7febdf | ||
|
|
90fdf59415 |
2
.github/ISSUE_TEMPLATE/release.md
vendored
2
.github/ISSUE_TEMPLATE/release.md
vendored
@@ -11,6 +11,7 @@ assignees: ''
|
||||
|
||||
- [ ] Merge pull requests in the [Ready To Go] column
|
||||
- [ ] Include translations: `script/release/update_locales`
|
||||
- You need the [Transifex Client] installed on your local dev environement to run the script.
|
||||
- [ ] Increment version number: `git push upstream HEAD:refs/tags/vX.Y.Z`
|
||||
- Major: if server changes are required (eg. provision with ofn-install)
|
||||
- Minor: larger change that is irreversible (eg. migration deleting data)
|
||||
@@ -53,3 +54,4 @@ The full process is described at https://github.com/openfoodfoundation/openfoodn
|
||||
[#global-community]: https://app.slack.com/client/T02G54U79/C59ADD8F2
|
||||
[Create issue]: https://github.com/openfoodfoundation/openfoodnetwork/issues/new?assignees=&labels=&projects=&template=release.md&title=Release
|
||||
[#core-devs]: https://openfoodnetwork.slack.com/archives/GK2T38QPJ
|
||||
[Transifex Client]: https://developers.transifex.com/docs/cli
|
||||
|
||||
118
.github/workflows/build.yml
vendored
118
.github/workflows/build.yml
vendored
@@ -3,7 +3,7 @@ name: Build
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches-ignore:
|
||||
branches-ignore:
|
||||
- 'dependabot/**'
|
||||
pull_request:
|
||||
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Set up Ruby
|
||||
@@ -81,11 +81,20 @@ jobs:
|
||||
# RSpec split test files by test examples feature - it's optional
|
||||
# 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}"
|
||||
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)
|
||||
bin/rake knapsack_pro:rspec
|
||||
|
||||
- name: Save SimpleCov file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: simplecov-chunk-controllers-${{ matrix.ci_node_index }}
|
||||
path: coverage/*.*
|
||||
retention-days: 2 # doesn't need to be long, because it's the combined results that matter
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
|
||||
models:
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
@@ -116,7 +125,7 @@ jobs:
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Set up Ruby
|
||||
@@ -141,10 +150,19 @@ jobs:
|
||||
# RSpec split test files by test examples feature - it's optional
|
||||
# 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/models/**/*_spec.rb}"
|
||||
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/models/**/*_spec.rb}"
|
||||
run: |
|
||||
bin/rake knapsack_pro:rspec
|
||||
|
||||
- name: Save SimpleCov file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: simplecov-chunk-models-${{ matrix.ci_node_index }}
|
||||
path: coverage/*.*
|
||||
retention-days: 2 # doesn't need to be long, because it's the combined results that matter
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
|
||||
system_admin:
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
@@ -175,7 +193,7 @@ jobs:
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Set up Ruby
|
||||
@@ -209,16 +227,25 @@ jobs:
|
||||
# RSpec split test files by test examples feature - it's optional
|
||||
# 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/system/admin/**/*_spec.rb}"
|
||||
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/system/admin/**/*_spec.rb}"
|
||||
|
||||
run: |
|
||||
bin/rake knapsack_pro:queue:rspec
|
||||
|
||||
- name: Save SimpleCov file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: simplecov-chunk-system-admin-${{ matrix.ci_node_index }}
|
||||
path: coverage/*.*
|
||||
retention-days: 2 # doesn't need to be long, because it's the combined results that matter
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
|
||||
- name: Archive failed tests screenshots
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: failed-admin-tests-screenshots
|
||||
name: failed-admin_${{ matrix.ci_node_index }}-tests-screenshots
|
||||
path: tmp/capybara/screenshots/*.png
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
@@ -247,13 +274,13 @@ jobs:
|
||||
ci_node_total: [12]
|
||||
# Indexes for parallel jobs (starting from zero).
|
||||
# E.g. use [0, 1] for 2 parallel jobs, [0, 1, 2] for 3 parallel jobs, etc.
|
||||
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
||||
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Set up Ruby
|
||||
@@ -287,16 +314,25 @@ jobs:
|
||||
# RSpec split test files by test examples feature - it's optional
|
||||
# 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/system/consumer/**/*_spec.rb}"
|
||||
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/system/consumer/**/*_spec.rb}"
|
||||
|
||||
run: |
|
||||
bin/rake knapsack_pro:queue:rspec
|
||||
|
||||
- name: Save SimpleCov file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: simplecov-chunk-system-consumer-${{ matrix.ci_node_index }}
|
||||
path: coverage/*.*
|
||||
retention-days: 2 # doesn't need to be long, because it's the combined results that matter
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
|
||||
- name: Archive failed tests screenshots
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: failed-consumer-tests-screenshots
|
||||
name: failed-consumer_${{ matrix.ci_node_index }}-tests-screenshots
|
||||
path: tmp/capybara/screenshots/*.png
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
@@ -331,7 +367,7 @@ jobs:
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Set up Ruby
|
||||
@@ -371,6 +407,15 @@ jobs:
|
||||
run: |
|
||||
bin/rake knapsack_pro:rspec
|
||||
|
||||
- name: Save SimpleCov file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: simplecov-chunk-engines-${{ matrix.ci_node_index }}
|
||||
path: coverage/*.*
|
||||
retention-days: 2 # doesn't need to be long, because it's the combined results that matter
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
|
||||
test_the_rest:
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
@@ -401,7 +446,7 @@ jobs:
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Set up Ruby
|
||||
@@ -439,6 +484,15 @@ jobs:
|
||||
run: |
|
||||
bin/rake knapsack_pro:rspec
|
||||
|
||||
- name: Save SimpleCov file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: simplecov-chunk-the-rest-${{ matrix.ci_node_index }}
|
||||
path: coverage/*.*
|
||||
retention-days: 2 # doesn't need to be long, because it's the combined results that matter
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
|
||||
non_knapsack_jest_karma:
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
@@ -476,3 +530,39 @@ jobs:
|
||||
|
||||
- name: Run jest tests
|
||||
run: yarn jest
|
||||
|
||||
collate_simplecov_results:
|
||||
runs-on: ubuntu-22.04
|
||||
needs:
|
||||
- controllers
|
||||
- models
|
||||
- engines
|
||||
- system_admin
|
||||
- system_consumer
|
||||
- test_the_rest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
||||
|
||||
- name: Download individual results from individual runners
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: simplecov-chunk-*
|
||||
path: tmp/simplecov
|
||||
merge-multiple: true
|
||||
|
||||
- name: collate results from each of the workers
|
||||
run: bundle exec rake 'simplecov:collate_results[tmp/simplecov]'
|
||||
|
||||
- name: Upload collated results
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: combined-simplecov-report
|
||||
path: coverage/**/*.*
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
|
||||
8
.github/workflows/mapi.yml
vendored
8
.github/workflows/mapi.yml
vendored
@@ -14,12 +14,12 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: docker/build
|
||||
- run: docker-compose up --detach
|
||||
- run: docker compose up --detach
|
||||
- run: until curl -f -s http://localhost:3000; do echo "waiting for api server"; sleep 1; done
|
||||
- run: docker-compose exec -T db psql postgresql://ofn:f00d@localhost:5432/open_food_network_dev --command="update spree_users set spree_api_key='testing' where login='ofn@example.com'"
|
||||
- run: docker compose exec -T db psql postgresql://ofn:f00d@localhost:5432/open_food_network_dev --command="update spree_users set spree_api_key='testing' where login='ofn@example.com'"
|
||||
# equivalent to Flipper.enable(:api_v1)
|
||||
- run: docker-compose exec -T db psql postgresql://ofn:f00d@localhost:5432/open_food_network_dev --command="insert into flipper_features (key, created_at, updated_at) values ('api_v1', localtimestamp, localtimestamp)"
|
||||
- run: docker-compose exec -T db psql postgresql://ofn:f00d@localhost:5432/open_food_network_dev --command="insert into flipper_gates (feature_key, key, value, created_at, updated_at) values ('api_v1', 'boolean', 'true', localtimestamp, localtimestamp)"
|
||||
- run: docker compose exec -T db psql postgresql://ofn:f00d@localhost:5432/open_food_network_dev --command="insert into flipper_features (key, created_at, updated_at) values ('api_v1', localtimestamp, localtimestamp)"
|
||||
- run: docker compose exec -T db psql postgresql://ofn:f00d@localhost:5432/open_food_network_dev --command="insert into flipper_gates (feature_key, key, value, created_at, updated_at) values ('api_v1', 'boolean', 'true', localtimestamp, localtimestamp)"
|
||||
|
||||
# Run Mayhem for API
|
||||
- name: Run Mayhem for API
|
||||
|
||||
@@ -14,4 +14,6 @@ SimpleCov.start 'rails' do
|
||||
add_filter '/log'
|
||||
add_filter '/db'
|
||||
add_filter '/lib/tasks/sample_data/'
|
||||
|
||||
formatter SimpleCov::Formatter::SimpleFormatter
|
||||
end
|
||||
|
||||
1
Gemfile
1
Gemfile
@@ -104,6 +104,7 @@ gem 'sidekiq-scheduler'
|
||||
gem "cable_ready"
|
||||
gem "stimulus_reflex"
|
||||
|
||||
gem "turbo_power"
|
||||
gem "turbo-rails"
|
||||
|
||||
gem 'combine_pdf'
|
||||
|
||||
@@ -785,6 +785,8 @@ GEM
|
||||
actionpack (>= 6.0.0)
|
||||
activejob (>= 6.0.0)
|
||||
railties (>= 6.0.0)
|
||||
turbo_power (0.6.2)
|
||||
turbo-rails (>= 1.3.0)
|
||||
tzinfo (2.0.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
unicode-display_width (2.5.0)
|
||||
@@ -835,7 +837,7 @@ GEM
|
||||
websocket-extensions (0.1.5)
|
||||
whenever (1.0.0)
|
||||
chronic (>= 0.6.3)
|
||||
wicked_pdf (2.6.3)
|
||||
wicked_pdf (2.8.1)
|
||||
activesupport
|
||||
wkhtmltopdf-binary (0.12.6.7)
|
||||
xml-simple (1.1.8)
|
||||
@@ -973,6 +975,7 @@ DEPENDENCIES
|
||||
stripe
|
||||
timecop
|
||||
turbo-rails
|
||||
turbo_power
|
||||
valid_email2
|
||||
validates_lengths_from_database
|
||||
vcr
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
//= require angular
|
||||
//= require angular-resource
|
||||
//= require angular-animate
|
||||
//= require angular-sanitize
|
||||
//= require angularjs-file-upload
|
||||
//= require ../shared/ng-infinite-scroll.min.js
|
||||
//= require ../shared/ng-tags-input.min.js
|
||||
@@ -60,11 +61,6 @@
|
||||
//= require ./variant_overrides/variant_overrides
|
||||
|
||||
// text, dates and translations
|
||||
//= require textAngular-rangy.min.js
|
||||
// This replaces angular-sanitize. We should include only one.
|
||||
// https://github.com/textAngular/textAngular#where-to-get-it
|
||||
//= require textAngular-sanitize.min.js
|
||||
//= require textAngular.min.js
|
||||
//= require i18n/translations
|
||||
//= require darkswarm/i18n.translate.js
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
angular.module("admin.enterprise_groups", ["admin.side_menu", "admin.users", "textAngular"])
|
||||
angular.module("admin.enterprise_groups", ["admin.side_menu", "admin.users", "ngSanitize"])
|
||||
|
||||
@@ -3,7 +3,6 @@ angular.module("admin.enterprises", [
|
||||
"admin.utils",
|
||||
"admin.shippingMethods",
|
||||
"admin.users",
|
||||
"textAngular",
|
||||
"admin.side_menu",
|
||||
"admin.taxons",
|
||||
'admin.indexUtils',
|
||||
@@ -11,16 +10,3 @@ angular.module("admin.enterprises", [
|
||||
'admin.dropdown',
|
||||
'ngSanitize']
|
||||
)
|
||||
# For more options: https://github.com/textAngular/textAngular/blob/master/src/textAngularSetup.js
|
||||
.config [
|
||||
'$provide', ($provide) ->
|
||||
$provide.decorator 'taTranslations', [
|
||||
'$delegate'
|
||||
(taTranslations) ->
|
||||
taTranslations.insertLink = {
|
||||
tooltip: t('admin.enterprises.form.shop_preferences.shopfront_message_link_tooltip'),
|
||||
dialogPrompt: t('admin.enterprises.form.shop_preferences.shopfront_message_link_prompt')
|
||||
}
|
||||
taTranslations
|
||||
]
|
||||
]
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
angular.module("admin.orderCycles").controller "OrderCyclesCtrl", ($scope, $q, Columns, StatusMessage, RequestMonitor, OrderCycles, Enterprises, Schedules, Dereferencer) ->
|
||||
$scope.RequestMonitor = RequestMonitor
|
||||
$scope.columns = Columns.columns
|
||||
$scope.saveAll = -> OrderCycles.saveChanges($scope.order_cycles_form)
|
||||
$scope.saveAll = ($event) ->
|
||||
trigger_action = $($event.target).data('trigger-action')
|
||||
confirm = $($event.target).data('confirm')
|
||||
OrderCycles.saveChanges($scope.order_cycles_form, { trigger_action, confirm })
|
||||
|
||||
$scope.ordersCloseAtLimit = -31 # days
|
||||
|
||||
$scope.resetSelectFilters = ->
|
||||
|
||||
@@ -1 +1 @@
|
||||
angular.module("admin.products", ["textAngular", "admin.utils", "OFNShared"])
|
||||
angular.module("admin.products", ["ngSanitize", "admin.utils", "OFNShared"])
|
||||
|
||||
@@ -29,13 +29,13 @@ angular.module("admin.resources").factory 'OrderCycles', ($q, $injector, OrderCy
|
||||
deferred.reject(response)
|
||||
deferred.promise
|
||||
|
||||
saveChanges: (form) ->
|
||||
saveChanges: (form, params = {}) ->
|
||||
changed = {}
|
||||
for id, orderCycle of @byID when not @saved(orderCycle)
|
||||
changed[Object.keys(changed).length] = @changesFor(orderCycle)
|
||||
if Object.keys(changed).length > 0
|
||||
StatusMessage.display('progress', "Saving...")
|
||||
OrderCycleResource.bulkUpdate { order_cycle_set: { collection_attributes: changed } }, (data) =>
|
||||
OrderCycleResource.bulkUpdate { order_cycle_set: { collection_attributes: changed }, confirm: params['confirm'], trigger_action: params['trigger_action'] }, (data) =>
|
||||
for orderCycle in data
|
||||
delete orderCycle.coordinator
|
||||
delete orderCycle.producers
|
||||
@@ -47,8 +47,10 @@ angular.module("admin.resources").factory 'OrderCycles', ($q, $injector, OrderCy
|
||||
, (response) =>
|
||||
if response.data.errors?
|
||||
StatusMessage.display('failure', response.data.errors[0])
|
||||
else if (response.data.trigger_action)
|
||||
StatusMessage.display('notice', t('js.order_cycles.unsaved_changes'), response.data.trigger_action)
|
||||
else
|
||||
StatusMessage.display('failure', "Oh no! I was unable to save your changes.")
|
||||
StatusMessage.display('failure', t('js.order_cycles.bulk_save_error'))
|
||||
|
||||
saved: (order_cycle) ->
|
||||
@diff(order_cycle).length == 0
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
angular.module("admin.utils").directive "textangularLinksTargetBlank", () ->
|
||||
restrict: 'CA'
|
||||
link: (scope, element, attrs) ->
|
||||
setTimeout ->
|
||||
element.find(".ta-editor").scope().defaultTagAttributes.a.target = '_blank'
|
||||
, 500
|
||||
@@ -1,11 +0,0 @@
|
||||
angular.module("admin.utils").directive "textangularStrip", () ->
|
||||
restrict: 'CA'
|
||||
link: (scope, element, attrs) ->
|
||||
scope.stripFormatting = ($html) ->
|
||||
element = document.createElement("div")
|
||||
element.innerHTML = String($html)
|
||||
allTags = element.getElementsByTagName("*")
|
||||
for child in allTags
|
||||
child.removeAttribute("style")
|
||||
child.removeAttribute("class")
|
||||
return element.innerHTML
|
||||
@@ -9,6 +9,7 @@ angular.module("admin.utils")
|
||||
$window.onbeforeunload = @onBeforeUnloadHandler
|
||||
|
||||
$rootScope.$on "$locationChangeStart", @locationChangeStartHandler
|
||||
$window.onBeforeUnloadHandler = @onBeforeUnloadHandler
|
||||
|
||||
# Action for regular browser navigation.
|
||||
onBeforeUnloadHandler: ($event) =>
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
- # NOTE: make sure that any changes in this template are reflected in app/views/admin/products_v3/product_preview.turbo_stream.haml
|
||||
%li{ "ng-class": "{active: selector.active}" }
|
||||
%a{ tooltip: "{{selector.object.value}}", "tooltip-placement": "bottom", "ng-transclude": true, "ng-class": "{active: selector.active, 'has-tip': selector.object.value}" }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
- # NOTE: make sure that any changes in this template are reflected in app/views/admin/products_v3/product_preview.turbo_stream.haml
|
||||
%ul
|
||||
%active-selector{ "ng-repeat": "selector in allSelectors", "ng-show": "ifDefined(selector.fits, true)" }
|
||||
%span{"ng-bind" => "::selector.object.name"}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
- # NOTE: make sure that any changes in this template are reflected in app/views/admin/products_v3/product_preview.turbo_stream.haml
|
||||
.row
|
||||
.columns.small-12.medium-6.large-6.product-header
|
||||
%h3{"ng-bind" => "::product.name"}
|
||||
|
||||
1
app/assets/stylesheets/mail.scss
Normal file
1
app/assets/stylesheets/mail.scss
Normal file
@@ -0,0 +1 @@
|
||||
@import './mail/all.scss';
|
||||
3
app/assets/stylesheets/mail/all.scss
Normal file
3
app/assets/stylesheets/mail/all.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
@import '../../../webpacker/css/admin/globals/palette.scss';
|
||||
@import 'email';
|
||||
@import 'payments_list';
|
||||
11
app/components/admin_tooltip_component.rb
Normal file
11
app/components/admin_tooltip_component.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AdminTooltipComponent < ViewComponent::Base
|
||||
def initialize(text:, link_text:, placement: "top", link: "", link_class: "")
|
||||
@text = text
|
||||
@link_text = link_text
|
||||
@placement = placement
|
||||
@link = link
|
||||
@link_class = link_class
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
%div{"data-controller": "tooltip", "data-tooltip-placement-value": @placement }
|
||||
%a{"data-tooltip-target": "element", href: @link, class: @link_class}
|
||||
= @link_text
|
||||
.tooltip-container
|
||||
.tooltip{"data-tooltip-target": "tooltip"}
|
||||
= sanitize @text
|
||||
.arrow{"data-tooltip-target": "arrow"}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ModalComponent < ViewComponent::Base
|
||||
def initialize(id:, close_button: true, instant: false, modal_class: :small)
|
||||
def initialize(id:, close_button: true, instant: false, modal_class: :small, **options)
|
||||
@id = id
|
||||
@close_button = close_button
|
||||
@instant = instant
|
||||
@modal_class = modal_class
|
||||
@options = options
|
||||
@data_controller = "modal #{@options.delete(:'data-controller')}".squish
|
||||
@data_action =
|
||||
"keyup@document->modal#closeIfEscapeKey #{@options.delete(:'data-action')}".squish
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
%div{ id: @id, "data-controller": "modal", "data-action": "keyup@document->modal#closeIfEscapeKey", "data-modal-instant-value": @instant }
|
||||
%div{ id: @id, "data-controller": @data_controller, "data-action": @data_action, "data-modal-instant-value": @instant, **@options }
|
||||
.reveal-modal-bg.fade{ "data-modal-target": "background", "data-action": "click->modal#close" }
|
||||
.reveal-modal.fade.modal-component{ "data-modal-target": "modal", class: @modal_class }
|
||||
= content
|
||||
|
||||
@@ -11,7 +11,8 @@ class SearchableDropdownComponent < ViewComponent::Base
|
||||
selected_option:,
|
||||
placeholder_value:,
|
||||
include_blank: false,
|
||||
aria_label: ''
|
||||
aria_label: '',
|
||||
other_attrs: {}
|
||||
)
|
||||
@f = form
|
||||
@name = name
|
||||
@@ -20,11 +21,13 @@ class SearchableDropdownComponent < ViewComponent::Base
|
||||
@placeholder_value = placeholder_value
|
||||
@include_blank = include_blank
|
||||
@aria_label = aria_label
|
||||
@other_attrs = other_attrs
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :f, :name, :options, :selected_option, :placeholder_value, :include_blank, :aria_label
|
||||
attr_reader :f, :name, :options, :selected_option, :placeholder_value, :include_blank,
|
||||
:aria_label, :other_attrs
|
||||
|
||||
def classes
|
||||
"fullwidth #{remove_search_plugin? ? 'no-input' : ''}"
|
||||
|
||||
@@ -1 +1 @@
|
||||
= f.select name, options_for_select(options, selected_option), { include_blank: }, class: classes, data:, 'aria-label': aria_label
|
||||
= f.select name, options_for_select(options, selected_option), { include_blank: }, class: classes, data:, 'aria-label': aria_label, **other_attrs
|
||||
|
||||
@@ -8,6 +8,10 @@ export default class extends Controller {
|
||||
window.addEventListener("click", this.#hideIfClickedOutside);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
window.removeEventListener("click", this.#hideIfClickedOutside);
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.contentTarget.classList.toggle("show");
|
||||
}
|
||||
|
||||
@@ -26,7 +26,15 @@ module Admin
|
||||
# * First step: import all products for given enterprise.
|
||||
# * Second step: render table and let user decide which ones to import.
|
||||
imported = graph.map do |subject|
|
||||
import_product(subject, enterprise)
|
||||
next unless subject.is_a? DataFoodConsortium::Connector::SuppliedProduct
|
||||
|
||||
existing_variant = enterprise.supplied_variants.linked_to(subject.semanticId)
|
||||
|
||||
if existing_variant
|
||||
SuppliedProductBuilder.update_product(subject, existing_variant)
|
||||
else
|
||||
SuppliedProductBuilder.store_product(subject, enterprise)
|
||||
end
|
||||
end
|
||||
|
||||
@count = imported.compact.count
|
||||
@@ -37,18 +45,5 @@ module Admin
|
||||
def fetch_catalog(url)
|
||||
DfcRequest.new(spree_current_user).call(url)
|
||||
end
|
||||
|
||||
# Most of this code is the same as in the DfcProvider::SuppliedProductsController.
|
||||
def import_product(subject, enterprise)
|
||||
return unless subject.is_a? DataFoodConsortium::Connector::SuppliedProduct
|
||||
|
||||
variant = SuppliedProductBuilder.import_variant(subject, enterprise)
|
||||
product = variant.product
|
||||
|
||||
product.save! if product.new_record?
|
||||
variant.save! if variant.new_record?
|
||||
|
||||
variant
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
module Admin
|
||||
class OrderCyclesController < Admin::ResourceController
|
||||
class DateTimeChangeError < StandardError; end
|
||||
|
||||
include ::OrderCyclesHelper
|
||||
include PaperTrailLogging
|
||||
|
||||
@@ -11,7 +13,6 @@ module Admin
|
||||
before_action :remove_protected_attrs, only: [:update]
|
||||
before_action :require_order_cycle_set_params, only: [:bulk_update]
|
||||
around_action :protect_invalid_destroy, only: :destroy
|
||||
before_action :verify_datetime_change, only: :update
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
@@ -63,9 +64,7 @@ module Admin
|
||||
end
|
||||
|
||||
def update
|
||||
@order_cycle_form = OrderCycles::FormService.new(@order_cycle, order_cycle_params,
|
||||
spree_current_user)
|
||||
|
||||
@order_cycle_form = set_order_cycle_form
|
||||
if @order_cycle_form.save
|
||||
update_nil_subscription_line_items_price_estimate(@order_cycle)
|
||||
respond_to do |format|
|
||||
@@ -78,6 +77,9 @@ module Admin
|
||||
elsif request.format.json?
|
||||
render json: { errors: @order_cycle.errors.full_messages }, status: :unprocessable_entity
|
||||
end
|
||||
rescue DateTimeChangeError
|
||||
render json: { trigger_action: params[:trigger_action] },
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def bulk_update
|
||||
@@ -91,6 +93,9 @@ module Admin
|
||||
order_cycle = order_cycle_set.collection.find{ |oc| oc.errors.present? }
|
||||
render json: { errors: order_cycle.errors.full_messages }, status: :unprocessable_entity
|
||||
end
|
||||
rescue DateTimeChangeError
|
||||
render json: { trigger_action: params[:trigger_action] },
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def bulk_update_nil_subscription_line_items_price_estimate
|
||||
@@ -271,7 +276,10 @@ module Admin
|
||||
end
|
||||
|
||||
def order_cycle_set
|
||||
@order_cycle_set ||= Sets::OrderCycleSet.new(@order_cycles, order_cycle_bulk_params)
|
||||
@order_cycle_set ||= Sets::OrderCycleSet.new(
|
||||
@order_cycles, { **order_cycle_bulk_params,
|
||||
confirm_datetime_change: params[:confirm], error_class: DateTimeChangeError }
|
||||
)
|
||||
end
|
||||
|
||||
def require_order_cycle_set_params
|
||||
@@ -296,21 +304,13 @@ module Admin
|
||||
).to_h.with_indifferent_access
|
||||
end
|
||||
|
||||
# Check that order cycle datetime values changed if it has existing orders
|
||||
def verify_datetime_change
|
||||
return unless params[:order_cycle][:confirm]
|
||||
return unless @order_cycle.orders.exists?
|
||||
return if same_dates(@order_cycle.orders_open_at, order_cycle_params[:orders_open_at]) &&
|
||||
same_dates(@order_cycle.orders_close_at, order_cycle_params[:orders_close_at])
|
||||
|
||||
render json: { trigger_action: params[:order_cycle][:trigger_action] },
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def same_dates(date, string)
|
||||
false unless date && string
|
||||
|
||||
DateTime.parse(string).to_fs(:short) == date.to_fs(:short)
|
||||
def set_order_cycle_form
|
||||
OrderCycles::FormService.new(
|
||||
@order_cycle, order_cycle_params.merge(
|
||||
{ confirm_datetime_change: params[:order_cycle][:confirm],
|
||||
error_class: DateTimeChangeError }
|
||||
), spree_current_user
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
22
app/controllers/admin/product_preview_controller.rb
Normal file
22
app/controllers/admin/product_preview_controller.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ProductPreviewController < Spree::Admin::BaseController
|
||||
def show
|
||||
@product = Spree::Product.find(params[:id])
|
||||
authorize! :show, @product
|
||||
|
||||
respond_with do |format|
|
||||
format.turbo_stream {
|
||||
render "admin/products_v3/product_preview", status: :ok
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def model_class
|
||||
Spree::Product
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -40,6 +40,8 @@ module Admin
|
||||
{ id: params[:id] }
|
||||
).find_product
|
||||
|
||||
authorize! :delete, @record
|
||||
|
||||
@record.destroyed_by = spree_current_user
|
||||
status = :ok
|
||||
|
||||
@@ -74,6 +76,8 @@ module Admin
|
||||
|
||||
def clone
|
||||
@product = Spree::Product.find(params[:id])
|
||||
authorize! :clone, @product
|
||||
|
||||
status = :ok
|
||||
|
||||
begin
|
||||
@@ -84,8 +88,8 @@ module Admin
|
||||
@producer_options = producers
|
||||
@category_options = categories
|
||||
@tax_category_options = tax_category_options
|
||||
rescue ActiveRecord::ActiveRecordError => _e
|
||||
flash.now[:error] = t('.error')
|
||||
rescue ActiveRecord::ActiveRecordError => e
|
||||
flash.now[:error] = clone_error_message(e)
|
||||
status = :unprocessable_entity
|
||||
@product_index = "-1" # Create a unique enough index
|
||||
end
|
||||
@@ -209,6 +213,15 @@ module Admin
|
||||
params.permit(products: ::PermittedAttributes::Product.attributes)
|
||||
.to_h.with_indifferent_access
|
||||
end
|
||||
|
||||
def clone_error_message(error)
|
||||
case error
|
||||
when ActiveRecord::RecordInvalid
|
||||
error.record.errors.full_messages.to_sentence
|
||||
else
|
||||
t('.error')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/ClassLength
|
||||
|
||||
@@ -6,7 +6,7 @@ module Admin
|
||||
include ReportsActions
|
||||
helper ReportsHelper
|
||||
|
||||
before_action :authorize_report, only: [:show]
|
||||
before_action :authorize_report, only: [:show, :create]
|
||||
|
||||
# Define model class for Can? permissions
|
||||
def model_class
|
||||
@@ -20,14 +20,17 @@ module Admin
|
||||
end
|
||||
|
||||
def show
|
||||
@report = report_class.new(spree_current_user, params, render: render_data?)
|
||||
@rendering_options = rendering_options # also stores user preferences
|
||||
@report = report_class.new(spree_current_user, params, render: false)
|
||||
@rendering_options = rendering_options
|
||||
|
||||
if render_data?
|
||||
render_in_background
|
||||
else
|
||||
show_report
|
||||
end
|
||||
show_report
|
||||
end
|
||||
|
||||
def create
|
||||
@report = report_class.new(spree_current_user, params, render: true)
|
||||
update_rendering_options
|
||||
|
||||
render_in_background
|
||||
end
|
||||
|
||||
private
|
||||
@@ -54,31 +57,15 @@ module Admin
|
||||
@variant_serialized = Api::Admin::VariantSerializer.new(variant)
|
||||
end
|
||||
|
||||
def render_data?
|
||||
request.post?
|
||||
end
|
||||
|
||||
def render_in_background
|
||||
cable_ready[ScopedChannel.for_id(params[:uuid])]
|
||||
.inner_html(
|
||||
selector: "#report-go",
|
||||
html: helpers.button(t(:go), "report__submit-btn", "submit", disabled: true)
|
||||
).inner_html(
|
||||
selector: "#report-table",
|
||||
html: render_to_string(partial: "admin/reports/loading")
|
||||
).scroll_into_view(
|
||||
selector: "#report-table",
|
||||
block: "start"
|
||||
).broadcast
|
||||
@blob = ReportBlob.create_for_upload_later!(report_filename)
|
||||
|
||||
ReportJob.perform_later(
|
||||
report_class:, user: spree_current_user, params:,
|
||||
format: report_format,
|
||||
filename: report_filename,
|
||||
blob: @blob,
|
||||
channel: ScopedChannel.for_id(params[:uuid]),
|
||||
)
|
||||
|
||||
head :no_content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,8 @@ class CartController < BaseController
|
||||
order.cap_quantity_at_stock!
|
||||
order.recreate_all_fees!
|
||||
|
||||
StockSyncJob.sync_linked_catalogs(order)
|
||||
|
||||
render json: { error: false, stock_levels: stock_levels(order) }, status: :ok
|
||||
else
|
||||
render json: { error: cart_service.errors.full_messages.join(",") },
|
||||
|
||||
@@ -9,6 +9,12 @@ module CheckoutCallbacks
|
||||
# Otherwise we fail on duplicate indexes or end up with negative stock.
|
||||
prepend_around_action CurrentOrderLocker, only: [:edit, :update]
|
||||
|
||||
# We want to download the latest stock data before anything else happens.
|
||||
# We don't want it to be in the same database transaction as the order
|
||||
# locking because this action locks a different set of variants and it
|
||||
# could cause race conditions.
|
||||
prepend_around_action :sync_stock, only: :update
|
||||
|
||||
prepend_before_action :check_hub_ready_for_checkout
|
||||
prepend_before_action :check_order_cycle_expiry
|
||||
prepend_before_action :require_order_cycle
|
||||
@@ -25,6 +31,14 @@ module CheckoutCallbacks
|
||||
|
||||
private
|
||||
|
||||
def sync_stock
|
||||
if current_order&.state == "confirmation"
|
||||
StockSyncJob.sync_linked_catalogs_now(current_order)
|
||||
end
|
||||
|
||||
yield
|
||||
end
|
||||
|
||||
def load_order
|
||||
@order = current_order
|
||||
@order.manual_shipping_selection = true
|
||||
@@ -63,12 +77,6 @@ module CheckoutCallbacks
|
||||
end
|
||||
end
|
||||
|
||||
def valid_order_line_items?
|
||||
@order.insufficient_stock_lines.empty? &&
|
||||
OrderCycles::DistributedVariantsService.new(@order.order_cycle, @order.distributor).
|
||||
distributes_order_variants?(@order)
|
||||
end
|
||||
|
||||
def ensure_order_not_completed
|
||||
redirect_to main_app.cart_path if @order.completed?
|
||||
end
|
||||
|
||||
@@ -88,14 +88,10 @@ module ReportsActions
|
||||
display_header_row: false
|
||||
}
|
||||
end
|
||||
update_rendering_options
|
||||
@rendering_options
|
||||
end
|
||||
|
||||
def update_rendering_options
|
||||
return unless request.post?
|
||||
|
||||
@rendering_options.update(
|
||||
rendering_options.update(
|
||||
options: {
|
||||
fields_to_show: params[:fields_to_show],
|
||||
display_summary_row: params[:display_summary_row].present?,
|
||||
|
||||
@@ -10,8 +10,11 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_new_variant(product)
|
||||
product.variants.build
|
||||
def prepare_new_variant(product, producer_options)
|
||||
# e.g producer_options = [['producer name', id]]
|
||||
product.variants.build do |new_variant|
|
||||
new_variant.supplier_id = producer_options.first.second if producer_options.one?
|
||||
end
|
||||
end
|
||||
|
||||
def unit_value_with_description(variant)
|
||||
@@ -37,5 +40,11 @@ module Admin
|
||||
|
||||
"#{admin_products_path}#{url_filters.empty? ? '' : "#?#{url_filters.to_query}"}"
|
||||
end
|
||||
|
||||
# if user hasn't saved any preferences on products page and there's only one producer;
|
||||
# we need to hide producer column
|
||||
def hide_producer_column?(producer_options)
|
||||
spree_current_user.column_preferences.bulk_edit_product.empty? && producer_options.one?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,15 +61,6 @@ module ApplicationHelper
|
||||
classes << shopfront_layout
|
||||
end
|
||||
|
||||
def pdf_stylesheet_pack_tag(source)
|
||||
if running_in_development?
|
||||
options = { media: "all", host: "#{Webpacker.dev_server.host}:#{Webpacker.dev_server.port}" }
|
||||
stylesheet_pack_tag(source, **options)
|
||||
else
|
||||
wicked_pdf_stylesheet_pack_tag(source)
|
||||
end
|
||||
end
|
||||
|
||||
def cache_with_locale(key = nil, options = {}, &block)
|
||||
cache(cache_key_with_locale(key, I18n.locale), options) do
|
||||
yield(block)
|
||||
|
||||
@@ -8,11 +8,13 @@ module InjectionHelper
|
||||
include OrderCyclesHelper
|
||||
|
||||
def inject_enterprises(enterprises = nil)
|
||||
enterprises ||= default_enterprise_query
|
||||
|
||||
inject_json_array(
|
||||
"enterprises",
|
||||
enterprises || default_enterprise_query,
|
||||
enterprises,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data,
|
||||
enterprise_injection_data(enterprises.map(&:id)),
|
||||
)
|
||||
end
|
||||
|
||||
@@ -57,15 +59,16 @@ module InjectionHelper
|
||||
inject_json_array "enterprises",
|
||||
enterprises_and_relatives,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
enterprise_injection_data(enterprises_and_relatives.map(&:id))
|
||||
end
|
||||
|
||||
def inject_group_enterprises(group)
|
||||
enterprises = group.enterprises.activated.visible.all
|
||||
inject_json_array(
|
||||
"enterprises",
|
||||
group.enterprises.activated.visible.all,
|
||||
enterprises,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data,
|
||||
enterprise_injection_data(enterprises.map(&:id)),
|
||||
)
|
||||
end
|
||||
|
||||
@@ -73,7 +76,7 @@ module InjectionHelper
|
||||
inject_json "currentHub",
|
||||
current_distributor,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
enterprise_injection_data(current_distributor ? [current_distributor.id] : nil)
|
||||
end
|
||||
|
||||
def inject_current_order
|
||||
@@ -153,7 +156,9 @@ module InjectionHelper
|
||||
Enterprise.activated.includes(address: [:state, :country]).all
|
||||
end
|
||||
|
||||
def enterprise_injection_data
|
||||
@enterprise_injection_data ||= { data: OpenFoodNetwork::EnterpriseInjectionData.new }
|
||||
def enterprise_injection_data(enterprise_ids)
|
||||
{
|
||||
data: OpenFoodNetwork::EnterpriseInjectionData.new(enterprise_ids)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
135
app/jobs/backorder_job.rb
Normal file
135
app/jobs/backorder_job.rb
Normal file
@@ -0,0 +1,135 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BackorderJob < ApplicationJob
|
||||
# In the current FDC project, one shop wants to review and adjust orders
|
||||
# before finalising. They also run a market stall and need to adjust stock
|
||||
# levels after the market. This should be done within four hours.
|
||||
SALE_SESSION_DELAYS = {
|
||||
# https://openfoodnetwork.org.uk/handleyfarm/shop
|
||||
"https://openfoodnetwork.org.uk/api/dfc/enterprises/203468" => 4.hours,
|
||||
}.freeze
|
||||
|
||||
queue_as :default
|
||||
sidekiq_options retry: 0
|
||||
|
||||
def self.check_stock(order)
|
||||
links = SemanticLink.where(variant_id: order.line_items.select(:variant_id))
|
||||
|
||||
perform_later(order) if links.exists?
|
||||
rescue StandardError => e
|
||||
# Errors here shouldn't affect the checkout. So let's report them
|
||||
# separately:
|
||||
Bugsnag.notify(e) do |payload|
|
||||
payload.add_metadata(:order, order)
|
||||
end
|
||||
end
|
||||
|
||||
def perform(order)
|
||||
OrderLocker.lock_order_and_variants(order) do
|
||||
place_backorder(order)
|
||||
end
|
||||
rescue StandardError
|
||||
# If the backordering fails, we need to tell the shop owner because they
|
||||
# need to organgise more stock.
|
||||
BackorderMailer.backorder_failed(order).deliver_later
|
||||
|
||||
raise
|
||||
end
|
||||
|
||||
def place_backorder(order)
|
||||
user = order.distributor.owner
|
||||
items = backorderable_items(order)
|
||||
|
||||
# We are assuming that all variants are linked to the same wholesale
|
||||
# shop and its catalog:
|
||||
reference_link = items[0].variant.semantic_links[0].semantic_id
|
||||
urls = FdcUrlBuilder.new(reference_link)
|
||||
orderer = FdcBackorderer.new(user, urls)
|
||||
|
||||
backorder = orderer.find_or_build_order(order)
|
||||
broker = load_broker(order.distributor.owner, urls)
|
||||
ordered_quantities = {}
|
||||
|
||||
items.each do |item|
|
||||
retail_quantity = add_item_to_backorder(item, broker, backorder, orderer)
|
||||
ordered_quantities[item] = retail_quantity
|
||||
end
|
||||
|
||||
place_order(user, order, orderer, backorder)
|
||||
|
||||
items.each do |item|
|
||||
variant = item.variant
|
||||
variant.on_hand += ordered_quantities[item] if variant.on_demand
|
||||
end
|
||||
end
|
||||
|
||||
# We look at linked variants which are either stock controlled or
|
||||
# are on demand with negative stock.
|
||||
def backorderable_items(order)
|
||||
order.line_items.select do |item|
|
||||
# TODO: scope variants to hub.
|
||||
# We are only supporting producer stock at the moment.
|
||||
variant = item.variant
|
||||
variant.semantic_links.present? &&
|
||||
(variant.on_demand == false || variant.on_hand&.negative?)
|
||||
end
|
||||
end
|
||||
|
||||
def add_item_to_backorder(line_item, broker, backorder, orderer)
|
||||
variant = line_item.variant
|
||||
needed_quantity = needed_quantity(line_item)
|
||||
solution = broker.best_offer(variant.semantic_links[0].semantic_id)
|
||||
|
||||
# The number of wholesale packs we need to order to fulfill the
|
||||
# needed quantity.
|
||||
# For example, we order 2 packs of 12 cans if we need 15 cans.
|
||||
wholesale_quantity = (needed_quantity.to_f / solution.factor).ceil
|
||||
|
||||
# The number of individual retail items we get with the wholesale order.
|
||||
# For example, if we order 2 packs of 12 cans, we will get 24 cans
|
||||
# and we'll account for that in our stock levels.
|
||||
retail_quantity = wholesale_quantity * solution.factor
|
||||
|
||||
line = orderer.find_or_build_order_line(backorder, solution.offer)
|
||||
line.quantity = line.quantity.to_i + wholesale_quantity
|
||||
|
||||
retail_quantity
|
||||
end
|
||||
|
||||
# We have two different types of stock management:
|
||||
#
|
||||
# 1. on demand
|
||||
# We don't restrict sales but account for the quantity sold in our local
|
||||
# stock level. If it goes negative, we need more stock and trigger a
|
||||
# backorder.
|
||||
# 2. limited stock
|
||||
# The local stock level is a copy from another catalog. We limit sales
|
||||
# according to that stock level. Every order reduces the local stock level
|
||||
# and needs to trigger a backorder of the same quantity to stay in sync.
|
||||
def needed_quantity(line_item)
|
||||
variant = line_item.variant
|
||||
|
||||
if variant.on_demand
|
||||
-1 * variant.on_hand # on_hand is negative and we need to replenish it.
|
||||
else
|
||||
line_item.quantity # We need to order exactly what's we sold.
|
||||
end
|
||||
end
|
||||
|
||||
def load_broker(user, urls)
|
||||
FdcOfferBroker.new(user, urls)
|
||||
end
|
||||
|
||||
def place_order(user, order, orderer, backorder)
|
||||
placed_order = orderer.send_order(backorder)
|
||||
|
||||
return unless orderer.new?(backorder)
|
||||
|
||||
delay = SALE_SESSION_DELAYS.fetch(backorder.client, 1.minute)
|
||||
wait_until = order.order_cycle.orders_close_at + delay
|
||||
CompleteBackorderJob.set(wait_until:)
|
||||
.perform_later(
|
||||
user, order.distributor, order.order_cycle, placed_order.semanticId
|
||||
)
|
||||
end
|
||||
end
|
||||
79
app/jobs/complete_backorder_job.rb
Normal file
79
app/jobs/complete_backorder_job.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# After an order cycle closed, we need to finalise open draft orders placed
|
||||
# to replenish stock.
|
||||
class CompleteBackorderJob < ApplicationJob
|
||||
sidekiq_options retry: 0
|
||||
|
||||
# Required parameters:
|
||||
#
|
||||
# * user: to authenticate DFC requests
|
||||
# * distributor: to reconile with its catalog
|
||||
# * order_cycle: to scope the catalog when looking up variants
|
||||
# Multiple variants can be linked to the same remote product.
|
||||
# To reduce ambiguity, we'll reconcile only with products
|
||||
# from the given distributor in a given order cycle for which
|
||||
# the remote backorder was placed.
|
||||
# * order_id: the remote semantic id of a draft order
|
||||
# Having the id makes sure that we don't accidentally finalise
|
||||
# someone else's order.
|
||||
def perform(user, distributor, order_cycle, order_id)
|
||||
order = FdcBackorderer.new(user, nil).find_order(order_id)
|
||||
urls = FdcUrlBuilder.new(order.lines[0].offer.offeredItem.semanticId)
|
||||
|
||||
variants = order_cycle.variants_distributed_by(distributor)
|
||||
adjust_quantities(order_cycle, user, order, urls, variants)
|
||||
|
||||
FdcBackorderer.new(user, urls).complete_order(order)
|
||||
rescue StandardError
|
||||
BackorderMailer.backorder_incomplete(user, distributor, order_cycle, order_id).deliver_later
|
||||
|
||||
raise
|
||||
end
|
||||
|
||||
# Check if we have enough stock to reduce the backorder.
|
||||
#
|
||||
# Our local stock can increase when users cancel their orders.
|
||||
# But stock levels could also have been adjusted manually. So we review all
|
||||
# quantities before finalising the order.
|
||||
def adjust_quantities(order_cycle, user, order, urls, variants)
|
||||
broker = FdcOfferBroker.new(user, urls)
|
||||
|
||||
order.lines.each do |line|
|
||||
line.quantity = line.quantity.to_i
|
||||
wholesale_product_id = line.offer.offeredItem.semanticId
|
||||
transformation = broker.wholesale_to_retail(wholesale_product_id)
|
||||
linked_variant = variants.linked_to(transformation.retail_product_id)
|
||||
|
||||
# Find all line items for this order cycle
|
||||
# Update quantity accordingly
|
||||
if linked_variant.on_demand
|
||||
release_superfluous_stock(line, linked_variant, transformation)
|
||||
else
|
||||
aggregate_final_quantities(order_cycle, line, linked_variant, transformation)
|
||||
end
|
||||
end
|
||||
|
||||
# Clean up empty lines:
|
||||
order.lines.reject! { |line| line.quantity.zero? }
|
||||
end
|
||||
|
||||
def release_superfluous_stock(line, linked_variant, transformation)
|
||||
# Note that a division of integers dismisses the remainder, like `floor`:
|
||||
wholesale_items_contained_in_stock = linked_variant.on_hand / transformation.factor
|
||||
|
||||
# But maybe we didn't actually order that much:
|
||||
deductable_quantity = [line.quantity, wholesale_items_contained_in_stock].min
|
||||
line.quantity -= deductable_quantity
|
||||
|
||||
retail_stock_changes = deductable_quantity * transformation.factor
|
||||
linked_variant.on_hand -= retail_stock_changes
|
||||
end
|
||||
|
||||
def aggregate_final_quantities(order_cycle, line, variant, transformation)
|
||||
orders = order_cycle.orders.invoiceable
|
||||
quantity = Spree::LineItem.where(order: orders, variant:).sum(:quantity)
|
||||
wholesale_quantity = (quantity.to_f / transformation.factor).ceil
|
||||
line.quantity = wholesale_quantity
|
||||
end
|
||||
end
|
||||
@@ -9,12 +9,12 @@ class ReportJob < ApplicationJob
|
||||
|
||||
NOTIFICATION_TIME = 5.seconds
|
||||
|
||||
def perform(report_class:, user:, params:, format:, filename:, channel: nil)
|
||||
def perform(report_class:, user:, params:, format:, blob:, channel: nil)
|
||||
start_time = Time.zone.now
|
||||
|
||||
report = report_class.new(user, params, render: true)
|
||||
result = report.render_as(format)
|
||||
blob = ReportBlob.create!(filename, result)
|
||||
blob.store(result)
|
||||
|
||||
execution_time = Time.zone.now - start_time
|
||||
|
||||
|
||||
79
app/jobs/stock_sync_job.rb
Normal file
79
app/jobs/stock_sync_job.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StockSyncJob < ApplicationJob
|
||||
# No retry but stay as failed job:
|
||||
sidekiq_options retry: 0
|
||||
|
||||
# We synchronise stock of stock-controlled variants linked to a remote
|
||||
# product. These variants are rare though and we check first before we
|
||||
# enqueue a new job. That should save some time loading the order with
|
||||
# all the stock data to make this decision.
|
||||
def self.sync_linked_catalogs(order)
|
||||
user = order.distributor.owner
|
||||
catalog_ids(order).each do |catalog_id|
|
||||
perform_later(user, catalog_id)
|
||||
end
|
||||
rescue StandardError => e
|
||||
# Errors here shouldn't affect the shopping. So let's report them
|
||||
# separately:
|
||||
Bugsnag.notify(e) do |payload|
|
||||
payload.add_metadata(:order, order)
|
||||
end
|
||||
end
|
||||
|
||||
def self.sync_linked_catalogs_now(order)
|
||||
user = order.distributor.owner
|
||||
catalog_ids(order).each do |catalog_id|
|
||||
perform_now(user, catalog_id)
|
||||
end
|
||||
rescue StandardError => e
|
||||
# Errors here shouldn't affect the shopping. So let's report them
|
||||
# separately:
|
||||
Bugsnag.notify(e) do |payload|
|
||||
payload.add_metadata(:order, order)
|
||||
end
|
||||
end
|
||||
|
||||
def self.catalog_ids(order)
|
||||
stock_controlled_variants = order.variants.reject(&:on_demand)
|
||||
links = SemanticLink.where(variant_id: stock_controlled_variants.map(&:id))
|
||||
semantic_ids = links.pluck(:semantic_id)
|
||||
semantic_ids.map do |product_id|
|
||||
FdcUrlBuilder.new(product_id).catalog_url
|
||||
end.uniq
|
||||
end
|
||||
|
||||
def perform(user, catalog_id)
|
||||
products = load_products(user, catalog_id)
|
||||
products_by_id = products.index_by(&:semanticId)
|
||||
product_ids = products_by_id.keys
|
||||
variants = linked_variants(user.enterprises, product_ids)
|
||||
|
||||
# Avoid race condition between checkout and stock sync.
|
||||
Spree::Variant.transaction do
|
||||
variants.order(:id).lock.each do |variant|
|
||||
next if variant.on_demand
|
||||
|
||||
product = products_by_id[variant.semantic_links[0].semantic_id]
|
||||
catalog_item = product&.catalogItems&.first
|
||||
CatalogItemBuilder.apply_stock(catalog_item, variant)
|
||||
variant.stock_items[0].save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def load_products(user, catalog_id)
|
||||
json_catalog = DfcRequest.new(user).call(catalog_id)
|
||||
graph = DfcIo.import(json_catalog)
|
||||
|
||||
graph.select do |subject|
|
||||
subject.is_a? DataFoodConsortium::Connector::SuppliedProduct
|
||||
end
|
||||
end
|
||||
|
||||
def linked_variants(enterprises, product_ids)
|
||||
Spree::Variant.where(supplier: enterprises)
|
||||
.includes(:semantic_links).references(:semantic_links)
|
||||
.where(semantic_links: { semantic_id: product_ids })
|
||||
end
|
||||
end
|
||||
24
app/mailers/backorder_mailer.rb
Normal file
24
app/mailers/backorder_mailer.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BackorderMailer < ApplicationMailer
|
||||
include I18nHelper
|
||||
|
||||
def backorder_failed(order)
|
||||
@order = order
|
||||
@linked_variants = order.variants
|
||||
|
||||
I18n.with_locale valid_locale(order.distributor.owner) do
|
||||
mail(to: order.distributor.owner.email)
|
||||
end
|
||||
end
|
||||
|
||||
def backorder_incomplete(user, distributor, order_cycle, order_id)
|
||||
@distributor = distributor
|
||||
@order_cycle = order_cycle
|
||||
@order_id = order_id
|
||||
|
||||
I18n.with_locale valid_locale(user) do
|
||||
mail(to: user.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -15,10 +15,11 @@ class ColumnPreference < ApplicationRecord
|
||||
validates :column_name, presence: true, inclusion: { in: proc { |p|
|
||||
valid_columns_for(p.action_name)
|
||||
} }
|
||||
scope :bulk_edit_product, -> { where(action_name: 'products_v3_index') }
|
||||
|
||||
def self.for(user, action_name)
|
||||
stored_preferences = where(user_id: user.id, action_name:)
|
||||
default_preferences = __send__("#{action_name}_columns")
|
||||
default_preferences = get_default_preferences(action_name, user)
|
||||
filter(default_preferences, user, action_name)
|
||||
default_preferences.each_with_object([]) do |(column_name, default_attributes), preferences|
|
||||
stored_preference = stored_preferences.find_by(column_name:)
|
||||
@@ -36,7 +37,7 @@ class ColumnPreference < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.valid_columns_for(action_name)
|
||||
__send__("#{action_name}_columns").keys.map(&:to_s)
|
||||
get_default_preferences(action_name, Spree::User.new).keys.map(&:to_s)
|
||||
end
|
||||
|
||||
def self.known_actions
|
||||
@@ -52,4 +53,13 @@ class ColumnPreference < ApplicationRecord
|
||||
|
||||
default_preferences.delete(:schedules)
|
||||
end
|
||||
|
||||
def self.get_default_preferences(action_name, user)
|
||||
case action_name
|
||||
when 'products_v3_index'
|
||||
products_v3_index_columns(user)
|
||||
else
|
||||
__send__("#{action_name}_columns")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
# `count_on_hand` can either be: nil or a number
|
||||
#
|
||||
# This means that a variant override can be in six different stock states
|
||||
# but only three of them are valid.
|
||||
# but only four of them are valid.
|
||||
#
|
||||
# | on_demand | count_on_hand | stock_overridden? | use_producer_stock_settings? | valid? |
|
||||
# |-----------|---------------|-------------------|------------------------------|--------|
|
||||
# | 1 | nil | false | false | true |
|
||||
# | 1 | nil | true | false | true |
|
||||
# | 0 | x | true | false | true |
|
||||
# | nil | nil | false | true | true |
|
||||
# | 1 | x | ? | ? | false |
|
||||
# | 1 | x | true | false | true |
|
||||
# | 0 | nil | ? | ? | false |
|
||||
# | nil | x | ? | ? | false |
|
||||
#
|
||||
@@ -27,7 +27,6 @@ module StockSettingsOverrideValidation
|
||||
|
||||
def require_compatible_on_demand_and_count_on_hand
|
||||
disallow_count_on_hand_if_using_producer_stock_settings
|
||||
disallow_count_on_hand_if_on_demand
|
||||
require_count_on_hand_if_limited_stock
|
||||
end
|
||||
|
||||
@@ -39,14 +38,6 @@ module StockSettingsOverrideValidation
|
||||
errors.add(:count_on_hand, error_message)
|
||||
end
|
||||
|
||||
def disallow_count_on_hand_if_on_demand
|
||||
return unless on_demand? && count_on_hand.present?
|
||||
|
||||
error_message = I18n.t("count_on_hand.on_demand_but_count_on_hand_set",
|
||||
scope: i18n_scope_for_stock_settings_override_validation_error)
|
||||
errors.add(:count_on_hand, error_message)
|
||||
end
|
||||
|
||||
def require_count_on_hand_if_limited_stock
|
||||
return unless on_demand == false && count_on_hand.blank?
|
||||
|
||||
|
||||
@@ -43,19 +43,9 @@ module VariantStock
|
||||
def on_demand
|
||||
# A variant that has not been saved yet or has been soft-deleted doesn't have a stock item
|
||||
# This provides a default value for variant.on_demand
|
||||
# using Spree::StockLocation.backorderable_default
|
||||
return Spree::StockLocation.first.backorderable_default if new_record? || deleted?
|
||||
return false if new_record? || deleted?
|
||||
|
||||
# This can be removed unless we have seen this error in Bugsnag recently
|
||||
if stock_item.nil?
|
||||
Bugsnag.notify(
|
||||
RuntimeError.new("Variant #stock_item called, but the stock_item does not exist!"),
|
||||
object: as_json
|
||||
)
|
||||
return Spree::StockLocation.first.backorderable_default
|
||||
end
|
||||
|
||||
stock_item.backorderable?
|
||||
stock_item&.backorderable?
|
||||
end
|
||||
|
||||
# Sets whether the variant can be ordered on demand or not. Note that
|
||||
@@ -96,7 +86,7 @@ module VariantStock
|
||||
# Here we depend only on variant.total_on_hand and variant.on_demand.
|
||||
# This way, variant_overrides only need to override variant.total_on_hand and variant.on_demand.
|
||||
def fill_status(quantity)
|
||||
on_hand = if total_on_hand >= quantity || on_demand
|
||||
on_hand = if total_on_hand.to_i >= quantity || on_demand
|
||||
quantity
|
||||
else
|
||||
[0, total_on_hand].max
|
||||
@@ -112,8 +102,7 @@ module VariantStock
|
||||
#
|
||||
# This enables us to override this behaviour for variant overrides
|
||||
def move(quantity, originator = nil)
|
||||
# Don't change variant stock if variant is on_demand or has been deleted
|
||||
return if on_demand || deleted_at
|
||||
return if deleted_at
|
||||
|
||||
raise_error_if_no_stock_item_available
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require "mini_magick"
|
||||
|
||||
class Enterprise < ApplicationRecord
|
||||
SELLS = %w(unspecified none own any).freeze
|
||||
ENTERPRISE_SEARCH_RADIUS = 100
|
||||
@@ -249,14 +247,17 @@ class Enterprise < ApplicationRecord
|
||||
count(distinct: true)
|
||||
end
|
||||
|
||||
# Remove any unsupported HTML.
|
||||
def long_description
|
||||
HtmlSanitizer.sanitize(super)
|
||||
def long_description=(html)
|
||||
super(HtmlSanitizer.sanitize_and_enforce_link_target_blank(html))
|
||||
end
|
||||
|
||||
# Remove any unsupported HTML.
|
||||
def long_description=(html)
|
||||
super(HtmlSanitizer.sanitize(html))
|
||||
def preferred_shopfront_message=(html)
|
||||
self.prefers_shopfront_message = HtmlSanitizer.sanitize_and_enforce_link_target_blank(html)
|
||||
end
|
||||
|
||||
def preferred_shopfront_closed_message=(html)
|
||||
self.prefers_shopfront_closed_message =
|
||||
HtmlSanitizer.sanitize_and_enforce_link_target_blank(html)
|
||||
end
|
||||
|
||||
def contact
|
||||
@@ -479,7 +480,7 @@ class Enterprise < ApplicationRecord
|
||||
return unless image.variable?
|
||||
|
||||
image_variant_url_for(image.variant(name))
|
||||
rescue ActiveStorage::Error, MiniMagick::Error, ActionView::Template::Error => e
|
||||
rescue StandardError => e
|
||||
Bugsnag.notify "Enterprise ##{id} #{image.try(:name)} error: #{e.message}"
|
||||
Rails.logger.error(e.message)
|
||||
|
||||
|
||||
@@ -76,12 +76,12 @@ class EnterpriseGroup < ApplicationRecord
|
||||
|
||||
# Remove any unsupported HTML.
|
||||
def long_description
|
||||
HtmlSanitizer.sanitize(super)
|
||||
HtmlSanitizer.sanitize_and_enforce_link_target_blank(super)
|
||||
end
|
||||
|
||||
# Remove any unsupported HTML.
|
||||
def long_description=(html)
|
||||
super(HtmlSanitizer.sanitize(html))
|
||||
super(HtmlSanitizer.sanitize_and_enforce_link_target_blank(html))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -148,17 +148,20 @@ class OrderCycle < ApplicationRecord
|
||||
|
||||
# Find the earliest closing times for each distributor in an active order cycle, and return
|
||||
# them in the format {distributor_id => closing_time, ...}
|
||||
def self.earliest_closing_times
|
||||
Hash[
|
||||
Exchange.
|
||||
outgoing.
|
||||
joins(:order_cycle).
|
||||
merge(OrderCycle.active).
|
||||
group('exchanges.receiver_id').
|
||||
select("exchanges.receiver_id AS receiver_id,
|
||||
MIN(order_cycles.orders_close_at) AS earliest_close_at").
|
||||
map { |ex| [ex.receiver_id, ex.earliest_close_at.to_time] }
|
||||
]
|
||||
#
|
||||
# Optionally, specify some distributor_ids as a parameter to scope the results
|
||||
def self.earliest_closing_times(distributor_ids = nil)
|
||||
cycles = Exchange.
|
||||
outgoing.
|
||||
joins(:order_cycle).
|
||||
merge(OrderCycle.active).
|
||||
group('exchanges.receiver_id')
|
||||
|
||||
cycles = cycles.where(receiver_id: distributor_ids) if distributor_ids.present?
|
||||
|
||||
cycles.pluck("exchanges.receiver_id AS receiver_id",
|
||||
"MIN(order_cycles.orders_close_at) AS earliest_close_at")
|
||||
.to_h
|
||||
end
|
||||
|
||||
def attachable_distributor_payment_methods
|
||||
@@ -314,6 +317,13 @@ class OrderCycle < ApplicationRecord
|
||||
coordinator.sells == 'own'
|
||||
end
|
||||
|
||||
def same_datetime_value(attribute, string)
|
||||
return true if self[attribute].blank? && string.blank?
|
||||
return false if self[attribute].blank? || string.blank?
|
||||
|
||||
DateTime.parse(string).to_fs(:short) == self[attribute]&.to_fs(:short)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def opening?
|
||||
|
||||
@@ -5,7 +5,7 @@ class ReportBlob < ActiveStorage::Blob
|
||||
# AWS S3 limits URL expiry to one week.
|
||||
LIFETIME = 1.week
|
||||
|
||||
def self.create!(filename, content)
|
||||
def self.create_locally!(filename, content)
|
||||
create_and_upload!(
|
||||
io: StringIO.new(content),
|
||||
filename:,
|
||||
@@ -15,11 +15,34 @@ class ReportBlob < ActiveStorage::Blob
|
||||
)
|
||||
end
|
||||
|
||||
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:,
|
||||
byte_size: 0,
|
||||
checksum: "0",
|
||||
content_type: content_type(filename),
|
||||
service_name: :local,
|
||||
).tap do |blob|
|
||||
ActiveStorage::PurgeJob.set(wait: LIFETIME).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 result
|
||||
return if checksum == "0"
|
||||
|
||||
@result ||= download.force_encoding(Encoding::UTF_8)
|
||||
end
|
||||
|
||||
|
||||
@@ -29,14 +29,12 @@ module Spree
|
||||
can :update, Order do |order, token|
|
||||
order.user == user || (order.token && token == order.token)
|
||||
end
|
||||
can [:index, :read], Product
|
||||
can [:index, :read], ProductProperty
|
||||
can [:index, :read], Property
|
||||
can :create, Spree::User
|
||||
can [:read, :update, :destroy], Spree::User, id: user.id
|
||||
can [:index, :read], State
|
||||
can [:index, :read], StockItem
|
||||
can [:index, :read], StockLocation
|
||||
can [:index, :read], StockMovement
|
||||
can [:index, :read], Taxon
|
||||
can [:index, :read], Variant
|
||||
@@ -243,8 +241,8 @@ module Spree
|
||||
can [:admin, :index], ::Admin::DfcProductImportsController
|
||||
|
||||
# Reports page
|
||||
can [:admin, :index, :show], ::Admin::ReportsController
|
||||
can [:admin, :show, :customers, :orders_and_distributors, :group_buys, :payments,
|
||||
can [:admin, :index, :show, :create], ::Admin::ReportsController
|
||||
can [:admin, :show, :create, :customers, :orders_and_distributors, :group_buys, :payments,
|
||||
:orders_and_fulfillment, :products_and_inventory, :order_cycle_management,
|
||||
:packing, :enterprise_fee_summary, :bulk_coop], :report
|
||||
end
|
||||
@@ -324,7 +322,7 @@ module Spree
|
||||
end
|
||||
|
||||
# Reports page
|
||||
can [:admin, :index, :show], ::Admin::ReportsController
|
||||
can [:admin, :index, :show, :create], ::Admin::ReportsController
|
||||
can [:admin, :customers, :group_buys, :sales_tax, :payments,
|
||||
:orders_and_distributors, :orders_and_fulfillment, :products_and_inventory,
|
||||
:order_cycle_management, :xero_invoices, :enterprise_fee_summary, :bulk_coop], :report
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "mini_magick"
|
||||
|
||||
module Spree
|
||||
class Image < Asset
|
||||
has_one_attached :attachment, service: image_service do |attachment|
|
||||
@@ -35,7 +33,7 @@ module Spree
|
||||
return self.class.default_image_url(size) unless attachment.attached?
|
||||
|
||||
image_variant_url_for(variant(size))
|
||||
rescue ActiveStorage::Error, MiniMagick::Error, ActionView::Template::Error => e
|
||||
rescue StandardError => e
|
||||
Bugsnag.notify "Product ##{viewable_id} Image ##{id} error: #{e.message}"
|
||||
Rails.logger.error(e.message)
|
||||
|
||||
|
||||
@@ -388,6 +388,8 @@ module Spree
|
||||
|
||||
deliver_order_confirmation_email
|
||||
|
||||
BackorderJob.check_stock(self)
|
||||
|
||||
state_changes.create(
|
||||
previous_state: 'cart',
|
||||
next_state: 'complete',
|
||||
|
||||
@@ -263,10 +263,12 @@ module Spree
|
||||
|
||||
# Format as per WeightsAndMeasures (todo: re-orgnaise maybe after product/variant refactor)
|
||||
def variant_unit_with_scale
|
||||
# Our code is based upon English based number formatting with a period `.`
|
||||
scale_clean = ActiveSupport::NumberHelper.number_to_rounded(variant_unit_scale,
|
||||
precision: nil,
|
||||
significant: false,
|
||||
strip_insignificant_zeros: true)
|
||||
strip_insignificant_zeros: true,
|
||||
locale: :en)
|
||||
[variant_unit, scale_clean].compact_blank.join("_")
|
||||
end
|
||||
|
||||
@@ -295,14 +297,8 @@ module Spree
|
||||
# eg clone product. Will raise error if clonning a product with no variant
|
||||
return if variants.first&.valid?
|
||||
|
||||
unless Spree::Taxon.find_by(id: primary_taxon_id)
|
||||
errors.add(:primary_taxon_id,
|
||||
I18n.t('activerecord.errors.models.spree/product.must_exist'))
|
||||
end
|
||||
return if Enterprise.find_by(id: supplier_id)
|
||||
|
||||
errors.add(:supplier_id,
|
||||
I18n.t('activerecord.errors.models.spree/product.must_exist'))
|
||||
errors.add(:primary_taxon_id, :blank) unless Spree::Taxon.find_by(id: primary_taxon_id)
|
||||
errors.add(:supplier_id, :blank) unless Enterprise.find_by(id: supplier_id)
|
||||
end
|
||||
|
||||
def update_units
|
||||
|
||||
@@ -87,16 +87,20 @@ module Spree
|
||||
|
||||
# Return the services (pickup, delivery) that different distributors provide, in the format:
|
||||
# {distributor_id => {pickup: true, delivery: false}, ...}
|
||||
def self.services
|
||||
Hash[
|
||||
Spree::ShippingMethod.
|
||||
joins(:distributor_shipping_methods).
|
||||
group('distributor_id').
|
||||
select("distributor_id").
|
||||
select("BOOL_OR(spree_shipping_methods.require_ship_address = 'f') AS pickup").
|
||||
select("BOOL_OR(spree_shipping_methods.require_ship_address = 't') AS delivery").
|
||||
map { |sm| [sm.distributor_id.to_i, { pickup: sm.pickup, delivery: sm.delivery }] }
|
||||
]
|
||||
#
|
||||
# Optionally, specify some distributor_ids as a parameter to scope the results
|
||||
def self.services(distributor_ids = nil)
|
||||
methods = Spree::ShippingMethod.joins(:distributor_shipping_methods).group('distributor_id')
|
||||
|
||||
if distributor_ids.present?
|
||||
methods = methods.where(distributor_shipping_methods: { distributor_id: distributor_ids })
|
||||
end
|
||||
|
||||
methods.
|
||||
pluck(Arel.sql("distributor_id"),
|
||||
Arel.sql("BOOL_OR(spree_shipping_methods.require_ship_address = 'f') AS pickup"),
|
||||
Arel.sql("BOOL_OR(spree_shipping_methods.require_ship_address = 't') AS delivery")).
|
||||
to_h { |(distributor_id, pickup, delivery)| [distributor_id.to_i, { pickup:, delivery: }] }
|
||||
end
|
||||
|
||||
def self.backend
|
||||
|
||||
@@ -7,7 +7,7 @@ module Spree
|
||||
|
||||
def initialize(variant)
|
||||
@variant = variant
|
||||
@stock_items = fetch_stock_items
|
||||
@stock_items = @variant.stock_items
|
||||
end
|
||||
|
||||
def total_on_hand
|
||||
@@ -25,16 +25,6 @@ module Spree
|
||||
def can_supply?(required)
|
||||
total_on_hand >= required || backorderable?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fetch_stock_items
|
||||
# Don't re-fetch associated stock items from the DB if we've already eager-loaded them
|
||||
return @variant.stock_items if @variant.stock_items.loaded?
|
||||
|
||||
Spree::StockItem.joins(:stock_location).
|
||||
where(:variant_id => @variant, Spree::StockLocation.table_name => { active: true })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
module Spree
|
||||
class StockLocation < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
self.ignored_columns += [:backorderable_default, :active]
|
||||
|
||||
has_many :stock_items, dependent: :delete_all, inverse_of: :stock_location
|
||||
has_many :stock_movements, through: :stock_items
|
||||
@@ -12,15 +13,9 @@ module Spree
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
scope :active, -> { where(active: true) }
|
||||
|
||||
after_create :create_stock_items
|
||||
|
||||
# Wrapper for creating a new stock item respecting the backorderable config
|
||||
def propagate_variant(variant)
|
||||
stock_items.create!(variant:, backorderable: backorderable_default)
|
||||
end
|
||||
|
||||
def stock_item(variant)
|
||||
stock_items.where(variant_id: variant).order(:id).first
|
||||
end
|
||||
@@ -56,7 +51,7 @@ module Spree
|
||||
private
|
||||
|
||||
def create_stock_items
|
||||
Variant.find_each { |variant| propagate_variant(variant) }
|
||||
Variant.find_each { |variant| stock_items.create!(variant:) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,18 +25,19 @@ module Spree
|
||||
|
||||
# Find all the taxons of supplied products for each enterprise, indexed by enterprise.
|
||||
# Format: {enterprise_id => [taxon_id, ...]}
|
||||
def self.supplied_taxons
|
||||
taxons = {}
|
||||
#
|
||||
# Optionally, specify some enterprise_ids to scope the results
|
||||
def self.supplied_taxons(enterprise_ids = nil)
|
||||
taxons = Spree::Taxon.joins(variants: :supplier)
|
||||
|
||||
Spree::Taxon.
|
||||
joins(variants: :supplier).
|
||||
select('spree_taxons.*, enterprises.id AS enterprise_id').
|
||||
each do |t|
|
||||
taxons[t.enterprise_id.to_i] ||= Set.new
|
||||
taxons[t.enterprise_id.to_i] << t.id
|
||||
end
|
||||
taxons = taxons.where(enterprises: { id: enterprise_ids }) if enterprise_ids.present?
|
||||
|
||||
taxons
|
||||
.pluck('spree_taxons.id, enterprises.id AS enterprise_id')
|
||||
.each_with_object({}) do |(taxon_id, enterprise_id), collection|
|
||||
collection[enterprise_id.to_i] ||= Set.new
|
||||
collection[enterprise_id.to_i] << taxon_id
|
||||
end
|
||||
end
|
||||
|
||||
# Find all the taxons of distributed products for each enterprise, indexed by enterprise.
|
||||
@@ -44,7 +45,9 @@ module Spree
|
||||
# or :current taxons (distributed in an open order cycle).
|
||||
#
|
||||
# Format: {enterprise_id => [taxon_id, ...]}
|
||||
def self.distributed_taxons(which_taxons = :all)
|
||||
#
|
||||
# Optionally, specify some enterprise_ids to scope the results
|
||||
def self.distributed_taxons(which_taxons = :all, enterprise_ids = nil)
|
||||
ents_and_vars = ExchangeVariant.joins(exchange: :order_cycle).merge(Exchange.outgoing)
|
||||
.select("DISTINCT variant_id, receiver_id AS enterprise_id")
|
||||
|
||||
@@ -57,6 +60,10 @@ module Spree
|
||||
INNER JOIN (#{ents_and_vars.to_sql}) AS ents_and_vars
|
||||
ON spree_variants.id = ents_and_vars.variant_id")
|
||||
|
||||
if enterprise_ids.present?
|
||||
taxons = taxons.where(ents_and_vars: { enterprise_id: enterprise_ids })
|
||||
end
|
||||
|
||||
taxons.each_with_object({}) do |t, ts|
|
||||
ts[t.enterprise_id.to_i] ||= Set.new
|
||||
ts[t.enterprise_id.to_i] << t.id
|
||||
|
||||
@@ -42,6 +42,7 @@ module Spree
|
||||
has_many :credit_cards, dependent: :destroy
|
||||
has_many :report_rendering_options, class_name: "::ReportRenderingOptions", dependent: :destroy
|
||||
has_many :webhook_endpoints, dependent: :destroy
|
||||
has_many :column_preferences, dependent: :destroy
|
||||
has_one :oidc_account, dependent: :destroy
|
||||
|
||||
accepts_nested_attributes_for :enterprise_roles, allow_destroy: true
|
||||
|
||||
@@ -170,6 +170,11 @@ module Spree
|
||||
select("spree_variants.id") })
|
||||
end
|
||||
|
||||
def self.linked_to(semantic_id)
|
||||
includes(:semantic_links).references(:semantic_links)
|
||||
.where(semantic_links: { semantic_id: }).first
|
||||
end
|
||||
|
||||
def tax_category
|
||||
super || TaxCategory.find_by(is_default: true)
|
||||
end
|
||||
@@ -235,8 +240,10 @@ module Spree
|
||||
end
|
||||
|
||||
def create_stock_items
|
||||
return unless stock_items.empty?
|
||||
|
||||
StockLocation.find_each do |stock_location|
|
||||
stock_location.propagate_variant(self)
|
||||
stock_items.create!(stock_location:)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ class VariantOverride < ApplicationRecord
|
||||
# Need to ensure this can be set by the user.
|
||||
validates :default_stock, numericality: { greater_than_or_equal_to: 0 }, allow_nil: true
|
||||
validates :price, numericality: { greater_than_or_equal_to: 0 }, allow_nil: true
|
||||
validates :count_on_hand, numericality: { greater_than_or_equal_to: 0 }, allow_nil: true
|
||||
validates :count_on_hand, numericality: {
|
||||
greater_than_or_equal_to: 0, unless: :on_demand?
|
||||
}, allow_nil: true
|
||||
|
||||
default_scope { where(permission_revoked_at: nil) }
|
||||
|
||||
@@ -36,9 +38,8 @@ class VariantOverride < ApplicationRecord
|
||||
end
|
||||
|
||||
def stock_overridden?
|
||||
# If count_on_hand is present, it means on_demand is false
|
||||
# See StockSettingsOverrideValidation for details
|
||||
count_on_hand.present?
|
||||
# Testing for not nil because for a boolean `false.present?` is false.
|
||||
!on_demand.nil? || !count_on_hand.nil?
|
||||
end
|
||||
|
||||
def use_producer_stock_settings?
|
||||
|
||||
@@ -95,9 +95,7 @@ module Api
|
||||
.merge(Exchange.to_enterprise(enterprise))
|
||||
.select('DISTINCT spree_properties.*')
|
||||
|
||||
return properties.merge(OrderCycle.active) if active
|
||||
|
||||
properties
|
||||
properties.merge(OrderCycle.active)
|
||||
end
|
||||
|
||||
def distributed_producer_properties
|
||||
@@ -106,16 +104,14 @@ module Api
|
||||
properties = Spree::Property
|
||||
.joins(
|
||||
producer_properties: {
|
||||
producer: { supplied_products: { variants: { exchanges: :order_cycle } } }
|
||||
producer: { supplied_variants: { exchanges: :order_cycle } }
|
||||
}
|
||||
)
|
||||
.merge(Exchange.outgoing)
|
||||
.merge(Exchange.to_enterprise(enterprise))
|
||||
.select('DISTINCT spree_properties.*')
|
||||
|
||||
return properties.merge(OrderCycle.active) if active
|
||||
|
||||
properties
|
||||
properties.merge(OrderCycle.active)
|
||||
end
|
||||
|
||||
def active
|
||||
|
||||
@@ -7,7 +7,7 @@ module Api
|
||||
attributes :orders_close_at, :active
|
||||
|
||||
def orders_close_at
|
||||
options[:data].earliest_closing_times[object.id]
|
||||
options[:data].earliest_closing_times[object.id]&.to_time
|
||||
end
|
||||
|
||||
def active
|
||||
|
||||
@@ -10,33 +10,6 @@ class CurrentOrderLocker
|
||||
# https://guides.rubyonrails.org/action_controller_overview.html#filters
|
||||
#
|
||||
def self.around(controller, &)
|
||||
lock_order_and_variants(controller.current_order, &)
|
||||
OrderLocker.lock_order_and_variants(controller.current_order, &)
|
||||
end
|
||||
|
||||
# Locking will not prevent all access to these rows. Other processes are
|
||||
# only waiting if they try to lock one of these rows as well.
|
||||
#
|
||||
# https://api.rubyonrails.org/classes/ActiveRecord/Locking/Pessimistic.html
|
||||
#
|
||||
def self.lock_order_and_variants(order)
|
||||
return yield if order.nil?
|
||||
|
||||
order.with_lock do
|
||||
lock_variants_of(order)
|
||||
yield
|
||||
end
|
||||
end
|
||||
private_class_method :lock_order_and_variants
|
||||
|
||||
# There are many places in which stock is stored in the database. Row locking
|
||||
# on variant level ensures that there are no conflicts even when an item is
|
||||
# sold through multiple shops.
|
||||
def self.lock_variants_of(order)
|
||||
variant_ids = order.line_items.select(:variant_id)
|
||||
|
||||
# Ordering the variants by id prevents deadlocks. Plucking the ids sends
|
||||
# the locking query without building Spree::Variant objects.
|
||||
Spree::Variant.where(id: variant_ids).order(:id).lock.pluck(:id)
|
||||
end
|
||||
private_class_method :lock_variants_of
|
||||
end
|
||||
|
||||
133
app/services/fdc_backorderer.rb
Normal file
133
app/services/fdc_backorderer.rb
Normal file
@@ -0,0 +1,133 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Place and update orders based on missing stock.
|
||||
class FdcBackorderer
|
||||
attr_reader :user, :urls
|
||||
|
||||
def initialize(user, urls)
|
||||
@user = user
|
||||
@urls = urls
|
||||
end
|
||||
|
||||
def find_or_build_order(ofn_order)
|
||||
find_open_order || build_new_order(ofn_order)
|
||||
end
|
||||
|
||||
def build_new_order(ofn_order)
|
||||
OrderBuilder.new_order(ofn_order, urls.orders_url).tap do |order|
|
||||
order.saleSession = build_sale_session(ofn_order)
|
||||
end
|
||||
end
|
||||
|
||||
def find_open_order
|
||||
graph = import(urls.orders_url)
|
||||
open_orders = graph&.select do |o|
|
||||
o.semanticType == "dfc-b:Order" && o.orderStatus[:path] == "Held"
|
||||
end
|
||||
|
||||
return if open_orders.blank?
|
||||
|
||||
# If there are multiple open orders, we don't know which one to choose.
|
||||
# We want the order we placed for the same distributor in the same order
|
||||
# cycle before. So here are some assumptions for this to work:
|
||||
#
|
||||
# * We see only orders for our distributor. The endpoint URL contains the
|
||||
# the distributor name and is currently hardcoded.
|
||||
# * There's only one open order cycle at a time. Otherwise we may select
|
||||
# an order of an old order cycle.
|
||||
# * Orders are finalised when the order cycle closes. So _Held_ orders
|
||||
# always belong to an open order cycle.
|
||||
# * We see only our own orders. This assumption is wrong. The Shopify
|
||||
# integration places held orders as well and they are visible to us.
|
||||
#
|
||||
# Unfortunately, the endpoint doesn't tell who placed the order.
|
||||
# TODO: We need to remember the link to the order locally.
|
||||
# Or the API is updated to include the orderer.
|
||||
#
|
||||
# For now, we just guess:
|
||||
open_orders.last.tap do |order|
|
||||
# The DFC Connector doesn't recognise status values properly yet.
|
||||
# So we are overriding the value with something that can be exported.
|
||||
order.orderStatus = "dfc-v:Held"
|
||||
end
|
||||
end
|
||||
|
||||
def find_order(semantic_id)
|
||||
find_subject(import(semantic_id), "dfc-b:Order")
|
||||
end
|
||||
|
||||
def find_or_build_order_line(order, offer)
|
||||
find_order_line(order, offer) || build_order_line(order, offer)
|
||||
end
|
||||
|
||||
def build_order_line(order, offer)
|
||||
# Order lines are enumerated in the FDC API and we must assign a unique
|
||||
# semantic id. We need to look at current ids to avoid collisions.
|
||||
# existing_ids = order.lines.map do |line|
|
||||
# line.semanticId.match(/[0-9]+$/).to_s.to_i
|
||||
# end
|
||||
# next_id = existing_ids.max.to_i + 1
|
||||
|
||||
# Suggested by FDC team:
|
||||
next_id = order.lines.count + 1
|
||||
|
||||
OrderLineBuilder.build(offer, 0).tap do |line|
|
||||
line.semanticId = "#{order.semanticId}/OrderLines/#{next_id}"
|
||||
order.lines << line
|
||||
end
|
||||
end
|
||||
|
||||
def find_order_line(order, offer)
|
||||
order.lines.find do |line|
|
||||
line.offer.offeredItem.semanticId == offer.offeredItem.semanticId
|
||||
end
|
||||
end
|
||||
|
||||
def find_subject(object_or_graph, type)
|
||||
if object_or_graph.is_a?(Array)
|
||||
object_or_graph.find { |i| i.semanticType == type }
|
||||
else
|
||||
object_or_graph
|
||||
end
|
||||
end
|
||||
|
||||
def import(url)
|
||||
api = DfcRequest.new(user)
|
||||
json = api.call(url)
|
||||
DfcIo.import(json)
|
||||
end
|
||||
|
||||
def send_order(backorder)
|
||||
lines = backorder.lines
|
||||
offers = lines.map(&:offer)
|
||||
products = offers.map(&:offeredItem)
|
||||
sessions = [backorder.saleSession].compact
|
||||
json = DfcIo.export(backorder, *lines, *offers, *products, *sessions)
|
||||
|
||||
api = DfcRequest.new(user)
|
||||
|
||||
method = if new?(backorder)
|
||||
:post # -> create
|
||||
else
|
||||
:put # -> update
|
||||
end
|
||||
|
||||
result = api.call(backorder.semanticId, json, method:)
|
||||
find_subject(DfcIo.import(result), "dfc-b:Order")
|
||||
end
|
||||
|
||||
def complete_order(backorder)
|
||||
backorder.orderStatus = "dfc-v:Complete"
|
||||
send_order(backorder)
|
||||
end
|
||||
|
||||
def new?(order)
|
||||
order.semanticId == urls.orders_url
|
||||
end
|
||||
|
||||
def build_sale_session(order)
|
||||
SaleSessionBuilder.build(order.order_cycle).tap do |session|
|
||||
session.semanticId = urls.sale_session_url
|
||||
end
|
||||
end
|
||||
end
|
||||
89
app/services/fdc_offer_broker.rb
Normal file
89
app/services/fdc_offer_broker.rb
Normal file
@@ -0,0 +1,89 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Finds wholesale offers for retail products.
|
||||
class FdcOfferBroker
|
||||
# TODO: Find a better way to provide this data.
|
||||
Solution = Struct.new(:product, :factor, :offer)
|
||||
RetailSolution = Struct.new(:retail_product_id, :factor)
|
||||
|
||||
def self.load_catalog(user, urls)
|
||||
api = DfcRequest.new(user)
|
||||
catalog_json = api.call(urls.catalog_url)
|
||||
DfcIo.import(catalog_json)
|
||||
end
|
||||
|
||||
def initialize(user, urls)
|
||||
@user = user
|
||||
@urls = urls
|
||||
end
|
||||
|
||||
def catalog
|
||||
@catalog ||= self.class.load_catalog(@user, @urls)
|
||||
end
|
||||
|
||||
def best_offer(product_id)
|
||||
Solution.new(
|
||||
wholesale_product(product_id),
|
||||
contained_quantity(product_id),
|
||||
offer_of(wholesale_product(product_id))
|
||||
)
|
||||
end
|
||||
|
||||
def wholesale_product(product_id)
|
||||
production_flow = catalog_item("#{product_id}/AsPlannedProductionFlow")
|
||||
|
||||
if production_flow
|
||||
wholesale_product_id = production_flow.product
|
||||
catalog_item(wholesale_product_id)
|
||||
else
|
||||
# We didn't find a wholesale variant, falling back to the given product.
|
||||
catalog_item(product_id)
|
||||
end
|
||||
end
|
||||
|
||||
def contained_quantity(product_id)
|
||||
consumption_flow = catalog_item("#{product_id}/AsPlannedConsumptionFlow")
|
||||
|
||||
# If we don't find a transformation, we return the original product,
|
||||
# which contains exactly one of itself (identity).
|
||||
consumption_flow&.quantity&.value&.to_i || 1
|
||||
end
|
||||
|
||||
def wholesale_to_retail(wholesale_product_id)
|
||||
production_flow = flow_producing(wholesale_product_id)
|
||||
|
||||
return RetailSolution.new(wholesale_product_id, 1) if production_flow.nil?
|
||||
|
||||
consumption_flow = catalog_item(
|
||||
production_flow.semanticId.sub("AsPlannedProductionFlow", "AsPlannedConsumptionFlow")
|
||||
)
|
||||
retail_product_id = consumption_flow.product
|
||||
|
||||
contained_quantity = consumption_flow.quantity.value.to_i
|
||||
|
||||
RetailSolution.new(retail_product_id, contained_quantity)
|
||||
end
|
||||
|
||||
def offer_of(product)
|
||||
product&.catalogItems&.first&.offers&.first&.tap do |offer|
|
||||
# Unfortunately, the imported catalog doesn't provide the reverse link:
|
||||
offer.offeredItem = product
|
||||
end
|
||||
end
|
||||
|
||||
def catalog_item(id)
|
||||
@catalog_by_id ||= catalog.index_by(&:semanticId)
|
||||
@catalog_by_id[id]
|
||||
end
|
||||
|
||||
def flow_producing(wholesale_product_id)
|
||||
@production_flows_by_product_id ||= production_flows.index_by(&:product)
|
||||
@production_flows_by_product_id[wholesale_product_id]
|
||||
end
|
||||
|
||||
def production_flows
|
||||
@production_flows ||= catalog.select do |i|
|
||||
i.semanticType == "dfc-b:AsPlannedProductionFlow"
|
||||
end
|
||||
end
|
||||
end
|
||||
16
app/services/fdc_url_builder.rb
Normal file
16
app/services/fdc_url_builder.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# The DFC standard doesn't include endpoint discovery yet.
|
||||
# So for now we are guessing URLs based on our FDC pilot project.
|
||||
class FdcUrlBuilder
|
||||
attr_reader :catalog_url, :orders_url, :sale_session_url
|
||||
|
||||
# At the moment, we start with a product link like this:
|
||||
#
|
||||
# https://env-0105831.jcloud-ver-jpe.ik-server.com/api/dfc/Enterprises/test-hodmedod/SuppliedProducts/44519466467635
|
||||
def initialize(semantic_id)
|
||||
@catalog_url, _slash, _id = semantic_id.rpartition("/")
|
||||
@orders_url = @catalog_url.sub("/SuppliedProducts", "/Orders")
|
||||
@sale_session_url = @catalog_url.sub("/SuppliedProducts", "/SalesSession/#")
|
||||
end
|
||||
end
|
||||
@@ -18,4 +18,16 @@ class HtmlSanitizer
|
||||
html, tags: ALLOWED_TAGS, attributes: (ALLOWED_ATTRIBUTES + ALLOWED_TRIX_DATA_ATTRIBUTES)
|
||||
)
|
||||
end
|
||||
|
||||
def self.sanitize_and_enforce_link_target_blank(html)
|
||||
sanitize(enforce_link_target_blank(html))
|
||||
end
|
||||
|
||||
def self.enforce_link_target_blank(html)
|
||||
return if html.nil?
|
||||
|
||||
Nokogiri::HTML::DocumentFragment.parse(html).tap do |document|
|
||||
document.css("a").each { |link| link["target"] = "_blank" }
|
||||
end.to_s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,6 +7,8 @@ module OrderCycles
|
||||
class FormService
|
||||
def initialize(order_cycle, order_cycle_params, user)
|
||||
@order_cycle = order_cycle
|
||||
@confirm_datetime_change = order_cycle_params.delete :confirm_datetime_change
|
||||
@error_class = order_cycle_params.delete :error_class
|
||||
@order_cycle_params = order_cycle_params
|
||||
@specified_params = order_cycle_params.keys
|
||||
@user = user
|
||||
@@ -21,6 +23,9 @@ module OrderCycles
|
||||
end
|
||||
|
||||
def save
|
||||
# Check that order cycle datetime values changed if it has existing orders
|
||||
verify_datetime_change!
|
||||
|
||||
schedule_ids = build_schedule_ids
|
||||
order_cycle.assign_attributes(order_cycle_params)
|
||||
return false unless order_cycle.valid?
|
||||
@@ -229,5 +234,16 @@ module OrderCycles
|
||||
DistributorShippingMethod.where(distributor_id: user_distributors_ids)
|
||||
.pluck(:id)
|
||||
end
|
||||
|
||||
def verify_datetime_change!
|
||||
return unless @confirm_datetime_change
|
||||
return unless @order_cycle.orders.exists?
|
||||
return if @order_cycle.same_datetime_value(:orders_open_at,
|
||||
@order_cycle_params[:orders_open_at]) &&
|
||||
@order_cycle.same_datetime_value(:orders_close_at,
|
||||
@order_cycle_params[:orders_close_at])
|
||||
|
||||
raise @error_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
33
app/services/order_locker.rb
Normal file
33
app/services/order_locker.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Locks an order including its variants.
|
||||
#
|
||||
# It should be used when making major changes like checking out the order.
|
||||
# It can keep stock checking in sync and prevent overselling of an item.
|
||||
class OrderLocker
|
||||
# Locking will not prevent all access to these rows. Other processes are
|
||||
# only waiting if they try to lock one of these rows as well.
|
||||
#
|
||||
# https://api.rubyonrails.org/classes/ActiveRecord/Locking/Pessimistic.html
|
||||
#
|
||||
def self.lock_order_and_variants(order)
|
||||
return yield if order.nil?
|
||||
|
||||
order.with_lock do
|
||||
lock_variants_of(order)
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
# There are many places in which stock is stored in the database. Row locking
|
||||
# on variant level ensures that there are no conflicts even when an item is
|
||||
# sold through multiple shops.
|
||||
def self.lock_variants_of(order)
|
||||
variant_ids = order.line_items.select(:variant_id)
|
||||
|
||||
# Ordering the variants by id prevents deadlocks. Plucking the ids sends
|
||||
# the locking query without building Spree::Variant objects.
|
||||
Spree::Variant.where(id: variant_ids).order(:id).lock.pluck(:id)
|
||||
end
|
||||
private_class_method :lock_variants_of
|
||||
end
|
||||
@@ -9,7 +9,7 @@ module PermittedAttributes
|
||||
:unit_description, :variant_unit_name,
|
||||
:display_as, :sku, :group_buy, :group_buy_unit_size,
|
||||
:taxon_ids, :primary_taxon_id, :tax_category_id, :supplier_id,
|
||||
:meta_keywords, :notes, :inherits_properties,
|
||||
:meta_keywords, :notes, :inherits_properties, :shipping_category_id,
|
||||
{ product_properties_attributes: [:id, :property_name, :value],
|
||||
variants_attributes: [PermittedAttributes::Variant.attributes],
|
||||
image_attributes: [:attachment] }
|
||||
|
||||
@@ -3,7 +3,31 @@
|
||||
module Sets
|
||||
class OrderCycleSet < ModelSet
|
||||
def initialize(collection, attributes = {})
|
||||
@confirm_datetime_change = attributes.delete :confirm_datetime_change
|
||||
@error_class = attributes.delete :error_class
|
||||
|
||||
super(OrderCycle, collection, attributes)
|
||||
end
|
||||
|
||||
def process(order_cycle, attributes)
|
||||
if @confirm_datetime_change &&
|
||||
order_cycle.orders.exists? &&
|
||||
datetime_value_changed(order_cycle, attributes)
|
||||
raise @error_class
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def datetime_value_changed(order_cycle, attributes)
|
||||
# return true if either key is present in params and change in values detected
|
||||
return true if attributes.key?(:orders_open_at) &&
|
||||
!order_cycle.same_datetime_value(:orders_open_at, attributes[:orders_open_at])
|
||||
|
||||
attributes.key?(:orders_close_at) &&
|
||||
!order_cycle.same_datetime_value(:orders_close_at, attributes[:orders_close_at])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ShopsListService
|
||||
# shops that are ready for checkout, and have an order cycle that is currently open
|
||||
def open_shops
|
||||
shops_list.ready_for_checkout.all
|
||||
shops_list.
|
||||
ready_for_checkout.
|
||||
distributors_with_active_order_cycles
|
||||
end
|
||||
|
||||
# shops that are either not ready for checkout, or don't have an open order cycle; the inverse of
|
||||
# #open_shops
|
||||
def closed_shops
|
||||
shops_list.not_ready_for_checkout.all
|
||||
shops_list.where.not(id: open_shops.reselect("enterprises.id"))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -26,9 +26,15 @@ class WeightsAndMeasures
|
||||
def self.variant_unit_options
|
||||
available_units_sorted.flat_map do |measurement, measurement_info|
|
||||
measurement_info.filter_map do |scale, unit_info|
|
||||
# Our code is based upon English based number formatting
|
||||
# Some language locales like +hu+ uses a comma(,) for decimal separator
|
||||
# While in English, decimal separator is represented by a period.
|
||||
# e.g. en: 0.001, hu: 0,001
|
||||
# Hence the results become "weight_0,001" for hu while or code recognizes "weight_0.001"
|
||||
scale_clean =
|
||||
ActiveSupport::NumberHelper.number_to_rounded(scale, precision: nil, significant: false,
|
||||
strip_insignificant_zeros: true)
|
||||
strip_insignificant_zeros: true,
|
||||
locale: :en)
|
||||
[
|
||||
"#{I18n.t(measurement)} (#{unit_info['name']})", # Label (eg "Weight (g)")
|
||||
"#{measurement}_#{scale_clean}", # Scale ID (eg "weight_1")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
%fieldset.alpha.no-border-bottom#about_panel{ data: { "tabs-and-panels-target": "panel" } }
|
||||
%legend= t('.about')
|
||||
= f.field_container :long_description do
|
||||
%text-angular{'id' => 'enterprise_group_long_description', 'name' => 'enterprise_group[long_description]', 'class' => 'text-angular', "textangular-links-target-blank" => true,
|
||||
'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear'],['insertLink']]"}
|
||||
!= @enterprise_group[:long_description]
|
||||
= f.hidden_field :long_description, id: "enterprise_group_long_description"
|
||||
%trix-editor{ input: "enterprise_group_long_description", "data-controller": "trixeditor" }
|
||||
|
||||
@@ -4,14 +4,7 @@
|
||||
.omega.eight.columns
|
||||
= f.text_field :description, maxlength: 255, placeholder: t('.desc_short_placeholder')
|
||||
.row
|
||||
.alpha.three.columns
|
||||
.alpha.eleven.columns
|
||||
= f.label :long_description, t('.desc_long')
|
||||
.omega.eight.columns
|
||||
-# textAngular toolbar options, add to the ta-toolbar array below and separate into groups with extra ],[ if needed:
|
||||
-# ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'quote'],
|
||||
-# ['bold', 'italics', 'underline', 'strikeThrough', 'ul', 'ol', 'redo', 'undo', 'clear'],
|
||||
-# ['justifyLeft','justifyCenter','justifyRight','indent','outdent'],
|
||||
-# ['html', 'insertImage', 'insertLink', 'insertVideo']
|
||||
%text-angular{'ng-model' => 'Enterprise.long_description', 'id' => 'enterprise_long_description', 'name' => 'enterprise[long_description]', 'class' => 'text-angular', "textangular-links-target-blank" => true,
|
||||
'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear'],['insertLink']]",
|
||||
'placeholder' => t('.desc_long_placeholder')}
|
||||
= f.hidden_field :long_description, id: "enterprise_long_description"
|
||||
%trix-editor{ input: "enterprise_long_description", "data-controller": "trixeditor" }
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
.row
|
||||
.three.columns.alpha
|
||||
.eleven.columns.alpha
|
||||
= f.label "enterprise_preferred_shopfront_message", t('.shopfront_message')
|
||||
.eight.columns.omega
|
||||
%text-angular{'ng-model' => 'Enterprise.preferred_shopfront_message', 'id' => 'enterprise_preferred_shopfront_message', 'name' => 'enterprise[preferred_shopfront_message]', 'class' => 'text-angular textangular-strip', 'ta-paste' => "stripFormatting($html)", "textangular-links-target-blank" => true,
|
||||
'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear'],['insertLink']]",
|
||||
'placeholder' => t('.shopfront_message_placeholder')}
|
||||
= f.hidden_field :preferred_shopfront_message, id: "enterprise_preferred_shopfront_message"
|
||||
%trix-editor{ input: "enterprise_preferred_shopfront_message", "data-controller": "trixeditor", placeholder: t('.shopfront_message_placeholder') }
|
||||
.row
|
||||
.three.columns.alpha
|
||||
.eleven.columns.alpha
|
||||
= f.label "enterprise_preferred_shopfront_closed_message", t('.shopfront_closed_message')
|
||||
.eight.columns.omega
|
||||
%text-angular{'ng-model' => 'Enterprise.preferred_shopfront_closed_message', 'id' => 'enterprise_preferred_shopfront_closed_message', 'name' => 'enterprise[preferred_shopfront_closed_message]', 'class' => 'text-angular textangular-strip', 'ta-paste' => "stripFormatting($html)", "textangular-links-target-blank" => true,
|
||||
'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear'],['insertLink']]",
|
||||
'placeholder' => t('.shopfront_closed_message_placeholder')}
|
||||
= f.hidden_field :preferred_shopfront_closed_message, id: "enterprise_preferred_shopfront_closed_message"
|
||||
%trix-editor{ input: "enterprise_preferred_shopfront_closed_message", "data-controller": "trixeditor", placeholder: t('.shopfront_closed_message_placeholder') }
|
||||
|
||||
.row
|
||||
.text-normal
|
||||
@@ -77,7 +73,7 @@
|
||||
= f.radio_button :preferred_product_low_stock_display, true, 'ng-model' => 'Enterprise.preferred_product_low_stock_display', 'ng-value' => 'true'
|
||||
= f.label :preferred_product_low_stock_display, t('.enabled'), value: :true
|
||||
.five.columns.omega
|
||||
= f.radio_button :preferred_product_low_stock_display, false, 'ng-model' => 'Enterprise.preferred_product_low_stock_display', 'ng-value' => 'false'
|
||||
= f.radio_button :preferred_product_low_stock_display, false, 'ng-model' => 'Enterprise.preferred_product_low_stock_display', 'ng-value' => 'false'
|
||||
= f.label :preferred_product_low_stock_display, t('.disabled'), value: :false
|
||||
|
||||
.row
|
||||
|
||||
@@ -4,11 +4,16 @@
|
||||
%div{ style: 'font-size: 1rem;' }
|
||||
= t('.content')
|
||||
%p.modal-actions.justify-end.gap-1
|
||||
%button.button.secondary{ "ng-click": "submit($event, null)", type: "button", style: "display: none;", data: { action: 'click->modal#close', 'trigger-action': 'save' } }
|
||||
= t('.proceed')
|
||||
%button.button.secondary{ "ng-click": "submit($event, '#{main_app.admin_order_cycle_incoming_path(@order_cycle)}')", type: "button", style: "display: none;", data: { action: 'click->modal#close', 'trigger-action': 'saveAndNext' } }
|
||||
= t('.proceed')
|
||||
%button.button.secondary{ "ng-click": "submit($event, '#{main_app.admin_order_cycles_path}')", type: "button", style: "display: none;", data: { action: 'click->modal#close', 'trigger-action': 'saveAndBack' } }
|
||||
= t('.proceed')
|
||||
%button.button.primary{ type: "button", 'data-action': 'click->modal#close' }
|
||||
= t('.cancel')
|
||||
- if action == 'simple_update'
|
||||
%button.button.secondary{ "ng-click": "submit($event, null)", type: "button", style: "display: none;", data: { action: 'click->modal#close', 'trigger-action': 'save' } }
|
||||
= t('.proceed')
|
||||
%button.button.secondary{ "ng-click": "submit($event, '#{main_app.admin_order_cycle_incoming_path(@order_cycle)}')", type: "button", style: "display: none;", data: { action: 'click->modal#close', 'trigger-action': 'saveAndNext' } }
|
||||
= t('.proceed')
|
||||
%button.button.secondary{ "ng-click": "submit($event, '#{main_app.admin_order_cycles_path}')", type: "button", style: "display: none;", data: { action: 'click->modal#close', 'trigger-action': 'saveAndBack' } }
|
||||
= t('.proceed')
|
||||
= link_to t('.cancel'), admin_order_cycles_path, id: 'cancel', class: 'button primary', data: { 'order-cycle-form-target': 'cancel' }
|
||||
- if action == 'bulk_update'
|
||||
%button.button.secondary{ "ng-click": "saveAll($event)", type: "button", style: "display: none;", data: { action: 'click->modal#close', trigger_action: 'bulk_save' } }
|
||||
= t('.proceed')
|
||||
%button.button.primary{ type: "button", 'data-action': 'click->modal#close' }
|
||||
= t('.cancel')
|
||||
@@ -37,4 +37,4 @@
|
||||
%button.modal-target-trigger{ type: 'button', data: { 'action': 'modal-link#open' }, style: 'display: none;' }
|
||||
= render ModalComponent.new(id: "linked-order-warning-modal", close_button: false) do
|
||||
.content.flex-column.gap-2
|
||||
= render 'date_time_warning_modal_content'
|
||||
= render 'date_time_warning_modal_content', action: 'simple_update'
|
||||
@@ -23,12 +23,20 @@
|
||||
.thirteen.columns.alpha
|
||||
%columns-dropdown{ action: "#{controller_name}_#{action_name}" }
|
||||
|
||||
%form{ name: 'order_cycles_form' }
|
||||
%save-bar{ dirty: "order_cycles_form.$dirty", persist: "false" }
|
||||
%input.red{ type: "button", value: t(:save_changes), "ng-click": "saveAll()", "ng-disabled": "!order_cycles_form.$dirty" }
|
||||
%table.index#listing_order_cycles{ "ng-show": 'orderCycles.length > 0' }
|
||||
= render 'admin/order_cycles/header' #, simple_index: simple_index
|
||||
%tbody
|
||||
= render 'admin/order_cycles/row' #, simple_index: simple_index
|
||||
= render 'admin/order_cycles/loading_flash'
|
||||
= render 'admin/order_cycles/show_more'
|
||||
%div{ data: { controller: 'order-cycle-form' } }
|
||||
%form{ name: 'order_cycles_form' }
|
||||
%save-bar{ dirty: "order_cycles_form.$dirty", persist: "false" }
|
||||
%input.red{ type: "button", value: t(:save_changes), "ng-click": "saveAll($event)", "ng-disabled": "!order_cycles_form.$dirty",
|
||||
data: { confirm: "true", 'trigger-action': 'bulk_save' } }
|
||||
%table.index#listing_order_cycles{ "ng-show": 'orderCycles.length > 0' }
|
||||
= render 'admin/order_cycles/header' #, simple_index: simple_index
|
||||
%tbody
|
||||
= render 'admin/order_cycles/row' #, simple_index: simple_index
|
||||
= render 'admin/order_cycles/loading_flash'
|
||||
= render 'admin/order_cycles/show_more'
|
||||
|
||||
%div.warning-modal{ data: { controller: 'modal modal-link', 'modal-link-target-value': "linked-order-warning-modal" } }
|
||||
%button.modal-target-trigger{ type: 'button', data: { 'action': 'modal-link#open' }, style: 'display: none;' }
|
||||
= render ModalComponent.new(id: "linked-order-warning-modal", close_button: false) do
|
||||
.content.flex-column.gap-2
|
||||
= render 'date_time_warning_modal_content', action: 'bulk_update'
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
-# empty
|
||||
%td.col-on_hand.align-right
|
||||
-# empty
|
||||
%td.col-on_hand.align-right
|
||||
%td.col-producer.align-right
|
||||
-# empty
|
||||
%td.col-category.align-left
|
||||
-# empty
|
||||
@@ -40,3 +40,4 @@
|
||||
"data-modal-link-target-value": "product-delete-modal", "class": "delete",
|
||||
"data-modal-link-modal-dataset-value": {'data-delete-path': admin_product_destroy_path(product)}.to_json }
|
||||
= t('admin.products_page.actions.delete')
|
||||
= link_to t('admin.products_page.actions.preview'), admin_product_preview_path(product), {"data-turbo-stream": "" }
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
%tr.condensed{ id: dom_id(variant), 'data-controller': "variant", 'class': "nested-form-wrapper", 'data-new-record': variant.new_record? ? "true" : false }
|
||||
= render partial: 'variant_row', locals: { variant:, f: variant_form, category_options:, tax_category_options:, producer_options: }
|
||||
|
||||
= form.fields_for("products][#{product_index}][variants_attributes][NEW_RECORD", prepare_new_variant(product)) do |new_variant_form|
|
||||
= form.fields_for("products][#{product_index}][variants_attributes][NEW_RECORD", prepare_new_variant(product, producer_options)) do |new_variant_form|
|
||||
%template{ 'data-nested-form-target': "template" }
|
||||
%tr.condensed{ 'data-controller': "variant", 'class': "nested-form-wrapper", 'data-new-record': "true" }
|
||||
= render partial: 'variant_row', locals: { variant: new_variant_form.object, f: new_variant_form, category_options:, tax_category_options:, producer_options: }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#sort
|
||||
%div.pagination-description
|
||||
- if pagy.present?
|
||||
= t(".pagination.total_html", total: pagy.count, from: pagy.from, to: pagy.to)
|
||||
= t(".pagination.products_total_html", count: pagy.count, from: pagy.from, to: pagy.to)
|
||||
|
||||
- if search_term.present? || producer_id.present? || category_id.present?
|
||||
%a{ href: url_for(page: 1), class: "button disruptive", data: { 'turbo-frame': "_self", 'turbo-action': "advance" } }
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
= hidden_field_tag :producer_id, @producer_id
|
||||
= hidden_field_tag :category_id, @category_id
|
||||
|
||||
%table.products{ 'data-column-preferences-target': "table" }
|
||||
%table.products{ 'data-column-preferences-target': "table", class: (hide_producer_column?(producer_options) ? 'hide-producer' : '') }
|
||||
%colgroup
|
||||
-# The `min-width` property works in Chrome but not Firefox so is considered progressive enhancement.
|
||||
%col.col-image{ width:"56px" }= # (image size + padding)
|
||||
%col.col-image{ width:"44px" }= # (image size + padding)
|
||||
%col.col-name{ style:"min-width: 6em" }= # (grow to fill)
|
||||
%col.col-sku{ width:"8%", style:"min-width: 6em" }
|
||||
%col.col-unit_scale{ width:"8%" }
|
||||
%col.col-unit{ width:"8%" }
|
||||
%col.col-price{ width:"5%", style:"min-width: 5em" }
|
||||
%col.col-on_hand{ width:"10%"}
|
||||
%col.col-price{ width:"10%", style:"min-width: 5em" }
|
||||
%col.col-on_hand{ width:"8%" }
|
||||
%col.col-producer{ style:"min-width: 6em" }= # (grow to fill)
|
||||
%col.col-category{ width:"8%" }
|
||||
%col.col-tax_category{ width:"8%" }
|
||||
|
||||
@@ -20,3 +20,4 @@
|
||||
= render partial: 'delete_modal', locals: { object_type: }
|
||||
#modal-component
|
||||
#edit_image_modal
|
||||
#product-preview-modal-container
|
||||
|
||||
119
app/views/admin/products_v3/product_preview.turbo_stream.haml
Normal file
119
app/views/admin/products_v3/product_preview.turbo_stream.haml
Normal file
@@ -0,0 +1,119 @@
|
||||
= turbo_stream.update "product-preview-modal-container" do
|
||||
= render ModalComponent.new(id: "product-preview-modal", instant: true, modal_class: "big") do
|
||||
#product-preview{ "data-controller": "tabs" }
|
||||
%h1
|
||||
= t("admin.products_page.product_preview.product_preview")
|
||||
%dl.admin-tabs
|
||||
%dd
|
||||
%a{ data: { "tabs-target": "tab", "action": "tabs#select" } }
|
||||
= t("admin.products_page.product_preview.shop_tab")
|
||||
%dd
|
||||
%a{ data: { "tabs-target": "tab", "action": "tabs#select" } }
|
||||
= t("admin.products_page.product_preview.product_details_tab")
|
||||
.tabs-content
|
||||
.content.active
|
||||
%div{ data: { "tabs-target": "content" } }
|
||||
.product-thumb
|
||||
%a
|
||||
- if @product.group_buy
|
||||
%span.product-thumb__bulk-label
|
||||
= t(".bulk")
|
||||
= image_tag @product.image&.url(:small) || Spree::Image.default_image_url(:small)
|
||||
|
||||
.summary
|
||||
.summary-header
|
||||
%h3
|
||||
%a
|
||||
%span
|
||||
= @product.name
|
||||
- if @product.description
|
||||
.product-description{ "data-controller": "add-blank-to-link" }
|
||||
- # description is sanitized in Spree::Product#description method
|
||||
= @product.description.html_safe
|
||||
|
||||
- if @product.variants.first.supplier.visible
|
||||
%div
|
||||
.product-producer
|
||||
= t :products_from
|
||||
%span
|
||||
%a
|
||||
= @product.variants.first.supplier.name
|
||||
.product-properties.filter-shopfront.property-selectors
|
||||
.filter-shopfront.property-selectors.inline-block
|
||||
%ul
|
||||
- @product.properties_including_inherited.each do |property|
|
||||
%li
|
||||
- if property[:value].present?
|
||||
= render AdminTooltipComponent.new(text: property[:value], link_text: property[:name], placement: "bottom")
|
||||
- else
|
||||
%a
|
||||
%span
|
||||
= property[:name]
|
||||
.shop-variants
|
||||
- @product.variants.sort { |v1, v2| v1.name_to_display <=> v2.name_to_display }.sort { |v1, v2| v1.unit_value <=> v2.unit_value }.each do |variant|
|
||||
.variants.row
|
||||
.small-3.columns.variant-name
|
||||
- if variant.display_name.present?
|
||||
.inline
|
||||
= variant.display_name
|
||||
.variant-unit
|
||||
= variant.unit_to_display
|
||||
.small-4.medium-3.columns.variant-price
|
||||
= number_to_currency(variant.price)
|
||||
.unit-price.variant-unit-price
|
||||
= render AdminTooltipComponent.new(text: t("js.shopfront.unit_price_tooltip"), link_text: "", placement: "top", link_class: "question-mark-icon")
|
||||
- # TODO use an helper
|
||||
- unit_price = UnitPrice.new(variant)
|
||||
- price_per_unit = variant.price / (unit_price.denominator || 1)
|
||||
= "#{number_to_currency(price_per_unit)} / #{unit_price.unit}".html_safe
|
||||
|
||||
|
||||
.medium-3.columns.total-price
|
||||
%span
|
||||
= number_to_currency(0.00)
|
||||
.small-5.medium-3.large-3.columns.variant-quantity-column.text-right
|
||||
.variant-quantity-inputs
|
||||
%button.add-variant
|
||||
= t("js.shopfront.variant.add_to_cart")
|
||||
|
||||
- # TODO can't check the shop preferrence here, display by default ?
|
||||
- if !variant.on_demand && variant.on_hand <= 3
|
||||
.variant-remaining-stock
|
||||
= t("js.shopfront.variant.remaining_in_stock", quantity: variant.on_hand)
|
||||
|
||||
%div{ data: { "tabs-target": "content" } }
|
||||
.row
|
||||
.columns.small-12.medium-6.large-6.product-header
|
||||
%h3
|
||||
= @product.name
|
||||
%span
|
||||
%em
|
||||
= t("products_from")
|
||||
%span
|
||||
= @product.variants.first.supplier.name
|
||||
|
||||
%br
|
||||
|
||||
.filter-shopfront.property-selectors.inline-block
|
||||
%ul
|
||||
- @product.properties_including_inherited.each do |property|
|
||||
%li
|
||||
- if property[:value].present?
|
||||
= render AdminTooltipComponent.new(text: property[:value], link_text: property[:name], placement: "bottom")
|
||||
- else
|
||||
%a
|
||||
%span
|
||||
= property[:name]
|
||||
|
||||
|
||||
- if @product.description
|
||||
.product-description{ 'data-controller': "add-blank-to-link" }
|
||||
%p.text-small
|
||||
- # description is sanitized in Spree::Product#description method
|
||||
= @product.description.html_safe
|
||||
|
||||
.columns.small-12.medium-6.large-6.product-img
|
||||
- if @product.image
|
||||
%img{ src: @product.image.url(:large) }
|
||||
-else
|
||||
%img.placeholder{ src: Spree::Image.default_image_url(:large) }
|
||||
47
app/views/admin/reports/_fallback_display.html.haml
Normal file
47
app/views/admin/reports/_fallback_display.html.haml
Normal file
@@ -0,0 +1,47 @@
|
||||
.download.hidden
|
||||
= link_to t("admin.reports.download.button"), file_url, target: "_blank", class: "button icon icon-file"
|
||||
|
||||
:javascript
|
||||
(function () {
|
||||
const tryDownload = function() {
|
||||
const link = document.querySelector(".download a");
|
||||
|
||||
// If the report was already rendered via web sockets:
|
||||
if (link == null) return;
|
||||
|
||||
fetch(link.href).then((response) => {
|
||||
if (response.ok) {
|
||||
response.blob().then((blob) => blob.text()).then((text) => {
|
||||
const loading = document.querySelector(".loading");
|
||||
|
||||
if (loading == null) return;
|
||||
|
||||
loading.remove();
|
||||
document.querySelector("#report-go button").disabled = false;
|
||||
|
||||
if (link.href.endsWith(".html")) {
|
||||
// This replaces the hidden download button with the report:
|
||||
link.parentElement.outerHTML = text;
|
||||
} else {
|
||||
// Or just show the download button when it's ready:
|
||||
document.querySelector(".download").classList.remove("hidden")
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setTimeout(tryDownload, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
A lot of reports are rendered within 250ms. Others take at least
|
||||
2.5 seconds. There's a big gap in between. Observed on:
|
||||
https://openfoodnetwork.org.au/admin/sidekiq/metrics/ReportJob?period=8h
|
||||
https://openfoodnetwork.org.uk/admin/sidekiq/metrics/ReportJob?period=8h
|
||||
https://coopcircuits.fr/admin/sidekiq/metrics/ReportJob?period=8h
|
||||
|
||||
But let's leave the timed response to websockets for now and just poll
|
||||
as a backup mechanism.
|
||||
*/
|
||||
setTimeout(tryDownload, 3000);
|
||||
})();
|
||||
6
app/views/admin/reports/create.turbo_stream.haml
Normal file
6
app/views/admin/reports/create.turbo_stream.haml
Normal file
@@ -0,0 +1,6 @@
|
||||
= turbo_stream.update "report-go" do
|
||||
= button t(:go), "report__submit-btn", "submit", disabled: true
|
||||
= turbo_stream.update "report-table" do
|
||||
= render "admin/reports/loading"
|
||||
= render "admin/reports/fallback_display", file_url: @blob.expiring_service_url
|
||||
= turbo_stream.scroll_into_view("#report-table", behavior: "smooth")
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
- content_for :minimal_js, true
|
||||
|
||||
= form_for @report.search, { url: url_for, data: { remote: "true" } } do |f|
|
||||
= form_for @report.search, { url: url_for, data: { turbo: "true" } } do |f|
|
||||
= hidden_field_tag "uuid", request.uuid
|
||||
|
||||
%fieldset.no-border-bottom.print-hidden
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
%div{"data-controller": "tooltip"}
|
||||
%a{"data-tooltip-target": "element", href: link, class: link_class}
|
||||
= link_text
|
||||
.tooltip-container
|
||||
.tooltip{"data-tooltip-target": "tooltip"}
|
||||
= sanitize tooltip_text
|
||||
.arrow{"data-tooltip-target": "arrow"}
|
||||
@@ -1 +1 @@
|
||||
= render partial: 'admin/shared/tooltip', locals: {link_class: "" ,link: nil, link_text: t('admin.whats_this'), tooltip_text: tooltip_text}
|
||||
= render AdminTooltipComponent.new(text: tooltip_text, link_text: t('admin.whats_this'), link: nil)
|
||||
|
||||
16
app/views/backorder_mailer/backorder_failed.haml
Normal file
16
app/views/backorder_mailer/backorder_failed.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
%h1= t ".headline"
|
||||
|
||||
%p= t ".description"
|
||||
|
||||
%p= t ".hints"
|
||||
%p= t ".order", number: @order.number
|
||||
|
||||
%table
|
||||
%tr
|
||||
%th= t ".stock"
|
||||
%th= t ".product"
|
||||
|
||||
- @linked_variants.each do |variant|
|
||||
%tr
|
||||
%td= variant.on_hand
|
||||
%td= variant.product_and_full_name
|
||||
9
app/views/backorder_mailer/backorder_incomplete.haml
Normal file
9
app/views/backorder_mailer/backorder_incomplete.haml
Normal file
@@ -0,0 +1,9 @@
|
||||
%h1= t ".headline"
|
||||
|
||||
%p= t ".description"
|
||||
|
||||
%p= t ".hints"
|
||||
|
||||
%p= t ".affected", enterprise: @distributor.name, order_cycle: @order_cycle.name
|
||||
|
||||
%pre= @order_id
|
||||
@@ -1,10 +1,10 @@
|
||||
= form_with url: checkout_update_path(checkout_step), model: @order, method: :put, data: { remote: "true" } do |f|
|
||||
= form_with url: checkout_update_path(checkout_step), model: @order, method: :put, data: { remote: "true", 'guest-checkout-target': 'summary' } do |f|
|
||||
.summary-main
|
||||
= render partial: "checkout/already_ordered" if show_bought_items? && checkout_step?(:summary)
|
||||
.checkout-substep
|
||||
.checkout-title
|
||||
= t("checkout.step3.delivery_details.title")
|
||||
%a.summary-edit{href: main_app.checkout_step_path(:details)}
|
||||
%a.summary-edit{ href: main_app.checkout_step_path(:details), data: { action: "guest-checkout#removeUnloadEvent" } }
|
||||
= t("checkout.step3.delivery_details.edit")
|
||||
|
||||
.summary-subtitle
|
||||
@@ -51,7 +51,7 @@
|
||||
.checkout-substep
|
||||
.checkout-title
|
||||
= t("checkout.step3.payment_method.title")
|
||||
%a.summary-edit{href: main_app.checkout_step_path(:payment)}
|
||||
%a.summary-edit{ href: main_app.checkout_step_path(:payment), data: { action: "guest-checkout#removeUnloadEvent" } }
|
||||
= t("checkout.step3.payment_method.edit")
|
||||
.two-columns
|
||||
- payment_method = last_payment_method(@order)
|
||||
@@ -74,7 +74,7 @@
|
||||
%div.checkout-substep
|
||||
%div.checkout-title
|
||||
= t("checkout.step3.order.title")
|
||||
%a.summary-edit{href: main_app.cart_path}
|
||||
%a.summary-edit{ href: main_app.cart_path, data: { action: "guest-checkout#removeUnloadEvent" } }
|
||||
= t("checkout.step3.order.edit")
|
||||
|
||||
= render 'spree/orders/summary', order: @order, display_footer: false
|
||||
@@ -108,4 +108,4 @@
|
||||
.checkout-submit
|
||||
- if any_terms_required?(@order.distributor)
|
||||
= render partial: "terms_and_conditions", locals: { f: f }
|
||||
= f.submit t("checkout.step3.submit"), name: "confirm_order", class: "button primary", disabled: @terms_and_conditions_accepted == false || @platform_tos_accepted == false
|
||||
= f.submit t("checkout.step3.submit"), name: "confirm_order", class: "button primary", disabled: @terms_and_conditions_accepted == false || @platform_tos_accepted == false, data: { action: "click -> guest-checkout#removeUnloadEvent" }
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
|
||||
%title
|
||||
= Spree::Config[:site_name]
|
||||
= stylesheet_pack_tag 'mail'
|
||||
= stylesheet_link_tag 'mail'
|
||||
%body{:bgcolor => "#FFFFFF" }
|
||||
- unless @hide_ofn_navigation
|
||||
%table.head-wrap{:bgcolor => "#f2f2f2"}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
- # NOTE: make sure that any changes in this template are reflected in app/views/admin/products_v3/product_preview.turbo_stream.haml
|
||||
= cache_with_locale do
|
||||
%form{action: main_app.cart_path}
|
||||
%products{"ng-init" => "refreshStaleData()", "ng-show" => "order_cycle.order_cycle_id != null", "ng-cloak" => true }
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
- # NOTE: make sure that any changes in this template are reflected in app/views/admin/products_v3/product_preview.turbo_stream.haml
|
||||
= cache_with_locale do
|
||||
.small-4.medium-4.large-5.columns.variant-name
|
||||
.small-3.columns.variant-name
|
||||
.inline{"ng-if" => "::variant.display_name"} {{ ::variant.display_name }}
|
||||
.variant-unit {{ ::variant.unit_to_display }}
|
||||
.small-3.medium-3.large-2.columns.variant-price
|
||||
.small-4.medium-3.columns.variant-price
|
||||
%price-breakdown{"price-breakdown" => "_", variant: "variant",
|
||||
"price-breakdown-append-to-body" => "true",
|
||||
"price-breakdown-placement" => "bottom",
|
||||
@@ -16,7 +17,7 @@
|
||||
key: "'js.shopfront.unit_price_tooltip'"}
|
||||
{{ variant.unit_price_price | localizeCurrency }} / {{ variant.unit_price_unit }}
|
||||
|
||||
.medium-2.large-2.columns.total-price
|
||||
.medium-3.columns.total-price
|
||||
%span{"ng-class" => "{filled: variant.line_item.total_price}"}
|
||||
{{ variant.line_item.total_price | localizeCurrency }}
|
||||
= render partial: "shop/products/shop_variant_no_group_buy"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
- # NOTE: make sure that any changes in this template are reflected in app/views/admin/products_v3/product_preview.turbo_stream.haml
|
||||
= cache_with_locale do
|
||||
.small-5.medium-3.large-3.columns.variant-quantity-column.text-right{"ng-if" => "::!variant.product.group_buy"}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user