Compare commits

..

146 Commits

Author SHA1 Message Date
Maikel Linke
fddb76f002 Merge branch 'active-storage' into HEAD
Creating a seperate release off the master branch.
2022-06-08 12:05:56 +10:00
Maikel Linke
3e3fc4a5a2 Update translations 2022-06-03 10:43:36 +10:00
Filipe
4a2fd10bdb Merge pull request #9237 from mgrigoriev8109/bug/update-tracking-font
Fix shipped email tracking information font size
2022-06-02 18:37:27 +01:00
Filipe
1a2c1d004c Merge pull request #9239 from kvaithin/9233-spacing-between-btns
Add spacing between coordinator dropdown and continue button
2022-06-02 18:35:08 +01:00
Filipe
6ff2d4a9d5 Merge pull request #9109 from apricot12/8917-Link-to-enterprise-site
Adding a link to enterprise's own site from Order confirmation page.
2022-06-02 17:59:03 +01:00
Filipe
b3d81154e6 Merge pull request #9174 from georgethoppil/nan-items-subscription
Updating order cycle will ensure any $NaN subscription item prices to be recalculated
2022-06-02 17:28:54 +01:00
Filipe
4a15ed9b39 Merge pull request #9190 from georgethoppil/duplicate-transaction-fees
Destroy all adjustments on cart empty
2022-06-02 11:36:27 +01:00
jibees
1d8b8c3be8 Merge pull request #9253 from jibees/fix-deployment
add `@babel/preset` dependency
2022-06-02 10:42:18 +02:00
Jean-Baptiste Bellet
454a4e3435 add @babel/preset dependency
Add to dependencies (not dev ones)
2022-06-02 10:07:43 +02:00
Maikel Linke
076efd653d Correct checksum of big files stored on AWS S3 2022-06-02 12:28:52 +10:00
Maikel Linke
4facab0335 Guard against invariable file types
Australian production had one JPG image which was not recognised as
such. The `content_type` was missing and trying to generate a URL for a
variant raised an error and crashed the page.

Testing for `variable?` includes testing for `attached?` and is more
defensive.
2022-06-01 17:16:55 +10:00
Maikel Linke
bea080a9b1 Remove Paperclip
It has been replaced by Active Storage.
2022-06-01 17:16:55 +10:00
Maikel Linke
86731d7e30 Remove compatibility code for migrating files
The migration should be complete now.
2022-06-01 17:16:55 +10:00
Maikel Linke
b7efa1b018 Replace Paperclip on Spree::Image 2022-06-01 17:16:55 +10:00
Maikel Linke
4a0ed99919 Replace Paperclip on Enterprise model
We configured Paperclip to convert images to JPG in some cases but I
omitted that here because we don't need it. If an image is better
represented as PNG or another format then the user should be able to
choose that.

Some specs were also testing the generated URL but the Active Storage
URL doesn't contain a style name anymore and it's not helpful to test
the URL.
2022-06-01 17:16:55 +10:00
Maikel Linke
45995ac984 Replace Paperclip on EnterpriseGroup 2022-06-01 17:16:55 +10:00
Maikel Linke
421ffae78c Replace Paperclip on TermsOfServeFile 2022-06-01 17:16:54 +10:00
Maikel Linke
f29e569f1b Remove Paperclip migration code 2022-06-01 17:16:54 +10:00
Maikel Linke
727eef3c4f Replace Paperclippable ContentConfig
The old Paperclip configuration was very clever and easy to use but it
was also a complicated implementation building on the complicated Spree
preference system.

