mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-12 18:36:49 +00:00
Compare commits
333 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c7337b53a | ||
|
|
60edb4363e | ||
|
|
93c0a06403 | ||
|
|
1bdb668cd3 | ||
|
|
d035d4bb87 | ||
|
|
f5eb72c804 | ||
|
|
2836751698 | ||
|
|
bf7a559a32 | ||
|
|
d90653c682 | ||
|
|
ca5300284c | ||
|
|
406cb572ea | ||
|
|
ca90b5cee2 | ||
|
|
760860a06d | ||
|
|
189207f751 | ||
|
|
1bd9182cea | ||
|
|
969d0b6687 | ||
|
|
8fe20ecfbe | ||
|
|
83141ec05c | ||
|
|
4b707b9310 | ||
|
|
1c277e5547 | ||
|
|
be48a6c295 | ||
|
|
11f45dc2f8 | ||
|
|
4303cabe56 | ||
|
|
f1f3ecc4f7 | ||
|
|
ad033e8d44 | ||
|
|
f25a3650bd | ||
|
|
e4d8dd9f87 | ||
|
|
b29d38f3fb | ||
|
|
1c52fe1648 | ||
|
|
a170b93cc1 | ||
|
|
2a943ecafb | ||
|
|
3a1579104f | ||
|
|
ec4c7b79bf | ||
|
|
9f12295a89 | ||
|
|
46fd6b1a3a | ||
|
|
8a5608435c | ||
|
|
d02d0b8847 | ||
|
|
4b6ef7796e | ||
|
|
b60a6fbd05 | ||
|
|
2e267091f6 | ||
|
|
eb3fe1b7a5 | ||
|
|
61f34a23a7 | ||
|
|
2d7356f2bb | ||
|
|
62c2d9a290 | ||
|
|
a329aab007 | ||
|
|
e24198fe85 | ||
|
|
b30e962cdd | ||
|
|
5f1f717974 | ||
|
|
b6f2fe0e92 | ||
|
|
a9bf7a2498 | ||
|
|
e11518938f | ||
|
|
c4dc5e0718 | ||
|
|
c67d61a376 | ||
|
|
0b4556e72b | ||
|
|
8c7f92d42e | ||
|
|
21a0017352 | ||
|
|
d115c4ce2c | ||
|
|
b05d46c3e3 | ||
|
|
aae0fc59fb | ||
|
|
d1f7cc1b2a | ||
|
|
964481f188 | ||
|
|
9bca22ae3b | ||
|
|
064c843c90 | ||
|
|
482d438ec9 | ||
|
|
9f0a66659a | ||
|
|
1176ea2a5f | ||
|
|
dfc651ed2c | ||
|
|
f42a9e3a66 | ||
|
|
8d9a8d8db5 | ||
|
|
84df1bfeab | ||
|
|
b9431cd121 | ||
|
|
74d18fb6ff | ||
|
|
5e26e49764 | ||
|
|
c9dada4215 | ||
|
|
630169f8bb | ||
|
|
152af5e105 | ||
|
|
918425fd93 | ||
|
|
a46eef291c | ||
|
|
d2fbb0bde2 | ||
|
|
c42dfdde10 | ||
|
|
959dcb82e1 | ||
|
|
51d5817665 | ||
|
|
a8384b3155 | ||
|
|
394bfd00d8 | ||
|
|
bda1a527d3 | ||
|
|
77bd832dd6 | ||
|
|
b1de28eeea | ||
|
|
679fcc0114 | ||
|
|
35778ecf1d | ||
|
|
70a6e9f44b | ||
|
|
30ba29382a | ||
|
|
9584205a8e | ||
|
|
3644dbc0fd | ||
|
|
05a7276c9c | ||
|
|
1fc60d498a | ||
|
|
dae8703b02 | ||
|
|
3078c599f9 | ||
|
|
5d91ac217d | ||
|
|
f2edb6d404 | ||
|
|
7cd1b5d5db | ||
|
|
ad82f66173 | ||
|
|
62bfa9e04c | ||
|
|
28c9d72342 | ||
|
|
7317d6ca34 | ||
|
|
edb8da4b4d | ||
|
|
00d5bd9165 | ||
|
|
1730c9eb60 | ||
|
|
5b9815f4a3 | ||
|
|
445eb45ad7 | ||
|
|
8770471ada | ||
|
|
6d45940ca4 | ||
|
|
69383ac621 | ||
|
|
945cb84127 | ||
|
|
343a2db1bf | ||
|
|
de8f5e13b3 | ||
|
|
75b5d1fd6f | ||
|
|
0c1606e50c | ||
|
|
fa05554f15 | ||
|
|
2cc509de15 | ||
|
|
41afad73e4 | ||
|
|
b17b25516f | ||
|
|
8444fca19a | ||
|
|
18d90114fe | ||
|
|
2f17a02974 | ||
|
|
135bc7e2f8 | ||
|
|
3810d79cad | ||
|
|
4960402643 | ||
|
|
3557c10cd6 | ||
|
|
45dd421f1f | ||
|
|
81606e841a | ||
|
|
e633670e01 | ||
|
|
11653c9430 | ||
|
|
d068094044 | ||
|
|
b892bf726e | ||
|
|
fa373518fb | ||
|
|
76357789a3 | ||
|
|
5dd7246b85 | ||
|
|
ba45dd84dd | ||
|
|
92e2a83e0e | ||
|
|
f42f513f8c | ||
|
|
54342254b6 | ||
|
|
470761da86 | ||
|
|
6fdf9fa038 | ||
|
|
bbec01a9cb | ||
|
|
e3001cc8c4 | ||
|
|
ad0d0e393e | ||
|
|
2690ff5eb5 | ||
|
|
2594382488 | ||
|
|
9b3cfe80ff | ||
|
|
04d33adaf2 | ||
|
|
915bd19d7b | ||
|
|
9998025687 | ||
|
|
89cb3b7c14 | ||
|
|
1955a6719c | ||
|
|
f71e5ee43c | ||
|
|
0ac2358f2c | ||
|
|
3e0b358370 | ||
|
|
f206b7ed9e | ||
|
|
946b69242c | ||
|
|
a409d3b97e | ||
|
|
a27b64a66b | ||
|
|
0f54d3950d | ||
|
|
7e306693a8 | ||
|
|
1f661c1e69 | ||
|
|
97f51d24b8 | ||
|
|
c3d274c84f | ||
|
|
213fb42a05 | ||
|
|
bde46fa1e9 | ||
|
|
dc560d3793 | ||
|
|
52f134fc9e | ||
|
|
c08e264afa | ||
|
|
0b03152f3b | ||
|
|
6f492d868c | ||
|
|
dab2a4af75 | ||
|
|
f7935bde34 | ||
|
|
61850f7e92 | ||
|
|
4e32bfd70b | ||
|
|
7df456c1e3 | ||
|
|
2fa86492d1 | ||
|
|
722c660697 | ||
|
|
ac666a6fce | ||
|
|
ba1d985932 | ||
|
|
0f28d318ac | ||
|
|
6172d1f2e5 | ||
|
|
05a040b4c3 | ||
|
|
73a81310f8 | ||
|
|
85860692ae | ||
|
|
8ad4d2cc2e | ||
|
|
c967eca9c4 | ||
|
|
7fff82eec3 | ||
|
|
c30ed0f7c8 | ||
|
|
cde420716b | ||
|
|
ee37c5d4a3 | ||
|
|
e9d236f761 | ||
|
|
8b78c28feb | ||
|
|
43e51cb592 | ||
|
|
6570891349 | ||
|
|
0f3e2ae572 | ||
|
|
f0110d20a2 | ||
|
|
353acfd6ae | ||
|
|
e43a018dc7 | ||
|
|
f6fac018ea | ||
|
|
ce1bd12760 | ||
|
|
364ccc2146 | ||
|
|
2a7cb50fa9 | ||
|
|
29ddc68d20 | ||
|
|
d40f3414ea | ||
|
|
f5e2edb028 | ||
|
|
7af26e6579 | ||
|
|
824d4adf21 | ||
|
|
00cc8da2fc | ||
|
|
ae5f2cc19d | ||
|
|
41ce4fbc16 | ||
|
|
48753df5f0 | ||
|
|
1f3e66316b | ||
|
|
6b1426d0c6 | ||
|
|
c68987c0f2 | ||
|
|
2cb25e6366 | ||
|
|
073f46e590 | ||
|
|
23beea8a13 | ||
|
|
096e388fdf | ||
|
|
3dfaf882a3 | ||
|
|
7b51f45b4d | ||
|
|
b9b2fa7c94 | ||
|
|
ee30d3d139 | ||
|
|
871b2f8816 | ||
|
|
214bdc6fbe | ||
|
|
d2fce053a7 | ||
|
|
11a7aa9f96 | ||
|
|
c0203e7091 | ||
|
|
44cc5cc665 | ||
|
|
6c8e383ab8 | ||
|
|
5c6d9a092e | ||
|
|
8d500a2c27 | ||
|
|
425674c4e5 | ||
|
|
e91e827f29 | ||
|
|
8f201c830a | ||
|
|
1b536d9265 | ||
|
|
1b8a9244a6 | ||
|
|
a40e883d17 | ||
|
|
6bf21d2abd | ||
|
|
29b9777a96 | ||
|
|
283dd84ad6 | ||
|
|
03828c5608 | ||
|
|
dad4061ff9 | ||
|
|
b19df0dfbf | ||
|
|
efb2ae6843 | ||
|
|
407fca17cb | ||
|
|
33409725a5 | ||
|
|
c70a694111 | ||
|
|
9c88c77066 | ||
|
|
42585bb074 | ||
|
|
697f2795d4 | ||
|
|
b0211d0930 | ||
|
|
0675422509 | ||
|
|
5ff1b0d358 | ||
|
|
43cbac7d17 | ||
|
|
98e4f867b4 | ||
|
|
ebb15781d5 | ||
|
|
028c4f4281 | ||
|
|
ef7dfa3b4f | ||
|
|
71f9415d21 | ||
|
|
12848acf21 | ||
|
|
4f751c2711 | ||
|
|
920e2564a4 | ||
|
|
6b4e150e2a | ||
|
|
2d43e32688 | ||
|
|
a6cd393c57 | ||
|
|
b1060bf1c9 | ||
|
|
1bf5fbaf3a | ||
|
|
2ace3afd67 | ||
|
|
0bfceb877d | ||
|
|
c1d28b2e8f | ||
|
|
2841b42296 | ||
|
|
98e44e7a40 | ||
|
|
51c6c19f80 | ||
|
|
26947a64c0 | ||
|
|
df5c21048a | ||
|
|
8a124fb6be | ||
|
|
7d51979c06 | ||
|
|
ced49e0217 | ||
|
|
75b7a1864b | ||
|
|
281d0eb417 | ||
|
|
496f5199c9 | ||
|
|
f13c0e1dca | ||
|
|
f801d4a4cb | ||
|
|
d94da8df1e | ||
|
|
8c6e0a841c | ||
|
|
70d9cfa08e | ||
|
|
193ae7936e | ||
|
|
0971e8d9b5 | ||
|
|
e78b44b9ca | ||
|
|
c5779eff81 | ||
|
|
b616c14f63 | ||
|
|
03cb14c926 | ||
|
|
da78e06a39 | ||
|
|
f4c351febf | ||
|
|
30184ac6aa | ||
|
|
a123d45eca | ||
|
|
a75f16e23c | ||
|
|
546e90b286 | ||
|
|
bf9f47a000 | ||
|
|
3da6e6b5ed | ||
|
|
111705f6f2 | ||
|
|
68d5327b12 | ||
|
|
688285c374 | ||
|
|
9d0a69cceb | ||
|
|
15058299d8 | ||
|
|
4e92f33b1c | ||
|
|
c7cb982c9a | ||
|
|
34e9112c0a | ||
|
|
28eb11bda5 | ||
|
|
d8e82d9c88 | ||
|
|
061fc321b4 | ||
|
|
5201e54f82 | ||
|
|
5192a08082 | ||
|
|
94d3f136e2 | ||
|
|
db3a923ea7 | ||
|
|
619eb43c57 | ||
|
|
5c221621d3 | ||
|
|
60d7ed5036 | ||
|
|
e74328f1d7 | ||
|
|
6abd652251 | ||
|
|
3821eede51 | ||
|
|
020af0c0e4 | ||
|
|
00a3976905 | ||
|
|
3bd8e430f9 | ||
|
|
77733169fc | ||
|
|
54d5d0ed80 | ||
|
|
ac5cbcf19e | ||
|
|
e10ea4b686 | ||
|
|
913f8bbad0 | ||
|
|
fc951e92ac |
@@ -5,9 +5,17 @@
|
||||
#
|
||||
# cp .env.development .env.local
|
||||
|
||||
VERBOSE_QUERY_LOGS=true
|
||||
|
||||
SECRET_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
|
||||
OFN_REDIS_URL="redis://localhost:6379/1"
|
||||
OFN_REDIS_JOBS_URL="redis://localhost:6379/2"
|
||||
|
||||
SITE_URL="0.0.0.0:3000"
|
||||
|
||||
# Deactivate rack-timeout in development.
|
||||
# https://github.com/zombocom/rack-timeout#configuring
|
||||
RACK_TIMEOUT_SERVICE_TIMEOUT="0"
|
||||
RACK_TIMEOUT_WAIT_TIMEOUT="0"
|
||||
RACK_TIMEOUT_WAIT_OVERTIME="0"
|
||||
|
||||
1
.github/workflows/brakeman-analysis.yml
vendored
1
.github/workflows/brakeman-analysis.yml
vendored
@@ -41,6 +41,7 @@ jobs:
|
||||
- name: Scan
|
||||
continue-on-error: true
|
||||
run: |
|
||||
git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
|
||||
brakeman -f sarif -o output.sarif.json .
|
||||
|
||||
# Upload the SARIF file generated in the previous step
|
||||
|
||||
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@@ -18,7 +18,7 @@ permissions:
|
||||
|
||||
jobs:
|
||||
knapsack_rspec_controllers:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10
|
||||
@@ -68,7 +68,6 @@ jobs:
|
||||
bundle exec rake db:schema:load
|
||||
|
||||
- name: Run tests
|
||||
|
||||
env:
|
||||
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: 864ef557d85ea8e603e086c0387d5154
|
||||
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
|
||||
@@ -82,12 +81,12 @@ jobs:
|
||||
# https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it
|
||||
#KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true
|
||||
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/controllers/**/*_spec.rb}"
|
||||
|
||||
run: |
|
||||
git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
|
||||
bundle exec rake knapsack_pro:rspec
|
||||
|
||||
knapsack_rspec_models:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10
|
||||
@@ -156,7 +155,7 @@ jobs:
|
||||
bundle exec rake knapsack_pro:rspec
|
||||
|
||||
knapsack_rspec_system_admin:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10
|
||||
@@ -234,7 +233,7 @@ jobs:
|
||||
if-no-files-found: ignore
|
||||
|
||||
knapsack_rspec_system_consumer:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10
|
||||
@@ -312,7 +311,7 @@ jobs:
|
||||
if-no-files-found: ignore
|
||||
|
||||
knapsack_rspec_engines:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10
|
||||
@@ -390,7 +389,7 @@ jobs:
|
||||
if-no-files-found: ignore
|
||||
|
||||
knapsack_rspec_test_the_rest:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10
|
||||
@@ -460,7 +459,7 @@ jobs:
|
||||
bundle exec rake knapsack_pro:rspec
|
||||
|
||||
non_knapsack_jest_karma:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10
|
||||
|
||||
6
.github/workflows/linters.yml
vendored
6
.github/workflows/linters.yml
vendored
@@ -9,7 +9,11 @@ jobs:
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- uses: ruby/setup-ruby@v1
|
||||
|
||||
- run: git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
|
||||
|
||||
- name: rubocop
|
||||
uses: reviewdog/action-rubocop@v2
|
||||
with:
|
||||
@@ -32,6 +36,8 @@ jobs:
|
||||
- name: Install JS dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- run: git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
|
||||
|
||||
- name: prettier
|
||||
uses: EPMatt/reviewdog-action-prettier@v1
|
||||
with:
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# Basically, ignore everythings expect app/webpacker/controllers/*.js and app/webpacker/packs/*.js
|
||||
*.css
|
||||
*.scss
|
||||
# Except v2
|
||||
!/app/webpacker/css/admin/v2/**/*.scss
|
||||
|
||||
*.md
|
||||
*.yml
|
||||
*.yaml
|
||||
@@ -12,6 +9,10 @@
|
||||
babel.config.js
|
||||
postcss.config.js
|
||||
|
||||
/app/webpacker/css/darkswarm/
|
||||
/app/webpacker/css/mail/
|
||||
/app/webpacker/css/shared/
|
||||
|
||||
/app/assets/
|
||||
/config/
|
||||
/coverage/
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
{}
|
||||
{
|
||||
"printWidth": 100
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
#
|
||||
# These are the rules we agreed upon and we work towards.
|
||||
AllCops:
|
||||
NewCops: disable
|
||||
NewCops: enable
|
||||
SuggestExtensions: false
|
||||
TargetRailsVersion: 5.0
|
||||
Exclude:
|
||||
- 'bin/**/*'
|
||||
- 'db/**/*'
|
||||
@@ -41,6 +40,7 @@ Metrics/BlockLength:
|
||||
"resources",
|
||||
"scenario",
|
||||
"shared_examples",
|
||||
"shared_examples_for",
|
||||
"xdescribe",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400`
|
||||
# on 2023-04-01 00:21:28 UTC using RuboCop version 1.47.0.
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`
|
||||
# using RuboCop version 1.50.2.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
|
||||
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
||||
Bundler/OrderedGems:
|
||||
Exclude:
|
||||
- 'Gemfile'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: Severity, Include.
|
||||
# Include: **/*.gemspec
|
||||
@@ -63,11 +55,10 @@ Layout/BlockAlignment:
|
||||
Exclude:
|
||||
- 'spec/services/products_renderer_spec.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Offense count: 4
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Layout/BlockEndNewline:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/subscriptions_controller.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
|
||||
- 'spec/system/admin/orders_spec.rb'
|
||||
|
||||
@@ -93,21 +84,13 @@ Layout/EmptyLinesAroundBlockBody:
|
||||
- 'spec/requests/checkout/concurrency_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/list_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
||||
Layout/ExtraSpacing:
|
||||
Exclude:
|
||||
- 'spec/spec_helper.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
||||
Layout/FirstArgumentIndentation:
|
||||
Exclude:
|
||||
- 'spec/system/admin/orders_spec.rb'
|
||||
- 'spec/system/admin/products_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
@@ -117,7 +100,7 @@ Layout/FirstHashElementIndentation:
|
||||
Exclude:
|
||||
- 'spec/services/products_renderer_spec.rb'
|
||||
|
||||
# Offense count: 13
|
||||
# Offense count: 11
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
||||
# SupportedHashRocketStyles: key, separator, table
|
||||
@@ -125,31 +108,25 @@ Layout/FirstHashElementIndentation:
|
||||
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
||||
Layout/HashAlignment:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/subscriptions_controller.rb'
|
||||
- 'app/controllers/spree/users_controller.rb'
|
||||
- 'app/models/spree/image.rb'
|
||||
- 'spec/migrations/migrate_customer_names_spec.rb'
|
||||
- 'spec/models/enterprise_spec.rb'
|
||||
- 'spec/support/request/stripe_stubs.rb'
|
||||
- 'spec/system/admin/customers_spec.rb'
|
||||
- 'spec/system/admin/order_spec.rb'
|
||||
- 'spec/system/admin/orders_spec.rb'
|
||||
- 'spec/system/admin/tag_rules_spec.rb'
|
||||
- 'spec/system/consumer/shopping/cart_spec.rb'
|
||||
|
||||
# Offense count: 18
|
||||
# Offense count: 4
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: normal, indented_internal_methods
|
||||
Layout/IndentationConsistency:
|
||||
Exclude:
|
||||
- 'spec/system/admin/order_cycles/complex_editing_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/simple_spec.rb'
|
||||
- 'spec/system/admin/order_spec.rb'
|
||||
- 'spec/system/admin/orders_spec.rb'
|
||||
- 'spec/system/admin/product_import_spec.rb'
|
||||
- 'spec/system/consumer/split_checkout_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
@@ -165,7 +142,64 @@ Layout/LeadingCommentSpace:
|
||||
Exclude:
|
||||
- 'spec/system/admin/enterprises_spec.rb'
|
||||
|
||||
# Offense count: 603
|
||||
# Offense count: 114
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: space, no_space
|
||||
Layout/LineContinuationSpacing:
|
||||
Exclude:
|
||||
- 'app/helpers/checkout_helper.rb'
|
||||
- 'engines/order_management/spec/services/order_management/order/updater_spec.rb'
|
||||
- 'engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb'
|
||||
- 'engines/web/app/helpers/web/cookies_policy_helper.rb'
|
||||
- 'spec/system/admin/bulk_order_management_spec.rb'
|
||||
- 'spec/system/admin/configuration/content_spec.rb'
|
||||
- 'spec/system/admin/customers_spec.rb'
|
||||
- 'spec/system/admin/enterprise_fees_spec.rb'
|
||||
- 'spec/system/admin/enterprises/index_spec.rb'
|
||||
- 'spec/system/admin/enterprises_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/list_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/simple_spec.rb'
|
||||
- 'spec/system/admin/order_spec.rb'
|
||||
- 'spec/system/admin/orders_spec.rb'
|
||||
- 'spec/system/admin/overview_spec.rb'
|
||||
- 'spec/system/admin/payment_method_spec.rb'
|
||||
- 'spec/system/admin/product_import_spec.rb'
|
||||
- 'spec/system/admin/subscriptions_spec.rb'
|
||||
- 'spec/system/admin/tag_rules_spec.rb'
|
||||
- 'spec/system/admin/users_spec.rb'
|
||||
- 'spec/system/admin/variant_overrides_spec.rb'
|
||||
- 'spec/system/consumer/authentication_spec.rb'
|
||||
- 'spec/system/consumer/caching/shops_caching_spec.rb'
|
||||
- 'spec/system/consumer/cookies_spec.rb'
|
||||
- 'spec/system/consumer/shopping/cart_spec.rb'
|
||||
- 'spec/system/consumer/shopping/checkout_auth_spec.rb'
|
||||
- 'spec/system/consumer/shopping/checkout_spec.rb'
|
||||
- 'spec/system/consumer/shopping/products_spec.rb'
|
||||
- 'spec/system/consumer/shopping/shopping_spec.rb'
|
||||
- 'spec/system/consumer/shopping/unit_price_spec.rb'
|
||||
- 'spec/system/consumer/split_checkout_spec.rb'
|
||||
|
||||
# Offense count: 18
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: aligned, indented
|
||||
Layout/LineEndStringConcatenationIndentation:
|
||||
Exclude:
|
||||
- 'app/mailers/spree/user_mailer.rb'
|
||||
- 'engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb'
|
||||
- 'engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb'
|
||||
- 'spec/system/admin/configuration/content_spec.rb'
|
||||
- 'spec/system/admin/customers_spec.rb'
|
||||
- 'spec/system/admin/overview_spec.rb'
|
||||
- 'spec/system/admin/payment_method_spec.rb'
|
||||
- 'spec/system/admin/subscriptions_spec.rb'
|
||||
- 'spec/system/admin/tag_rules_spec.rb'
|
||||
- 'spec/system/consumer/caching/shops_caching_spec.rb'
|
||||
- 'spec/system/consumer/cookies_spec.rb'
|
||||
- 'spec/system/consumer/shopping/cart_spec.rb'
|
||||
|
||||
# Offense count: 615
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
||||
# URISchemes: http, https
|
||||
@@ -378,7 +412,7 @@ Layout/TrailingEmptyLines:
|
||||
Exclude:
|
||||
- 'Rakefile'
|
||||
|
||||
# Offense count: 69
|
||||
# Offense count: 70
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowInHeredoc.
|
||||
Layout/TrailingWhitespace:
|
||||
@@ -406,6 +440,16 @@ Layout/TrailingWhitespace:
|
||||
- 'spec/system/admin/shipping_methods_spec.rb'
|
||||
- 'spec/system/consumer/split_checkout_spec.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Lint/AmbiguousOperatorPrecedence:
|
||||
Exclude:
|
||||
- 'app/models/calculator/flexi_rate.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/spree/ability.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/preferences/store.rb'
|
||||
|
||||
# Offense count: 17
|
||||
# Configuration parameters: AllowedMethods.
|
||||
# AllowedMethods: enums
|
||||
@@ -424,6 +468,16 @@ Lint/ConstantDefinitionInBlock:
|
||||
- 'spec/validators/date_time_string_validator_spec.rb'
|
||||
- 'spec/validators/integer_array_validator_spec.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
|
||||
Lint/DuplicateBranch:
|
||||
Exclude:
|
||||
- 'app/helpers/spree/admin/base_helper.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/spree/calculator.rb'
|
||||
- 'app/models/spree/preference.rb'
|
||||
- 'app/models/spree/preferences/preferable.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Lint/DuplicateMethods:
|
||||
Exclude:
|
||||
@@ -435,6 +489,30 @@ Lint/DuplicateRequire:
|
||||
Exclude:
|
||||
- 'spec/lib/open_food_network/scope_variants_to_search_spec.rb'
|
||||
|
||||
# Offense count: 20
|
||||
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
||||
Lint/EmptyBlock:
|
||||
Exclude:
|
||||
- 'engines/catalog/config/routes.rb'
|
||||
- 'spec/components/distributor_title_component_spec.rb'
|
||||
- 'spec/components/example_component_spec.rb'
|
||||
- 'spec/controllers/admin/subscription_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/shipments_controller_spec.rb'
|
||||
- 'spec/controllers/concerns/extra_fields_spec.rb'
|
||||
- 'spec/factories.rb'
|
||||
- 'spec/factories/enterprise_factory.rb'
|
||||
- 'spec/jobs/order_cycle_opened_job_spec.rb'
|
||||
- 'spec/jobs/subscription_placement_job_spec.rb'
|
||||
- 'spec/models/product_import/entry_validator_spec.rb'
|
||||
- 'spec/requests/checkout/concurrency_spec.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Configuration parameters: AllowComments.
|
||||
Lint/EmptyClass:
|
||||
Exclude:
|
||||
- 'spec/controllers/spree/admin/base_controller_spec.rb'
|
||||
- 'spec/lib/reports/report_loader_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: AllowComments.
|
||||
Lint/EmptyFile:
|
||||
@@ -452,6 +530,26 @@ Lint/IneffectiveAccessModifier:
|
||||
Exclude:
|
||||
- 'app/models/spree/user.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Lint/NoReturnInBeginEndBlocks:
|
||||
Exclude:
|
||||
- 'app/controllers/payment_gateways/stripe_controller.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Lint/NonAtomicFileOperation:
|
||||
Exclude:
|
||||
- 'app/services/bulk_invoice_service.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Lint/RedundantDirGlobSort:
|
||||
Exclude:
|
||||
- 'engines/catalog/spec/spec_helper.rb'
|
||||
- 'engines/dfc_provider/spec/spec_helper.rb'
|
||||
- 'spec/base_spec_helper.rb'
|
||||
- 'spec/system_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowedMethods.
|
||||
@@ -482,14 +580,12 @@ Lint/UselessMethodDefinition:
|
||||
Exclude:
|
||||
- 'app/models/spree/gateway.rb'
|
||||
|
||||
# Offense count: 13
|
||||
# Offense count: 3
|
||||
# Configuration parameters: CheckForMethodsWithNoSideEffects.
|
||||
Lint/Void:
|
||||
Exclude:
|
||||
- 'spec/system/admin/order_cycles/complex_editing_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/simple_spec.rb'
|
||||
- 'spec/system/admin/order_spec.rb'
|
||||
|
||||
# Offense count: 27
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
||||
@@ -746,12 +842,6 @@ Naming/AccessorMethodName:
|
||||
- 'spec/support/request/shop_workflow.rb'
|
||||
- 'spec/support/request/web_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: AsciiConstants.
|
||||
Naming/AsciiIdentifiers:
|
||||
Exclude:
|
||||
- 'spec/system/admin/products_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: ForbiddenDelimiters.
|
||||
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
||||
@@ -791,6 +881,40 @@ Naming/VariableNumber:
|
||||
- 'spec/models/spree/tax_rate_spec.rb'
|
||||
- 'spec/requests/api/orders_spec.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: ExpectedOrder, Include.
|
||||
# ExpectedOrder: index, show, new, edit, create, update, destroy
|
||||
# Include: app/controllers/**/*.rb
|
||||
Rails/ActionOrder:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/resource_controller.rb'
|
||||
- 'app/controllers/api/v0/orders_controller.rb'
|
||||
- 'app/controllers/spree/admin/images_controller.rb'
|
||||
- 'app/controllers/spree/admin/invoices_controller.rb'
|
||||
- 'app/controllers/spree/admin/products_controller.rb'
|
||||
- 'app/controllers/spree/admin/taxons_controller.rb'
|
||||
- 'app/controllers/spree/admin/variants_controller.rb'
|
||||
- 'app/controllers/user_confirmations_controller.rb'
|
||||
|
||||
# Offense count: 15
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/ActiveRecordCallbacksOrder:
|
||||
Exclude:
|
||||
- 'app/models/customer.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_group.rb'
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/order.rb'
|
||||
- 'app/models/spree/payment.rb'
|
||||
- 'app/models/spree/product.rb'
|
||||
- 'app/models/spree/return_authorization.rb'
|
||||
- 'app/models/spree/user.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: Severity, Include.
|
||||
# Include: app/models/**/*.rb
|
||||
@@ -810,12 +934,6 @@ Rails/ApplicationJob:
|
||||
Exclude:
|
||||
- 'app/jobs/report_job.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/ApplicationMailer:
|
||||
Exclude:
|
||||
- 'app/mailers/spree/base_mailer.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
|
||||
@@ -826,6 +944,45 @@ Rails/Blank:
|
||||
- 'engines/order_management/app/services/order_management/stock/package.rb'
|
||||
- 'lib/stripe/authorize_response_patcher.rb'
|
||||
|
||||
# Offense count: 17
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/CompactBlank:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/users_controller.rb'
|
||||
- 'app/models/concerns/address_display.rb'
|
||||
- 'app/models/spree/zone.rb'
|
||||
- 'app/services/order_cycle_form.rb'
|
||||
- 'lib/reporting/report_headers_builder.rb'
|
||||
- 'lib/reporting/report_ruler.rb'
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/parameters.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/DotSeparatedKeys:
|
||||
Exclude:
|
||||
- 'app/controllers/api/v1/base_controller.rb'
|
||||
|
||||
# Offense count: 27
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/DurationArithmetic:
|
||||
Exclude:
|
||||
- 'app/services/create_order_cycle.rb'
|
||||
- 'spec/jobs/order_cycle_closing_job_spec.rb'
|
||||
- 'spec/jobs/order_cycle_opened_job_spec.rb'
|
||||
- 'spec/services/permissions/order_spec.rb'
|
||||
- 'spec/services/terms_of_service_spec.rb'
|
||||
- 'spec/system/admin/bulk_order_management_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/list_spec.rb'
|
||||
- 'spec/system/admin/orders_spec.rb'
|
||||
- 'spec/system/admin/reports/orders_and_fulfillment_spec.rb'
|
||||
- 'spec/system/admin/reports/packing_report_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/ExpandedDateRange:
|
||||
Exclude:
|
||||
- 'app/models/spree/product.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: slashes, arguments
|
||||
@@ -894,17 +1051,38 @@ Rails/HelperInstanceVariable:
|
||||
- 'app/helpers/spree/admin/orders_helper.rb'
|
||||
- 'app/helpers/spree/orders_helper.rb'
|
||||
|
||||
# Offense count: 37
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/controllers/**/*.rb
|
||||
Rails/I18nLazyLookup:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/proxy_orders_controller.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Configuration parameters: Include.
|
||||
# Include: spec/**/*.rb, test/**/*.rb
|
||||
Rails/I18nLocaleAssignment:
|
||||
Exclude:
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
- 'spec/helpers/i18n_helper_spec.rb'
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/list_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Rails/I18nLocaleTexts:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/stripe_accounts_controller.rb'
|
||||
|
||||
# Offense count: 27
|
||||
# Configuration parameters: IgnoreScopes, Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/InverseOf:
|
||||
Exclude:
|
||||
- 'app/models/concerns/calculated_adjustments.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/spree/adjustment.rb'
|
||||
- 'app/models/spree/country.rb'
|
||||
- 'app/models/spree/credit_card.rb'
|
||||
- 'app/models/spree/inventory_unit.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/option_type.rb'
|
||||
@@ -912,9 +1090,7 @@ Rails/InverseOf:
|
||||
- 'app/models/spree/payment.rb'
|
||||
- 'app/models/spree/price.rb'
|
||||
- 'app/models/spree/product.rb'
|
||||
- 'app/models/spree/shipment.rb'
|
||||
- 'app/models/spree/stock_item.rb'
|
||||
- 'app/models/spree/tax_rate.rb'
|
||||
- 'app/models/spree/taxonomy.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
- 'app/models/subscription_line_item.rb'
|
||||
@@ -944,6 +1120,19 @@ Rails/LexicallyScopedActionFilter:
|
||||
- 'app/controllers/spree/admin/zones_controller.rb'
|
||||
- 'app/controllers/spree/users_controller.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/NegateInclude:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/resource_controller.rb'
|
||||
- 'app/models/calculator/weight.rb'
|
||||
- 'app/models/product_import/spreadsheet_entry.rb'
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
- 'app/services/order_cart_reset.rb'
|
||||
- 'engines/order_management/app/services/order_management/stock/estimator.rb'
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'spec/support/matchers/table_matchers.rb'
|
||||
|
||||
# Offense count: 18
|
||||
Rails/OutputSafety:
|
||||
Exclude:
|
||||
@@ -959,12 +1148,112 @@ Rails/OutputSafety:
|
||||
- 'lib/reporting/queries/query_interface.rb'
|
||||
- 'lib/spree/money.rb'
|
||||
|
||||
# Offense count: 29
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/Pluck:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/variant_overrides_controller.rb'
|
||||
- 'app/helpers/shop_helper.rb'
|
||||
- 'app/services/cart_service.rb'
|
||||
- 'app/services/sets/product_set.rb'
|
||||
- 'lib/reporting/report_headers_builder.rb'
|
||||
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/orders_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/products_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/shops_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/states_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/taxons_controller_spec.rb'
|
||||
- 'spec/helpers/spree/admin/orders_helper_spec.rb'
|
||||
- 'spec/lib/reports/lettuce_share_report_spec.rb'
|
||||
- 'spec/lib/reports/users_and_enterprises_report_spec.rb'
|
||||
- 'spec/serializers/api/admin/for_order_cycle/supplied_product_serializer_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: conservative, aggressive
|
||||
Rails/PluckInWhere:
|
||||
Exclude:
|
||||
- 'app/models/spree/variant.rb'
|
||||
|
||||
# Offense count: 28
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/RedundantPresenceValidationOnBelongsTo:
|
||||
Exclude:
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_fee.rb'
|
||||
- 'app/models/enterprise_group.rb'
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/enterprise_role.rb'
|
||||
- 'app/models/exchange.rb'
|
||||
- 'app/models/inventory_item.rb'
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/spree/address.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/order.rb'
|
||||
- 'app/models/spree/product.rb'
|
||||
- 'app/models/spree/product_property.rb'
|
||||
- 'app/models/spree/return_authorization.rb'
|
||||
- 'app/models/spree/state.rb'
|
||||
- 'app/models/spree/stock_item.rb'
|
||||
- 'app/models/spree/stock_movement.rb'
|
||||
- 'app/models/spree/tax_rate.rb'
|
||||
- 'app/models/subscription_line_item.rb'
|
||||
- 'app/models/tag_rule.rb'
|
||||
- 'app/models/variant_override.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/RelativeDateConstant:
|
||||
Exclude:
|
||||
- 'lib/tasks/data/remove_transient_data.rb'
|
||||
|
||||
# Offense count: 58
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Include.
|
||||
# Include: spec/controllers/**/*.rb, spec/requests/**/*.rb, test/controllers/**/*.rb, test/integration/**/*.rb
|
||||
Rails/ResponseParsedBody:
|
||||
Exclude:
|
||||
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/customers_controller_spec.rb'
|
||||
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/admin/proxy_orders_controller_spec.rb'
|
||||
- 'spec/controllers/admin/schedules_controller_spec.rb'
|
||||
- 'spec/controllers/admin/stripe_accounts_controller_spec.rb'
|
||||
- 'spec/controllers/admin/subscription_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
|
||||
- 'spec/controllers/cart_controller_spec.rb'
|
||||
- 'spec/controllers/line_items_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/search_controller_spec.rb'
|
||||
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/RootPathnameMethods:
|
||||
Exclude:
|
||||
- 'spec/lib/reports/orders_and_fulfillment/order_cycle_customer_totals_report_spec.rb'
|
||||
- 'spec/models/content_configuration_spec.rb'
|
||||
- 'spec/models/terms_of_service_file_spec.rb'
|
||||
- 'spec/system/admin/configuration/terms_of_service_files_spec.rb'
|
||||
|
||||
# Offense count: 13
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/RootPublicPath:
|
||||
Exclude:
|
||||
- 'app/controllers/concerns/request_timeouts.rb'
|
||||
- 'lib/spree/core/controller_helpers/common.rb'
|
||||
- 'spec/controllers/api/v0/product_images_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/terms_and_conditions_controller_spec.rb'
|
||||
- 'spec/models/terms_of_service_file_spec.rb'
|
||||
- 'spec/system/admin/bulk_product_update_spec.rb'
|
||||
- 'spec/system/admin/enterprises/terms_and_conditions_spec.rb'
|
||||
- 'spec/system/consumer/shopping/checkout_spec.rb'
|
||||
- 'spec/system/consumer/shopping/embedded_groups_spec.rb'
|
||||
- 'spec/system/consumer/split_checkout_spec.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: ForbiddenMethods, AllowedMethods.
|
||||
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
|
||||
@@ -973,6 +1262,24 @@ Rails/SkipsModelValidations:
|
||||
- 'app/models/variant_override.rb'
|
||||
- 'spec/models/spree/line_item_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/SquishedSQLHeredocs:
|
||||
Exclude:
|
||||
- 'app/queries/customers_with_balance.rb'
|
||||
- 'app/queries/outstanding_balance.rb'
|
||||
- 'spec/queries/outstanding_balance_spec.rb'
|
||||
|
||||
# Offense count: 24
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/StripHeredoc:
|
||||
Exclude:
|
||||
- 'app/models/content_configuration.rb'
|
||||
- 'app/queries/customers_with_balance.rb'
|
||||
- 'app/queries/outstanding_balance.rb'
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
|
||||
- 'lib/tasks/data/truncate_data.rake'
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
@@ -984,6 +1291,11 @@ Rails/TimeZone:
|
||||
- 'spec/models/spree/tax_rate_spec.rb'
|
||||
- 'spec/services/customer_order_cancellation_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Rails/TransactionExitStatement:
|
||||
Exclude:
|
||||
- 'app/services/place_proxy_order.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/models/**/*.rb
|
||||
@@ -1002,6 +1314,77 @@ Rails/UnknownEnv:
|
||||
Exclude:
|
||||
- 'app/models/spree/app_configuration.rb'
|
||||
|
||||
# Offense count: 55
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/WhereEquals:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/products_controller.rb'
|
||||
- 'app/mailers/producer_mailer.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_fee.rb'
|
||||
- 'app/models/enterprise_group.rb'
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/exchange.rb'
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/product_import/entry_processor.rb'
|
||||
- 'app/models/proxy_order.rb'
|
||||
- 'app/models/schedule.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/order.rb'
|
||||
- 'app/models/spree/payment_method.rb'
|
||||
- 'app/models/spree/product.rb'
|
||||
- 'app/models/spree/shipping_method.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
- 'app/models/subscription.rb'
|
||||
- 'app/queries/payments_requiring_action.rb'
|
||||
- 'app/serializers/api/enterprise_shopfront_serializer.rb'
|
||||
- 'app/serializers/api/order_serializer.rb'
|
||||
- 'lib/open_food_network/enterprise_fee_calculator.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/reporting/reports/customers/base.rb'
|
||||
- 'lib/reporting/reports/products_and_inventory/base.rb'
|
||||
- 'lib/tasks/data.rake'
|
||||
- 'lib/tasks/data/anonymize_data.rake'
|
||||
- 'lib/tasks/data/remove_transient_data.rb'
|
||||
- 'spec/services/product_tag_rules_filterer_spec.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: exists, where
|
||||
Rails/WhereExists:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/overview_controller.rb'
|
||||
- 'app/controllers/spree/admin/tax_rates_controller.rb'
|
||||
- 'app/controllers/spree/user_sessions_controller.rb'
|
||||
- 'app/models/spree/preferences/store.rb'
|
||||
- 'lib/tasks/sample_data/customer_factory.rb'
|
||||
- 'lib/tasks/sample_data/group_factory.rb'
|
||||
- 'lib/tasks/sample_data/order_cycle_factory.rb'
|
||||
- 'lib/tasks/sample_data/taxon_factory.rb'
|
||||
|
||||
# Offense count: 24
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/WhereNot:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/products_controller.rb'
|
||||
- 'app/models/concerns/permalink_generator.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_fee.rb'
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/product_import/inventory_reset_strategy.rb'
|
||||
- 'app/models/proxy_order.rb'
|
||||
- 'app/models/spree/credit_card.rb'
|
||||
- 'app/models/spree/product.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
- 'app/models/spree/zone.rb'
|
||||
- 'app/models/variant_override.rb'
|
||||
- 'app/services/cap_quantity.rb'
|
||||
- 'engines/catalog/app/services/catalog/product_import/products_reset_strategy.rb'
|
||||
- 'engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb'
|
||||
- 'lib/reporting/reports/users_and_enterprises/base.rb'
|
||||
- 'lib/tasks/data/anonymize_data.rake'
|
||||
|
||||
# Offense count: 1
|
||||
Security/Open:
|
||||
Exclude:
|
||||
@@ -1020,14 +1403,6 @@ Style/CaseEquality:
|
||||
Exclude:
|
||||
- 'spec/models/spree/payment_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Style/CaseLikeIf:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/order_cycles_controller.rb'
|
||||
- 'app/models/calculator/weight.rb'
|
||||
- 'app/models/spree/payment/processing.rb'
|
||||
|
||||
# Offense count: 25
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
@@ -1063,6 +1438,27 @@ Style/ClassVars:
|
||||
Exclude:
|
||||
- 'lib/spree/core/delegate_belongs_to.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowedVars.
|
||||
Style/FetchEnvVar:
|
||||
Exclude:
|
||||
- 'app/helpers/discourse_helper.rb'
|
||||
- 'app/models/spree/preferences/configuration.rb'
|
||||
- 'app/models/spree/preferences/preferable.rb'
|
||||
- 'app/services/default_country.rb'
|
||||
- 'spec/base_spec_helper.rb'
|
||||
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
|
||||
- 'spec/models/order_balance_spec.rb'
|
||||
- 'spec/support/vcr_setup.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/FileRead:
|
||||
Exclude:
|
||||
- 'lib/tasks/karma.rake'
|
||||
- 'spec/services/upload_sanitizer_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
|
||||
@@ -1117,27 +1513,36 @@ Style/GuardClause:
|
||||
- 'spec/support/request/shop_workflow.rb'
|
||||
- 'spec/system/support/precompile_assets.rb'
|
||||
|
||||
# Offense count: 12
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowSplatArgument.
|
||||
Style/HashConversion:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/column_preferences_controller.rb'
|
||||
- 'app/controllers/admin/variant_overrides_controller.rb'
|
||||
- 'app/controllers/spree/admin/products_controller.rb'
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/product_import/product_importer.rb'
|
||||
- 'app/models/spree/shipping_method.rb'
|
||||
- 'app/serializers/api/admin/exchange_serializer.rb'
|
||||
- 'app/services/variants_stock_levels.rb'
|
||||
- 'spec/controllers/admin/inventory_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/variant_overrides_controller_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: MinBranchesCount.
|
||||
Style/HashLikeCase:
|
||||
Exclude:
|
||||
- 'app/models/enterprise.rb'
|
||||
|
||||
# Offense count: 11
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: InverseMethods, InverseBlocks.
|
||||
Style/InverseMethods:
|
||||
Style/MapToHash:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/resource_controller.rb'
|
||||
- 'app/models/calculator/weight.rb'
|
||||
- 'app/models/product_import/spreadsheet_entry.rb'
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
- 'app/models/spree/order_contents.rb'
|
||||
- 'app/models/spree/payment.rb'
|
||||
- 'app/services/order_cart_reset.rb'
|
||||
- 'engines/order_management/app/services/order_management/stock/estimator.rb'
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'spec/support/matchers/table_matchers.rb'
|
||||
- 'lib/reporting/report_query_template.rb'
|
||||
- 'lib/reporting/report_row_builder.rb'
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/base.rb'
|
||||
- 'lib/tasks/sample_data/user_factory.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Style/MissingRespondToMissing:
|
||||
@@ -1152,6 +1557,13 @@ Style/MultilineTernaryOperator:
|
||||
Exclude:
|
||||
- 'spec/system/admin/subscriptions_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/NegatedIfElseCondition:
|
||||
Exclude:
|
||||
- 'app/mailers/spree/shipment_mailer.rb'
|
||||
- 'spec/support/matchers/table_matchers.rb'
|
||||
|
||||
# Offense count: 22
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/NestedModifier:
|
||||
@@ -1167,13 +1579,18 @@ Style/NestedModifier:
|
||||
- 'spec/system/admin/payments_stripe_spec.rb'
|
||||
- 'spec/system/admin/reports_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowedMethods.
|
||||
# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with
|
||||
Style/NestedParenthesizedCalls:
|
||||
# Offense count: 36
|
||||
Style/OpenStructUse:
|
||||
Exclude:
|
||||
- 'spec/system/admin/products_spec.rb'
|
||||
- 'app/helpers/injection_helper.rb'
|
||||
- 'app/models/spree/shipment.rb'
|
||||
- 'lib/open_food_network/enterprise_fee_calculator.rb'
|
||||
- 'lib/reporting/report_row_builder.rb'
|
||||
- 'lib/reporting/report_rows_builder.rb'
|
||||
- 'spec/lib/reports/report_renderer_spec.rb'
|
||||
- 'spec/lib/reports/report_spec.rb'
|
||||
- 'spec/lib/reports/users_and_enterprises_report_spec.rb'
|
||||
- 'spec/serializers/api/enterprise_serializer_spec.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# Configuration parameters: AllowedMethods.
|
||||
@@ -1207,12 +1624,70 @@ Style/PreferredHashMethods:
|
||||
Exclude:
|
||||
- 'app/controllers/api/v0/shipments_controller.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: same_as_string_literals, single_quotes, double_quotes
|
||||
Style/QuotedSymbols:
|
||||
Exclude:
|
||||
- 'app/services/exchange_products_renderer.rb'
|
||||
- 'lib/stripe/credit_card_cloner.rb'
|
||||
- 'spec/controllers/api/v0/exchange_products_controller_spec.rb'
|
||||
- 'spec/requests/api/orders_spec.rb'
|
||||
- 'spec/requests/api/v1/customers_spec.rb'
|
||||
- 'spec/support/request/stripe_stubs.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Methods.
|
||||
Style/RedundantArgument:
|
||||
Exclude:
|
||||
- 'engines/dfc_provider/app/services/authorization_control.rb'
|
||||
- 'spec/support/query_counter.rb'
|
||||
|
||||
# Offense count: 15
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/RedundantConstantBase:
|
||||
Exclude:
|
||||
- 'app/controllers/checkout_controller.rb'
|
||||
- 'app/controllers/split_checkout_controller.rb'
|
||||
- 'app/controllers/webhook_endpoints_controller.rb'
|
||||
- 'config.ru'
|
||||
- 'spec/base_spec_helper.rb'
|
||||
- 'spec/helpers/checkout_helper_spec.rb'
|
||||
- 'spec/models/spree/order_spec.rb'
|
||||
- 'spec/models/spree/payment_method_spec.rb'
|
||||
- 'spec/models/spree/payment_spec.rb'
|
||||
- 'spec/queries/complete_visible_orders_spec.rb'
|
||||
- 'spec/services/paypal_items_builder_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/RedundantDoubleSplatHashBraces:
|
||||
Exclude:
|
||||
- 'spec/system/support/cuprite_setup.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowComments.
|
||||
Style/RedundantInitialize:
|
||||
Exclude:
|
||||
- 'spec/models/spree/gateway_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/RedundantRegexpEscape:
|
||||
Exclude:
|
||||
- 'app/models/spree/order.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/RedundantStringEscape:
|
||||
Exclude:
|
||||
- 'app/models/spree/calculator.rb'
|
||||
- 'spec/controllers/spree/admin/shipping_methods_controller_spec.rb'
|
||||
- 'spec/system/admin/enterprise_fees_spec.rb'
|
||||
|
||||
# Offense count: 206
|
||||
Style/Send:
|
||||
Exclude:
|
||||
|
||||
@@ -57,6 +57,7 @@ TL;DR:
|
||||
* Maintain a clean commit history
|
||||
* Use a style consistent with the rest of the codebase
|
||||
* Before submitting, [rebase your work][rebase] on the current master branch
|
||||
* After submitting, be sure to check the [CI test results](ci). Click on a ❌ result to view the logged results and investigate.
|
||||
|
||||
From here, your pull request will progress through the [Review, Test, Merge & Deploy process][process].
|
||||
|
||||
@@ -70,4 +71,5 @@ From here, your pull request will progress through the [Review, Test, Merge & De
|
||||
[slack-dev]: https://openfoodnetwork.slack.com/messages/C2GQ45KNU
|
||||
[ofn-transifex]: https://www.transifex.com/open-food-foundation/open-food-network/
|
||||
[i18n]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Internationalisation-%28i18n%29
|
||||
[welcome-dev]: https://github.com/orgs/openfoodfoundation/projects/2
|
||||
[welcome-dev]: https://github.com/orgs/openfoodfoundation/projects/5
|
||||
[ci]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Continuous-Integration
|
||||
|
||||
11
Gemfile
11
Gemfile
@@ -14,11 +14,11 @@ gem "aws-sdk-s3", require: false
|
||||
gem "image_processing"
|
||||
|
||||
gem 'activemerchant', '>= 1.78.0'
|
||||
gem 'rexml'
|
||||
gem 'angular-rails-templates', '>= 0.3.0'
|
||||
gem 'awesome_nested_set'
|
||||
gem 'ransack', '~> 2.6.0'
|
||||
gem 'responders'
|
||||
gem 'rexml'
|
||||
gem 'webpacker', '~> 5'
|
||||
|
||||
gem 'i18n'
|
||||
@@ -70,8 +70,8 @@ gem 'rswag-api'
|
||||
gem 'rswag-ui'
|
||||
|
||||
gem 'omniauth_openid_connect'
|
||||
gem 'openid_connect', '~> 1.3'
|
||||
gem 'omniauth-rails_csrf_protection'
|
||||
gem 'openid_connect', '~> 1.3'
|
||||
|
||||
gem 'angularjs-rails', '1.8.0'
|
||||
gem 'bugsnag'
|
||||
@@ -92,6 +92,7 @@ gem 'gmaps4rails'
|
||||
gem 'mimemagic', '> 0.3.5'
|
||||
gem 'paper_trail', '~> 12.1'
|
||||
gem 'rack-rewrite'
|
||||
gem 'rack-timeout'
|
||||
gem 'roadie-rails'
|
||||
|
||||
gem 'hiredis'
|
||||
@@ -141,7 +142,6 @@ gem "private_address_check"
|
||||
|
||||
group :production, :staging do
|
||||
gem 'ddtrace'
|
||||
gem 'rack-timeout'
|
||||
gem 'sd_notify' # For better Systemd process management. Used by Puma.
|
||||
end
|
||||
|
||||
@@ -150,6 +150,7 @@ group :test, :development do
|
||||
gem 'capybara'
|
||||
gem 'cuprite'
|
||||
gem 'database_cleaner', require: false
|
||||
gem 'debug', '>= 1.0.0'
|
||||
gem "factory_bot_rails", '6.2.0', require: false
|
||||
gem 'fuubar', '~> 2.5.1'
|
||||
gem 'json_spec', '~> 1.1.4'
|
||||
@@ -160,7 +161,6 @@ group :test, :development do
|
||||
gem 'rswag-specs'
|
||||
gem 'shoulda-matchers'
|
||||
gem 'timecop'
|
||||
gem 'debug', '>= 1.0.0'
|
||||
end
|
||||
|
||||
group :test do
|
||||
@@ -175,10 +175,11 @@ end
|
||||
|
||||
group :development do
|
||||
gem 'debugger-linecache'
|
||||
gem 'rails-erd'
|
||||
gem 'foreman'
|
||||
gem 'listen'
|
||||
gem 'pry', '~> 0.13.0'
|
||||
gem 'query_count'
|
||||
gem 'rails-erd'
|
||||
gem 'rubocop'
|
||||
gem 'rubocop-rails'
|
||||
gem 'spring'
|
||||
|
||||
84
Gemfile.lock
84
Gemfile.lock
@@ -137,7 +137,7 @@ GEM
|
||||
activerecord (>= 6.0, < 7.1)
|
||||
acts_as_list (1.0.4)
|
||||
activerecord (>= 4.2)
|
||||
addressable (2.8.2)
|
||||
addressable (2.8.4)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
aes_key_wrap (1.1.0)
|
||||
afm (0.2.2)
|
||||
@@ -157,16 +157,16 @@ GEM
|
||||
awesome_nested_set (3.5.0)
|
||||
activerecord (>= 4.0.0, < 7.1)
|
||||
aws-eventstream (1.2.0)
|
||||
aws-partitions (1.739.0)
|
||||
aws-sdk-core (3.171.0)
|
||||
aws-partitions (1.760.0)
|
||||
aws-sdk-core (3.171.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
aws-partitions (~> 1, >= 1.651.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
aws-sdk-kms (1.63.0)
|
||||
aws-sdk-kms (1.64.0)
|
||||
aws-sdk-core (~> 3, >= 3.165.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.120.0)
|
||||
aws-sdk-s3 (1.122.0)
|
||||
aws-sdk-core (~> 3, >= 3.165.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.4)
|
||||
@@ -219,7 +219,7 @@ GEM
|
||||
matrix
|
||||
ruby-rc4 (>= 0.1.5)
|
||||
concurrent-ruby (1.2.2)
|
||||
connection_pool (2.3.0)
|
||||
connection_pool (2.4.0)
|
||||
crack (0.4.5)
|
||||
rexml
|
||||
crass (1.0.6)
|
||||
@@ -235,13 +235,13 @@ GEM
|
||||
database_cleaner-core (~> 2.0.0)
|
||||
database_cleaner-core (2.0.1)
|
||||
date (3.3.3)
|
||||
ddtrace (1.10.1)
|
||||
ddtrace (1.11.1)
|
||||
debase-ruby_core_source (>= 0.10.16, <= 3.2.0)
|
||||
libdatadog (~> 2.0.0.1.0)
|
||||
libddwaf (~> 1.6.2.0.0)
|
||||
libddwaf (~> 1.8.2.0.0)
|
||||
msgpack
|
||||
debase-ruby_core_source (3.2.0)
|
||||
debug (1.7.2)
|
||||
debug (1.8.0)
|
||||
irb (>= 1.5.0)
|
||||
reline (>= 0.3.1)
|
||||
debugger-linecache (1.2.0)
|
||||
@@ -338,7 +338,7 @@ GEM
|
||||
hiredis (0.6.3)
|
||||
htmlentities (4.3.4)
|
||||
httpclient (2.8.3)
|
||||
i18n (1.12.0)
|
||||
i18n (1.13.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n-js (3.9.2)
|
||||
i18n (>= 0.6.6)
|
||||
@@ -349,7 +349,7 @@ GEM
|
||||
activerecord (>= 3.0)
|
||||
io-console (0.6.0)
|
||||
ipaddress (0.8.3)
|
||||
irb (1.6.3)
|
||||
irb (1.6.4)
|
||||
reline (>= 0.3.0)
|
||||
jmespath (1.6.2)
|
||||
jquery-rails (4.4.0)
|
||||
@@ -373,14 +373,14 @@ GEM
|
||||
jsonapi-serializer (2.2.0)
|
||||
activesupport (>= 4.2)
|
||||
jwt (2.7.0)
|
||||
knapsack_pro (3.9.0)
|
||||
knapsack_pro (3.11.0)
|
||||
rake
|
||||
launchy (2.5.0)
|
||||
addressable (~> 2.7)
|
||||
letter_opener (1.8.1)
|
||||
launchy (>= 2.2, < 3)
|
||||
libdatadog (2.0.0.1.0)
|
||||
libddwaf (1.6.2.0.0)
|
||||
libddwaf (1.8.2.0.0)
|
||||
ffi (~> 1.0)
|
||||
libv8-node (16.10.0.0)
|
||||
listen (3.8.0)
|
||||
@@ -405,7 +405,7 @@ GEM
|
||||
rake
|
||||
mini_magick (4.11.0)
|
||||
mini_mime (1.1.2)
|
||||
mini_portile2 (2.8.1)
|
||||
mini_portile2 (2.8.2)
|
||||
mini_racer (0.6.3)
|
||||
libv8-node (~> 16.10.0.0)
|
||||
minitest (5.18.0)
|
||||
@@ -413,7 +413,7 @@ GEM
|
||||
money (~> 6.12)
|
||||
money (6.16.0)
|
||||
i18n (>= 0.6.4, <= 2)
|
||||
msgpack (1.6.1)
|
||||
msgpack (1.7.0)
|
||||
multi_json (1.15.0)
|
||||
multi_xml (0.6.0)
|
||||
net-imap (0.3.4)
|
||||
@@ -425,8 +425,8 @@ GEM
|
||||
timeout
|
||||
net-smtp (0.3.3)
|
||||
net-protocol
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.14.2)
|
||||
nio4r (2.5.9)
|
||||
nokogiri (1.14.3)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
racc (~> 1.4)
|
||||
oauth2 (1.4.11)
|
||||
@@ -485,11 +485,14 @@ GEM
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
public_suffix (5.0.1)
|
||||
puma (6.2.1)
|
||||
puma (6.2.2)
|
||||
nio4r (~> 2.0)
|
||||
query_count (1.1.1)
|
||||
activerecord (>= 4.2)
|
||||
railties (>= 4.2)
|
||||
raabro (1.4.0)
|
||||
racc (1.6.2)
|
||||
rack (2.2.6.4)
|
||||
rack (2.2.7)
|
||||
rack-mini-profiler (2.3.4)
|
||||
rack (>= 1.2.0)
|
||||
rack-oauth2 (1.21.3)
|
||||
@@ -556,9 +559,9 @@ GEM
|
||||
ffi (~> 1.0)
|
||||
redcarpet (3.6.0)
|
||||
redis (4.8.1)
|
||||
redis-client (0.14.0)
|
||||
redis-client (0.14.1)
|
||||
connection_pool
|
||||
regexp_parser (2.7.0)
|
||||
regexp_parser (2.8.0)
|
||||
reline (0.3.3)
|
||||
io-console (~> 0.5)
|
||||
request_store (1.5.1)
|
||||
@@ -583,36 +586,36 @@ GEM
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
rspec-mocks (~> 3.12.0)
|
||||
rspec-core (3.12.1)
|
||||
rspec-core (3.12.2)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-expectations (3.12.2)
|
||||
rspec-expectations (3.12.3)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-mocks (3.12.3)
|
||||
rspec-mocks (3.12.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-rails (6.0.1)
|
||||
rspec-rails (6.0.2)
|
||||
actionpack (>= 6.1)
|
||||
activesupport (>= 6.1)
|
||||
railties (>= 6.1)
|
||||
rspec-core (~> 3.11)
|
||||
rspec-expectations (~> 3.11)
|
||||
rspec-mocks (~> 3.11)
|
||||
rspec-support (~> 3.11)
|
||||
rspec-core (~> 3.12)
|
||||
rspec-expectations (~> 3.12)
|
||||
rspec-mocks (~> 3.12)
|
||||
rspec-support (~> 3.12)
|
||||
rspec-retry (0.6.2)
|
||||
rspec-core (> 3.3)
|
||||
rspec-support (3.12.0)
|
||||
rswag-api (2.8.0)
|
||||
rswag-api (2.9.0)
|
||||
railties (>= 3.1, < 7.1)
|
||||
rswag-specs (2.8.0)
|
||||
rswag-specs (2.9.0)
|
||||
activesupport (>= 3.1, < 7.1)
|
||||
json-schema (>= 2.2, < 4.0)
|
||||
railties (>= 3.1, < 7.1)
|
||||
rspec-core (>= 2.14)
|
||||
rswag-ui (2.8.0)
|
||||
rswag-ui (2.9.0)
|
||||
actionpack (>= 3.1, < 7.1)
|
||||
railties (>= 3.1, < 7.1)
|
||||
rubocop (1.49.0)
|
||||
rubocop (1.50.2)
|
||||
json (~> 2.3)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.2.0.0)
|
||||
@@ -624,7 +627,7 @@ GEM
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.28.0)
|
||||
parser (>= 3.2.1.0)
|
||||
rubocop-rails (2.18.0)
|
||||
rubocop-rails (2.19.1)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.33.0, < 2.0)
|
||||
@@ -652,11 +655,11 @@ GEM
|
||||
semantic_range (3.0.0)
|
||||
shoulda-matchers (5.3.0)
|
||||
activesupport (>= 5.2.0)
|
||||
sidekiq (7.0.7)
|
||||
sidekiq (7.1.0)
|
||||
concurrent-ruby (< 2)
|
||||
connection_pool (>= 2.3.0)
|
||||
rack (>= 2.2.4)
|
||||
redis-client (>= 0.11.0)
|
||||
redis-client (>= 0.14.0)
|
||||
sidekiq-scheduler (5.0.2)
|
||||
rufus-scheduler (~> 3.2)
|
||||
sidekiq (>= 6, < 8)
|
||||
@@ -697,8 +700,8 @@ GEM
|
||||
rack (>= 2, < 4)
|
||||
railties (>= 5.2, < 8)
|
||||
redis (>= 4.0, < 6.0)
|
||||
stringex (2.8.5)
|
||||
stripe (8.3.0)
|
||||
stringex (2.8.6)
|
||||
stripe (8.5.0)
|
||||
swd (1.3.0)
|
||||
activesupport (>= 3)
|
||||
attr_required (>= 0.0.5)
|
||||
@@ -726,7 +729,7 @@ GEM
|
||||
activemodel (>= 3.0.0)
|
||||
public_suffix
|
||||
vcr (6.1.0)
|
||||
view_component (2.82.0)
|
||||
view_component (3.0.0)
|
||||
activesupport (>= 5.2.0, < 8.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
method_source (~> 1.0)
|
||||
@@ -765,7 +768,7 @@ GEM
|
||||
xml-simple (1.1.8)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
zeitwerk (2.6.7)
|
||||
zeitwerk (2.6.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -857,6 +860,7 @@ DEPENDENCIES
|
||||
private_address_check
|
||||
pry (~> 0.13.0)
|
||||
puma
|
||||
query_count
|
||||
rack-mini-profiler (< 3.0.0)
|
||||
rack-rewrite
|
||||
rack-timeout
|
||||
|
||||
4
Procfile
4
Procfile
@@ -1,5 +1,5 @@
|
||||
# Foreman Procfile. Start all dev server processes with: `foreman start`
|
||||
|
||||
rails: bundle exec rails s -p 3000
|
||||
rails: DEV_CACHING=true bundle exec rails s -p 3000
|
||||
webpack: ./bin/webpack-dev-server
|
||||
sidekiq: bundle exec sidekiq -q mailers -q default
|
||||
sidekiq: DEV_CACHING=true bundle exec sidekiq -q mailers -q default
|
||||
|
||||
@@ -12,5 +12,6 @@ angular.module("ofn.admin", [
|
||||
"admin.orders"
|
||||
]).config ($httpProvider, $locationProvider, $qProvider) ->
|
||||
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"
|
||||
# for the next line, you should also probably check file: app/assets/javascripts/admin/utils/utils.js.coffee
|
||||
$locationProvider.hashPrefix('')
|
||||
$qProvider.errorOnUnhandledRejections(false)
|
||||
|
||||
@@ -11,5 +11,6 @@ angular.module("admin.indexUtils").factory 'SortOptions', ->
|
||||
sortingExpr
|
||||
|
||||
toggle: (predicate) ->
|
||||
@reverse = (@predicate == predicate) && !@reverse
|
||||
# predicate is a string or an array of strings
|
||||
@reverse = (JSON.stringify(@predicate) == JSON.stringify(predicate)) && !@reverse
|
||||
@predicate = predicate
|
||||
|
||||
@@ -17,6 +17,7 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
|
||||
]
|
||||
$scope.page = 1
|
||||
$scope.per_page = $scope.per_page_options[0].id
|
||||
$scope.filterByVariantId = null
|
||||
searchThrough = ["order_distributor_name",
|
||||
"order_bill_address_phone",
|
||||
"order_bill_address_firstname",
|
||||
@@ -68,6 +69,7 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
|
||||
|
||||
RequestMonitor.load LineItems.index(
|
||||
"q[#{searchThrough}]": $scope.query,
|
||||
"q[variant_id_eq]": $scope.filterByVariantId if $scope.filterByVariantId,
|
||||
"q[order_state_not_eq]": "canceled",
|
||||
"q[order_shipment_state_not_eq]": "shipped",
|
||||
"q[order_completed_at_not_null]": "true",
|
||||
@@ -176,6 +178,17 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
|
||||
$scope.setSelectedUnitsVariant = (unitsProduct,unitsVariant) ->
|
||||
$scope.selectedUnitsProduct = unitsProduct
|
||||
$scope.selectedUnitsVariant = unitsVariant
|
||||
$scope.filterByVariantId = unitsVariant.id
|
||||
$scope.page = 1
|
||||
$scope.refreshData()
|
||||
|
||||
$scope.resetSelectedUnitsVariant = ->
|
||||
$scope.selectedUnitsProduct = { }
|
||||
$scope.selectedUnitsVariant = { }
|
||||
$scope.filterByVariantId = null
|
||||
$scope.sharedResource = false
|
||||
$scope.page = 1
|
||||
$scope.refreshData()
|
||||
|
||||
$scope.getLineItemScale = (lineItem) ->
|
||||
if lineItem.units_product && lineItem.units_variant && (lineItem.units_product.variant_unit == "weight" || lineItem.units_product.variant_unit == "volume")
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
angular.module("admin.lineItems").filter "variantFilter", ->
|
||||
return (lineItems,selectedUnitsProduct,selectedUnitsVariant,sharedResource) ->
|
||||
filtered = []
|
||||
filtered.push lineItem for lineItem in lineItems when (angular.equals(selectedUnitsProduct,{}) ||
|
||||
(lineItem.units_product.id == selectedUnitsProduct.id && (sharedResource || lineItem.units_variant.id == selectedUnitsVariant.id ) ) )
|
||||
filtered
|
||||
@@ -15,7 +15,7 @@ $(document).ready(function() {
|
||||
console.log(msg);
|
||||
});
|
||||
}
|
||||
$('[data-hook=admin_order_edit_form] a.ship').click(handle_ship_click);
|
||||
$('.admin-order-edit-form a.ship').click(handle_ship_click);
|
||||
|
||||
//handle shipping method edit click
|
||||
$('a.edit-method').click(toggleMethodEdit);
|
||||
@@ -37,7 +37,7 @@ $(document).ready(function() {
|
||||
console.log(msg);
|
||||
});
|
||||
}
|
||||
$('[data-hook=admin_order_edit_form] a.save-method').click(handle_shipping_method_save);
|
||||
$('.admin-order-edit-form a.save-method').click(handle_shipping_method_save);
|
||||
|
||||
//handle tracking info edit/delete
|
||||
|
||||
@@ -64,8 +64,8 @@ $(document).ready(function() {
|
||||
return Spree.url( Spree.routes.orders_api + "/" + order_number + "/shipments/" + shipmentNumber + ".json");
|
||||
}
|
||||
|
||||
$('[data-hook=admin_order_edit_form] a.save-tracking').click(saveTrackingInfo);
|
||||
$('[data-hook=admin_order_edit_form] a.delete-tracking').click(deleteTrackingInfo);
|
||||
$('.admin-order-edit-form a.save-tracking').click(saveTrackingInfo);
|
||||
$('.admin-order-edit-form a.delete-tracking').click(deleteTrackingInfo);
|
||||
|
||||
// handle note edit/delete
|
||||
|
||||
@@ -96,8 +96,8 @@ $(document).ready(function() {
|
||||
});
|
||||
}
|
||||
|
||||
$('[data-hook=admin_order_edit_form] a.save-note').click(saveNote);
|
||||
$('[data-hook=admin_order_edit_form] a.delete-note').click(deleteNote);
|
||||
$('.admin-order-edit-form a.save-note').click(saveNote);
|
||||
$('.admin-order-edit-form a.delete-note').click(deleteNote);
|
||||
|
||||
// Makes API call for notes/tracking info
|
||||
makeApiCall = function(url, params) {
|
||||
|
||||
@@ -4,7 +4,8 @@ $(document).ready(function() {
|
||||
|
||||
initAlert()
|
||||
initConfirm()
|
||||
initCancelOrder()
|
||||
initButtonCancel()
|
||||
initLinkCancel()
|
||||
|
||||
if ($('#variant_autocomplete_template').length > 0) {
|
||||
window.variantTemplate = Handlebars.compile($('#variant_autocomplete_template').text());
|
||||
@@ -276,17 +277,23 @@ ofnConfirm = function(callback) {
|
||||
$('#custom-confirm').show();
|
||||
}
|
||||
|
||||
initCancelOrder = function() {
|
||||
$('#cancel_order_form').submit(function(e){
|
||||
ofnCancelOrderAlert((confirm, sendEmailCancellation, restock_items) => {
|
||||
if (confirm) {
|
||||
var redirectTo = new URL(Spree.routes.cancel_order.toString());
|
||||
redirectTo.searchParams.append("send_cancellation_email", sendEmailCancellation);
|
||||
redirectTo.searchParams.append("restock_items", restock_items);
|
||||
window.location.href = redirectTo.toString();
|
||||
}
|
||||
});
|
||||
e.preventDefault();
|
||||
return false;
|
||||
initCancelAction = function(e){
|
||||
ofnCancelOrderAlert((confirm, sendEmailCancellation, restock_items) => {
|
||||
if (confirm) {
|
||||
var redirectTo = new URL(Spree.routes.cancel_order.toString());
|
||||
redirectTo.searchParams.append("send_cancellation_email", sendEmailCancellation);
|
||||
redirectTo.searchParams.append("restock_items", restock_items);
|
||||
window.location.href = redirectTo.toString();
|
||||
}
|
||||
});
|
||||
e.preventDefault();
|
||||
return false;
|
||||
};
|
||||
|
||||
initButtonCancel = function() {
|
||||
$('#cancel_order_form').submit(initCancelAction)
|
||||
}
|
||||
|
||||
initLinkCancel = function() {
|
||||
$('#links-dropdown a[href$="cancel"]').click(initCancelAction);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
angular.module("admin.utils", ["templates", "ngSanitize"]).config ($httpProvider, $locationProvider) ->
|
||||
# for the next line, you should also probably check file: app/assets/javascripts/admin/admin_ofn.js.coffee
|
||||
$locationProvider.hashPrefix('')
|
||||
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"
|
||||
|
||||
@@ -2,6 +2,7 @@ angular.module('Darkswarm').factory "EnterpriseModal", ($modal, $rootScope, $htt
|
||||
# Build a modal popup for an enterprise.
|
||||
new class EnterpriseModal
|
||||
open: (enterprise)->
|
||||
return if enterprise.visible == 'hidden'
|
||||
scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise
|
||||
scope.embedded_layout = window.location.search.indexOf("embedded_shopfront=true") != -1
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ConfirmModalComponent < ModalComponent
|
||||
def initialize(id:, confirm_actions: nil, controllers: nil, message: nil)
|
||||
def initialize(id:, confirm_actions: nil, controllers: nil, message: nil, confirm_reflexes: nil)
|
||||
super(id: id, close_button: true)
|
||||
@confirm_actions = confirm_actions
|
||||
@confirm_reflexes = confirm_reflexes
|
||||
@controllers = controllers
|
||||
@message = message
|
||||
end
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
|
||||
.modal-actions
|
||||
%input{ class: "button icon-plus #{close_button_class}", type: 'button', value: t('js.admin.modals.cancel'), "data-action": "click->modal#close" }
|
||||
%input{ class: "button icon-plus primary", type: 'button', value: t('js.admin.modals.confirm'), "data-action": @confirm_actions }
|
||||
%input{ class: "button icon-plus primary", type: 'button', value: t('js.admin.modals.confirm'), "data-action": @confirm_actions, "data-reflex": @confirm_reflexes }
|
||||
|
||||
@@ -18,6 +18,8 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
ContentConfig.updated_at = Time.zone.now
|
||||
|
||||
flash[:success] =
|
||||
t(:successfully_updated, resource: I18n.t('admin.contents.edit.your_content'))
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
require 'open_food_network/address_finder'
|
||||
|
||||
# rubocop:disable Metrics/ClassLength
|
||||
module Admin
|
||||
class CustomersController < Admin::ResourceController
|
||||
before_action :load_managed_shops, only: :index, if: :html_request?
|
||||
@@ -67,7 +68,7 @@ module Admin
|
||||
|
||||
def collection
|
||||
if json_request? && params[:enterprise_id].present?
|
||||
CustomersWithBalance.new(Customer.of(managed_enterprise_id)).query.
|
||||
CustomersWithBalance.new(customers).query.
|
||||
includes(
|
||||
:enterprise,
|
||||
{ bill_address: [:state, :country] },
|
||||
@@ -79,6 +80,15 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
def customers
|
||||
return @customers if @customers.present?
|
||||
|
||||
@customers = Customer.managed_by(spree_current_user)
|
||||
return @customers if params[:enterprise_id].blank?
|
||||
|
||||
@customers = @customers.where(enterprise_id: params[:enterprise_id])
|
||||
end
|
||||
|
||||
def managed_enterprise_id
|
||||
@managed_enterprise_id ||= Enterprise.managed_by(spree_current_user).
|
||||
select('enterprises.id').find_by(id: params[:enterprise_id])
|
||||
@@ -120,3 +130,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/ClassLength
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module Admin
|
||||
class ReportsController < Spree::Admin::BaseController
|
||||
include ActiveStorage::SetCurrent
|
||||
include ReportsActions
|
||||
helper ReportsHelper
|
||||
|
||||
@@ -21,11 +22,13 @@ module Admin
|
||||
def show
|
||||
@report = report_class.new(spree_current_user, params, render: render_data?)
|
||||
|
||||
if report_format.present?
|
||||
if params[:report_format].present?
|
||||
export_report
|
||||
else
|
||||
show_report
|
||||
end
|
||||
rescue Timeout::Error
|
||||
render_timeout_error
|
||||
end
|
||||
|
||||
private
|
||||
@@ -36,6 +39,7 @@ module Admin
|
||||
|
||||
def show_report
|
||||
assign_view_data
|
||||
@table = render_report_as(:html) if render_data?
|
||||
render "show"
|
||||
end
|
||||
|
||||
@@ -45,7 +49,6 @@ module Admin
|
||||
@report_subtype = report_subtype
|
||||
@report_title = report_title
|
||||
@rendering_options = rendering_options
|
||||
@table = render_report_as(:html) if render_data?
|
||||
@data = Reporting::FrontendData.new(spree_current_user)
|
||||
end
|
||||
|
||||
@@ -55,16 +58,43 @@ module Admin
|
||||
|
||||
def render_report_as(format)
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:background_reports, spree_current_user)
|
||||
job = ReportJob.perform_later(
|
||||
report_class, spree_current_user, params, format
|
||||
@blob = ReportBlob.create_for_upload_later!(report_filename)
|
||||
ReportJob.perform_later(
|
||||
report_class, spree_current_user, params, format, @blob
|
||||
)
|
||||
sleep 1 until job.done?
|
||||
Timeout.timeout(max_wait_time) do
|
||||
sleep 1 until @blob.content_stored?
|
||||
end
|
||||
|
||||
# This result has been rendered by Rails in safe mode already.
|
||||
job.result.html_safe # rubocop:disable Rails/OutputSafety
|
||||
@blob.result.html_safe # rubocop:disable Rails/OutputSafety
|
||||
else
|
||||
@report.render_as(format)
|
||||
end
|
||||
end
|
||||
|
||||
def render_timeout_error
|
||||
assign_view_data
|
||||
if @blob
|
||||
@error = ".report_taking_longer_html"
|
||||
@error_url = @blob.url
|
||||
else
|
||||
@error = ".report_taking_longer"
|
||||
@error_url = ""
|
||||
end
|
||||
render "show"
|
||||
end
|
||||
|
||||
def max_wait_time
|
||||
# This value is used by rack-timeout and nginx, usually 30 seconds in
|
||||
# staging and production:
|
||||
server_timeout = ENV.fetch("RACK_TIMEOUT_SERVICE_TIMEOUT", "15").to_f
|
||||
|
||||
# Zero disables the timeout:
|
||||
return 0 if server_timeout.zero?
|
||||
|
||||
# We want to time out earlier than nginx:
|
||||
server_timeout - 2.seconds
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -63,7 +63,7 @@ module Admin
|
||||
|
||||
options = [{ id: '0', name: 'All' }]
|
||||
import_dates.collect(&:import_date).map { |i|
|
||||
options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long))
|
||||
options.push(id: i.to_date, name: i.to_date.to_fs(:long))
|
||||
}
|
||||
|
||||
options
|
||||
|
||||
@@ -80,9 +80,7 @@ module Api
|
||||
end
|
||||
|
||||
def visible_customers
|
||||
current_api_user.customers.or(
|
||||
Customer.where(enterprise_id: editable_enterprises)
|
||||
)
|
||||
Customer.managed_by(current_api_user)
|
||||
end
|
||||
|
||||
def customer_params
|
||||
@@ -106,10 +104,6 @@ module Api
|
||||
attributes
|
||||
end
|
||||
|
||||
def editable_enterprises
|
||||
OpenFoodNetwork::Permissions.new(current_api_user).editable_enterprises.select(:id)
|
||||
end
|
||||
|
||||
def include_options
|
||||
fields = [params.fetch(:include, [])].flatten
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ module ReportsActions
|
||||
end
|
||||
|
||||
def report_format
|
||||
params[:report_format]
|
||||
params[:report_format].presence || "html"
|
||||
end
|
||||
|
||||
def report_filename
|
||||
|
||||
@@ -10,5 +10,12 @@ module WhiteLabel
|
||||
# if the distributor has the hide_ofn_navigation preference set to true
|
||||
# then we should hide the OFN navigation
|
||||
@hide_ofn_navigation = distributor.hide_ofn_navigation
|
||||
|
||||
# if the distributor has the hide_ofn_navigation preference
|
||||
# set to false, there is no need to check the white_label_logo preference
|
||||
return unless @hide_ofn_navigation
|
||||
|
||||
@white_label_logo = distributor.white_label_logo
|
||||
@white_label_distributor = distributor
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,6 +65,7 @@ module Spree
|
||||
params.require(:order).permit(
|
||||
:email,
|
||||
:use_billing,
|
||||
:customer_id,
|
||||
bill_address_attributes: ::PermittedAttributes::Address.attributes,
|
||||
ship_address_attributes: ::PermittedAttributes::Address.attributes
|
||||
)
|
||||
|
||||
@@ -9,11 +9,9 @@ module Spree
|
||||
helper CheckoutHelper
|
||||
|
||||
before_action :load_order, only: [:edit, :update, :fire, :resend,
|
||||
:invoice, :print]
|
||||
before_action :load_distribution_choices, only: [:new, :edit, :update]
|
||||
:invoice, :print, :distribution]
|
||||
before_action :load_distribution_choices, only: [:new, :edit, :update, :distribution]
|
||||
|
||||
# Ensure that the distributor is set for an order when
|
||||
before_action :ensure_distribution, only: :new
|
||||
before_action :require_distributor_abn, only: :invoice
|
||||
|
||||
respond_to :html, :json
|
||||
@@ -21,8 +19,20 @@ module Spree
|
||||
def new
|
||||
@order = Order.create
|
||||
@order.created_by = spree_current_user
|
||||
@order.generate_order_number
|
||||
@order.save
|
||||
redirect_to spree.edit_admin_order_url(@order)
|
||||
redirect_to spree.distribution_admin_order_path(@order)
|
||||
end
|
||||
|
||||
def distribution
|
||||
return if order_params.blank?
|
||||
|
||||
on_update
|
||||
|
||||
@order.assign_attributes(order_params)
|
||||
return unless @order.save(context: :set_distribution_step)
|
||||
|
||||
redirect_to spree.admin_order_customer_path(@order)
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -33,12 +43,7 @@ module Spree
|
||||
end
|
||||
|
||||
def update
|
||||
@order.recreate_all_fees!
|
||||
|
||||
unless @order.cart?
|
||||
@order.create_tax_charge!
|
||||
@order.update_order!
|
||||
end
|
||||
on_update
|
||||
|
||||
if params[:set_distribution_step] && @order.update(order_params)
|
||||
return redirect_to spree.admin_order_customer_path(@order)
|
||||
@@ -105,6 +110,15 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def on_update
|
||||
@order.recreate_all_fees!
|
||||
|
||||
return if @order.cart?
|
||||
|
||||
@order.create_tax_charge!
|
||||
@order.update_order!
|
||||
end
|
||||
|
||||
def order_params
|
||||
return params[:order] if params[:order].blank?
|
||||
|
||||
@@ -142,17 +156,6 @@ module Spree
|
||||
ocs.closed +
|
||||
ocs.undated
|
||||
end
|
||||
|
||||
def ensure_distribution
|
||||
unless @order
|
||||
@order = Spree::Order.new
|
||||
@order.generate_order_number
|
||||
@order.save!
|
||||
end
|
||||
return if @order.distribution_set?
|
||||
|
||||
render 'set_distribution', locals: { order: @order }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,6 @@ module Spree
|
||||
before_action :load_data
|
||||
before_action :validate_payment_method_provider, only: [:create]
|
||||
before_action :load_hubs, only: [:new, :edit, :update]
|
||||
before_action :validate_calculator_preferred_value, only: [:update]
|
||||
|
||||
respond_to :html
|
||||
|
||||
@@ -17,6 +16,10 @@ module Spree
|
||||
@payment_method = payment_method_class.constantize.new(base_params)
|
||||
@object = @payment_method
|
||||
|
||||
if !base_params["calculator_type"] && gateway_params["calculator_type"]
|
||||
@payment_method.calculator_type = gateway_params["calculator_type"]
|
||||
end
|
||||
|
||||
load_hubs
|
||||
|
||||
if @payment_method.save
|
||||
@@ -44,6 +47,7 @@ module Spree
|
||||
redirect_to spree.edit_admin_payment_method_path(@payment_method)
|
||||
else
|
||||
respond_with(@payment_method)
|
||||
clear_preference_cache
|
||||
end
|
||||
end
|
||||
|
||||
@@ -182,33 +186,23 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
# Ensure the calculator to be updated is the correct type
|
||||
if params_for_update["calculator_type"] && params_for_update["calculator_attributes"]
|
||||
add_type_to_calculator_attributes(params_for_update)
|
||||
end
|
||||
|
||||
params_for_update
|
||||
end
|
||||
end
|
||||
|
||||
def validate_calculator_preferred_value
|
||||
return if calculator_preferred_values.all? do |value|
|
||||
preferred_value_from_params = gateway_params.dig(:calculator_attributes, value)
|
||||
preferred_value_from_params.nil? || Float(preferred_value_from_params,
|
||||
exception: false)
|
||||
def clear_preference_cache
|
||||
@payment_method.calculator.preferences.each_key do |key|
|
||||
Rails.cache.delete(@payment_method.calculator.preference_cache_key(key))
|
||||
end
|
||||
|
||||
flash[:error] = I18n.t(:calculator_preferred_value_error)
|
||||
redirect_to spree.edit_admin_payment_method_path(@payment_method)
|
||||
end
|
||||
|
||||
def calculator_preferred_values
|
||||
[
|
||||
:preferred_amount,
|
||||
:preferred_flat_percent,
|
||||
:preferred_flat_percent,
|
||||
:preferred_first_item,
|
||||
:preferred_additional_item,
|
||||
:preferred_max_items,
|
||||
:preferred_normal_amount,
|
||||
:preferred_discount_amount,
|
||||
:preferred_minimal_amount
|
||||
]
|
||||
def add_type_to_calculator_attributes(hash)
|
||||
hash["calculator_attributes"]["type"] = hash["calculator_type"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -177,7 +177,7 @@ module Spree
|
||||
def product_import_dates
|
||||
options = [{ id: '0', name: '' }]
|
||||
product_import_dates_query.collect(&:import_date).
|
||||
map { |i| options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) }
|
||||
map { |i| options.push(id: i.to_date, name: i.to_date.to_fs(:long)) }
|
||||
|
||||
options
|
||||
end
|
||||
|
||||
@@ -14,7 +14,6 @@ module Admin
|
||||
producers.size == 1 ? producers.first.id : nil
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def enterprise_side_menu_items(enterprise)
|
||||
is_shop = enterprise.sells != "none"
|
||||
show_properties = !!enterprise.is_primary_producer
|
||||
@@ -58,6 +57,5 @@ module Admin
|
||||
|
||||
{ name: 'white_label', icon_class: "icon-leaf", show: true }
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,4 +68,14 @@ module ApplicationHelper
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
def cache_key_with_locale(key, locale)
|
||||
Array.wrap(key) + [locale.to_s, I18nDigests.for_locale(locale)]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,4 +87,10 @@ module EnterprisesHelper
|
||||
main_app.producers_url
|
||||
end
|
||||
end
|
||||
|
||||
def main_logo_link(enterprise)
|
||||
return enterprise.white_label_logo_link if enterprise&.white_label_logo_link.present?
|
||||
|
||||
main_app.root_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
module ReportsHelper
|
||||
def report_order_cycle_options(order_cycles)
|
||||
order_cycles.map do |oc|
|
||||
orders_open_at = oc.orders_open_at&.to_s(:short) || 'NA'
|
||||
orders_close_at = oc.orders_close_at&.to_s(:short) || 'NA'
|
||||
orders_open_at = oc.orders_open_at&.to_fs(:short) || 'NA'
|
||||
orders_close_at = oc.orders_close_at&.to_fs(:short) || 'NA'
|
||||
["#{oc.name} (#{orders_open_at} - #{orders_close_at})".html_safe, oc.id]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,8 +29,8 @@ module Spree
|
||||
|
||||
def preference_field_tag(name, value, options)
|
||||
case options[:type]
|
||||
when :integer
|
||||
text_field_tag(name, value, preference_field_options(options))
|
||||
when :integer, :decimal
|
||||
number_field_tag(name, value, preference_field_options(options))
|
||||
when :boolean
|
||||
hidden_field_tag(name, 0) +
|
||||
check_box_tag(name, 1, value, preference_field_options(options))
|
||||
@@ -49,8 +49,8 @@ module Spree
|
||||
|
||||
def preference_field_for(form, field, options, object)
|
||||
case options[:type]
|
||||
when :integer
|
||||
form.text_field(field, preference_field_options(options))
|
||||
when :integer, :decimal
|
||||
form.number_field(field, preference_field_options(options))
|
||||
when :boolean
|
||||
form.check_box(field, preference_field_options(options))
|
||||
when :string
|
||||
@@ -80,26 +80,24 @@ module Spree
|
||||
end
|
||||
|
||||
def preference_field_options(options)
|
||||
field_options = case options[:type]
|
||||
when :integer
|
||||
{ size: 10,
|
||||
class: 'input_integer' }
|
||||
when :boolean
|
||||
{}
|
||||
when :string
|
||||
{ size: 10,
|
||||
class: 'input_string fullwidth' }
|
||||
when :password
|
||||
{ size: 10,
|
||||
class: 'password_string fullwidth' }
|
||||
when :text
|
||||
{ rows: 15,
|
||||
cols: 85,
|
||||
class: 'fullwidth' }
|
||||
else
|
||||
{ size: 10,
|
||||
class: 'input_string fullwidth' }
|
||||
end
|
||||
field_options =
|
||||
case options[:type]
|
||||
when :integer
|
||||
{ size: 10, class: 'input_integer', step: 1 }
|
||||
when :decimal
|
||||
# Allow any number of decimal places
|
||||
{ size: 10, class: 'input_integer', step: :any }
|
||||
when :boolean
|
||||
{}
|
||||
when :string
|
||||
{ size: 10, class: 'input_string fullwidth' }
|
||||
when :password
|
||||
{ size: 10, class: 'password_string fullwidth' }
|
||||
when :text
|
||||
{ rows: 15, cols: 85, class: 'fullwidth' }
|
||||
else
|
||||
{ size: 10, class: 'input_string fullwidth' }
|
||||
end
|
||||
|
||||
field_options.merge!(
|
||||
readonly: options[:readonly],
|
||||
|
||||
@@ -105,8 +105,7 @@ module Spree
|
||||
def cancel_order_link
|
||||
{ name: t(:cancel_order),
|
||||
url: spree.fire_admin_order_path(@order.number, e: 'cancel'),
|
||||
icon: 'icon-trash',
|
||||
confirm: t(:are_you_sure) }
|
||||
icon: 'icon-trash' }
|
||||
end
|
||||
|
||||
def cancel_event_link
|
||||
|
||||
@@ -1,34 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Renders a report and saves it to a temporary file.
|
||||
class ReportJob < ActiveJob::Base
|
||||
def perform(report_class, user, params, format)
|
||||
# Renders a report and stores it in a given blob.
|
||||
class ReportJob < ApplicationJob
|
||||
def perform(report_class, user, params, format, blob)
|
||||
report = report_class.new(user, params, render: true)
|
||||
result = report.render_as(format)
|
||||
write(result)
|
||||
end
|
||||
|
||||
def done?
|
||||
@done ||= File.file?(filename)
|
||||
end
|
||||
|
||||
def result
|
||||
@result ||= read_result
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def write(result)
|
||||
File.write(filename, result, mode: "wb")
|
||||
end
|
||||
|
||||
def read_result
|
||||
File.read(filename)
|
||||
ensure
|
||||
File.unlink(filename)
|
||||
end
|
||||
|
||||
def filename
|
||||
Rails.root.join("tmp/report-#{job_id}")
|
||||
blob.store(result)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +37,7 @@ class JsonApiSchema
|
||||
end
|
||||
|
||||
def relationship_properties
|
||||
relationships.to_h { |name| [name, relationship_schema(name)] }
|
||||
relationships.index_with { |name| relationship_schema(name) }
|
||||
end
|
||||
|
||||
# Example
|
||||
|
||||
23
app/mailers/application_mailer.rb
Normal file
23
app/mailers/application_mailer.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
# Inline stylesheets
|
||||
include Roadie::Rails::Automatic
|
||||
|
||||
helper TermsAndConditionsHelper
|
||||
|
||||
default from: -> { Spree::Config[:mails_from] }
|
||||
layout 'mailer'
|
||||
|
||||
def money(amount)
|
||||
Spree::Money.new(amount).to_s
|
||||
end
|
||||
helper_method :money
|
||||
|
||||
protected
|
||||
|
||||
def roadie_options
|
||||
# This lets us specify assets using relative paths in email templates
|
||||
super.merge(url_options: { host: URI(main_app.root_url).host })
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/mailers/helpers'
|
||||
class EnterpriseMailer < Spree::BaseMailer
|
||||
class EnterpriseMailer < ApplicationMailer
|
||||
include Devise::Mailers::Helpers
|
||||
include I18nHelper
|
||||
|
||||
@@ -12,7 +12,6 @@ class EnterpriseMailer < Spree::BaseMailer
|
||||
enterprise: @enterprise.name,
|
||||
sitename: Spree::Config[:site_name])
|
||||
mail(to: enterprise.contact.email,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
end
|
||||
end
|
||||
@@ -20,12 +19,10 @@ class EnterpriseMailer < Spree::BaseMailer
|
||||
def manager_invitation(enterprise, user)
|
||||
@enterprise = enterprise
|
||||
@instance = Spree::Config[:site_name]
|
||||
@instance_email = from_address
|
||||
|
||||
I18n.with_locale valid_locale(@enterprise.owner) do
|
||||
subject = t('enterprise_mailer.invite_manager.subject', enterprise: @enterprise.name)
|
||||
mail(to: user.email,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PaymentMailer < Spree::BaseMailer
|
||||
class PaymentMailer < ApplicationMailer
|
||||
include I18nHelper
|
||||
|
||||
def authorize_payment(payment)
|
||||
@@ -8,7 +8,7 @@ class PaymentMailer < Spree::BaseMailer
|
||||
subject = I18n.t('spree.payment_mailer.authorize_payment.subject',
|
||||
distributor: @payment.order.distributor.name)
|
||||
I18n.with_locale valid_locale(@payment.order.user) do
|
||||
mail(to: payment.order.email, from: from_address, subject: subject)
|
||||
mail(to: payment.order.email, subject: subject)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,6 @@ class PaymentMailer < Spree::BaseMailer
|
||||
order: @payment.order)
|
||||
I18n.with_locale valid_locale(shop_owner) do
|
||||
mail(to: shop_owner.email,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ProducerMailer < Spree::BaseMailer
|
||||
class ProducerMailer < ApplicationMailer
|
||||
include I18nHelper
|
||||
|
||||
def order_cycle_report(producer, order_cycle)
|
||||
@@ -14,7 +14,6 @@ class ProducerMailer < Spree::BaseMailer
|
||||
|
||||
mail(
|
||||
to: @producer.contact.email,
|
||||
from: from_address,
|
||||
subject: subject,
|
||||
reply_to: @coordinator.contact.email,
|
||||
cc: @coordinator.contact.email
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class BaseMailer < ActionMailer::Base
|
||||
# Inline stylesheets
|
||||
include Roadie::Rails::Automatic
|
||||
|
||||
helper TermsAndConditionsHelper
|
||||
|
||||
layout 'mailer'
|
||||
|
||||
def from_address
|
||||
Spree::Config[:mails_from]
|
||||
end
|
||||
|
||||
def money(amount)
|
||||
Spree::Money.new(amount).to_s
|
||||
end
|
||||
helper_method :money
|
||||
|
||||
protected
|
||||
|
||||
def roadie_options
|
||||
# This lets us specify assets using relative paths in email templates
|
||||
super.merge(url_options: { host: URI(main_app.root_url).host })
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class OrderMailer < BaseMailer
|
||||
class OrderMailer < ApplicationMailer
|
||||
helper 'checkout'
|
||||
helper SpreeCurrencyHelper
|
||||
helper Spree::PaymentMethodsHelper
|
||||
@@ -13,7 +13,6 @@ module Spree
|
||||
@order = find_order(order_or_order_id)
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
mail(to: @order.email,
|
||||
from: from_address,
|
||||
subject: mail_subject(t('spree.order_mailer.cancel_email.subject'), resend))
|
||||
end
|
||||
end
|
||||
@@ -23,7 +22,6 @@ module Spree
|
||||
I18n.with_locale valid_locale(@order.distributor.owner) do
|
||||
subject = I18n.t('spree.order_mailer.cancel_email_for_shop.subject')
|
||||
mail(to: @order.distributor.contact.email,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
end
|
||||
end
|
||||
@@ -33,7 +31,6 @@ module Spree
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
|
||||
mail(to: @order.email,
|
||||
from: from_address,
|
||||
subject: subject,
|
||||
reply_to: @order.distributor.contact.email)
|
||||
end
|
||||
@@ -44,7 +41,6 @@ module Spree
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
|
||||
mail(to: @order.distributor.contact.email,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
end
|
||||
end
|
||||
@@ -56,7 +52,6 @@ module Spree
|
||||
attach_file("invoice-#{@order.number}.pdf", pdf)
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
mail(to: @order.email,
|
||||
from: from_address,
|
||||
subject: mail_subject(t(:invoice), false),
|
||||
reply_to: @order.distributor.contact.email)
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class ShipmentMailer < BaseMailer
|
||||
class ShipmentMailer < ApplicationMailer
|
||||
def shipped_email(shipment, delivery:)
|
||||
@shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment)
|
||||
@delivery = delivery
|
||||
subject = base_subject
|
||||
mail(to: @shipment.order.email, from: from_address, subject: subject)
|
||||
mail(to: @shipment.order.email, subject: subject)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class TestMailer < BaseMailer
|
||||
class TestMailer < ApplicationMailer
|
||||
def test_email(user)
|
||||
recipient = user.respond_to?(:id) ? user : Spree::User.find(user)
|
||||
subject = "#{Spree::Config[:site_name]} #{t('spree.test_mailer.test_email.subject')}"
|
||||
mail(to: recipient.email, from: from_address, subject: subject)
|
||||
mail(to: recipient.email, subject: subject)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This mailer is configured to be the Devise mailer
|
||||
# Some methods here override Devise::Mailer methods
|
||||
module Spree
|
||||
class UserMailer < BaseMailer
|
||||
class UserMailer < ApplicationMailer
|
||||
include I18nHelper
|
||||
|
||||
helper MailerHelper
|
||||
@@ -16,7 +16,7 @@ module Spree
|
||||
"#{I18n.t('spree.user_mailer.reset_password_instructions.subject')}"
|
||||
|
||||
I18n.with_locale valid_locale(user) do
|
||||
mail(to: user.email, from: from_address, subject: subject)
|
||||
mail(to: user.email, subject: subject)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ module Spree
|
||||
def signup_confirmation(user)
|
||||
@user = user
|
||||
I18n.with_locale valid_locale(@user) do
|
||||
mail(to: user.email, from: from_address,
|
||||
mail(to: user.email,
|
||||
subject: t(:welcome_to) + ' ' + Spree::Config[:site_name])
|
||||
end
|
||||
end
|
||||
@@ -39,7 +39,6 @@ module Spree
|
||||
I18n.with_locale valid_locale(@user) do
|
||||
subject = t('spree.user_mailer.confirmation_instructions.subject')
|
||||
mail(to: confirmation_email_address,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SubscriptionMailer < Spree::BaseMailer
|
||||
class SubscriptionMailer < ApplicationMailer
|
||||
helper 'checkout'
|
||||
helper MailerHelper
|
||||
helper ShopMailHelper
|
||||
@@ -37,7 +37,6 @@ class SubscriptionMailer < Spree::BaseMailer
|
||||
@shop = Enterprise.find(summary.shop_id)
|
||||
@summary = summary
|
||||
mail(to: @shop.contact.email,
|
||||
from: from_address,
|
||||
subject: "#{Spree::Config[:site_name]} #{t('subscription_mailer.placement_summary_email.subject')}")
|
||||
end
|
||||
|
||||
@@ -45,7 +44,6 @@ class SubscriptionMailer < Spree::BaseMailer
|
||||
@shop = Enterprise.find(summary.shop_id)
|
||||
@summary = summary
|
||||
mail(to: @shop.contact.email,
|
||||
from: from_address,
|
||||
subject: "#{Spree::Config[:site_name]} #{t('subscription_mailer.confirmation_summary_email.subject')}")
|
||||
end
|
||||
|
||||
@@ -56,7 +54,6 @@ class SubscriptionMailer < Spree::BaseMailer
|
||||
confirm_email_subject = t('spree.order_mailer.confirm_email.subject')
|
||||
subject = "#{Spree::Config[:site_name]} #{confirm_email_subject} ##{order.number}"
|
||||
mail(to: order.email,
|
||||
from: from_address,
|
||||
subject: subject,
|
||||
reply_to: order.distributor.contact.email)
|
||||
end
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
class FlatPercentItemTotal < Spree::Calculator
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
preference :flat_percent, :decimal, default: 0
|
||||
|
||||
localize_number :preferred_flat_percent
|
||||
validates :preferred_flat_percent,
|
||||
numericality: true
|
||||
|
||||
def self.description
|
||||
Spree.t(:flat_percent)
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spree/localized_number'
|
||||
|
||||
class Calculator::FlatPercentPerItem < Spree::Calculator
|
||||
# Spree's FlatPercentItemTotal calculator sums all amounts, and then calculates a percentage
|
||||
# on them.
|
||||
# In the cart, we display line item individual amounts rounded, so to have consistent
|
||||
# calculations we do the same internally. Here, we round adjustments at the individual
|
||||
# item level first, then multiply by the item quantity.
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
preference :flat_percent, :decimal, default: 0
|
||||
|
||||
localize_number :preferred_flat_percent
|
||||
validates :preferred_flat_percent,
|
||||
numericality: true
|
||||
|
||||
def self.description
|
||||
I18n.t(:flat_percent_per_item)
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
class FlatRate < Spree::Calculator
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
preference :amount, :decimal, default: 0
|
||||
|
||||
localize_number :preferred_amount
|
||||
validates :preferred_amount,
|
||||
numericality: true
|
||||
|
||||
def self.description
|
||||
I18n.t(:flat_rate_per_order)
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
class FlexiRate < Spree::Calculator
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
preference :first_item, :decimal, default: 0.0
|
||||
preference :additional_item, :decimal, default: 0.0
|
||||
preference :max_items, :integer, default: 0
|
||||
|
||||
localize_number :preferred_first_item,
|
||||
:preferred_additional_item
|
||||
validates :preferred_first_item,
|
||||
:preferred_additional_item,
|
||||
numericality: true
|
||||
|
||||
def self.description
|
||||
I18n.t(:flexible_rate)
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
class PerItem < Spree::Calculator
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
preference :amount, :decimal, default: 0
|
||||
|
||||
localize_number :preferred_amount
|
||||
validates :preferred_amount,
|
||||
numericality: true
|
||||
|
||||
def self.description
|
||||
I18n.t(:flat_rate_per_item)
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require 'spree/localized_number'
|
||||
|
||||
module Calculator
|
||||
class PriceSack < Spree::Calculator
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
preference :minimal_amount, :decimal, default: 0
|
||||
preference :normal_amount, :decimal, default: 0
|
||||
preference :discount_amount, :decimal, default: 0
|
||||
|
||||
localize_number :preferred_minimal_amount,
|
||||
:preferred_normal_amount,
|
||||
:preferred_discount_amount
|
||||
validates :preferred_minimal_amount,
|
||||
:preferred_normal_amount,
|
||||
:preferred_discount_amount,
|
||||
numericality: true
|
||||
|
||||
def self.description
|
||||
I18n.t(:price_sack)
|
||||
|
||||
@@ -4,4 +4,8 @@ module AddressDisplay
|
||||
def full_name_reverse
|
||||
[lastname, firstname].reject(&:blank?).join(" ")
|
||||
end
|
||||
|
||||
def full_name_for_sorting
|
||||
[last_name, first_name].reject(&:blank?).join(", ")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -83,4 +83,19 @@ class ContentConfiguration < Spree::Preferences::Configuration
|
||||
|
||||
# User Guide
|
||||
preference :user_guide_link, :string, default: 'https://guide.openfoodnetwork.org/'
|
||||
|
||||
# ContentConfig Caching
|
||||
preference :updated_at_timestamp, :integer, default: Time.zone.today.to_time.to_i
|
||||
|
||||
def updated_at
|
||||
Time.zone.at updated_at_timestamp
|
||||
end
|
||||
|
||||
def updated_at=(time)
|
||||
self.updated_at_timestamp = time.to_i
|
||||
end
|
||||
|
||||
def cache_key
|
||||
"ContentConfig:#{updated_at_timestamp}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,6 +35,7 @@ class Customer < ApplicationRecord
|
||||
uniqueness: { scope: :enterprise_id, message: I18n.t('validation_msg_is_associated_with_an_exising_customer') }
|
||||
|
||||
scope :of, ->(enterprise) { where(enterprise_id: enterprise) }
|
||||
scope :managed_by, ->(user) { user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none }
|
||||
|
||||
before_create :associate_user
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ class Enterprise < ApplicationRecord
|
||||
medium: { resize_to_fill: [720, 156] },
|
||||
large: { resize_to_fill: [1200, 260] },
|
||||
}.freeze
|
||||
WHITE_LABEL_LOGO_SIZES = {
|
||||
default: { gravity: "Center", resize_to_fill: [217, 44] },
|
||||
mobile: { gravity: "Center", resize_to_fill: [75, 26] },
|
||||
}.freeze
|
||||
VALID_INSTAGRAM_REGEX = %r{\A[a-zA-Z0-9._]{1,30}([^/-]*)\z}
|
||||
|
||||
searchable_attributes :sells, :is_primary_producer, :name
|
||||
@@ -84,9 +88,14 @@ class Enterprise < ApplicationRecord
|
||||
has_one_attached :logo
|
||||
has_one_attached :promo_image
|
||||
has_one_attached :terms_and_conditions
|
||||
has_one_attached :white_label_logo
|
||||
|
||||
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validates :logo,
|
||||
processable_image: true,
|
||||
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validates :promo_image,
|
||||
processable_image: true,
|
||||
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validates :terms_and_conditions, content_type: {
|
||||
in: "application/pdf",
|
||||
message: I18n.t(:enterprise_terms_and_conditions_type_error),
|
||||
@@ -267,8 +276,7 @@ class Enterprise < ApplicationRecord
|
||||
|
||||
def plus_parents_and_order_cycle_producers(order_cycles)
|
||||
oc_producer_ids = Exchange.in_order_cycle(order_cycles).incoming.pluck :sender_id
|
||||
Enterprise.not_hidden.is_primary_producer
|
||||
.parents_of_one_union_others(id, oc_producer_ids | [id])
|
||||
Enterprise.is_primary_producer.parents_of_one_union_others(id, oc_producer_ids | [id])
|
||||
end
|
||||
|
||||
def relatives_including_self
|
||||
@@ -299,6 +307,14 @@ class Enterprise < ApplicationRecord
|
||||
)
|
||||
end
|
||||
|
||||
def white_label_logo_url(name = :default)
|
||||
return unless white_label_logo.variable?
|
||||
|
||||
Rails.application.routes.url_helpers.url_for(
|
||||
white_label_logo.variant(WHITE_LABEL_LOGO_SIZES[name])
|
||||
)
|
||||
end
|
||||
|
||||
def website
|
||||
strip_url self[:website]
|
||||
end
|
||||
|
||||
@@ -28,8 +28,12 @@ class EnterpriseGroup < ApplicationRecord
|
||||
has_one_attached :logo
|
||||
has_one_attached :promo_image
|
||||
|
||||
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validates :logo,
|
||||
processable_image: true,
|
||||
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validates :promo_image,
|
||||
processable_image: true,
|
||||
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
|
||||
scope :by_position, -> { order('position ASC') }
|
||||
scope :on_front_page, -> { where(on_front_page: true) }
|
||||
|
||||
@@ -13,6 +13,7 @@ class EnterpriseRelationship < ApplicationRecord
|
||||
|
||||
after_save :update_permissions_of_child_variant_overrides
|
||||
before_destroy :revoke_all_child_variant_overrides
|
||||
before_destroy :destroy_related_exchanges
|
||||
|
||||
scope :with_enterprises, -> {
|
||||
joins("
|
||||
@@ -102,6 +103,10 @@ class EnterpriseRelationship < ApplicationRecord
|
||||
child_variant_overrides.update_all(permission_revoked_at: Time.zone.now)
|
||||
end
|
||||
|
||||
def destroy_related_exchanges
|
||||
Exchange.where(sender: parent, receiver: child, incoming: true).destroy_all
|
||||
end
|
||||
|
||||
def child_variant_overrides
|
||||
VariantOverride.unscoped.for_hubs(child)
|
||||
.joins(variant: :product).where("spree_products.supplier_id IN (?)", parent)
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnterpriseRelationshipPermission < ApplicationRecord
|
||||
belongs_to :enterprise_relationship
|
||||
default_scope { order('name') }
|
||||
before_destroy :destroy_related_exchanges
|
||||
|
||||
def destroy_related_exchanges
|
||||
return if name != "add_to_order_cycle"
|
||||
|
||||
Exchange
|
||||
.where(sender: enterprise_relationship.parent,
|
||||
receiver: enterprise_relationship.child, incoming: true).destroy_all
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,4 +3,9 @@
|
||||
class ExchangeVariant < ApplicationRecord
|
||||
belongs_to :exchange
|
||||
belongs_to :variant, class_name: 'Spree::Variant'
|
||||
after_destroy :destroy_related_outgoing_variants
|
||||
|
||||
def destroy_related_outgoing_variants
|
||||
VariantDeleter.new.destroy_related_outgoing_variants(variant_id, exchange.order_cycle)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,6 +39,8 @@ module ProductImport
|
||||
enterprise_validation(entry)
|
||||
unit_fields_validation(entry)
|
||||
variant_of_product_validation(entry)
|
||||
price_validation(entry)
|
||||
on_hand_on_demand_validation(entry)
|
||||
|
||||
next if entry.enterprise_id.blank?
|
||||
|
||||
@@ -170,6 +172,11 @@ module ProductImport
|
||||
error: I18n.t('admin.product_import.model.blank'))
|
||||
end
|
||||
|
||||
unless is_numeric(entry.units) && entry.units.to_f > 0
|
||||
mark_as_invalid(entry, attribute: 'units',
|
||||
error: I18n.t('admin.product_import.model.incorrect_value'))
|
||||
end
|
||||
|
||||
return if import_into_inventory?
|
||||
|
||||
# unit_type must be valid type
|
||||
@@ -189,6 +196,42 @@ module ProductImport
|
||||
error: I18n.t('admin.product_import.model.conditional_blank'))
|
||||
end
|
||||
|
||||
def is_numeric(value)
|
||||
return true unless Float(value, exception: false).nil?
|
||||
end
|
||||
|
||||
def price_validation(entry)
|
||||
return if is_numeric(entry.price)
|
||||
|
||||
error_string = if empty_or_placeholder_value(entry.price)
|
||||
'admin.product_import.model.blank'
|
||||
else
|
||||
'admin.product_import.model.incorrect_value'
|
||||
end
|
||||
mark_as_invalid(entry, attribute: 'price', error: I18n.t(error_string))
|
||||
end
|
||||
|
||||
def on_hand_on_demand_validation(entry)
|
||||
on_hand_present_numeric = !empty_or_placeholder_value(entry.on_hand) &&
|
||||
is_numeric(entry.on_hand)
|
||||
on_hand_value = entry.on_hand&.to_i
|
||||
on_demand_present_numeric = !empty_or_placeholder_value(entry.on_demand) &&
|
||||
is_numeric(entry.on_demand)
|
||||
on_demand_value = entry.on_demand&.to_i
|
||||
|
||||
return if (on_hand_present_numeric && on_hand_value >= 0) ||
|
||||
(on_demand_present_numeric && on_demand_value == 1)
|
||||
|
||||
mark_as_invalid(entry, attribute: 'on_hand',
|
||||
error: I18n.t('admin.product_import.model.incorrect_value'))
|
||||
mark_as_invalid(entry, attribute: 'on_demand',
|
||||
error: I18n.t('admin.product_import.model.incorrect_value'))
|
||||
end
|
||||
|
||||
def empty_or_placeholder_value(value)
|
||||
value.blank? || value.to_s.strip == "-"
|
||||
end
|
||||
|
||||
def variant_of_product_validation(entry)
|
||||
return if entry.producer.blank? || entry.name.blank?
|
||||
|
||||
@@ -293,8 +336,7 @@ module ProductImport
|
||||
entry.primary_taxon_id = @spreadsheet_data.categories_index[category_name]
|
||||
else
|
||||
mark_as_invalid(entry, attribute: "category",
|
||||
error: I18n.t(:error_not_found_in_database,
|
||||
name: category_name))
|
||||
error: I18n.t('admin.product_import.model.category_not_found'))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
36
app/models/report_blob.rb
Normal file
36
app/models/report_blob.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Stores a generated report.
|
||||
class ReportBlob < ActiveStorage::Blob
|
||||
def self.create_for_upload_later!(filename)
|
||||
# ActiveStorage discourages modifying a blob later but we need a blob
|
||||
# before we know anything about the report file. It enables us to use the
|
||||
# same blob in the controller to read the result.
|
||||
create_before_direct_upload!(
|
||||
filename: filename,
|
||||
byte_size: 0,
|
||||
checksum: "0",
|
||||
content_type: content_type(filename),
|
||||
).tap do |blob|
|
||||
ActiveStorage::PurgeJob.set(wait: 1.month).perform_later(blob)
|
||||
end
|
||||
end
|
||||
|
||||
def self.content_type(filename)
|
||||
MIME::Types.of(filename).first&.to_s || "application/octet-stream"
|
||||
end
|
||||
|
||||
def store(content)
|
||||
io = StringIO.new(content)
|
||||
upload(io, identify: false)
|
||||
save!
|
||||
end
|
||||
|
||||
def content_stored?
|
||||
@content_stored ||= reload.checksum != "0"
|
||||
end
|
||||
|
||||
def result
|
||||
@result ||= download.force_encoding(Encoding::UTF_8)
|
||||
end
|
||||
end
|
||||
@@ -274,7 +274,7 @@ module Spree
|
||||
# Enterprise User can access orders that are placed inside a OC they coordinate
|
||||
order.order_cycle&.coordinated_by?(user)
|
||||
end
|
||||
can [:admin, :bulk_management, :managed], Spree::Order do
|
||||
can [:admin, :bulk_management, :managed, :distribution], Spree::Order do
|
||||
user.admin? || user.enterprises.any?(&:is_distributor)
|
||||
end
|
||||
can [:admin, :create, :show, :poll], :invoice
|
||||
|
||||
@@ -88,7 +88,6 @@ module Spree
|
||||
# Default mail headers settings
|
||||
preference :mails_from, :string, default: 'ofn@example.com'
|
||||
preference :mail_bcc, :string, default: 'ofn@example.com'
|
||||
preference :intercept_email, :string, default: nil
|
||||
|
||||
# Default smtp settings
|
||||
preference :mail_host, :string, default: 'localhost'
|
||||
|
||||
@@ -11,8 +11,10 @@ module Spree
|
||||
|
||||
has_one_attached :attachment
|
||||
|
||||
validates :attachment, attached: true,
|
||||
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validates :attachment,
|
||||
attached: true,
|
||||
processable_image: true,
|
||||
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
|
||||
validate :no_attachment_errors
|
||||
|
||||
def variant(name)
|
||||
|
||||
@@ -97,6 +97,8 @@ module Spree
|
||||
validates :email, presence: true,
|
||||
format: /\A([\w.%+\-']+)@([\w\-]+\.)+(\w{2,})\z/i,
|
||||
if: :require_email
|
||||
validates :order_cycle, presence: true, on: :set_distribution_step
|
||||
validates :distributor, presence: true, on: :set_distribution_step
|
||||
|
||||
make_permalink field: :number
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ module Spree
|
||||
# first unshipped that's leaving from a stock_location that stocks this variant
|
||||
def determine_target_shipment(variant)
|
||||
target_shipment = order.shipments.detect do |shipment|
|
||||
(shipment.ready? || shipment.pending?) && shipment.include?(variant)
|
||||
(shipment.ready? || shipment.pending?) && shipment.contains?(variant)
|
||||
end
|
||||
|
||||
target_shipment || order.shipments.detect do |shipment|
|
||||
|
||||
@@ -17,6 +17,7 @@ module Spree
|
||||
|
||||
validates :name, presence: true
|
||||
validate :distributor_validation
|
||||
validates_associated :calculator
|
||||
|
||||
after_initialize :init
|
||||
|
||||
@@ -40,9 +41,8 @@ module Spree
|
||||
where(id: non_unique_matches.map(&:id))
|
||||
}
|
||||
|
||||
scope :for_distributor, lambda { |distributor|
|
||||
joins(:distributors).
|
||||
where('enterprises.id = ?', distributor)
|
||||
scope :for_distributor, ->(distributor) {
|
||||
joins(:distributors).where('enterprises.id = ?', distributor)
|
||||
}
|
||||
|
||||
scope :for_subscriptions, -> { where(type: Subscription::ALLOWED_PAYMENT_METHOD_TYPES) }
|
||||
|
||||
@@ -22,7 +22,8 @@ module Spree
|
||||
when :password
|
||||
self[:value].to_s
|
||||
when :decimal
|
||||
BigDecimal(self[:value].to_s).round(2, BigDecimal::ROUND_HALF_UP)
|
||||
BigDecimal(self[:value].to_s, exception: false)&.round(2, BigDecimal::ROUND_HALF_UP) ||
|
||||
self[:value]
|
||||
when :integer
|
||||
self[:value].to_i
|
||||
when :boolean
|
||||
|
||||
@@ -117,7 +117,7 @@ module Spree
|
||||
value.to_s
|
||||
when :decimal
|
||||
value = 0 if value.blank?
|
||||
BigDecimal(value.to_s).round(2, BigDecimal::ROUND_HALF_UP)
|
||||
BigDecimal(value.to_s, exception: false)&.round(2, BigDecimal::ROUND_HALF_UP) || value
|
||||
when :integer
|
||||
value.to_i
|
||||
when :boolean
|
||||
|
||||
@@ -114,6 +114,7 @@ module Spree
|
||||
presence: { if: ->(p) { %w(weight volume).include? p.variant_unit } }
|
||||
validates :variant_unit_name,
|
||||
presence: { if: ->(p) { p.variant_unit == 'items' } }
|
||||
validate :validate_image_for_master
|
||||
|
||||
attr_accessor :option_values_hash
|
||||
|
||||
@@ -474,5 +475,11 @@ module Spree
|
||||
requested = permalink.presence || permalink_was.presence || name.presence || 'product'
|
||||
self.permalink = create_unique_permalink(requested.parameterize)
|
||||
end
|
||||
|
||||
def validate_image_for_master
|
||||
return if master.images.all?(&:valid?)
|
||||
|
||||
errors.add(:base, I18n.t('spree.admin.products.image_not_processable'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -246,7 +246,7 @@ module Spree
|
||||
@tracking_url ||= shipping_method.build_tracking_url(tracking)
|
||||
end
|
||||
|
||||
def include?(variant)
|
||||
def contains?(variant)
|
||||
inventory_units_for(variant).present?
|
||||
end
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ module Spree
|
||||
# Here we allow checkout with shipping methods without zones (see issue #3928 for details)
|
||||
# and also checkout with addresses outside of the zones of the selected shipping method
|
||||
# This method could be used, like in Spree, to validate shipping method zones on checkout.
|
||||
def include?(address)
|
||||
def delivers_to?(address)
|
||||
address.present?
|
||||
end
|
||||
|
||||
|
||||
@@ -69,7 +69,8 @@ module Spree
|
||||
return 0 unless category
|
||||
|
||||
address ||= Address.new(country_id: DefaultCountry.id)
|
||||
rate = category.tax_rates.detect { |tax_rate| tax_rate.zone.include? address }.try(:amount)
|
||||
rate = category.tax_rates
|
||||
.detect { |tax_rate| tax_rate.zone.contains_address? address }.try(:amount)
|
||||
|
||||
rate || 0
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ module Spree
|
||||
# do nothing - just here to satisfy the form
|
||||
end
|
||||
|
||||
def include?(address)
|
||||
def contains_address?(address)
|
||||
return false unless address
|
||||
|
||||
members.any? do |zone_member|
|
||||
@@ -44,7 +44,7 @@ module Spree
|
||||
def self.match(address)
|
||||
return unless matches = includes(:zone_members).
|
||||
order('zone_members_count', 'created_at').
|
||||
select { |zone| zone.include? address }
|
||||
select { |zone| zone.contains_address? address }
|
||||
|
||||
['state', 'country'].each do |zone_kind|
|
||||
if match = matches.detect { |zone| zone_kind == zone.kind }
|
||||
|
||||
12
app/reflexes/concerns/enterprise_concern.rb
Normal file
12
app/reflexes/concerns/enterprise_concern.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module EnterpriseConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_reflex do
|
||||
@enterprise = Enterprise.find_by(permalink: params[:id])
|
||||
authorize! :update, @enterprise
|
||||
end
|
||||
end
|
||||
end
|
||||
26
app/reflexes/white_label_reflex.rb
Normal file
26
app/reflexes/white_label_reflex.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WhiteLabelReflex < ApplicationReflex
|
||||
include EnterpriseConcern
|
||||
delegate :view_context, to: :controller
|
||||
|
||||
def remove_logo
|
||||
@enterprise.update!(white_label_logo: nil)
|
||||
# delete the white_label_logo_link attribute as well since it has no meaning without the logo
|
||||
@enterprise.update!(white_label_logo_link: "")
|
||||
|
||||
f = ActionView::Helpers::FormBuilder.new(:enterprise, @enterprise, view_context, {})
|
||||
|
||||
html = with_locale {
|
||||
render(partial: "admin/enterprises/form/white_label",
|
||||
locals: { f: f, enterprise: @enterprise })
|
||||
}
|
||||
morph "#white_label_panel", html
|
||||
|
||||
flash[:success] = with_locale {
|
||||
I18n.t("admin.enterprises.form.white_label.remove_logo_success")
|
||||
}
|
||||
cable_ready.dispatch_event(name: "modal:close")
|
||||
morph "#flashes", render(partial: "shared/flashes", locals: { flashes: flash })
|
||||
end
|
||||
end
|
||||
@@ -14,7 +14,8 @@ module Api
|
||||
:logo, :promo_image, :terms_and_conditions,
|
||||
:terms_and_conditions_file_name, :terms_and_conditions_updated_at,
|
||||
:preferred_invoice_order_by_supplier, :preferred_product_low_stock_display,
|
||||
:visible, :hide_ofn_navigation
|
||||
:visible, :hide_ofn_navigation, :white_label_logo,
|
||||
:white_label_logo_link
|
||||
|
||||
has_one :owner, serializer: Api::Admin::UserSerializer
|
||||
has_many :users, serializer: Api::Admin::UserSerializer
|
||||
@@ -29,6 +30,10 @@ module Api
|
||||
attachment_urls(object.promo_image, Enterprise::PROMO_IMAGE_SIZES)
|
||||
end
|
||||
|
||||
def white_label_logo
|
||||
attachment_urls(object.white_label_logo, Enterprise::WHITE_LABEL_LOGO_SIZES)
|
||||
end
|
||||
|
||||
def terms_and_conditions
|
||||
return unless object.terms_and_conditions.attached?
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
module Api
|
||||
module Admin
|
||||
class OrderSerializer < ActiveModel::Serializer
|
||||
attributes :id, :number, :user_id, :full_name, :email, :phone, :completed_at,
|
||||
:completed_at_utc_iso8601, :display_total,
|
||||
include AddressDisplay
|
||||
|
||||
attributes :id, :number, :user_id, :full_name, :full_name_for_sorting, :email, :phone,
|
||||
:completed_at, :completed_at_utc_iso8601, :display_total,
|
||||
:edit_path, :state, :payment_state, :shipment_state,
|
||||
:payments_path, :ready_to_ship, :ready_to_capture, :created_at,
|
||||
:distributor_name, :special_instructions, :display_outstanding_balance,
|
||||
@@ -17,6 +19,14 @@ module Api
|
||||
object.billing_address.nil? ? "" : ( object.billing_address.full_name || "" )
|
||||
end
|
||||
|
||||
def first_name
|
||||
object.billing_address&.first_name || ""
|
||||
end
|
||||
|
||||
def last_name
|
||||
object.billing_address&.last_name || ""
|
||||
end
|
||||
|
||||
def distributor_name
|
||||
object.distributor&.name
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ module Api
|
||||
:phone, :whatsapp_phone, :whatsapp_url, :visible, :email_address, :hash, :logo,
|
||||
:promo_image, :path, :category, :active, :producers, :orders_close_at, :hubs,
|
||||
:taxons, :supplied_taxons, :pickup, :delivery, :preferred_product_low_stock_display,
|
||||
:hide_ofn_navigation
|
||||
:hide_ofn_navigation, :white_label_logo, :white_label_logo_link
|
||||
|
||||
has_one :address, serializer: Api::AddressSerializer
|
||||
has_many :supplied_properties, serializer: Api::PropertySerializer
|
||||
@@ -49,6 +49,10 @@ module Api
|
||||
enterprise.promo_image_url(:large)
|
||||
end
|
||||
|
||||
def white_label_logo
|
||||
enterprise.white_label_logo_url
|
||||
end
|
||||
|
||||
def path
|
||||
enterprise_shop_path(enterprise)
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
module Api
|
||||
class EnterpriseThinSerializer < ActiveModel::Serializer
|
||||
attributes :name, :id, :active, :path
|
||||
attributes :name, :id, :active, :path, :visible
|
||||
|
||||
has_one :address, serializer: Api::AddressSerializer
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ class MailConfiguration
|
||||
secure_connection_type: ENV.fetch('MAIL_SECURE_CONNECTION', 'None'),
|
||||
mails_from: ENV.fetch('MAILS_FROM', "no-reply@#{ENV.fetch('MAIL_DOMAIN')}"),
|
||||
mail_bcc: ENV.fetch('MAIL_BCC', ''),
|
||||
intercept_email: ''
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -31,9 +31,7 @@ module Permissions
|
||||
end
|
||||
|
||||
def visible_line_items
|
||||
Spree::LineItem.where(id:
|
||||
editable_line_items.select(:id) |
|
||||
produced_line_items.select("spree_line_items.id"))
|
||||
editable_line_items.or(produced_line_items)
|
||||
end
|
||||
|
||||
# Any line items that I can edit
|
||||
|
||||
@@ -35,7 +35,7 @@ module PermittedAttributes
|
||||
:show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method,
|
||||
:preferred_invoice_order_by_supplier,
|
||||
:preferred_product_low_stock_display,
|
||||
:hide_ofn_navigation
|
||||
:hide_ofn_navigation, :white_label_logo, :white_label_logo_link
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,15 @@ class VariantDeleter
|
||||
variant.destroy
|
||||
end
|
||||
|
||||
def destroy_related_outgoing_variants(variant_id, order_cycle)
|
||||
internal_variants = ExchangeVariant.where(variant_id: variant_id).
|
||||
joins(:exchange).
|
||||
where(
|
||||
exchanges: { order_cycle: order_cycle, incoming: false }
|
||||
)
|
||||
internal_variants.destroy_all
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def only_variant_on_product?(variant)
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
- @preference_sections.each do |preference_section|
|
||||
= render 'fieldset', name: preference_section[:name], preferences: preference_section[:preferences]
|
||||
|
||||
.form-buttons.filter-actions.actions{"data-hook" => "buttons"}
|
||||
.form-buttons.filter-actions.actions
|
||||
= button t(:update), 'icon-refresh'
|
||||
= link_to_with_icon 'icon-remove', t(:cancel), main_app.edit_admin_contents_path, class: 'button'
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
%col{style: "width: 18%;"}/
|
||||
%col{style: "width: 25%;"}/
|
||||
%thead
|
||||
%tr{"data-hook" => "enterprises_header"}
|
||||
%tr
|
||||
%th= t('.name')
|
||||
%th= t('.role')
|
||||
- if spree_current_user.admin?
|
||||
@@ -32,7 +32,7 @@
|
||||
%td= enterprise_form.check_box :visible, {}, 'public', 'hidden'
|
||||
- if spree_current_user.admin?
|
||||
%td= enterprise_form.select :owner_id, enterprise.users.map{ |e| [ e.email, e.id ] }, {}, class: "select2 fullwidth"
|
||||
%td{"data-hook" => "admin_users_index_row_actions"}
|
||||
%td
|
||||
= render 'actions', enterprise: enterprise
|
||||
- if @enterprises.empty?
|
||||
%tr
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
%div#add_manager_modal
|
||||
%form{ "data-reflex": "submit->InviteManager#invite", "data-reflex-serialize-form": true }
|
||||
.margin-bottom-30.text-center
|
||||
.text-big
|
||||
= t('js.admin.modals.invite_title')
|
||||
%form#add_manager_modal{ 'data-reflex': 'submit->InviteManager#invite', 'data-reflex-serialize-form': true }
|
||||
.margin-bottom-30.text-center
|
||||
.text-big
|
||||
= t('js.admin.modals.invite_title')
|
||||
|
||||
- if success
|
||||
%p.alert-box.ok= t('user_invited', email: email)
|
||||
|
||||
- if error
|
||||
%p.alert-box.error= error
|
||||
|
||||
= text_field_tag :email, nil, class: 'fullwidth margin-bottom-20'
|
||||
= hidden_field_tag :enterprise_id, @enterprise&.id || enterprise.id
|
||||
|
||||
.modal-actions
|
||||
- if success
|
||||
%p.alert-box.ok= t('user_invited', email: email)
|
||||
|
||||
- if error
|
||||
%p.alert-box.error= error
|
||||
|
||||
= text_field_tag :email, nil, class: 'fullwidth margin-bottom-20'
|
||||
= hidden_field_tag :enterprise_id, @enterprise&.id || enterprise.id
|
||||
|
||||
.modal-actions
|
||||
- if success
|
||||
%input{ class: "button icon-plus secondary", type: 'button', value: t('js.admin.modals.close'), "data-action": "click->help-modal#close" }
|
||||
- else
|
||||
%input{ class: "button icon-plus secondary", type: 'button', value: t('js.admin.modals.cancel'), "data-action": "click->help-modal#close" }
|
||||
= submit_tag "#{t('js.admin.modals.invite')}"
|
||||
|
||||
%input{ class: "button icon-plus secondary", type: 'button', value: t('js.admin.modals.close'), "data-action": "click->help-modal#close" }
|
||||
- else
|
||||
%input{ class: "button icon-plus secondary", type: 'button', value: t('js.admin.modals.cancel'), "data-action": "click->help-modal#close" }
|
||||
= submit_tag "#{t('js.admin.modals.invite')}"
|
||||
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
- @object ||= enterprise
|
||||
|
||||
.row
|
||||
.three.columns.alpha
|
||||
= f.label :hide_ofn_navigation, t('.hide_ofn_navigation')
|
||||
.three.columns
|
||||
= f.check_box :hide_ofn_navigation
|
||||
= f.check_box :hide_ofn_navigation, { "data-controller": "checkbox-display", "data-checkbox-display-target-id-value": "white_label_logo" }
|
||||
|
||||
%div{id: "white_label_logo"}
|
||||
.row
|
||||
.three.columns.alpha
|
||||
= f.label :white_label_logo, t('.upload_logo')
|
||||
.three.columns
|
||||
= image_tag @object.white_label_logo_url if @object.white_label_logo.present?
|
||||
= f.file_field :white_label_logo, accept: "image/*"
|
||||
- if @object.white_label_logo.present?
|
||||
%button.button.small{ type: "button", "data-controller": "modal-link", "data-action": "click->modal-link#open", "data-modal-link-target-value": "remove_logo" }
|
||||
= t('.remove_logo')
|
||||
|
||||
- if @object.white_label_logo.present?
|
||||
.row
|
||||
.three.columns.alpha
|
||||
= f.label :white_label_logo_link, t('.white_label_logo_link_label')
|
||||
.three.columns
|
||||
= f.text_field :white_label_logo_link
|
||||
|
||||
|
||||
- if @object.white_label_logo.present?
|
||||
= render ConfirmModalComponent.new(id: "remove_logo", confirm_reflexes: "click->WhiteLabel#remove_logo" ) do
|
||||
.margin-bottom-30
|
||||
= t('.remove_logo_confirm')
|
||||
|
||||
@@ -20,5 +20,5 @@
|
||||
= check_box_tag 'preferences[enterprise_number_required_on_invoices?]', '1', Spree::Config[:enterprise_number_required_on_invoices?]
|
||||
= label_tag nil, t('.enterprise_number_required_on_invoices?')
|
||||
|
||||
.form-buttons{"data-hook" => "buttons"}
|
||||
.form-buttons
|
||||
= button t(:update), 'icon-refresh'
|
||||
|
||||
@@ -23,5 +23,5 @@
|
||||
= preference_field_tag("preferences[#{:matomo_tag_manager_url}]", Spree::Config[:matomo_tag_manager_url], type: Spree::Config.preference_type(:matomo_tag_manager_url))
|
||||
.warning.note= t('.config_instructions_tag_manager_html')
|
||||
|
||||
.form-buttons{"data-hook" => "buttons"}
|
||||
.form-buttons
|
||||
= button t(:update), 'icon-refresh'
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
%fieldset.no-border-top
|
||||
.add_producer_properties{"data-hook" => "add_producer_properties"}
|
||||
.add_producer_properties
|
||||
= image_pack_tag 'spinner.gif', :plugin => 'spree', :style => 'display:none;', :id => 'busy_indicator'
|
||||
%table.index.sortable{"data-hook" => "", "data-sortable-link" => main_app.update_positions_admin_enterprise_producer_properties_url(@enterprise)}
|
||||
%table.index.sortable{"data-sortable-link" => main_app.update_positions_admin_enterprise_producer_properties_url(@enterprise)}
|
||||
%thead
|
||||
%tr{"data-hook" => "producer_properties_header"}
|
||||
%tr
|
||||
%th{colspan: "2"}= t('admin.products.properties.property_name')
|
||||
%th= t('admin.description')
|
||||
%th.actions
|
||||
%tbody#producer_properties{"data-hook" => ""}
|
||||
%tbody#producer_properties
|
||||
= f.fields_for :producer_properties do |pp_form|
|
||||
= render 'admin/producer_properties/producer_property_fields', f: pp_form
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-# admin/admin.js.erb in spree requires id to start with "spree_" for sortable tables
|
||||
%tr.product_property.fields{"data-hook" => "producer_property", id: "spree_#{dom_id(f.object)}"}
|
||||
%tr.product_property.fields{id: "spree_#{dom_id(f.object)}"}
|
||||
%td.no-border
|
||||
%span.handle
|
||||
= f.hidden_field :id
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
.report__header.print-hidden
|
||||
- if @report.message.present?
|
||||
%p.report__message= @report.message
|
||||
- if request.post?
|
||||
- if request.post? && !@error
|
||||
%button.btn-print.icon-print{ onclick: "window.print()"}= t(:report_print)
|
||||
|
||||
= t(@error, link: link_to(t(".report_link_label"), @error_url)) if @error
|
||||
= @table
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
- content_for :sub_menu do
|
||||
%ul#sub_nav.inline-menu{"data-hook" => "admin_enterprise_sub_tabs"}
|
||||
%ul#sub_nav.inline-menu
|
||||
= tab :enterprises, url: main_app.admin_enterprises_path
|
||||
= tab :enterprise_relationships, url: main_app.admin_enterprise_relationships_path
|
||||
- if ENV["OPENID_APP_ID"].present? && ENV["OPENID_APP_SECRET"].present?
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user