I simplified this with Active Storage, storing simple references to blob
ids and default URLs as backup.
2022-06-01 17:16:54 +10:00
jibees
ddd9ae6ce2 Merge pull request #9208 from openfoodfoundation/transifex
Transifex
2022-06-01 08:06:35 +02:00
Transifex-Openfoodnetwork
fd1cd4a28a Updating translations for config/locales/fr_CA.yml 2022-06-01 09:51:26 +10:00
Transifex-Openfoodnetwork
9261d7b8fe Updating translations for config/locales/en_CA.yml 2022-06-01 09:30:59 +10:00
Mikhail Grigoriev
b169f1baf1 Fix shipped email's tracking information font size using p.lead 2022-05-31 14:39:02 -04:00
Maikel Linke
2e05210596 Preview shipping emails with tracking if present 2022-05-31 14:36:28 -04:00
Maikel
8645277a05 Merge pull request #9204 from AgriculturaFamiliar/8755-fix-search-input
Select all text upon focus on map search input for Google Maps
2022-05-31 10:57:02 +10:00
Maikel
f3d9b3d7ed Merge pull request #9157 from jibees/SC-sort-shipping-methods-case-insenstive
Split Checkout: Sort shipping methods case insensitive
2022-05-31 10:54:43 +10:00
jibees
c22c1ddf32 Merge pull request #9243 from openfoodfoundation/dependabot/npm_and_yarn/storybook/addon-controls-6.5.6
Bump @storybook/addon-controls from 6.4.22 to 6.5.6
2022-05-30 17:41:12 +02:00
jibees
97f0d76fcd Merge pull request #9244 from openfoodfoundation/dependabot/npm_and_yarn/storybook/server-6.5.6
Bump @storybook/server from 6.4.22 to 6.5.6
2022-05-30 17:41:01 +02:00
dependabot[bot]
d70acb57b6 Bump @storybook/addon-controls from 6.4.22 to 6.5.6
Bumps [@storybook/addon-controls](https://github.com/storybookjs/storybook/tree/HEAD/addons/controls) from 6.4.22 to 6.5.6.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.6/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.6/addons/controls)

---
updated-dependencies:
- dependency-name: "@storybook/addon-controls"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-30 15:18:10 +00:00
dependabot[bot]
ab52028d1c Bump @storybook/server from 6.4.22 to 6.5.6
Bumps [@storybook/server](https://github.com/storybookjs/storybook/tree/HEAD/app/server) from 6.4.22 to 6.5.6.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.6/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.6/app/server)

---
updated-dependencies:
- dependency-name: "@storybook/server"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-30 15:17:03 +00:00
jibees
0544baa75c Merge pull request #9245 from openfoodfoundation/dependabot/npm_and_yarn/storybook/addon-docs-6.5.6
Bump @storybook/addon-docs from 6.4.22 to 6.5.6
2022-05-30 17:16:01 +02:00
dependabot[bot]
acda515c8a Bump @storybook/addon-docs from 6.4.22 to 6.5.6
Bumps [@storybook/addon-docs](https://github.com/storybookjs/storybook/tree/HEAD/addons/docs) from 6.4.22 to 6.5.6.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.6/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.6/addons/docs)

---
updated-dependencies:
- dependency-name: "@storybook/addon-docs"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-30 09:05:55 +00:00
kvaithin
ad0effc565 spacing between co ordinator dropdown and continue btn 2022-05-28 11:13:16 +01:00
Maikel
b7cf397e15 Merge pull request #9227 from lin-d-hop/master
[Draft] Restore previous functionality for grouping product totals in Orders and Fulfilment reports
2022-05-26 10:18:11 +10:00
lin-d-hop
fb2279d26d Draft PR with potential fix to the reports S1. Untested. 2022-05-25 22:08:05 +01:00
Rachel Arnould
cb6cb05eca Merge pull request #9192 from jibees/9127-distinct-line-items-with-different-price
For all `orders_and_fulfillment` reports, distinct product by `variant`, `price` & `order_id`
2022-05-25 12:44:22 +02:00
Rachel Arnould
d0acd47935 Merge pull request #9219 from jibees/add-order-date-range-to-packing-reports
Add order date range to packing reports
2022-05-25 12:43:59 +02:00
Jean-Baptiste Bellet
e32797d2fd Do not group by order 2022-05-25 11:42:06 +02:00
Jean-Baptiste Bellet
f34b68a6e3 Add order date range to packing reports 2022-05-25 10:28:38 +02:00
jibees
f914a37a28 Merge pull request #9211 from openfoodfoundation/revert-9151-9140-fill-all-the-input-when-selecting-a-customer
Revert "When creating an order, and assigning a customer, fill all the customer inputs in the shipping/billing address form"
2022-05-24 10:35:46 +02:00
jibees
641df45fcd Revert "When creating an order, and assigning a customer, fill all the customer inputs in the shipping/billing address form" 2022-05-24 09:50:18 +02:00
georgethoppil
ec7d4b7c21 Restart checkout flow on cart empty if state of checkout is payment 2022-05-23 11:41:10 -04:00
Transifex-Openfoodnetwork
94f87b3bd7 Updating translations for config/locales/de_DE.yml 2022-05-23 22:33:33 +10:00
Maikel
a3d996d5f5 Merge pull request #9197 from openfoodfoundation/dependabot/npm_and_yarn/tom-select-2.0.3
Bump tom-select from 2.0.2 to 2.0.3
2022-05-23 16:47:13 +10:00
Diego de Araújo Martinez Camarinha
8a62d95c48 Select all text upon focus on map search input for Google Maps
On the map page, when we search a location and than want to search for
another, we would have to delete letter by letter of the previous search
text.

Now, when we click on the search input to type another search text, the
previous text will be all selected and we can remove everything with
just hitting the backspace once
2022-05-20 11:06:34 -03:00
Jean-Baptiste Bellet
7b2da4dbe4 Update all locales with the latest Transifex translations 2022-05-20 14:41:34 +02:00
jibees
0bb523c399 Merge pull request #9201 from openfoodfoundation/transifex
Transifex
2022-05-20 14:38:28 +02:00
Transifex-Openfoodnetwork
ca3c896b2e Updating translations for config/locales/nb.yml 2022-05-20 21:16:32 +10:00
Transifex-Openfoodnetwork
34286a8f8d Updating translations for config/locales/en_GB.yml 2022-05-20 21:13:33 +10:00
dependabot[bot]
533acda922 Bump tom-select from 2.0.2 to 2.0.3
Bumps [tom-select](https://github.com/orchidjs/tom-select) from 2.0.2 to 2.0.3.
- [Release notes](https://github.com/orchidjs/tom-select/releases)
- [Commits](https://github.com/orchidjs/tom-select/compare/v2.0.2...v2.0.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-20 09:05:25 +00:00
Jean-Baptiste Bellet
be88b95e8c orders_and_fulfillment reports, distinct product by variant & price 2022-05-19 10:42:53 +02:00
Maikel Linke
f4c7f24cce Remove old config option comment 2022-05-19 10:03:16 +10:00
Rachel Arnould
8779ef6b77 Merge pull request #9187 from jibees/9052-add-phone-number-to-alternative-invoice
Add phone number and email address to alternative invoice
2022-05-18 18:59:04 +02:00
Rachel Arnould
5dfc3c7a62 Merge pull request #9151 from jibees/9140-fill-all-the-input-when-selecting-a-customer
When creating an order, and assigning a customer, fill all the customer inputs in the shipping/billing address form
2022-05-18 17:41:59 +02:00
Rachel Arnould
9873380b94 Merge pull request #9185 from jibees/9184-remove-json-download-option-from-reports
Reports: Remove JSON as a download option
2022-05-18 10:11:33 +02:00
georgethoppil
a37f54e4b3 Find subscriptions in schedule to recalculate nil estimate price 2022-05-17 20:58:25 -04:00
georgethoppil
03b24bfc38 Destroy all adjustments on cart empty 2022-05-17 20:21:47 -04:00
Jean-Baptiste Bellet
cf687864cc Update specs to check on both invoice models presence of phone and email 2022-05-17 13:58:05 +02:00
Jean-Baptiste Bellet
d28545a7b2 Display both phone number and email to the alternative invoice 2022-05-17 12:10:41 +02:00
Jean-Baptiste Bellet
0b71f7298e Remove JSON as a download option 2022-05-17 10:47:19 +02:00
Maikel
9992f9c83b Merge pull request #9150 from mkllnk/active-storage-fix
Correct checksum in Paperclip migration task
2022-05-17 16:14:03 +10:00
jibees
f09b719af6 Merge pull request #9182 from openfoodfoundation/transifex
Transifex
2022-05-16 15:52:18 +02:00
Transifex-Openfoodnetwork
6b3ffddb74 Updating translations for config/locales/en_FR.yml 2022-05-16 20:35:31 +10:00
Transifex-Openfoodnetwork
0c7f962bf0 Updating translations for config/locales/fr.yml 2022-05-16 20:33:35 +10:00
Rachel Arnould
0f618dfbf9 Merge pull request #9032 from seballot/reports-improvement
Reports improvement
2022-05-16 10:29:28 +02:00
jibees
513b26f47c Merge pull request #9176 from openfoodfoundation/transifex
Transifex
2022-05-13 15:39:53 +02:00
jibees
2e3023eacc Merge pull request #9181 from openfoodfoundation/dependabot/npm_and_yarn/karma-6.3.20
Bump karma from 6.3.19 to 6.3.20
2022-05-13 15:38:29 +02:00
dependabot[bot]
2eeeb74374 Bump karma from 6.3.19 to 6.3.20
Bumps [karma](https://github.com/karma-runner/karma) from 6.3.19 to 6.3.20.
- [Release notes](https://github.com/karma-runner/karma/releases)
- [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma/compare/v6.3.19...v6.3.20)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-13 09:04:39 +00:00
Sebastian Castro
1be3b508bf Reports restore original results ordering 2022-05-12 16:54:14 +02:00
Sebastian Castro
294f7c2fb5 Reports restore original columns ordering 2022-05-12 16:54:14 +02:00
Sebastian Castro
89212736e9 Reports fix formatting cells 2022-05-12 16:54:14 +02:00
Sebastian Castro
35b5ca3a51 Csv Report: translate headers 2022-05-12 16:54:14 +02:00
Sebastian Castro
56fab26235 Reports: refactor to easily provide default_params 2022-05-12 16:54:14 +02:00
Sebastian Castro
b7991e5ae8 Packing Report: use field name as columns headers in spreadsheet export 2022-05-12 16:54:14 +02:00
Sebastian Castro
2008c10c6f Reports: use field name as header instead of translated value for raw renders (csv, json) 2022-05-12 16:54:14 +02:00
Sebastian Castro
0218f75f34 Packing Report: hide by default phone and price column to avoid breaking changes 2022-05-12 16:54:14 +02:00
Sebastian Castro
0545c9de28 Packing Report: revert column order change 2022-05-12 16:54:14 +02:00
Sebastian Castro
b54ec4354a Report TaxRate fix 2022-05-12 16:54:14 +02:00
Sebastian Castro
767afe1fba Reports Renderer: whitelist report formats 2022-05-12 16:54:14 +02:00
Sebastian Castro
2dd31d970e Reports Format cells: format some reports 2022-05-12 16:54:14 +02:00
Sebastian Castro
8a943f50ef Reports: Format cells for html, pdf, and spreadsheet
Currency, number format, dates
2022-05-12 16:54:14 +02:00
Sebastian Castro
3b01c44eae Reports: Improve Exports
Improve PDF style and encoding
Include header_row and summary_row, except for CSV and JSON
Style spreadsheets
Use only Xlsx no more Ods format
2022-05-12 16:54:14 +02:00
Sebastian Castro
5105ea345f Reports Refactor 4: Final Touch
Split report_template
Clean code
Adds spec
2022-05-12 16:54:14 +02:00
Sebastian Castro
b259f59d1e Packing Report: Adds new subreport "Pack by product" 2022-05-12 16:54:14 +02:00
Sebastian Castro
eeb525aedb Reports: Ability to hide columns 2022-05-12 16:54:14 +02:00
Sebastian Castro
9874c7996e Reports: Adds Print Button 2022-05-12 16:54:14 +02:00
Sebastian Castro
c7c5965eb5 Report Refactor 3 Clean
No longer need to handle old report class
Remove no longer used OrderGrouper service


sq
2022-05-12 16:54:14 +02:00
Sebastian Castro
cd30012334 Report Refactor 3: Xero Invoices
This one as actually not really been refactored, too much work to rewrite it so I just encapsulated the result within the new methods definitions
2022-05-12 16:54:14 +02:00
Sebastian Castro
42da443901 Report Refactor 3: Enterprise FeeSummary
This one as actually not really been refactored, too much work to rewrite it so I just encapsulated the result within the new methods definitions
2022-05-12 16:54:14 +02:00
Sebastian Castro
b3e1ffe9e2 Report Refactor 3: Products & Inventory 2022-05-12 16:54:14 +02:00
Sebastian Castro
71aca960ee Report Refactor 3: Order Cycle Management 2022-05-12 16:54:13 +02:00
Sebastian Castro
3808398807 Report Refactor 3: Payments 2022-05-12 16:54:13 +02:00
Sebastian Castro
93751f9ccb Report Refactor 3: Customers 2022-05-12 16:54:13 +02:00
Sebastian Castro
944d40e093 Report Refactor 3: BulkCoop 2022-05-12 16:54:13 +02:00
Sebastian Castro
22fe652e89 Report Refactor 3: Orders & Distributors 2022-05-12 16:54:13 +02:00
Sebastian Castro
7a9ed7a73c Report Refactor 3: Order & Fulfilment 2022-05-12 16:54:13 +02:00
Sebastian Castro
b25192c31d Report Refactor 3: Sales Tax 2022-05-12 16:54:13 +02:00
Sebastian Castro
529858946f Report Refactor 3: Packing
Stop using SQL for grouping, so we can use same grouping code than for other reports

Fix query builder default grouping_fields
2022-05-12 16:54:13 +02:00
Sebastian Castro
88bc417868 Report Refactor 3: User & Entreprises 2022-05-12 16:54:13 +02:00
Sebastian Castro
287e8f5845 Reports Refactor 3
Easily group and create header and summary row
Auto format cells when appropriate type (boolean, dates) and render_format (neither csv nor json)
2022-05-12 16:54:13 +02:00
Sebastian Castro
caccbb698b Reports Refactor 2: Fix linting 2022-05-12 16:54:13 +02:00
Sebastian Castro
452a3fa933 Reports Refactor 2: Merge Spree::reports into Admin::Reports 2022-05-12 16:54:13 +02:00
Sebastian Castro
288a35f062 Reports Refactor 2: New templates abstract classes 2022-05-12 16:54:13 +02:00
Sebastian Castro
5f78fdce8b Reports Refactor 2: Move all code to lib/reporting 2022-05-12 16:54:13 +02:00
Sebastian Castro
392166b57a Reports Refactor 2: Simplify render_content? method 2022-05-12 16:54:13 +02:00
Sebastian Castro
2985d2af15 Report Refactor 1 Cleaning
clean no longer used methods
Remove no longer needed require
Delete files not used
Fix Linting
2022-05-12 16:54:13 +02:00
Sebastian Castro
e9513f6172 Report Refactor 1: Enterprise Fee Summary
Disable enterprise fee summary spec for now

Will need to write them again
2022-05-12 16:54:13 +02:00
Sebastian Castro
4a99a7d1de Report Refactor 1: Xero Invoices 2022-05-12 16:54:13 +02:00
Sebastian Castro
41c11baa3f Report Refactor 1: Users & Entreprises 2022-05-12 16:54:13 +02:00
Sebastian Castro
3d1b61ae6e Report Refactor 1: Products & Inventory 2022-05-12 16:54:13 +02:00
Sebastian Castro
881a708ecf Report Refactor 1: Payments 2022-05-12 16:54:13 +02:00
Sebastian Castro
9d943625a3 Report Refactor 1: Sales Tax 2022-05-12 16:54:13 +02:00
Sebastian Castro
e20c2e3ced Report Refactor 1: Orders & Distributors 2022-05-12 16:54:13 +02:00
Sebastian Castro
01be6fb1f3 Report Refactor 1: Order Cycle Management 2022-05-12 16:54:13 +02:00
Sebastian Castro
1fee45035c Report Refactor 1: Customers 2022-05-12 16:54:12 +02:00
Sebastian Castro
e55462d18b Report Refactor 1: Orders & Fulfilment 2022-05-12 16:54:12 +02:00
Sebastian Castro
09247b21cd Reports Refactor 1
Use code closer to the new packing report controller
Handle nil @report_subtypes
2022-05-12 16:54:12 +02:00
Sebastian Castro
209b56ffd7 Packing Report: Better print 2022-05-12 16:54:12 +02:00
Sebastian Castro
cbb6bd63d4 Print: load css, hide navbar 2022-05-12 16:54:12 +02:00
Sebastian Castro
213c0dd060 Packing Report: add price and reorder columns
Adds price column
last_name column first because it's used for ordering
2022-05-12 16:54:12 +02:00
Sebastian Castro
d53d38906a Packing Report: Refactor view to be reusable by other reports
For now this view is used only in the context of packing, but later we would move all existing rpeort to use same view
2022-05-12 16:54:12 +02:00
Sebastian Castro
1ff98a1d8a Reports: Improve UI 2022-05-12 16:54:12 +02:00
Transifex-Openfoodnetwork
f012559ca8 Updating translations for config/locales/cy.yml 2022-05-12 21:06:24 +10:00
Maikel Linke
aafa416b9c Transifex update 2022-05-12 12:22:36 +10:00
Maikel
cae032a224 Merge pull request #9162 from openfoodfoundation/transifex
Transifex
2022-05-12 12:18:52 +10:00
Maikel Linke
94d8ada362 Use checksum of *original* image in Paperclip migration 2022-05-12 12:13:12 +10:00
Maikel Linke
92677385fa Correct checksum in Paperclip migration task
Active Storage needs a checksum for each file and AWS S3 provides this
checksum as "ETag". They are both MD5 but AWS stores it as hexdigest and
Active Storage as base64digest. We need to convert it from on to the
other to get a valid checksum for Active Storage.

Where the migration task has already run (only staging servers), delete all
Active Storage data first and then run the task again:

  bundle exec rake db:migrate:down VERSION=20220316055458
  bundle exec rake db:migrate

  bundle exec rake from_paperclip_to_active_storage:copy_content_config
  bundle exec rake from_paperclip_to_active_storage:migrate
2022-05-12 12:13:12 +10:00
Transifex-Openfoodnetwork
372939b260 Updating translations for config/locales/nb.yml 2022-05-12 11:26:47 +10:00
Transifex-Openfoodnetwork
8945d0cc33 Updating translations for config/locales/en_FR.yml 2022-05-12 11:23:43 +10:00
Transifex-Openfoodnetwork
8b05fb2210 Updating translations for config/locales/en_GB.yml 2022-05-12 11:23:40 +10:00
Maikel
c00a35b5a4 Merge pull request #9173 from jibees/9172-change-i18n-key-from-delivery-address-to-shipping-info
Split Checkout: Change i18n key on first step from delivery address to shipping info
2022-05-12 10:36:18 +10:00
georgethoppil
86a3f91ca2 When order cycle open/close times are updated, check to see if any subscription has line items that have price estimate as nil. Recalculate the price and save the column 2022-05-11 13:54:43 -04:00
georgethoppil
6a9fcbdd0c Adding a scope on subscription_line_item.rb to select records where price estimate is nil 2022-05-11 13:45:13 -04:00
Transifex-Openfoodnetwork
38d6b5d452 Updating translations for config/locales/ru.yml 2022-05-12 00:17:55 +10:00
Filipe
6141641c23 Merge pull request #9164 from jibees/9143-add-order-token-when-checkout-is-complete
Add `order_token` params to the redirect URL after checkout
2022-05-11 13:50:48 +01:00
Jean-Baptiste Bellet
d942adcdd0 Change i18n key on first step
Delivery address --> shipping info
2022-05-11 10:11:51 +02:00
Maikel
bfc3e385ba Merge pull request #9163 from openfoodfoundation/dependabot/npm_and_yarn/tom-select-2.0.2
Bump tom-select from 2.0.1 to 2.0.2
2022-05-11 14:02:25 +10:00
Nihal Mohammed
f5ecc6ffe4 Change gap between columns to fit new button 2022-05-09 23:29:40 +05:30
Jean-Baptiste Bellet
61f8dfd809 Add order_token params to the redirect URL after checkout 2022-05-09 17:45:52 +02:00
dependabot[bot]
51db3d5997 Bump tom-select from 2.0.1 to 2.0.2
Bumps [tom-select](https://github.com/orchidjs/tom-select) from 2.0.1 to 2.0.2.
- [Release notes](https://github.com/orchidjs/tom-select/releases)
- [Commits](https://github.com/orchidjs/tom-select/compare/v2.0.1...v2.0.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-09 09:56:35 +00:00
Jean-Baptiste Bellet
9c231a831d Replace Angular directive and use stimulus controller
+ Update specs as well
2022-05-05 14:53:32 +02:00
Jean-Baptiste Bellet
f2ac888f2c Sort shipping methods case insensitive 2022-05-05 14:37:27 +02:00
Jean-Baptiste Bellet
c98d669b92 Create a SelectCustomer controller
To be used in `/admin/orders/ORDER_ID/customer` page

 - Fetch `/admin/search/customers.json?` with query as params
 - Render each items response thanks to `renderOption()` method
 - `onItemSelect()` is here to fill the associated form in the page
2022-05-02 13:36:49 +02:00
Jean-Baptiste Bellet
11b224f805 Prepare tom-select controller to inherit others controllers 2022-05-02 13:33:57 +02:00
Jean-Baptiste Bellet
d7df714280 Formatting file 2022-04-29 10:36:53 +02:00
Nihal Mohammed
af58ba523c Renamed groups_helper to link_helper and removed strip_url method, as well as updated specs and ApplicationHelper. Added "Back To Website" button and i18n. 2022-04-26 01:38:25 +05:30
381 changed files with 9254 additions and 10652 deletions

7
.env
View File

@@ -61,10 +61,3 @@ SMTP_PASSWORD="f00d"
# STRIPE_INSTANCE_PUBLISHABLE_KEY="pk_test_xxxx" # This can be a test key or a live key
# STRIPE_CLIENT_ID="ca_xxxx" # This can be a development ID or a production ID
# STRIPE_ENDPOINT_SECRET="whsec_xxxx"
# Feature toggles
#
# Adding user emails separated by commas will enable them the use of certain features. See
# config/initializers/feature_toggles.rb for details.
#
# BETA_TESTERS="ofn@example.com,superadmin@example.com"

View File

@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400`
# on 2022-02-25 01:04:47 UTC using RuboCop version 1.22.2.
# on 2022-03-29 16:07:39 UTC using RuboCop version 1.22.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
@@ -53,7 +53,7 @@ Layout/LeadingCommentSpace:
Exclude:
- 'spec/system/admin/enterprises_spec.rb'
# Offense count: 828
# Offense count: 856
# Cop supports --auto-correct.
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
@@ -108,7 +108,6 @@ Layout/LineLength:
- 'app/services/order_syncer.rb'
- 'app/services/products_renderer.rb'
- 'app/services/variant_units/variant_and_line_item_naming.rb'
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
- 'engines/order_management/app/services/order_management/subscriptions/validator.rb'
- 'engines/order_management/spec/services/order_management/order/updater_spec.rb'
- 'engines/web/app/helpers/web/cookies_policy_helper.rb'
@@ -117,15 +116,19 @@ Layout/LineLength:
- 'lib/open_food_network/enterprise_fee_applicator.rb'
- 'lib/open_food_network/enterprise_fee_calculator.rb'
- 'lib/open_food_network/enterprise_issue_validator.rb'
- 'lib/open_food_network/lettuce_share_report.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/open_food_network/order_cycle_management_report.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/open_food_network/payments_report.rb'
- 'lib/open_food_network/reports/line_items.rb'
- 'lib/open_food_network/sales_tax_report.rb'
- 'lib/open_food_network/scope_variants_for_search.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'lib/reporting/line_items.rb'
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/reporting/reports/enterprise_fee_summary/report_data/enterprise_fee_type_total.rb'
- 'lib/reporting/reports/order_cycle_management/order_cycle_management_report.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/reporting/reports/orders_and_fulfillment/customer_totals_report.rb'
- 'lib/reporting/reports/orders_and_fulfillment/distributor_totals_by_supplier_report.rb'
- 'lib/reporting/reports/payments/payments_report.rb'
- 'lib/reporting/reports/products_and_inventory/lettuce_share_report.rb'
- 'lib/reporting/reports/sales_tax/sales_tax_report.rb'
- 'lib/reporting/reports/xero_invoices/base.rb'
- 'lib/spree/localized_number.rb'
- 'lib/tasks/data.rake'
- 'lib/tasks/enterprises.rake'
@@ -176,19 +179,20 @@ Layout/LineLength:
- 'spec/helpers/spree/admin/base_helper_spec.rb'
- 'spec/jobs/subscription_confirm_job_spec.rb'
- 'spec/jobs/subscription_placement_job_spec.rb'
- 'spec/lib/open_food_network/customers_report_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
- 'spec/lib/open_food_network/order_cycle_management_report_spec.rb'
- 'spec/lib/open_food_network/order_cycle_permissions_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/lib/open_food_network/permissions_spec.rb'
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
- 'spec/lib/open_food_network/scope_variant_to_hub_spec.rb'
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
- 'spec/lib/reports/customers_report_spec.rb'
- 'spec/lib/reports/order_cycle_management_report_spec.rb'
- 'spec/lib/reports/order_grouper_spec.rb'
- 'spec/lib/reports/orders_and_fulfillment/orders_and_fulfillment_report_spec.rb'
- 'spec/lib/reports/packing/packing_report_spec.rb'
- 'spec/lib/reports/products_and_inventory_report_spec.rb'
- 'spec/lib/reports/users_and_enterprises_report_spec.rb'
- 'spec/lib/reports/xero_invoices_report_spec.rb'
- 'spec/lib/stripe/authorize_response_patcher_spec.rb'
- 'spec/mailers/order_mailer_spec.rb'
- 'spec/mailers/producer_mailer_spec.rb'
@@ -309,7 +313,15 @@ Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'lib/reporting/queries/joins.rb'
# Offense count: 17
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'lib/reporting/reports/customers/customers_report.rb'
# Offense count: 20
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
@@ -331,7 +343,7 @@ Lint/ConstantDefinitionInBlock:
- 'lib/tasks/users.rake'
- 'spec/controllers/spree/admin/base_controller_spec.rb'
- 'spec/helpers/serializer_helper_spec.rb'
- 'spec/lib/open_food_network/reports/line_items_spec.rb'
- 'spec/lib/reports/line_items_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/gateway_spec.rb'
- 'spec/models/spree/preferences/configuration_spec.rb'
@@ -398,7 +410,7 @@ Lint/UselessMethodDefinition:
- 'app/controllers/spree/user_registrations_controller.rb'
- 'app/models/spree/gateway.rb'
# Offense count: 39
# Offense count: 38
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes, Max.
Metrics/AbcSize:
Exclude:
@@ -419,22 +431,20 @@ Metrics/AbcSize:
- 'app/models/spree/order/checkout.rb'
- 'app/models/spree/preferences/preferable_class_methods.rb'
- 'app/models/spree/return_authorization.rb'
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/customers_report.rb'
- 'lib/open_food_network/group_buy_report.rb'
- 'lib/open_food_network/order_and_distributor_report.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/reporting/reports/customers/customers_report.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/open_food_network/payments_report.rb'
- 'lib/open_food_network/sales_tax_report.rb'
- 'lib/reporting/reports/orders_and_distributors/orders_and_distributors_report.rb'
- 'lib/reporting/reports/packing/customer.rb'
- 'lib/reporting/reports/payments/payments_report.rb'
- 'lib/reporting/reports/sales_tax/sales_tax_report.rb'
- 'lib/spree/core/controller_helpers/order.rb'
- 'lib/spree/core/s3_support.rb'
- 'lib/tasks/enterprises.rake'
- 'spec/services/order_checkout_restart_spec.rb'
# Offense count: 45
# Offense count: 43
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
@@ -458,13 +468,12 @@ Metrics/BlockLength:
- 'spec/factories/subscription_factory.rb'
- 'spec/factories/user_factory.rb'
- 'spec/factories/variant_factory.rb'
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
- 'spec/requests/api/orders_spec.rb'
- 'spec/spec_helper.rb'
- 'spec/swagger_helper.rb'
- 'spec/support/cancan_helper.rb'
- 'spec/support/matchers/select2_matchers.rb'
- 'spec/support/matchers/table_matchers.rb'
- 'spec/swagger_helper.rb'
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
- 'spec/system/consumer/shopping/checkout_spec.rb'
@@ -474,7 +483,7 @@ Metrics/BlockNesting:
Exclude:
- 'app/models/spree/payment/processing.rb'
# Offense count: 49
# Offense count: 50
# Configuration parameters: CountComments, Max, CountAsOne.
Metrics/ClassLength:
Exclude:
@@ -518,18 +527,17 @@ Metrics/ClassLength:
- 'app/services/cart_service.rb'
- 'app/services/order_syncer.rb'
- 'engines/order_management/app/services/order_management/order/updater.rb'
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
- 'engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb'
- 'lib/open_food_network/enterprise_fee_calculator.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/open_food_network/order_cycle_management_report.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/open_food_network/payments_report.rb'
- 'lib/open_food_network/permissions.rb'
- 'lib/open_food_network/users_and_enterprises_report.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
- 'lib/reporting/reports/order_cycle_management/order_cycle_management_report.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/reporting/reports/payments/payments_report.rb'
- 'lib/reporting/reports/xero_invoices/base.rb'
# Offense count: 40
# Offense count: 39
# Configuration parameters: IgnoredMethods, Max.
Metrics/CyclomaticComplexity:
Exclude:
@@ -555,20 +563,19 @@ Metrics/CyclomaticComplexity:
- 'app/models/spree/tax_rate.rb'
- 'app/models/spree/variant.rb'
- 'app/models/spree/zone.rb'
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/customers_report.rb'
- 'lib/open_food_network/enterprise_issue_validator.rb'
- 'lib/open_food_network/group_buy_report.rb'
- 'lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb'
- 'lib/open_food_network/payments_report.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/reporting/reports/customers/customers_report.rb'
- 'lib/reporting/reports/orders_and_fulfillment/customer_totals_report.rb'
- 'lib/reporting/reports/payments/payments_report.rb'
- 'lib/reporting/reports/xero_invoices/base.rb'
- 'lib/spree/core/controller_helpers/order.rb'
- 'lib/spree/core/controller_helpers/respond_with.rb'
- 'lib/spree/localized_number.rb'
- 'spec/models/product_importer_spec.rb'
# Offense count: 31
# Offense count: 32
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Exclude:
@@ -578,23 +585,23 @@ Metrics/MethodLength:
- 'app/controllers/spree/orders_controller.rb'
- 'app/helpers/checkout_helper.rb'
- 'app/helpers/spree/admin/navigation_helper.rb'
- "app/json_schemas/json_api_schema.rb"
- 'app/json_schemas/json_api_schema.rb'
- 'app/models/spree/ability.rb'
- 'app/models/spree/gateway/pay_pal_express.rb'
- 'app/models/spree/order/checkout.rb'
- 'app/models/spree/payment/processing.rb'
- 'app/models/spree/preferences/preferable_class_methods.rb'
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
- 'engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb'
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/open_food_network/order_cycle_management_report.rb'
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
- 'lib/reporting/reports/order_cycle_management/order_cycle_management_report.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/open_food_network/payments_report.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'lib/reporting/reports/payments/payments_report.rb'
- 'lib/reporting/reports/xero_invoices/base.rb'
- 'lib/tasks/sample_data/product_factory.rb'
# Offense count: 51
# Offense count: 54
# Configuration parameters: CountComments, Max, CountAsOne.
Metrics/ModuleLength:
Exclude:
@@ -625,17 +632,20 @@ Metrics/ModuleLength:
- 'spec/controllers/spree/admin/adjustments_controller_spec.rb'
- 'spec/controllers/spree/admin/payment_methods_controller_spec.rb'
- 'spec/lib/open_food_network/address_finder_spec.rb'
- 'spec/lib/open_food_network/customers_report_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
- 'spec/lib/open_food_network/order_cycle_management_report_spec.rb'
- 'spec/lib/open_food_network/order_cycle_permissions_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/lib/open_food_network/permissions_spec.rb'
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
- 'spec/lib/open_food_network/scope_variant_to_hub_spec.rb'
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
- 'spec/lib/reports/customers_report_spec.rb'
- 'spec/lib/reports/enterprise_fee_summary/authorizer_spec.rb'
- 'spec/lib/reports/order_cycle_management_report_spec.rb'
- 'spec/lib/reports/order_grouper_spec.rb'
- 'spec/lib/reports/orders_and_fulfillment/customer_totals_report_spec.rb'
- 'spec/lib/reports/orders_and_fulfillment/orders_and_fulfillment_report_spec.rb'
- 'spec/lib/reports/products_and_inventory_report_spec.rb'
- 'spec/lib/reports/users_and_enterprises_report_spec.rb'
- 'spec/models/spree/adjustment_spec.rb'
- 'spec/models/spree/credit_card_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
@@ -656,11 +666,11 @@ Metrics/ParameterLists:
Exclude:
- 'app/helpers/angular_form_builder.rb'
- 'app/models/product_import/entry_processor.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'lib/reporting/reports/xero_invoices/base.rb'
- 'spec/support/controller_requests_helper.rb'
- 'spec/system/admin/reports_spec.rb'
# Offense count: 8
# Offense count: 7
# Configuration parameters: IgnoredMethods, Max.
Metrics/PerceivedComplexity:
Exclude:
@@ -669,9 +679,8 @@ Metrics/PerceivedComplexity:
- 'app/models/enterprise_relationship.rb'
- 'app/models/spree/ability.rb'
- 'app/models/spree/order/checkout.rb'
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/open_food_network/group_buy_report.rb'
- 'lib/open_food_network/payments_report.rb'
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/reporting/reports/payments/payments_report.rb'
# Offense count: 9
Naming/AccessorMethodName:
@@ -716,7 +725,7 @@ Naming/VariableNumber:
- 'app/controllers/spree/orders_controller.rb'
- 'app/models/content_configuration.rb'
- 'app/models/preference_sections/main_links_section.rb'
- 'lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb'
- 'lib/reporting/reports/orders_and_fulfillment/customer_totals_report.rb'
- 'lib/spree/core/controller_helpers/common.rb'
- 'spec/controllers/spree/admin/search_controller_spec.rb'
- 'spec/factories/stock_location_factory.rb'
@@ -895,7 +904,7 @@ Rails/LexicallyScopedActionFilter:
- 'app/controllers/spree/admin/zones_controller.rb'
- 'app/controllers/spree/users_controller.rb'
# Offense count: 18
# Offense count: 19
Rails/OutputSafety:
Exclude:
- 'app/controllers/spree/admin/reports_controller.rb'
@@ -1092,9 +1101,9 @@ Style/MissingRespondToMissing:
# Offense count: 1
Style/MixinUsage:
Exclude:
- 'lib/open_food_network/orders_and_fulfillments_report.rb'
- 'lib/reporting/reports/orders_and_fulfillment/orders_and_fulfillment_report.rb'
# Offense count: 2
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: literals, strict
@@ -1118,7 +1127,7 @@ Style/NestedModifier:
- 'spec/system/admin/payments_stripe_spec.rb'
- 'spec/system/admin/reports_spec.rb'
# Offense count: 25
# Offense count: 26
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
@@ -1132,16 +1141,7 @@ Style/OptionalBooleanParameter:
- 'app/models/spree/order_contents.rb'
- 'app/models/spree/preferences/file_configuration.rb'
- 'app/models/spree/shipment.rb'
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
- 'engines/order_management/app/services/order_management/stock/estimator.rb'
- 'lib/open_food_network/customers_report.rb'
- 'lib/open_food_network/order_and_distributor_report.rb'
- 'lib/open_food_network/order_cycle_management_report.rb'
- 'lib/open_food_network/orders_and_fulfillments_report.rb'
- 'lib/open_food_network/payments_report.rb'
- 'lib/open_food_network/products_and_inventory_report_base.rb'
- 'lib/open_food_network/users_and_enterprises_report.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'lib/spree/core/controller_helpers/order.rb'
- 'lib/spree/core/delegate_belongs_to.rb'
- 'spec/support/request/web_helper.rb'
@@ -1161,11 +1161,10 @@ Style/RedundantReturn:
Exclude:
- 'app/controllers/spree/admin/shipping_methods_controller.rb'
# Offense count: 213
# Offense count: 205
Style/Send:
Exclude:
- 'app/controllers/split_checkout_controller.rb'
- 'engines/order_management/spec/services/order_management/reports/bulk_coop/bulk_coop_report_spec.rb'
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
- 'spec/controllers/checkout_controller_spec.rb'
- 'spec/controllers/payment_gateways/paypal_controller_spec.rb'
@@ -1177,13 +1176,10 @@ Style/Send:
- 'spec/lib/open_food_network/address_finder_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_applicator_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/lettuce_share_report_spec.rb'
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
- 'spec/lib/open_food_network/permissions_spec.rb'
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
- 'spec/lib/open_food_network/sales_tax_report_spec.rb'
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
- 'spec/lib/open_food_network/xero_invoices_report_spec.rb'
- 'spec/lib/reports/xero_invoices_report_spec.rb'
- 'spec/lib/stripe/webhook_handler_spec.rb'
- 'spec/models/calculator/weight_spec.rb'
- 'spec/models/enterprise_spec.rb'
@@ -1208,7 +1204,7 @@ Style/SingleArgumentDig:
Exclude:
- 'app/services/checkout/form_data_adapter.rb'
# Offense count: 5
# Offense count: 4
# Cop supports --auto-correct.
Style/SlicingWithRange:
Exclude:
@@ -1216,9 +1212,8 @@ Style/SlicingWithRange:
- 'app/services/embedded_page_service.rb'
- 'engines/order_management/app/services/order_management/subscriptions/validator.rb'
- 'lib/discourse/single_sign_on.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
# Offense count: 31
# Offense count: 28
# Cop supports --auto-correct.
# Configuration parameters: Mode.
Style/StringConcatenation:
@@ -1235,11 +1230,8 @@ Style/StringConcatenation:
- 'app/serializers/api/enterprise_shopfront_list_serializer.rb'
- 'app/services/embedded_page_service.rb'
- 'app/services/products_renderer.rb'
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
- 'lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb'
- 'lib/spree/api/controller_setup.rb'
- 'lib/spree/core/environment_extension.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/variant_spec.rb'

View File

@@ -86,7 +86,6 @@ gem 'bootsnap', require: false
gem 'geocoder'
gem 'gmaps4rails'
gem 'mimemagic', '> 0.3.5'
gem 'paperclip', '~> 3.4.1'
gem 'paper_trail', '~> 12.1.0'
gem 'rack-rewrite'
gem 'rack-ssl', require: 'rack/ssl'

View File

@@ -219,10 +219,7 @@ GEM
rubyzip (>= 1.3.0, < 3)
childprocess (4.1.0)
chronic (0.10.2)
climate_control (0.2.0)
cliver (0.3.2)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.3)
coffee-rails (5.0.0)
coffee-script (>= 2.2.0)
@@ -392,9 +389,6 @@ GEM
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0225)
mimemagic (0.4.3)
nokogiri (~> 1)
rake
@@ -427,12 +421,6 @@ GEM
paper_trail (12.1.0)
activerecord (>= 5.2)
request_store (~> 1.1)
paperclip (3.4.2)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.0)
mime-types
parallel (1.21.0)
paranoia (2.4.3)
activerecord (>= 4.0, < 6.2)
@@ -785,7 +773,6 @@ DEPENDENCIES
order_management!
pagy (~> 5.1)
paper_trail (~> 12.1.0)
paperclip (~> 3.4.1)
paranoia (~> 2.4)
paypal-sdk-merchant (= 1.117.2)
pdf-reader

View File

@@ -3,7 +3,7 @@ angular.module('Darkswarm').directive 'mapSearch', ($timeout, Search) ->
restrict: 'E'
require: ['^uiGmapGoogleMap', 'ngModel']
replace: true
template: '<input id="pac-input" ng-model="query" placeholder="' + t('location_placeholder') + '"></input>'
template: '<input id="pac-input" ng-model="query" placeholder="' + t('location_placeholder') + '" onfocus="this.select()"></input>'
scope: {}
controller: ($scope) ->

View File

@@ -10,14 +10,14 @@ module Admin
def update
params.each do |name, value|
if ContentConfig.has_preference?(name) || ContentConfig.has_attachment?(name)
ContentConfig.public_send("#{name}=", value)
if value.is_a?(ActionDispatch::Http::UploadedFile)
blob = store_file(value)
update_preference("#{name}_blob_id", blob.id)
else
update_preference(name, value)
end
end
# Save any uploaded images
ContentConfig.save
flash[:success] =
t(:successfully_updated, resource: I18n.t('admin.contents.edit.your_content'))
@@ -26,6 +26,22 @@ module Admin
private
def store_file(attachable)
ActiveStorage::Blob.create_and_upload!(
io: attachable.open,
filename: attachable.original_filename,
content_type: attachable.content_type,
service_name: :local,
identify: false,
)
end
def update_preference(name, value)
return unless ContentConfig.has_preference?(name)
ContentConfig.public_send("#{name}=", value)
end
def preference_sections
[
PreferenceSections::HeaderSection.new,

View File

@@ -64,6 +64,7 @@ module Admin
@order_cycle_form = OrderCycleForm.new(@order_cycle, order_cycle_params, spree_current_user)
if @order_cycle_form.save
update_nil_subscription_line_items_price_estimate(@order_cycle)
respond_to do |format|
flash[:notice] = I18n.t(:order_cycles_update_notice) if params[:reloading] == '1'
format.html { redirect_back(fallback_location: root_path) }
@@ -76,6 +77,7 @@ module Admin
def bulk_update
if order_cycle_set&.save
bulk_update_nil_subscription_line_items_price_estimate
render_as_json @order_cycles,
ams_prefix: 'index',
current_user: spree_current_user,
@@ -86,6 +88,27 @@ module Admin
end
end
def bulk_update_nil_subscription_line_items_price_estimate
@collection.upcoming.each do |order_cycle|
update_nil_subscription_line_items_price_estimate(order_cycle)
end
end
def update_nil_subscription_line_items_price_estimate(order_cycle)
order_cycle.schedules.each do |schedule|
Subscription.where(schedule_id: schedule.id).each do |subscription|
shop = Enterprise.managed_by(spree_current_user).find_by(id: subscription.shop_id)
subscription.subscription_line_items.nil_price_estimate.each do |line_item|
variant = OrderManagement::Subscriptions::
VariantsList.eligible_variants(shop).find_by(id: line_item.variant_id)
fee_calculator = OpenFoodNetwork::EnterpriseFeeCalculator.new(shop, order_cycle)
price = variant.price + fee_calculator.indexed_fees_for(variant)
line_item.update_column(:price_estimate, price)
end
end
end
end
def clone
@order_cycle = OrderCycle.find params[:id]
@order_cycle.clone!

View File

@@ -5,14 +5,23 @@ module Admin
include ReportsActions
helper ReportsHelper
before_action :authorize_report
before_action :authorize_report, only: [:show]
# Define model class for Can? permissions
def model_class
Admin::ReportsController
end
def index
@reports = reports.select do |report_type, _description|
can? report_type, :report
end
end
def show
render_report && return if ransack_params.blank?
@report = report_class.new(spree_current_user, params, request)
@report = report_class.new(spree_current_user, ransack_params, report_options)
if export_spreadsheet?
if report_format.present?
export_report
else
render_report
@@ -22,33 +31,23 @@ module Admin
private
def export_report
render report_format.to_sym => @report.public_send("to_#{report_format}"),
:filename => report_filename
send_data @report.render_as(report_format, controller: self), filename: report_filename
end
def render_report
assign_view_data
load_form_options
render report_type
render "show"
end
def assign_view_data
@report_type = report_type
@report_subtype = report_subtype || report_loader.default_report_subtype
@report_subtypes = report_class.report_subtypes.map do |subtype|
[t("packing.#{subtype}_report", scope: i18n_scope), subtype]
end
end
@report_subtypes = report_subtypes
@report_subtype = report_subtype
def load_form_options
return unless form_options_required?
# Initialize data
params[:display_summary_row] = true if request.get?
form_options = Reporting::FrontendData.new(spree_current_user)
@distributors = form_options.distributors.to_a
@suppliers = form_options.suppliers.to_a
@order_cycles = form_options.order_cycles.to_a
@data = Reporting::FrontendData.new(spree_current_user)
end
end
end

View File

@@ -14,7 +14,7 @@ module Api
respond_to :json
def destroy
unless @enterprise.public_send("#{attachment_name}?")
unless @enterprise.public_send(attachment_name).attached?
return respond_with_conflict(error: destroy_attachment_does_not_exist_error_message)
end

View File

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

View File

@@ -10,7 +10,8 @@ module Api
before_action :validate_report, :authorize_report, :validate_query
def show
@report = report_class.new(current_api_user, ransack_params, report_options)
params[:report_format] = 'json'
@report = report_class.new(current_api_user, params)
render_report
end

View File

@@ -29,6 +29,7 @@ class ApplicationController < ActionController::Base
helper 'footer_links'
helper 'discourse'
helper 'checkout'
helper 'link'
helper 'terms_and_conditions'
protect_from_forgery

View File

@@ -47,7 +47,7 @@ module CheckoutCallbacks
end
def load_shipping_methods
@shipping_methods = available_shipping_methods.sort_by(&:name)
@shipping_methods = available_shipping_methods.sort { |a, b| a.name.casecmp(b.name) }
end
def redirect_to_shop?

View File

@@ -3,10 +3,14 @@
module ReportsActions
extend ActiveSupport::Concern
def reports
Reporting::Reports::List.all
end
private
def authorize_report
authorize! report_type&.to_sym, :report
authorize! report_type.to_sym, :report
end
def report_class
@@ -23,31 +27,26 @@ module ReportsActions
params[:report_type]
end
def report_subtypes
reports[report_type.to_sym] || []
end
def report_subtypes_codes
report_subtypes.map(&:second).map(&:to_s)
end
def report_subtype
params[:report_subtype]
params[:report_subtype] || report_subtypes_codes.first
end
def ransack_params
raw_params[:q]
end
def report_options
raw_params[:options]
end
def report_format
params[:report_format]
end
def export_spreadsheet?
['xlsx', 'ods', 'csv'].include?(report_format)
end
def form_options_required?
[:packing, :customers, :products_and_inventory, :order_cycle_management].
include? report_type.to_sym
end
def report_filename
"#{report_type || action_name}_#{file_timestamp}.#{report_format}"
end

View File

@@ -132,7 +132,7 @@ class SplitCheckoutController < ::BaseController
when "confirmation"
redirect_to checkout_step_path(:summary)
else
redirect_to order_path(@order)
redirect_to order_path(@order, order_token: @order.token)
end
end

View File

@@ -39,9 +39,6 @@ module Spree
render :new
end
end
rescue Paperclip::Errors::NotIdentifiedByImageMagickError
@object.errors.add(:base, t('spree.admin.products.image_upload_error'))
respond_with(@object)
end
def show

View File

@@ -1,310 +0,0 @@
# frozen_string_literal: true
require 'csv'
require 'open_food_network/reports/list'
require 'open_food_network/order_and_distributor_report'
require 'open_food_network/products_and_inventory_report'
require 'open_food_network/lettuce_share_report'
require 'open_food_network/group_buy_report'
require 'open_food_network/order_grouper'
require 'open_food_network/customers_report'
require 'open_food_network/users_and_enterprises_report'
require 'open_food_network/order_cycle_management_report'
require 'open_food_network/sales_tax_report'
require 'open_food_network/xero_invoices_report'
require 'open_food_network/payments_report'
require 'open_food_network/orders_and_fulfillments_report'
module Spree
module Admin
class ReportsController < Spree::Admin::BaseController
include Spree::ReportsHelper
helper ::ReportsHelper
ORDER_MANAGEMENT_ENGINE_REPORTS = [
:bulk_coop,
:enterprise_fee_summary
].freeze
helper_method :render_content?
before_action :cache_search_state
# Fetches user's distributors, suppliers and order_cycles
before_action :load_basic_data, only: [:customers, :products_and_inventory, :order_cycle_management]
before_action :load_associated_data, only: [:orders_and_fulfillment]
respond_to :html
def report_types
OpenFoodNetwork::Reports::List.all
end
def index
@reports = authorized_reports
respond_with(@reports)
end
def customers
@report_types = report_types[:customers]
@report_type = params[:report_type]
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, raw_params,
render_content?
render_report(@report.header, @report.table, params[:csv], "customers_#{timestamp}.csv")
end
def order_cycle_management
raw_params[:q] ||= {}
@report_types = report_types[:order_cycle_management]
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::OrderCycleManagementReport.new spree_current_user,
raw_params,
render_content?
@table = @report.table_items
render_report(@report.header, @table, params[:csv],
"order_cycle_management_#{timestamp}.csv")
end
def orders_and_distributors
@report = OpenFoodNetwork::OrderAndDistributorReport.new spree_current_user,
raw_params,
render_content?
@search = @report.search
csv_file_name = "orders_and_distributors_#{timestamp}.csv"
render_report(@report.header, @report.table, params[:csv], csv_file_name)
end
def sales_tax
@distributors = my_distributors
@report_type = params[:report_type]
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, raw_params,
render_content?
render_report(@report.header, @report.table, params[:csv], "sales_tax.csv")
end
def payments
# -- Prepare Form Options
@distributors = my_distributors
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, raw_params,
render_content?
@table = order_grouper_table
csv_file_name = "payments_#{timestamp}.csv"
render_report(@report.header, @table, params[:csv], csv_file_name)
end
def orders_and_fulfillment
raw_params[:q] ||= orders_and_fulfillment_default_filters
@report_types = report_types[:orders_and_fulfillment]
@report_type = params[:report_type]
@include_blank = I18n.t(:all)
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::OrdersAndFulfillmentsReport.new spree_current_user,
raw_params,
render_content?
@table = order_grouper_table
csv_file_name = "#{params[:report_type]}_#{timestamp}.csv"
render_report(@report.header, @table, params[:csv], csv_file_name)
end
def products_and_inventory
@report_types = report_types[:products_and_inventory]
@report = if params[:report_type] != 'lettuce_share'
OpenFoodNetwork::ProductsAndInventoryReport.new spree_current_user,
raw_params,
render_content?
else
OpenFoodNetwork::LettuceShareReport.new spree_current_user,
raw_params,
render_content?
end
render_report @report.header,
@report.table,
params[:csv],
"products_and_inventory_#{timestamp}.csv"
end
def users_and_enterprises
@report = OpenFoodNetwork::UsersAndEnterprisesReport.new raw_params, render_content?
render_report(@report.header, @report.table, params[:csv],
"users_and_enterprises_#{timestamp}.csv")
end
def xero_invoices
raw_params[:q] ||= {}
@distributors = my_distributors
@order_cycles = my_order_cycles
@report = OpenFoodNetwork::XeroInvoicesReport.new(spree_current_user,
raw_params,
render_content?)
render_report(@report.header, @report.table, params[:csv], "xero_invoices_#{timestamp}.csv")
end
private
def model_class
Spree::Admin::ReportsController
end
# Some actions are changing the `params` object. That is unfortunate Spree
# behavior and we are building on it. So we have to look at `params` early
# to check if we are searching or just displaying a report search form.
def cache_search_state
search_keys = [
# search parameter for ransack
:q,
# common in all reports, only set for CSV rendering
:csv,
# `button` is included in all forms. It's not important for searching,
# but the Users & Enterprises report doesn't have any other parameter
# for an empty search. So we use this one to display data.
:button,
# Some reports use filtering by enterprise or order cycle
:distributor_id,
:supplier_id,
:order_cycle_id,
# Xero Invoices can be filtered by date
:invoice_date,
:due_date
]
@searching = search_keys.any? { |key| raw_params.key? key }
end
# We don't want to render data unless search params are supplied.
# Compiling data can take a long time.
def render_content?
@searching
end
def render_report(header, table, create_csv, csv_file_name)
send_data csv_report(header, table), filename: csv_file_name if create_csv
@header = header
@table = table
# Rendering HTML is the default.
end
def load_associated_data
form_options = Reporting::FrontendData.new(spree_current_user)
@distributors = form_options.distributors
@suppliers = form_options.suppliers
@order_cycles = form_options.order_cycles
end
def csv_report(header, table)
CSV.generate do |csv|
csv << header
table.each { |row| csv << row }
end
end
def load_basic_data
@distributors = my_distributors
@suppliers = my_suppliers | suppliers_of_products_distributed_by(@distributors)
@order_cycles = my_order_cycles
end
# Load managed distributor enterprises of current user
def my_distributors
Enterprise.is_distributor.managed_by(spree_current_user)
end
# Load managed producer enterprises of current user
def my_suppliers
Enterprise.is_primary_producer.managed_by(spree_current_user)
end
def suppliers_of_products_distributed_by(distributors)
supplier_ids = Spree::Product.in_distributors(distributors.select('enterprises.id')).
select('spree_products.supplier_id')
Enterprise.where(id: supplier_ids)
end
# Load order cycles the current user has access to
def my_order_cycles
OrderCycle.
active_or_complete.
visible_by(spree_current_user).
order('orders_close_at DESC')
end
def order_grouper_table
order_grouper = OpenFoodNetwork::OrderGrouper.new @report.rules, @report.columns, @report
order_grouper.table(@report.table_items)
end
def authorized_reports
all_reports = [
:orders_and_distributors,
:bulk_coop,
:payments,
:orders_and_fulfillment,
:customers,
:products_and_inventory,
:users_and_enterprises,
:enterprise_fee_summary,
:order_cycle_management,
:sales_tax,
:xero_invoices,
:packing
]
reports = all_reports.select { |action| can? action, Spree::Admin::ReportsController }
reports.map { |report| [report, describe_report(report)] }.to_h
end
def describe_report(report)
name = I18n.t(:name, scope: [:admin, :reports, report])
description = begin
I18n.t!(:description, scope: [:admin, :reports, report])
rescue I18n::MissingTranslationData
render_to_string(
partial: "#{report}_description",
layout: false,
locals: { report_types: report_types[report] }
).html_safe
end
{ name: name, url: url_for_report(report), description: description }
end
def url_for_report(report)
if report_in_order_management_engine?(report)
main_app.public_send("new_order_management_reports_#{report}_url".to_sym)
else
spree.public_send("#{report}_admin_reports_url".to_sym)
end
rescue NoMethodError
main_app.admin_reports_url(report_type: report)
end
# List of reports that have been moved to the Order Management engine
def report_in_order_management_engine?(report)
ORDER_MANAGEMENT_ENGINE_REPORTS.include?(report)
end
def timestamp
Time.zone.now.strftime("%Y%m%d")
end
def orders_and_fulfillment_default_filters
now = Time.zone.now
{ completed_at_gt: (now - 1.month).beginning_of_day,
completed_at_lt: (now + 1.day).beginning_of_day }
end
end
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
module GroupsHelper
module LinkHelper
def link_to_service(baseurl, name, html_options = {}, &block)
return if name.blank?
@@ -15,8 +15,4 @@ module GroupsHelper
prefix + url
end
end
def strip_url(url)
url&.sub(%r{^https?://}i, '')
end
end

View File

@@ -9,7 +9,24 @@ module ReportsHelper
end
end
def report_subtypes(report)
Reporting::ReportLoader.new(report).report_subtypes
def report_payment_method_options(orders)
orders.map do |order|
payment_method = order.payments.last&.payment_method
next unless payment_method
[payment_method.name, payment_method.id]
end.compact.uniq
end
def report_shipping_method_options(orders)
orders.map do |o|
sm = o.shipping_method
[sm&.name, sm&.id]
end.uniq
end
def currency_symbol
Spree::Money.currency_symbol
end
end

View File

@@ -77,7 +77,7 @@ module Spree
klass = EnterpriseGroup if klass == :group
klass = VariantOverride if klass == :Inventory
klass = ProductImport::ProductImporter if klass == :import
klass = Spree::Admin::ReportsController if klass == :report
klass = ::Admin::ReportsController if klass == :report
klass
end

View File

@@ -1,33 +0,0 @@
# frozen_string_literal: true
require 'spree/money'
module Spree
module ReportsHelper
def report_payment_method_options(orders)
orders.map do |order|
payment_method = order.payments.last&.payment_method
next unless payment_method
[payment_method.name, payment_method.id]
end.compact.uniq
end
def report_shipping_method_options(orders)
orders.map do |o|
sm = o.shipping_method
[sm&.name, sm&.id]
end.uniq
end
def xero_report_types
[[I18n.t(:summary), 'summary'],
[I18n.t(:detailed), 'detailed']]
end
def currency_symbol
Spree::Money.currency_symbol
end
end
end

View File

@@ -0,0 +1,43 @@
# frozen_string_literal: true
module FilePreferences
extend ActiveSupport::Concern
included do
@default_urls = {}
end
class_methods do
def file_preference(name, default_url: nil)
preference "#{name}_blob_id", :integer
@default_urls[name] = default_url if default_url
end
def default_url(name)
@default_urls[name]
end
end
def preference_type(key)
if has_preference?("#{key}_blob_id")
:file
else
super(key)
end
end
def url_for(name)
blob = blob_for(name)
if blob
Rails.application.routes.url_helpers.url_for(blob)
else
self.class.default_url(name)
end
end
def blob_for(name)
blob_id = get_preference("#{name}_blob_id")
ActiveStorage::Blob.find_by(id: blob_id) if blob_id
end
end

View File

@@ -1,67 +0,0 @@
# frozen_string_literal: true
module HasMigratingFile
extend ActiveSupport::Concern
@migrating_models = []
def self.migrating_models
@migrating_models
end
included do
HasMigratingFile.migrating_models.push(name)
end
class_methods do
def has_one_migrating(name, paperclip_options = {})
# Active Storage declaration
has_one_attached name
# Backup Active Storage methods before they get overridden by Paperclip.
alias_method "active_storage_#{name}", name
alias_method "active_storage_#{name}=", "#{name}="
# Paperclip declaration
#
# This will define the `name` and `name=` methods as well.
has_attached_file name, paperclip_options
# Paperclip callback to duplicate file with Active Storage
#
# We store files with Paperclip *and* Active Storage while we migrate
# old Paperclip files to Active Storage. This enables availability
# during the migration.
public_send("after_#{name}_post_process") do
path = processed_local_file_path(name)
if public_send(name).errors.blank? && path.present?
attach_file(name, File.open(path))
end
end
end
end
def attach_file(name, io)
attachable = {
io: io,
filename: public_send("#{name}_file_name"),
content_type: public_send("#{name}_content_type"),
identify: false,
}
public_send("active_storage_#{name}=", attachable)
end
private
def processed_local_file_path(name)
attachment = public_send(name)
temporary = attachment.queued_for_write[:original]
if temporary&.path.present?
temporary.path
else
attachment.path
end
end
end

View File

@@ -1,23 +1,17 @@
# frozen_string_literal: true
require 'open_food_network/paperclippable'
class ContentConfiguration < Spree::Preferences::FileConfiguration
include OpenFoodNetwork::Paperclippable
class ContentConfiguration < Spree::Preferences::Configuration
include FilePreferences
# Header
preference :logo, :file
preference :logo_mobile, :file
preference :logo_mobile_svg, :file
has_attached_file :logo, default_url: "/default_images/ofn-logo.png"
has_attached_file :logo_mobile
has_attached_file :logo_mobile_svg, default_url: "/default_images/ofn-logo-mobile.svg"
file_preference :logo, default_url: "/default_images/ofn-logo.png"
file_preference :logo_mobile
file_preference :logo_mobile_svg, default_url: "/default_images/ofn-logo-mobile.svg"
# Home page
preference :home_page_alert_html, :text
preference :home_hero, :file
file_preference :home_hero, default_url: "/default_images/home.jpg"
preference :home_show_stats, :boolean, default: true
has_attached_file :home_hero, default_url: "/default_images/home.jpg"
# Map
preference :open_street_map_enabled, :boolean, default: false
@@ -66,8 +60,7 @@ class ContentConfiguration < Spree::Preferences::FileConfiguration
preference :menu_7_icon_name, :string, default: "ofn-i_013-help"
# Footer
preference :footer_logo, :file
has_attached_file :footer_logo, default_url: "/default_images/ofn-logo-footer.png"
file_preference :footer_logo, default_url: "/default_images/ofn-logo-footer.png"
# Other
preference :footer_facebook_url, :string, default: "https://www.facebook.com/OpenFoodNet"

View File

@@ -1,13 +1,20 @@
# frozen_string_literal: false
require 'spree/core/s3_support'
class Enterprise < ApplicationRecord
include HasMigratingFile
include Spree::Core::S3Support
SELLS = %w(unspecified none own any).freeze
ENTERPRISE_SEARCH_RADIUS = 100
# The next Rails version will have named variants but we need to store them
# ourselves for now.
LOGO_SIZES = {
thumb: { resize_to_limit: [100, 100] },
small: { resize_to_limit: [180, 180] },
medium: { resize_to_limit: [300, 300] },
}.freeze
PROMO_IMAGE_SIZES = {
thumb: { resize_to_limit: [100, 100] },
medium: { resize_to_fill: [720, 156] },
large: { resize_to_fill: [1200, 260] },
}.freeze
searchable_attributes :sells, :is_primary_producer
searchable_associations :properties
@@ -73,31 +80,16 @@ class Enterprise < ApplicationRecord
tag_rule[:preferred_customer_tags].blank?
}
has_one_migrating :logo,
styles: { medium: "300x300>", small: "180x180>", thumb: "100x100>" },
url: '/images/enterprises/logos/:id/:style/:basename.:extension',
path: 'public/images/enterprises/logos/:id/:style/:basename.:extension'
has_one_attached :logo
has_one_attached :promo_image
has_one_attached :terms_and_conditions
has_one_migrating :promo_image,
styles: {
large: ["1200x260#", :jpg],
medium: ["720x156#", :jpg],
thumb: ["100x100>", :jpg]
},
url: '/images/enterprises/promo_images/:id/:style/:basename.:extension',
path: 'public/images/enterprises/promo_images/:id/:style/:basename.:extension'
validates_attachment_content_type :logo, content_type: %r{\Aimage/.*\Z}
validates_attachment_content_type :promo_image, content_type: %r{\Aimage/.*\Z}
has_one_migrating :terms_and_conditions,
url: '/files/enterprises/terms_and_conditions/:id/:basename.:extension',
path: 'public/files/enterprises/terms_and_conditions/:id/:basename.:extension'
validates_attachment_content_type :terms_and_conditions,
content_type: "application/pdf",
message: I18n.t(:enterprise_terms_and_conditions_type_error)
supports_s3 :logo
supports_s3 :promo_image
validates :logo, content_type: %r{\Aimage/.*\Z}
validates :promo_image, content_type: %r{\Aimage/.*\Z}
validates :terms_and_conditions, content_type: {
in: "application/pdf",
message: I18n.t(:enterprise_terms_and_conditions_type_error),
}
validates :name, presence: true
validate :name_is_unique
@@ -284,6 +276,22 @@ class Enterprise < ApplicationRecord
relatives_including_self.is_primary_producer
end
def logo_url(name)
return unless logo.variable?
Rails.application.routes.url_helpers.url_for(
logo.variant(LOGO_SIZES[name])
)
end
def promo_image_url(name)
return unless promo_image.variable?
Rails.application.routes.url_helpers.url_for(
promo_image.variant(PROMO_IMAGE_SIZES[name])
)
end
def website
strip_url self[:website]
end

View File

@@ -1,12 +1,9 @@
# frozen_string_literal: true
require 'open_food_network/locking'
require 'spree/core/s3_support'
class EnterpriseGroup < ApplicationRecord
include HasMigratingFile
include PermalinkGenerator
include Spree::Core::S3Support
acts_as_list
@@ -28,21 +25,11 @@ class EnterpriseGroup < ApplicationRecord
delegate :phone, :address1, :address2, :city, :zipcode, :state, :country, to: :address
has_one_migrating :logo,
styles: { medium: "100x100" },
url: '/images/enterprise_groups/logos/:id/:style/:basename.:extension',
path: 'public/images/enterprise_groups/logos/:id/:style/:basename.:extension'
has_one_attached :logo
has_one_attached :promo_image
has_one_migrating :promo_image,
styles: { large: ["1200x260#", :jpg] },
url: '/images/enterprise_groups/promo_images/:id/:style/:basename.:extension',
path: 'public/images/enterprise_groups/promo_images/:id/:style/:basename.:extension'
validates_attachment_content_type :logo, content_type: %r{\Aimage/.*\Z}
validates_attachment_content_type :promo_image, content_type: %r{\Aimage/.*\Z}
supports_s3 :logo
supports_s3 :promo_image
validates :logo, content_type: %r{\Aimage/.*\Z}
validates :promo_image, content_type: %r{\Aimage/.*\Z}
scope :by_position, -> { order('position ASC') }
scope :on_front_page, -> { where(on_front_page: true) }

View File

@@ -236,12 +236,10 @@ module Spree
:validate_data, :reset_absent_products], ProductImport::ProductImporter
# Reports page
can [:admin, :index, :customers, :orders_and_distributors, :group_buys, :payments,
:orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :packing],
Spree::Admin::ReportsController
can [:admin, :show, :packing], :report
add_bulk_coop_abilities
add_enterprise_fee_summary_abilities
can [:admin, :index, :show], ::Admin::ReportsController
can [:admin, :show, :customers, :orders_and_distributors, :group_buys, :payments,
:orders_and_fulfillment, :products_and_inventory, :order_cycle_management,
:packing, :enterprise_fee_summary, :bulk_coop], :report
end
def add_order_cycle_management_abilities(user)
@@ -317,11 +315,10 @@ module Spree
end
# Reports page
can [:admin, :index, :customers, :group_buys, :sales_tax, :payments,
can [:admin, :index, :show], ::Admin::ReportsController
can [:admin, :customers, :group_buys, :sales_tax, :payments,
:orders_and_distributors, :orders_and_fulfillment, :products_and_inventory,
:order_cycle_management, :xero_invoices], Spree::Admin::ReportsController
add_bulk_coop_abilities
add_enterprise_fee_summary_abilities
:order_cycle_management, :xero_invoices, :enterprise_fee_summary, :bulk_coop], :report
can [:create], Customer
can [:admin, :index, :update,
@@ -346,19 +343,5 @@ module Spree
user.enterprises.include?(enterprise_relationship.child)
end
end
def add_bulk_coop_abilities
# Reveal the report link in spree/admin/reports#index
can [:bulk_coop], Spree::Admin::ReportsController
# Allow direct access to the report resource
can [:admin, :new, :create], :bulk_coop
end
def add_enterprise_fee_summary_abilities
# Reveal the report link in spree/admin/reports#index
can [:enterprise_fee_summary], Spree::Admin::ReportsController
# Allow direct access to the report resource
can [:admin, :new, :create], :enterprise_fee_summary
end
end
end

View File

@@ -105,6 +105,10 @@ module Spree
render_address([city, zipcode, state&.name])
end
def address_and_city
[address1, address2, city].select(&:present?).join(' ')
end
private
def require_zipcode?

View File

@@ -1,103 +1,39 @@
# frozen_string_literal: true
require 'spree/core/s3_support'
module Spree
class Image < Asset
include HasMigratingFile
SIZES = {
mini: { resize_to_fill: [48, 48] },
small: { resize_to_fill: [227, 227] },
product: { resize_to_limit: [240, 240] },
large: { resize_to_limit: [600, 600] },
}.freeze
validates_attachment_presence :attachment
has_one_attached :attachment
validates :attachment, attached: true, content_type: %r{\Aimage/.*\Z}
validate :no_attachment_errors
# This is where the styles are used in the app:
# - mini: used in the BackOffice: Bulk Product Edit page and Order Cycle edit page
# - small: used in the FrontOffice: Product List page
# - product: used in the BackOffice: Product Image upload modal in the Bulk Product Edit page
# and Product image edit page
# - large: used in the FrontOffice: product modal
has_one_migrating :attachment,
styles: { mini: "48x48#", small: "227x227#",
product: "240x240>", large: "600x600>" },
default_style: :product,
url: '/spree/products/:id/:style/:basename.:extension',
path: ':rails_root/public/spree/products/:id/:style/:basename.:extension',
convert_options: { all: '-strip -auto-orient -colorspace sRGB' }
# save the w,h of the original image (from which others can be calculated)
# we need to look at the write-queue for images which have not been saved yet
after_post_process :find_dimensions
include Spree::Core::S3Support
supports_s3 :attachment
# used by admin products autocomplete
def mini_url
attachment.url(:mini, false)
def variant(name)
attachment.variant(SIZES[name])
end
def find_dimensions
return if attachment.errors.present?
def url(size)
return unless attachment.variable?
geometry = Paperclip::Geometry.from_file(local_filename_of_original)
self.attachment_width = geometry.width
self.attachment_height = geometry.height
end
def local_filename_of_original
temporary = attachment.queued_for_write[:original]
if temporary&.path.present?
temporary.path
else
attachment.path
end
Rails.application.routes.url_helpers.url_for(variant(size))
end
# if there are errors from the plugin, then add a more meaningful message
def no_attachment_errors
return if attachment.errors.empty?
return if errors[:attachment].empty?
if errors.all? { |e| e.type == "Paperclip::Errors::NotIdentifiedByImageMagickError" }
if errors.all? { |e| e.type == :content_type_invalid }
attachment.errors.clear
errors.add :base, I18n.t('spree.admin.products.image_upload_error')
else
errors.add :attachment,
I18n.t('spree.admin.products.paperclip_image_error', attachment_file_name: attachment_file_name)
end
false
end
def self.set_attachment_attribute(attribute_name, attribute_value)
attachment_definitions[:attachment][attribute_name] = attribute_value
end
def self.set_storage_attachment_attributes
if Spree::Config[:use_s3]
set_s3_attachment_attributes
else
attachment_definitions[:attachment].delete(:storage)
end
end
def self.set_s3_attachment_attributes
set_attachment_attribute(:storage, :s3)
set_attachment_attribute(:s3_credentials, s3_credentials)
set_attachment_attribute(:s3_headers,
ActiveSupport::JSON.decode(Spree::Config[:s3_headers]))
set_attachment_attribute(:bucket, Spree::Config[:s3_bucket])
# We use :s3_alias_url (virtual host url style) and set the URL on property s3_host_alias
set_attachment_attribute(:s3_host_alias, attachment_definitions[:attachment][:url])
set_attachment_attribute(:url, ":s3_alias_url")
end
private_class_method :set_s3_attachment_attributes
def self.s3_credentials
{ access_key_id: Spree::Config[:s3_access_key],
secret_access_key: Spree::Config[:s3_secret],
bucket: Spree::Config[:s3_bucket] }
end
private_class_method :s3_credentials
end
end

View File

@@ -430,9 +430,10 @@ module Spree
def empty!
line_items.destroy_all
adjustments.destroy_all
all_adjustments.destroy_all
payments.clear
shipments.destroy_all
restart_checkout_flow if state == "payment"
end
def state_changed(name)

View File

@@ -1,62 +0,0 @@
# frozen_string_literal: true
module Spree
module Preferences
class FileConfiguration < Configuration
def self.preference(name, type, *args)
if type == :file
# Active Storage blob id:
super "#{name}_blob_id", :integer, *args
# Paperclip attachment attributes:
super "#{name}_file_name", :string, *args
super "#{name}_content_type", :string, *args
super "#{name}_file_size", :integer, *args
super "#{name}_updated_at", :string, *args
else
super name, type, *args
end
end
def get_preference(key)
if !has_preference?(key) && has_attachment?(key)
# Call Paperclip's attachment method:
public_send key
elsif key.ends_with?("_blob")
# Find referenced Active Storage blob:
blob_id = super("#{key}_id")
ActiveStorage::Blob.find_by(id: blob_id)
else
super key
end
end
alias :[] :get_preference
def preference_type(name)
if has_attachment? name
:file
else
super name
end
end
# Spree's Configuration responds to preference methods via method_missing, but doesn't
# override respond_to?, which consequently reports those methods as unavailable. Paperclip
# errors if respond_to? isn't correct, so we override it here.
def respond_to?(method, include_all = false)
name = method.to_s.delete('=')
reference_name = "#{name}_id"
super(self.class.preference_getter_method(name), include_all) ||
super(reference_name, include_all) ||
super(method, include_all)
end
def has_attachment?(name)
self.class.respond_to?(:attachment_definitions) &&
self.class.attachment_definitions.key?(name.to_sym)
end
end
end
end

View File

@@ -9,6 +9,7 @@ class SubscriptionLineItem < ApplicationRecord
validates :quantity, presence: true, numericality: { only_integer: true }
default_scope { order('id ASC') }
scope :nil_price_estimate, -> { where(price_estimate: nil) }
def total_estimate
(price_estimate || 0) * (quantity || 0)

View File

@@ -1,11 +1,9 @@
# frozen_string_literal: true
class TermsOfServiceFile < ApplicationRecord
include HasMigratingFile
has_one_attached :attachment
has_one_migrating :attachment
validates :attachment, presence: true
validates :attachment, attached: true
# The most recently uploaded file is the current one.
def self.current
@@ -13,7 +11,11 @@ class TermsOfServiceFile < ApplicationRecord
end
def self.current_url
current&.attachment&.url || Spree::Config.footer_tos_url
if current
Rails.application.routes.url_helpers.url_for(current.attachment)
else
Spree::Config.footer_tos_url
end
end
# If no file has been uploaded, we don't know when the old terms have
@@ -21,9 +23,4 @@ class TermsOfServiceFile < ApplicationRecord
def self.updated_at
current&.updated_at || Time.zone.now
end
def touch(_)
# Ignore Active Storage changing the timestamp during migrations.
# This can be removed once we got rid of Paperclip.
end
end

View File

@@ -22,21 +22,26 @@ module Api
has_one :business_address, serializer: Api::AddressSerializer
def logo
attachment_urls(object.logo, [:thumb, :small, :medium])
attachment_urls(object.logo, Enterprise::LOGO_SIZES)
end
def promo_image
attachment_urls(object.promo_image, [:thumb, :medium, :large])
attachment_urls(object.promo_image, Enterprise::PROMO_IMAGE_SIZES)
end
def terms_and_conditions
return unless object.terms_and_conditions.file?
return unless object.terms_and_conditions.attached?
object.terms_and_conditions.url
Rails.application.routes.url_helpers.
url_for(object.terms_and_conditions)
end
def terms_and_conditions_file_name
object.terms_and_conditions_blob&.filename
end
def terms_and_conditions_updated_at
object.terms_and_conditions_updated_at&.to_s
object.terms_and_conditions_blob&.created_at&.to_s
end
def tag_groups
@@ -76,19 +81,19 @@ module Api
# Returns a hash of URLs for specified versions of an attachment.
#
# Example:
# Example result:
#
# attachment_urls(object.logo, [:thumb, :small, :medium])
# # {
# # thumb: LOGO_THUMB_URL,
# # small: LOGO_SMALL_URL,
# # medium: LOGO_MEDIUM_URL
# # }
def attachment_urls(attachment, versions)
return unless attachment.file?
# {
# thumb: LOGO_THUMB_URL,
# small: LOGO_SMALL_URL,
# medium: LOGO_MEDIUM_URL
# }
def attachment_urls(attachment, styles)
return unless attachment.variable?
versions.each_with_object({}) do |version, urls|
urls[version] = attachment.url(version)
styles.transform_values do |transformation|
Rails.application.routes.url_helpers.
url_for(attachment.variant(transformation))
end
end
end

View File

@@ -11,7 +11,7 @@ module Api
end
def image_url
object.images.present? ? object.images.first.attachment.url(:mini) : nil
object.images.first&.url(:mini)
end
def master_id

View File

@@ -13,19 +13,11 @@ module Api
has_one :master, serializer: Api::Admin::VariantSerializer
def image_url
if object.images.present?
object.images.first.attachment.url(:product)
else
"/noimage/product.png"
end
object.images.first&.url(:product) || "/noimage/product.png"
end
def thumb_url
if object.images.present?
object.images.first.attachment.url(:mini)
else
"/noimage/mini.png"
end
object.images.first&.url(:mini) || "/noimage/mini.png"
end
def on_hand

View File

@@ -33,9 +33,7 @@ module Api
end
def image
return if object.product.images.empty?
object.product.images.first.mini_url
object.product.images.first&.url(:mini)
end
def in_stock

View File

@@ -44,11 +44,11 @@ module Api
end
def logo
enterprise.logo(:medium) if enterprise.logo?
enterprise.logo_url(:medium)
end
def promo_image
enterprise.promo_image(:large) if enterprise.promo_image?
enterprise.promo_image_url(:large)
end
def path

View File

@@ -41,11 +41,11 @@ module Api
end
def logo
enterprise.logo(:medium) if enterprise.logo?
enterprise.logo_url(:medium)
end
def promo_image
enterprise.promo_image(:large) if enterprise.promo_image?
enterprise.promo_image_url(:large)
end
def path

View File

@@ -4,18 +4,18 @@ class Api::ImageSerializer < ActiveModel::Serializer
attributes :id, :alt, :thumb_url, :small_url, :image_url, :large_url
def thumb_url
object.attachment.url(:mini, false)
object.url(:mini)
end
def small_url
object.attachment.url(:small, false)
object.url(:small)
end
def image_url
object.attachment.url(:product, false)
object.url(:product)
end
def large_url
object.attachment.url(:large, false)
object.url(:large)
end
end

View File

@@ -9,7 +9,7 @@ module Api
end
def logo
object.logo(:small) if object.logo?
object.logo_url(:small)
end
end
end

View File

@@ -35,11 +35,7 @@ class Api::VariantSerializer < ActiveModel::Serializer
end
def thumb_url
if object.product.images.present?
object.product.images.first.attachment.url(:mini)
else
"/noimage/mini.png"
end
object.product.images.first&.url(:mini) || "/noimage/mini.png"
end
def unit_price_price

View File

@@ -2,21 +2,12 @@
class ImageImporter
def import(url, product)
attach(download(url), product)
end
valid_url = URI.parse(url)
file = open(valid_url.to_s)
filename = File.basename(valid_url.path)
private
def download(url)
local_file = Tempfile.new
remote_file = open(url)
IO.copy_stream(remote_file, local_file)
local_file
end
def attach(file, product)
Spree::Image.create(
attachment: file,
attachment: { io: file, filename: filename },
viewable_id: product.master.id,
viewable_type: Spree::Variant,
)

View File

@@ -5,7 +5,7 @@ class TermsOfService
return false unless accepted_at = customer&.terms_and_conditions_accepted_at
accepted_at > if distributor
distributor.terms_and_conditions_updated_at
distributor.terms_and_conditions_blob.created_at
else
TermsOfServiceFile.updated_at
end
@@ -20,6 +20,6 @@ class TermsOfService
end
def self.distributor_terms_required?(distributor)
distributor.terms_and_conditions.file?
distributor.terms_and_conditions.attached?
end
end

View File

@@ -38,8 +38,13 @@
# post.valid? # => false
# post.errors[:published_at] # => ["must be valid"]
class DateTimeStringValidator < ActiveModel::EachValidator
NOT_STRING_ERROR = I18n.t("validators.date_time_string_validator.not_string_error")
INVALID_FORMAT_ERROR = I18n.t("validators.date_time_string_validator.invalid_format_error")
def self.not_string_error
I18n.t("validators.date_time_string_validator.not_string_error")
end
def self.invalid_format_error
I18n.t("validators.date_time_string_validator.invalid_format_error")
end
def validate_each(record, attribute, value)
return if value.nil? || value == ""
@@ -53,13 +58,13 @@ class DateTimeStringValidator < ActiveModel::EachValidator
def validate_attribute_is_string(record, attribute, value)
return if value.is_a?(String)
record.errors.add(attribute, NOT_STRING_ERROR)
record.errors.add(attribute, DateTimeStringValidator.not_string_error)
end
def validate_attribute_is_datetime_string(record, attribute, value)
return unless value.is_a?(String)
datetime = Time.zone.parse(value)
record.errors.add(attribute, INVALID_FORMAT_ERROR) if datetime.blank?
record.errors.add(attribute, DateTimeStringValidator.invalid_format_error) if datetime.blank?
end
end

View File

@@ -35,8 +35,13 @@
# post.valid? # => false
# post.errors[:related_post_ids] # => ["must contain only valid integers"]
class IntegerArrayValidator < ActiveModel::EachValidator
NOT_ARRAY_ERROR = I18n.t("validators.integer_array_validator.not_array_error")
INVALID_ELEMENT_ERROR = I18n.t("validators.integer_array_validator.invalid_element_error")
def self.not_array_error
I18n.t("validators.integer_array_validator.not_array_error")
end
def self.invalid_element_error
I18n.t("validators.integer_array_validator.invalid_element_error")
end
def validate_each(record, attribute, value)
return if value.nil?
@@ -50,7 +55,7 @@ class IntegerArrayValidator < ActiveModel::EachValidator
def validate_attribute_is_array(record, attribute, value)
return if value.is_a?(Array)
record.errors.add(attribute, NOT_ARRAY_ERROR)
record.errors.add(attribute, IntegerArrayValidator.not_array_error)
end
def validate_attribute_elements_are_integer(record, attribute, array)
@@ -60,6 +65,6 @@ class IntegerArrayValidator < ActiveModel::EachValidator
Integer(element)
end
rescue ArgumentError
record.errors.add(attribute, INVALID_ELEMENT_ERROR)
record.errors.add(attribute, IntegerArrayValidator.invalid_element_error)
end
end

View File

@@ -8,5 +8,8 @@
- text = t(key)
.field
= label_tag(key, text + ': ') + tag(:br) if type != :boolean
= preference_field_tag(key, ContentConfig[key], :type => type)
- if type == :file
= file_field_tag(key, type: type)
- else
= preference_field_tag(key, ContentConfig[key], type: type)
= label_tag(key, text) + tag(:br) if type == :boolean

View File

@@ -6,13 +6,13 @@
%div{'ofn-with-tip' => t('admin_enterprise_groups_data_powertip_logo')}
%a= t 'admin.whats_this'
.omega.eight.columns
= image_tag @object.logo.url if @object.logo.present?
= f.file_field :logo
= image_tag @object.logo if @object.logo.attached?
= f.file_field :logo, accept: "image/*"
.row
.alpha.three.columns
= f.label :promo_image, 'ofn-with-tip' => t(:admin_enterprise_groups_data_powertip_promo_image)
%div{'ofn-with-tip' => t('admin_enterprise_groups_data_powertip_promo_image')}
%a= t 'admin.whats_this'
.omega.eight.columns
= image_tag @object.promo_image.url if @object.promo_image.present?
= f.file_field :promo_image
= image_tag @object.promo_image if @object.promo_image.attached?
= f.file_field :promo_image, accept: "image/*"

View File

@@ -9,7 +9,7 @@
&nbsp;
.ten.columns
= select_tag :coordinator_id, options_for_select(permitted_coordinating_enterprise_options_for(@order_cycle)), { 'required' => true, class: 'select2 fullwidth'}
.two.columns.alpha
.two.columns
= f.submit "#{t(:continue)} >"
.two.columns.omega

View File

@@ -1,9 +1,10 @@
-# Field used for ransack search. This date range is mostly used for Spree::Order
-# so default field is 'completed_at'
- field ||= 'completed_at'
.row.date-range-filter
= label_tag nil, t(:date_range)
%br
= label_tag nil, t(:start), :class => 'inline'
= text_field_tag "q[order_completed_at_gt]", params.dig(:q, :order_completed_at_gt), :class => 'datetimepicker datepicker-from'
%span.range-divider
%i.icon-arrow-right
= text_field_tag "q[order_completed_at_lt]", params.dig(:q, :order_completed_at_lt), :class => 'datetimepicker datepicker-to'
= label_tag nil, t(:end), :class => 'inline'
.alpha.two.columns= label_tag nil, t(:date_range)
.omega.fourteen.columns
= f.text_field "#{field}_gt", :class => 'datetimepicker datepicker-from', :placeholder => t(:start)
%span.range-divider
%i.icon-arrow-right
= f.text_field "#{field}_lt", :class => 'datetimepicker datepicker-to', :placeholder => t(:stop)

View File

@@ -1,8 +1,36 @@
.row.rendering-options
= label_tag :report_format, t(".generate_report")
%br
= select_tag :report_format, options_for_select({t('.on_screen') => '', t('.csv_spreadsheet') => 'csv', t('.excel_spreadsheet') => 'xlsx', t('.openoffice_spreadsheet') => 'ods'})
- if @report_subtypes.present? && @report_subtypes.count > 1
.row
.alpha.two.columns= label_tag nil, t(:report_type)
.omega.fourteen.columns
= select_tag(:report_subtype, options_for_select(@report_subtypes, @report_subtype))
- if @report.header_option? || @report.summary_row_option?
.row
.alpha.two.columns= label_tag nil, t(".display")
.omega.fourteen.columns
- if @report.header_option?
%span.inline-checkbox{ style: "margin-right: 1rem;" }
= check_box_tag :display_header_row, true, params[:display_header_row]
= label_tag :display_header_row, t(".header_row")
- if @report.summary_row_option?
%span.inline-checkbox
= check_box_tag :display_summary_row, true, params[:display_summary_row]
= label_tag :display_summary_row, t(".summary_row")
- if @report.available_headers.present?
.row
.alpha.two.columns= label_tag nil, t(:report_hide_columns)
.omega.fourteen.columns
= select_tag(:fields_to_hide, options_for_select(@report.available_headers, params[:fields_to_hide]),
class: "select2 fullwidth", multiple: true)
.row.rendering-options
.alpha.two.columns
= label_tag :report_format, t(".generate_report")
.omega.fourteen.columns
= select_tag :report_format, grouped_options_for_select({ |
t('.formatted_data') => { t('.on_screen') => '', "PDF" => 'pdf', t('.spreadsheet') => 'xlsx' }, |
t('.raw_data') => { "CSV" => 'csv' }, |
})
-#.inline-checkbox
-# = check_box_tag "options[exclude_summaries]", true, params[:options].andand[:exclude_summaries]
-# = label_tag t(".hide_summary_rows")

View File

@@ -0,0 +1,22 @@
-# Locals :
-# - data
-# - report
- data.each do |group_or_row|
- if group_or_row[:is_group].present?
/ Header Row
- if group_or_row[:header].present? && report.display_header_row?
%tr
%td.header-row{ colspan: report.table_headers.count, class: group_or_row[:header_class] }
= group_or_row[:header].html_safe
/ Rows
= render partial: 'admin/reports/row_group', locals: { report: report, data: group_or_row[:data] }
/ Summary Row
- if group_or_row[:summary_row].present? && report.display_summary_row?
%tr.summary-row{ class: group_or_row[:summary_row_class] }
- group_or_row[:summary_row].to_h.each do |key, value|
%td= value
- else
%tr
- group_or_row.row.to_h.each do |key, value|
%td= value

View File

@@ -1,20 +1,15 @@
- if params[:q].present?
%table.report__table{id: id}
- report ||= @report
.report__table-container
%table.report__table
%thead
%tr
- @report.table_headers.each do |heading|
- report.table_headers.each do |heading|
%th
= t("admin.reports.table.headings.#{heading}")
= heading
%tbody
- @report.table_rows.each do |row|
- if row
%tr
- row.each do |cell|
%td
= cell
- if @report.table_rows.empty?
- if report.grouped_data.present?
= render partial: 'admin/reports/row_group', locals: { report: report, data: report.grouped_data }
- else
%tr
%td{colspan: @report.table_headers.count}= t(:none)
- else
%p.report__message
= t(".select_and_search", option: msg_option.upcase)
%td{colspan: report.table_headers.count}= t(:none)

View File

@@ -0,0 +1,6 @@
= render 'admin/reports/date_range_form', f: f
.row
.alpha.two.columns= label_tag nil, t(:report_hubs)
.omega.fourteen.columns
= f.collection_select(:distributor_id_in, @data.distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})

View File

@@ -0,0 +1,18 @@
.row
.alpha.two.columns= label_tag nil, t(:report_customers_distributor)
.omega.fourteen.columns
= select_tag(:distributor_id,
options_from_collection_for_select(@data.distributors, :id, :name, params[:distributor_id]),
{:include_blank => true, :class => "select2 fullwidth light"})
.row
.alpha.two.columns= label_tag nil, t(:report_customers_supplier)
.omega.fourteen.columns
= select_tag(:supplier_id,
options_from_collection_for_select(@data.suppliers, :id, :name, params[:supplier_id]),
{:include_blank => true, :class => "select2 fullwidth light"})
.row
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
.omega.fourteen.columns
= select_tag(:order_cycle_id,
options_for_select(report_order_cycle_options(@data.order_cycles), params[:order_cycle_id]),
{:include_blank => true, :class => "select2 fullwidth light"})

View File

@@ -0,0 +1,31 @@
= render 'admin/reports/date_range_form', f: f
.row
.alpha.two.columns= label_tag nil, t(:report_hubs)
.omega.fourteen.columns
= collection_select(:q, :distributor_ids, @report.permissions.allowed_distributors, :id, :name, {selected: params.dig(:q, :distributor_ids)}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_producers)
.omega.fourteen.columns
= collection_select(:q, :producer_ids, @report.permissions.allowed_producers, :id, :name, {selected: params.dig(:q, :producer_ids)}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:order_cycles)
.omega.fourteen.columns
= collection_select(:q, :order_cycle_ids, @report.permissions.allowed_order_cycles, :id, :name, {selected: params.dig(:q, :order_cycle_ids)}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_enterprise_fee)
.omega.fourteen.columns
= collection_select(:q, :enterprise_fee_ids, @report.permissions.allowed_enterprise_fees, :id, :name, {selected: params.dig(:q, :enterprise_fee_ids)}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t('spree.shipping_methods')
.omega.fourteen.columns
= collection_select(:q, :shipping_method_ids, @report.permissions.allowed_shipping_methods, :id, :name, {selected: params.dig(:q, :shipping_method_ids)}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_payment)
.omega.fourteen.columns
= collection_select(:q, :payment_method_ids, @report.permissions.allowed_payment_methods, :id, :name, {selected: params.dig(:q, :payment_method_ids)}, {class: "select2 fullwidth", multiple: true})

View File

@@ -0,0 +1,18 @@
= render 'admin/reports/date_range_form', f: f
.row
.alpha.two.columns= label_tag nil, t(:report_hubs)
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @data.distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
.omega.fourteen.columns
= f.select(:order_cycle_id_in, report_order_cycle_options(@data.order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_payment)
.omega.fourteen.columns= select_tag(:payment_method_in, options_for_select(report_payment_method_options(@report.query_result), params[:payment_method_in]), {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:shipping_methods)
.omega.fourteen.columns= select_tag(:shipping_method_in, options_for_select(report_shipping_method_options(@report.query_result), params[:shipping_method_in]), {class: "select2 fullwidth", multiple: true})

View File

@@ -0,0 +1 @@
= render 'admin/reports/date_range_form', f: f

View File

@@ -0,0 +1,14 @@
= render 'admin/reports/date_range_form', f: f
.row
.alpha.two.columns= label_tag nil, t(:report_hubs)
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @data.orders_distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_producers)
.omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@data.orders_suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
.omega.fourteen.columns
= f.select(:order_cycle_id_in, report_order_cycle_options(@data.order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})

View File

@@ -0,0 +1,16 @@
= render partial: 'admin/reports/date_range_form', locals: { f: f, field: 'order_completed_at' }
.row
.alpha.two.columns= label_tag nil, t(:report_hubs)
.omega.fourteen.columns
= collection_select("q", "order_distributor_id_in", @data.orders_distributors, :id, :name, {selected: params.dig(:q, :order_distributor_id_in)}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_producers)
.omega.fourteen.columns
= select_tag("q[supplier_id_in]", options_from_collection_for_select(@data.orders_suppliers, :id, :name, params.dig(:q, :supplier_id_in)), {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
.omega.fourteen.columns
= select_tag("q[order_cycle_id_in]", options_for_select(report_order_cycle_options(@data.order_cycles), params.dig(:q, :order_cycle_id_in)), {class: "select2 fullwidth", multiple: true})

View File

@@ -0,0 +1,6 @@
= render 'admin/reports/date_range_form', f: f
.row
.alpha.two.columns= label_tag nil, t(:report_distributor)
.omega.fourteen.columns
= f.collection_select(:distributor_id_eq, @data.distributors, :id, :name, {:include_blank => t(:report_all)}, {:class => "select2 fullwidth light"})

View File

@@ -0,0 +1,20 @@
.row
.alpha.two.columns= label_tag nil, t(:report_distributor)
.omega.fourteen.columns
= select_tag(:distributor_id,
options_from_collection_for_select(@data.distributors, :id, :name, params[:distributor_id]),
{:include_blank => true, :class => "select2 fullwidth light"})
.row
.alpha.two.columns= label_tag nil, t(:report_customers_supplier)
.omega.fourteen.columns
= select_tag(:supplier_id,
options_from_collection_for_select(@data.suppliers, :id, :name, params[:supplier_id]),
{:include_blank => true, :class => "select2 fullwidth light"})
.row
.alpha.two.columns= label_tag nil, t(:report_order_cycle)
.omega.fourteen.columns
= select_tag(:order_cycle_id,
options_for_select(report_order_cycle_options(@data.order_cycles), params[:order_cycle_id]),
{:include_blank => true, :class => "select2 fullwidth light"})

View File

@@ -0,0 +1,6 @@
= render 'admin/reports/date_range_form', f: f
.row
.alpha.two.columns= label_tag nil, t(:report_distributor)
.omega.fourteen.columns
= f.collection_select(:distributor_id_eq, @data.distributors, :id, :name, {:include_blank => t(:all)}, {:class => "select2 fullwidth light"})

View File

@@ -0,0 +1,7 @@
.row
.alpha.two.columns= label_tag nil, t(:report_enterprises)
.omega.fourteen.columns= select_tag(:enterprise_id_in, options_from_collection_for_select(Enterprise.all, :id, :name, params[:enterprise_id_in]), {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_users)
.omega.fourteen.columns= select_tag(:user_id_in, options_from_collection_for_select(Spree::User.all, :id, :email, params[:user_id_in]), {class: "select2 fullwidth", multiple: true})

View File

@@ -0,0 +1,25 @@
= render 'admin/reports/date_range_form', f: f
.row
.two.columns.alpha= label_tag nil, t(:report_hubs)
.fourteen.columns.omega= f.collection_select(:distributor_id_eq, @data.distributors, :id, :name, {:include_blank => 'All'}, {:class => "select2 fullwidth light"})
.row
.two.columns.alpha= label_tag nil, t(:report_order_cycle)
.fourteen.columns.omega= f.select(:order_cycle_id_eq,
options_for_select(report_order_cycle_options(@data.order_cycles), params.dig(:q, :order_cycle_id_eq)),
{:include_blank => true}, {:class => "select2 fullwidth light"})
%fieldset.no-border-bottom.print-hidden{ style: "padding-bottom: 0" }
%legend{ align: 'center'}= t(:report_xero_configuration)
.row
.two.columns.alpha= label_tag :initial_invoice_number, t(:initial_invoice_number)
.fourteen.columns.omega= number_field_tag :initial_invoice_number, params[:initial_invoice_number]
.row
.two.columns.alpha= label_tag :invoice_date, t(:invoice_date)
.fourteen.columns.omega= text_field_tag :invoice_date, params[:invoice_date], class: 'datetimepicker'
.row
.two.columns.alpha= label_tag :due_date, t(:due_date)
.fourteen.columns.omega= text_field_tag :due_date, params[:due_date], class: 'datetimepicker'
.row
.two.columns.alpha= label_tag :account_code, t(:account_code)
.fourteen.columns.omega= text_field_tag :account_code, params[:account_code]

View File

@@ -0,0 +1,25 @@
- content_for :page_title do
= t(:listing_reports)
.columns.twelve
%table.index
%thead
%tr
%th= t(:name)
%th= t(:description)
%tbody
- @reports.each do |report_type, report_subtypes|
%tr
%td
- name = I18n.t(:name, scope: [:admin, :reports, report_type])
- url = main_app.admin_report_url(report_type: report_type)
= link_to name, url
%td
- begin
= I18n.t!(:description, scope: [:admin, :reports, report_type])
- rescue I18n::MissingTranslationData
%ul{style: "margin-left: 12pt"}
- report_subtypes.each do |report_subtype|
%li
- url = main_app.admin_report_url(report_type: report_type, report_subtype: report_subtype[1])
= link_to report_subtype[0], url

View File

@@ -1,31 +0,0 @@
= form_tag main_app.admin_reports_path, report_type: 'packing' do
= render partial: 'date_range_form'
.row
.alpha.two.columns= label_tag nil, t(:report_hubs)
.omega.fourteen.columns
= collection_select("q", "order_distributor_id_in", @distributors, :id, :name, {selected: params.dig(:q, :order_distributor_id_in)}, {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_producers)
.omega.fourteen.columns
= select_tag("q[supplier_id_in]", options_from_collection_for_select(@suppliers, :id, :name, params.dig(:q, :supplier_id_in)), {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
.omega.fourteen.columns
= select_tag("q[order_cycle_id_in]", options_for_select(report_order_cycle_options(@order_cycles), params.dig(:q, :order_cycle_id_in)), {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_type)
.omega.fourteen.columns
= select_tag(:report_subtype, options_for_select(@report_subtypes, @report_subtype))
= render partial: "rendering_options"
.row
= button t(:search)
= render partial: "spree/admin/reports/customer_names_message"
= render "table", id: "listing_orders", msg_option: t(:search)

View File

@@ -0,0 +1,22 @@
= form_for @report.search, :url => url_for(only_path: false) do |f|
%fieldset.no-border-bottom.print-hidden
%legend{ align: 'center'}= t(:report_filters)
= render partial: "admin/reports/filters/#{@report_type}", locals: { f: f }
%fieldset.print-hidden
%legend{ align: 'center'}= t(:report_render_options)
= render partial: "rendering_options"
.actions.filter-actions
= button t(:go), "report__submit-btn"
.report__header.print-hidden
- if @report.message.present?
%p.report__message= @report.message
- if request.post?
%button.btn-print.icon-print{ onclick: "window.print()"}= t(:report_print)
/ We don't want to render data unless search params are supplied.
/ Compiling data can take a long time.
- if request.post?
= render "table"

View File

@@ -6,7 +6,7 @@
.admin-current-terms-of-service
- if @current_file
%p= t(".current_terms_html", tos_link: link_to(t(".terms_of_service"), @current_file.attachment.url), datetime: @current_file.updated_at)
%p= t(".current_terms_html", tos_link: link_to(t(".terms_of_service"), @current_file.attachment), datetime: @current_file.updated_at)
%p= link_to t(".delete"), main_app.admin_terms_of_service_files_path, method: "delete", data: { confirm: t(".confirm_delete") }
- else
%p

View File

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

View File

@@ -1,3 +1,3 @@
%p
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted=#{terms_and_conditions_already_accepted?}" } }
%label.small{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank'))
%label.small{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions, target: '_blank'))

View File

@@ -3,7 +3,7 @@
- content_for(:description) do
= current_distributor.description
- content_for(:image) do
= current_distributor.logo.url
= url_for(current_distributor.logo) if current_distributor.logo.attached?
- content_for :injection_data do
- cache(*CacheService::FragmentCaching.ams_shop(@enterprise)) do

View File

@@ -3,7 +3,7 @@
- content_for(:description) do
= @group.description
- content_for(:image) do
= @group.logo.url
= url_for(@group.logo) if @group.logo.attached?
- content_for :scripts do
= render partial: "shared/google_maps_js"
@@ -22,14 +22,13 @@
%header
.row
.small-12.columns
- if @group.promo_image.present?
%img{"src" => @group.promo_image}
= image_tag @group.promo_image.variant(resize_to_limit: [1200, 260]) if @group.promo_image.variable?
.row
.small-12.columns.group-header.pad-top
- if @group.logo.present?
%img.group-logo{"src" => @group.logo}
- if @group.logo.variable?
= image_tag @group.logo.variant(resize_to_limit: [100, 100]), class: "group-logo"
- else
%img.group-logo{"src" => '/noimage/group.png' }
= image_tag "/noimage/group.png", class: "group-logo"
%h2.group-name= @group.name
%p= @group.description

View File

@@ -1,5 +1,5 @@
:css
#tagline:before { background-image: url("#{ContentConfig.home_hero.url}") }
#tagline:before { background-image: url("#{ContentConfig.url_for(:home_hero)}") }
- content_for :page_alert do

View File

@@ -4,7 +4,7 @@
%meta{name: 'viewport', content: "width=device-width,initial-scale=1.0"}/
%meta{property: "og:title", content: content_for?(:title) ? yield(:title) : t(:title)}
%meta{property: "og:description", content: content_for?(:description) ? yield(:description) : t(:site_meta_description)}
%meta{property: "og:image", content: content_for?(:image) ? yield(:image) : ContentConfig.logo.url}
%meta{property: "og:image", content: content_for?(:image) ? yield(:image) : ContentConfig.url_for(:logo)}
- if !Rails.env.production? || @noindex_meta_tag
%meta{name: "robots", content: "noindex"}
%title= content_for?(:title) ? "#{yield(:title)} - #{t(:title)}".html_safe : "#{t(:welcome_to)} #{t(:title)}"

View File

@@ -15,7 +15,7 @@
%table{:bgcolor => "#f2f2f2"}
%tr
%td
%img{src: ContentConfig.footer_logo.url, width: "144", height: "50"}/
%img{src: ContentConfig.url_for(:footer_logo), width: "144", height: "50"}/
%td{:align => "right"}
%h6.collapse
= Spree::Config[:site_name]

View File

@@ -0,0 +1,56 @@
!!!
%html
%head
%meta{charset: 'utf-8'}
-# Using wicked_pdf_stylesheet_pack_tag with a new pdf pack was not working when using
-# WickedPdf.new.pdf_from_string cause the css file reference was not absolute
-# So I ended up putting inline css here, so it's included for sure in the PDF
:css
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
font-family: system-ui,-apple-system,"Helvetica Neue",Arial,sans-serif;
color: #212529;
}
table {
width: 100%;
border-collapse: collapse;
}
th {
text-align: left;
}
th, td {
padding: 7px 5px;
vertical-align: middle;
text-overflow: ellipsis;
padding-top: 12px;
}
tr {
border-bottom: 1px solid #e2e2e2;
}
thead {
background-color: #f6f6f6;
border-bottom: 1px solid grey;
}
.h1, .h2, .h3 {
font-weight: bold;
padding-top: 15px;
}
.h1 {
font-size: 1.6rem;
padding-top: 20px;
}
.h2 {
font-size: 1.3rem;
}
.h3 {
font-size: 1.15rem;
}
.text-bold {
font-weight: bold;
}
%body
= yield

View File

@@ -96,7 +96,7 @@
.row.legal
.small-12.medium-3.medium-offset-2.columns.text-left
%a{href: main_app.root_path}
%img{src: ContentConfig.footer_logo.url, width: "220"}
%img{src: ContentConfig.url_for(:footer_logo), width: "220"}
.small-12.medium-5.columns.text-left
%p.text-small
= t '.footer_legal_call'

View File

@@ -3,7 +3,7 @@
%ul.nav-logo
%li.ofn-logo
%a{href: main_app.root_path}
%img{src: ContentConfig.logo.url}
%img{src: ContentConfig.url_for(:logo)}
%li.powered-by
%img{src: '/favicon.ico'}
%span

View File

@@ -6,7 +6,7 @@
%section.left
.ofn-logo
%a{href: main_app.root_path}
%img{src: ContentConfig.logo_mobile.url, srcset: ContentConfig.logo_mobile_svg.url, width: "75", height: "26"}
%img{src: ContentConfig.url_for(:logo_mobile), srcset: ContentConfig.url_for(:logo_mobile_svg), width: "75", height: "26"}
%section.right{"ng-cloak" => true}
%span.cart-span{"ng-class" => "{ dirty: Cart.dirty || Cart.empty(), 'pure-dirty': Cart.dirty }"}

View File

@@ -2,7 +2,7 @@
%ul.off-canvas-list
%li.ofn-logo
%a{href: main_app.root_path}
%img{src: ContentConfig.logo_mobile.url, srcset: ContentConfig.logo_mobile_svg.url, width: "75", height: "26"}
%img{src: ContentConfig.url_for(:logo_mobile), srcset: ContentConfig.url_for(:logo_mobile_svg), width: "75", height: "26"}
- [*1..7].each do |menu_number|
- menu_name = "menu_#{menu_number}"
- if ContentConfig[menu_name].present?

View File

@@ -4,8 +4,8 @@
%distributor.details.row
.small-12.medium-12.large-8.columns
#distributor_title
- if distributor.logo?
%img.left{src: distributor.logo.url(:thumb)}
- if distributor.logo.variable?
= image_tag distributor.logo_url(:thumb), class: "left"
= render DistributorTitleComponent.new(name: distributor.name)
%location= distributor.address.city

View File

@@ -69,7 +69,7 @@
%div.checkout-substep{ "data-controller": "toggle shippingmethod" }
- selected_shipping_method = @order.shipping_method&.id || params[:shipping_method_id]
%div.checkout-title
= t("split_checkout.step1.delivery_address.title")
= t("split_checkout.step1.shipping_info.title")
- display_ship_address = false
- ship_method_description = nil

View File

@@ -43,7 +43,7 @@
%div.summary
%span.summary-label
= t("split_checkout.step1.delivery_address.title")
= t("split_checkout.step1.shipping_info.title")
%span.summary-value
= @order.shipping_method.name
%div.summary-description

View File

@@ -3,7 +3,7 @@
- if platform_terms_required? && distributor_terms_required?
= f.check_box :accept_terms, { name: "accept_terms", checked: all_terms_and_conditions_already_accepted? }, 1, nil
= f.label :accept_terms do
= t('split_checkout.step3.all_terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to_platform_terms)
= t('split_checkout.step3.all_terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions, target: '_blank'), tos_link: link_to_platform_terms)
- elsif platform_terms_required?
= f.check_box :accept_terms, { name: "accept_terms", checked: platform_tos_already_accepted? }, 1, nil
= f.label :accept_terms do
@@ -11,7 +11,7 @@
- elsif distributor_terms_required?
= f.check_box :accept_terms, { name: "accept_terms", checked: terms_and_conditions_already_accepted? }, 1, nil
= f.label :accept_terms do
= t('split_checkout.step3.terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions.url, target: '_blank'))
= t('split_checkout.step3.terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions, target: '_blank'))
= f.error_message_on :terms_and_conditions, standalone: true

View File

@@ -11,7 +11,9 @@
.field.alpha.three.columns.align-center
= f.label t('spree.thumbnail')
%br/
= link_to image_tag(@image.attachment.url(:small)), @image.attachment.url(:product)
- # A Rails bug makes it necessary to call `main_app.url_for` here.
- # https://github.com/rails/rails/issues/31325
= link_to image_tag(main_app.url_for(@image.variant(:small))), main_app.url_for(@image.variant(:product))
.nine.columns.omega
= render partial: 'form', locals: { f: f }
.clear

View File

@@ -32,7 +32,9 @@
%td.no-border
%span.handle
%td
= link_to image_tag(image.attachment.url(:mini)), image.attachment.url(:product)
- # A Rails bug makes it necessary to call `main_app.url_for` here.
- # https://github.com/rails/rails/issues/31325
= link_to image_tag(main_app.url_for(image.variant(:mini))), main_app.url_for(image.variant(:product))
%td= options_text_for(image)
%td= image.alt
%td.actions

View File

@@ -6,9 +6,9 @@
%td{ :align => "left" }
%h4
= t :tax_invoice
- if @order.distributor.display_invoice_logo? && @order.distributor.logo.present?
- if @order.distributor.display_invoice_logo? && @order.distributor.logo.variable?
%td{ :align => "right", rowspan: 2 }
= wicked_pdf_image_tag @order.distributor.logo(:small), width: 150, height: 150
= wicked_pdf_image_tag @order.distributor.logo.variant(resize_to_limit: [150, 150])
%tr{ valign: "top" }
%td{ :align => "left" }
- if @order.distributor.business_address.blank?
@@ -66,6 +66,12 @@
%br
- if @order.bill_address
= @order.bill_address.address_part2
- if @order.bill_address.phone.present?
%br
= @order.bill_address.phone
- if @order&.customer&.email.present?
%br
= @order.customer.email
= render 'spree/admin/orders/invoice_table2'

View File

@@ -1,2 +0,0 @@
%p.customer-names-tip
= t(".customer_names_tip")

View File

@@ -1,4 +0,0 @@
%ul{style: "margin-left: 12pt"}
- report_types.each do |report_type|
%li
= link_to report_type[0], "#{customers_admin_reports_url}?report_type=#{report_type[1]}"

View File

@@ -1,9 +0,0 @@
.row.date-range-filter
= label_tag nil, t(:date_range)
%br
= label_tag nil, t(:start), :class => 'inline'
= f.text_field :completed_at_gt, :class => 'datetimepicker datepicker-from'
%span.range-divider
%i.icon-arrow-right
= f.text_field :completed_at_lt, :class => 'datetimepicker datepicker-to'
= label_tag nil, t(:end), :class => 'inline'

View File

@@ -1,2 +0,0 @@
- order_number = value
= link_to order_number, edit_admin_order_url(order_number), class: 'edit-order'

View File

@@ -1,4 +0,0 @@
%ul{style: "margin-left: 12pt"}
- report_types.each do |report_type|
%li
= link_to report_type[0], "#{order_cycle_management_admin_reports_url}?report_type=#{report_type[1]}"

View File

@@ -1,5 +0,0 @@
%ul{style: "margin-left: 12pt"}
- report_types.each do |report_type|
%li
= link_to report_type[0], "#{orders_and_fulfillment_admin_reports_url}?report_type=#{report_type[1]}"

View File

@@ -1,5 +0,0 @@
%ul{style: "margin-left: 12pt"}
- report_subtypes("packing").each do |report_subtype|
%li
= link_to t("admin.reports.packing.#{report_subtype}_report"),
main_app.admin_reports_url(report_type: 'packing', report_subtype: report_subtype)

View File

@@ -1,4 +0,0 @@
%ul{style: "margin-left: 12pt"}
- report_types.each do |report_type|
%li
= link_to report_type[0], "#{products_and_inventory_admin_reports_url}?report_type=#{report_type[1]}"

View File

@@ -1,4 +0,0 @@
%ul{style: "margin-left: 12pt"}
- report_types.each do |report_type|
%li
= link_to report_type[0], "#{sales_tax_admin_reports_url}?report_type=#{report_type[1]}"

View File

@@ -1,23 +0,0 @@
- column_partials ||= {}
- if render_content?
%table.report__table{id: id}
%thead
%tr
- @header.each do |heading|
%th= heading
%tbody
- @table.each do |row|
%tr
- row.each_with_index do |cell_value, column_index|
%td
- partial = column_partials[column_index]
- if partial
= render partial, value: cell_value
- else
= cell_value
- if @table.empty?
%tr
%td{colspan: @header.count}= t(:none)
- else
%p.report__message
= t(".select_and_search", option: msg_option.upcase)

View File

@@ -1,32 +0,0 @@
= form_tag spree.customers_admin_reports_url do |f|
%br
.row
.four.columns.alpha
= label_tag nil, t(:report_customers_distributor)
= select_tag(:distributor_id,
options_from_collection_for_select(@distributors, :id, :name, params[:distributor_id]),
{:include_blank => true, :class => "select2 fullwidth"})
.four.columns
= label_tag nil, t(:report_customers_supplier)
= select_tag(:supplier_id,
options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id]),
{:include_blank => true, :class => "select2 fullwidth"})
.six.columns
= label_tag nil, t(:report_customers_cycle)
= select_tag(:order_cycle_id,
options_for_select(report_order_cycle_options(@order_cycles), params[:order_cycle_id]),
{:include_blank => true, :class => "select2 fullwidth"})
= label_tag nil, t(:report_customers_type)
= select_tag(:report_type, options_for_select(@report_types, @report_type))
%br
%br
= check_box_tag :csv
= label_tag :csv, t(:report_customers_csv)
%br
= button t(:go)
= render "table", id: "listing_customers", msg_option: t(:go)

View File

@@ -1,14 +0,0 @@
- content_for :page_title do
= t(:listing_reports)
.columns.twelve
%table.index
%thead
%tr
%th= t(:name)
%th= t(:description)
%tbody
- @reports.each do |key, value|
%tr
%td= link_to value[:name], value[:url]
%td= value[:description]

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