mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-18 19:36:48 +00:00
Compare commits
267 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20cabe6f12 | ||
|
|
fe849b8dfd | ||
|
|
167b44c30f | ||
|
|
ad247e2116 | ||
|
|
e46875376e | ||
|
|
d7223c508a | ||
|
|
a91a23aa39 | ||
|
|
370f66e36b | ||
|
|
f7cdcf02e0 | ||
|
|
1ee43fb495 | ||
|
|
e139d24639 | ||
|
|
0dfe749496 | ||
|
|
d6eade6fa3 | ||
|
|
109aed684e | ||
|
|
35d76ac991 | ||
|
|
1ab9e9d7a5 | ||
|
|
e5e716e150 | ||
|
|
b6510c3ab6 | ||
|
|
a158a986c6 | ||
|
|
c7643db66f | ||
|
|
eb8c22aa06 | ||
|
|
d0656485d7 | ||
|
|
640cc1b6d3 | ||
|
|
d65d17a9f3 | ||
|
|
bbea00e431 | ||
|
|
3cecba70e8 | ||
|
|
8bbff09066 | ||
|
|
a7a89d7ccb | ||
|
|
3ccf76ff5f | ||
|
|
6004208496 | ||
|
|
3ce9c712cf | ||
|
|
bfb0032fd2 | ||
|
|
fe37516ead | ||
|
|
289b75e143 | ||
|
|
09f0f8c33f | ||
|
|
8bc1718978 | ||
|
|
cbfce69a6d | ||
|
|
4e0ecdd44c | ||
|
|
23ab9a4bed | ||
|
|
f623446e3e | ||
|
|
6944fe1e46 | ||
|
|
7c9e3d7f06 | ||
|
|
bdcadf9fc6 | ||
|
|
9b7139fd45 | ||
|
|
543e275d2e | ||
|
|
560fa6b949 | ||
|
|
dbf34da87b | ||
|
|
d6022062e1 | ||
|
|
b082d3301b | ||
|
|
48cd542138 | ||
|
|
e2d341c9c2 | ||
|
|
89873a2640 | ||
|
|
b4be2cc2d4 | ||
|
|
35f89a9750 | ||
|
|
592a53b6f5 | ||
|
|
eab9d42eb0 | ||
|
|
cf05369ca9 | ||
|
|
5077b0e625 | ||
|
|
1299c0b5eb | ||
|
|
a2bc61cb4d | ||
|
|
057572a445 | ||
|
|
3403ab4162 | ||
|
|
9a036d18b7 | ||
|
|
f2b57057cd | ||
|
|
95bc8fa984 | ||
|
|
54c44c33eb | ||
|
|
8a732568e7 | ||
|
|
f4523f0305 | ||
|
|
56a7a49ea2 | ||
|
|
7d1ae3bf67 | ||
|
|
b9aa4e11da | ||
|
|
96428c11c6 | ||
|
|
c15660da0e | ||
|
|
9ea05b0794 | ||
|
|
c5b939c8ee | ||
|
|
c5a17bcde0 | ||
|
|
b712ec7f13 | ||
|
|
32a7f13dd2 | ||
|
|
713769b497 | ||
|
|
495de37620 | ||
|
|
05d24cf11a | ||
|
|
edd84530af | ||
|
|
6677543de0 | ||
|
|
30aa31252b | ||
|
|
b83d74a609 | ||
|
|
d31b50be3d | ||
|
|
42e3f2f2f4 | ||
|
|
96737da128 | ||
|
|
7f9f0d840c | ||
|
|
686840e262 | ||
|
|
2377b833ee | ||
|
|
3f3c33bce6 | ||
|
|
e35eff95bb | ||
|
|
e6408161db | ||
|
|
4540b32d3a | ||
|
|
9f8d2fddbc | ||
|
|
14047c620a | ||
|
|
2be1c231f7 | ||
|
|
c34646724c | ||
|
|
b731635270 | ||
|
|
c9a62fad4c | ||
|
|
70169d477c | ||
|
|
d95646ea98 | ||
|
|
d50bf928e1 | ||
|
|
3f7aff4b8b | ||
|
|
de9476a8a5 | ||
|
|
5fded022d4 | ||
|
|
bce41a2247 | ||
|
|
1f644f4020 | ||
|
|
cc11d4e5f0 | ||
|
|
5ecac77aa5 | ||
|
|
a5d2579c69 | ||
|
|
112adb11db | ||
|
|
5fdc11bdc7 | ||
|
|
c038b485b1 | ||
|
|
19eb93012c | ||
|
|
d998ec8453 | ||
|
|
0c93665030 | ||
|
|
c4d298d732 | ||
|
|
36883bc051 | ||
|
|
8c252fc160 | ||
|
|
c2f8803d72 | ||
|
|
07967275d8 | ||
|
|
c7db1b7fc0 | ||
|
|
fa57d71a23 | ||
|
|
be5e7bd18d | ||
|
|
5cfc2613ac | ||
|
|
903eb23122 | ||
|
|
d162e8c087 | ||
|
|
75a56c2be5 | ||
|
|
07a5963554 | ||
|
|
a6888cf0be | ||
|
|
ef35db6db2 | ||
|
|
375d4fbffd | ||
|
|
6153789055 | ||
|
|
032741c54f | ||
|
|
e9acf6e0de | ||
|
|
d5e90c3c6c | ||
|
|
7e7429446d | ||
|
|
535e389fb4 | ||
|
|
cecebb82f4 | ||
|
|
49665ae360 | ||
|
|
7e5c194515 | ||
|
|
fe0b3172c7 | ||
|
|
5b27ed6b9f | ||
|
|
bef4741e31 | ||
|
|
d604328bfb | ||
|
|
2af3de51c7 | ||
|
|
d0c77a8dc4 | ||
|
|
8fc4ca6f65 | ||
|
|
721a0d3a98 | ||
|
|
c46fe7b675 | ||
|
|
bb372984e1 | ||
|
|
2489a2f5f5 | ||
|
|
a6698230fe | ||
|
|
50731e929e | ||
|
|
baa09b88f7 | ||
|
|
2f3509bf9b | ||
|
|
e8f9ace8e6 | ||
|
|
04270b6cec | ||
|
|
1155931ea9 | ||
|
|
efd450606e | ||
|
|
2f60a85593 | ||
|
|
78cf35807a | ||
|
|
f3bc038c05 | ||
|
|
7817a40a35 | ||
|
|
a18f6f5b8f | ||
|
|
403653381c | ||
|
|
eb85dccac1 | ||
|
|
f32454b404 | ||
|
|
591efecde6 | ||
|
|
24afa21885 | ||
|
|
cd6d34663e | ||
|
|
c66e5fe1e9 | ||
|
|
4ec8fcd3a6 | ||
|
|
88893a2968 | ||
|
|
62599e8dfc | ||
|
|
b97c428f72 | ||
|
|
42b074f02e | ||
|
|
07e0951490 | ||
|
|
fc433ff8f0 | ||
|
|
8e33437fbb | ||
|
|
a5103c737d | ||
|
|
37c8f42244 | ||
|
|
0e8765636b | ||
|
|
6855e5c8f4 | ||
|
|
a96b56239c | ||
|
|
4f9eee2682 | ||
|
|
44761315c2 | ||
|
|
0d18b1a032 | ||
|
|
cc0dabcd1e | ||
|
|
e79c672263 | ||
|
|
bc6f7934e0 | ||
|
|
89029f46f9 | ||
|
|
144369e55f | ||
|
|
3833cbbf73 | ||
|
|
5b703a02cd | ||
|
|
1d4aebd3f9 | ||
|
|
845a764320 | ||
|
|
c66579a22f | ||
|
|
9291bf5c82 | ||
|
|
4781ab93ef | ||
|
|
def9ab7c47 | ||
|
|
2a68d34fb0 | ||
|
|
2ce56aef2c | ||
|
|
20f965731d | ||
|
|
8378dce752 | ||
|
|
d7a4e3a896 | ||
|
|
7d9de0ca70 | ||
|
|
f9c6f09cd4 | ||
|
|
4a83eca832 | ||
|
|
4954db64b3 | ||
|
|
b2c4b97d94 | ||
|
|
32c1eecece | ||
|
|
6d8c7a4bee | ||
|
|
bd2045cad7 | ||
|
|
e1c3d2442a | ||
|
|
3df65d0463 | ||
|
|
822a17f732 | ||
|
|
ffde0307e2 | ||
|
|
9e57807dc2 | ||
|
|
052bac196b | ||
|
|
00e789b95b | ||
|
|
a004822019 | ||
|
|
49f7b4c8e2 | ||
|
|
8b503b51ca | ||
|
|
4e431ecf18 | ||
|
|
81f8b127db | ||
|
|
f9f81086fd | ||
|
|
9807b432f9 | ||
|
|
6b0f3cd4f3 | ||
|
|
3c412b7b7d | ||
|
|
c4e6c0af2b | ||
|
|
e6387197ec | ||
|
|
746c4f03f6 | ||
|
|
37abdb7727 | ||
|
|
bdb3dd5aaf | ||
|
|
25fbab2e37 | ||
|
|
4d37aaac64 | ||
|
|
19e28cb14a | ||
|
|
a44a251d96 | ||
|
|
2921ee19e1 | ||
|
|
6796d91a07 | ||
|
|
69afcf7510 | ||
|
|
47056e3cc1 | ||
|
|
91a52ead58 | ||
|
|
caebcdf184 | ||
|
|
c66a659e8e | ||
|
|
b8b107dd2d | ||
|
|
3d32987227 | ||
|
|
902e51e580 | ||
|
|
743cb3b33a | ||
|
|
74e49787f4 | ||
|
|
afa8f97627 | ||
|
|
6e677fecce | ||
|
|
889a3e6d9d | ||
|
|
664be47ac3 | ||
|
|
0e4b5ad9ec | ||
|
|
5634f4af18 | ||
|
|
0dede39617 | ||
|
|
377b4a3755 | ||
|
|
0c809b2911 | ||
|
|
33472014f1 | ||
|
|
d038c27f1f | ||
|
|
3d718d9738 | ||
|
|
a2e6b84db2 | ||
|
|
d319f97733 |
66
.github/ISSUE_TEMPLATE.md
vendored
66
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,66 +0,0 @@
|
||||
<!-- Provide a general summary of the issue in the Title above.
|
||||
|
||||
If your issue is not a bug, please use the Feature template instead:
|
||||
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Feature-template
|
||||
|
||||
-->
|
||||
## Description
|
||||
<!-- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
|
||||
|
||||
|
||||
|
||||
## Expected Behavior
|
||||
<!-- Tell us what should happen -->
|
||||
|
||||
|
||||
|
||||
## Actual Behavior
|
||||
<!-- Tell us what happens instead -->
|
||||
|
||||
|
||||
|
||||
## Steps to Reproduce
|
||||
<!-- Provide an unambiguous set of steps to reproduce this bug -->
|
||||
<!-- Include code to reproduce if relevant -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
## Animated Gif/Screenshot
|
||||
<!-- Provide a screenshot or brief animated gif reproducing the bug. Linux users can use
|
||||
[Peek](https://github.com/phw/peek#ubuntu) while Mac users can use [Recordit](http://recordit.co/) -->
|
||||
|
||||
|
||||
|
||||
## Context
|
||||
<!-- How has this bug affected you? What were you trying to accomplish? -->
|
||||
|
||||
|
||||
|
||||
## Severity
|
||||
<!-- Assign a label and explain the impact.
|
||||
|
||||
bug-s1: a critical feature is broken: checkout, payments, signup, login
|
||||
bug-s2: a non-critical feature is broken, no workaround
|
||||
bug-s3: a feature is broken but there is a workaround
|
||||
bug-s4: it's annoying, but you can use it
|
||||
bug-s5: we can live with it, only a few users impacted
|
||||
|
||||
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Bug-severity
|
||||
-->
|
||||
|
||||
|
||||
|
||||
## Your Environment
|
||||
<!-- Include relevant details about the environment you experienced the bug in -->
|
||||
|
||||
* Version used:
|
||||
* Browser name and version:
|
||||
* Operating System and version (desktop or mobile):
|
||||
|
||||
## Possible Fix
|
||||
<!-- Not obligatory, but suggest a fix or reason for the bug -->
|
||||
|
||||
|
||||
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -9,6 +9,7 @@ assignees: ''
|
||||
|
||||
## Description
|
||||
<!-- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
|
||||
<!-- How has this bug affected you? What were you trying to accomplish? -->
|
||||
|
||||
|
||||
## Expected Behavior
|
||||
@@ -22,6 +23,8 @@ assignees: ''
|
||||
## Steps to Reproduce
|
||||
<!-- Provide an unambiguous set of steps to reproduce this bug -->
|
||||
<!-- Include code to reproduce if relevant -->
|
||||
<!-- Include links -->
|
||||
<!-- Include user ID -->
|
||||
|
||||
1.
|
||||
2.
|
||||
@@ -29,13 +32,11 @@ assignees: ''
|
||||
4.
|
||||
|
||||
## Animated Gif/Screenshot
|
||||
<!-- Provide a screenshot or brief animated gif reproducing the bug. Linux users can use
|
||||
[Peek](https://github.com/phw/peek#ubuntu) while Mac users can use [Recordit](http://recordit.co/) -->
|
||||
|
||||
|
||||
## Context
|
||||
<!-- How has this bug affected you? What were you trying to accomplish? -->
|
||||
<!-- Provide a screenshot or brief video reproducing the bug. -->
|
||||
<!-- Please try to have the dev tools opened on the network tab (press F12 to open the devtools of your browser -->
|
||||
|
||||
## Workaround
|
||||
<!-- Include a workaround for this bug (if relevant) -->
|
||||
|
||||
## Severity
|
||||
<!-- Assign a label and explain the impact.
|
||||
@@ -55,7 +56,6 @@ https://github.com/openfoodfoundation/openfoodnetwork/wiki/Bug-severity
|
||||
* Version used:
|
||||
* Browser name and version:
|
||||
* Operating System and version (desktop or mobile):
|
||||
* OFN Platform instance where you discovered the bug, and which version of the software they are using.
|
||||
|
||||
## Possible Fix
|
||||
<!-- Not obligatory, but suggest a fix or reason for the bug -->
|
||||
|
||||
11
.github/ISSUE_TEMPLATE/story-template.md
vendored
11
.github/ISSUE_TEMPLATE/story-template.md
vendored
@@ -14,5 +14,12 @@ assignees: ''
|
||||
**- I want to be able to do:** (specify the desired behavior)
|
||||
(Link to others issues or resources to provide context > only if really necessary). -->
|
||||
|
||||
## Acceptance Criteria
|
||||
<!-- Document the outcomes that need to be achieved before this component can be considered complete. -->
|
||||
## Acceptance Criteria & Tests
|
||||
<!-- Document the outcomes that need to be achieved before this component can be considered complete.
|
||||
-->
|
||||
<!-- Provide an unambiguous set of steps a tester should do to validate the PR that will solve this issue -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
@@ -110,18 +110,6 @@ Metrics/LineLength:
|
||||
- app/models/variant_override.rb
|
||||
- app/models/variant_override_set.rb
|
||||
- app/overrides/add_enterprise_fees_to_admin_configurations_menu.rb
|
||||
- app/serializers/api/admin/basic_enterprise_serializer.rb
|
||||
- app/serializers/api/admin/enterprise_fee_serializer.rb
|
||||
- app/serializers/api/admin/enterprise_serializer.rb
|
||||
- app/serializers/api/admin/exchange_serializer.rb
|
||||
- app/serializers/api/admin/for_order_cycle/enterprise_serializer.rb
|
||||
- app/serializers/api/admin/index_enterprise_serializer.rb
|
||||
- app/serializers/api/admin/index_order_cycle_serializer.rb
|
||||
- app/serializers/api/admin/line_item_serializer.rb
|
||||
- app/serializers/api/admin/order_cycle_serializer.rb
|
||||
- app/serializers/api/admin/subscription_serializer.rb
|
||||
- app/serializers/api/admin/tag_rule_serializer.rb
|
||||
- app/serializers/api/admin/variant_override_serializer.rb
|
||||
- app/services/cart_service.rb
|
||||
- app/services/default_stock_location.rb
|
||||
- app/services/embedded_page_service.rb
|
||||
@@ -148,7 +136,6 @@ Metrics/LineLength:
|
||||
- lib/open_food_network/order_cycle_form_applicator.rb
|
||||
- lib/open_food_network/order_cycle_management_report.rb
|
||||
- lib/open_food_network/order_grouper.rb
|
||||
- lib/open_food_network/orders_and_fulfillments_report.rb
|
||||
- lib/open_food_network/payments_report.rb
|
||||
- lib/open_food_network/permalink_generator.rb
|
||||
- lib/open_food_network/products_cache.rb
|
||||
@@ -454,7 +441,6 @@ Metrics/AbcSize:
|
||||
- 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/orders_and_fulfillments_report.rb
|
||||
- lib/open_food_network/packing_report.rb
|
||||
- lib/open_food_network/payments_report.rb
|
||||
- lib/open_food_network/permissions.rb
|
||||
@@ -532,7 +518,6 @@ Metrics/CyclomaticComplexity:
|
||||
- lib/discourse/single_sign_on.rb
|
||||
- lib/open_food_network/bulk_coop_report.rb
|
||||
- lib/open_food_network/enterprise_issue_validator.rb
|
||||
- lib/open_food_network/orders_and_fulfillments_report.rb
|
||||
- lib/spree/core/controller_helpers/order_decorator.rb
|
||||
- lib/spree/core/controller_helpers/respond_with_decorator.rb
|
||||
- lib/spree/localized_number.rb
|
||||
@@ -557,7 +542,6 @@ Metrics/PerceivedComplexity:
|
||||
- lib/discourse/single_sign_on.rb
|
||||
- lib/open_food_network/bulk_coop_report.rb
|
||||
- lib/open_food_network/enterprise_issue_validator.rb
|
||||
- lib/open_food_network/orders_and_fulfillments_report.rb
|
||||
- lib/spree/core/controller_helpers/order_decorator.rb
|
||||
- lib/spree/core/controller_helpers/respond_with_decorator.rb
|
||||
- lib/spree/localized_number.rb
|
||||
@@ -627,7 +611,6 @@ Metrics/MethodLength:
|
||||
- lib/open_food_network/order_cycle_management_report.rb
|
||||
- lib/open_food_network/order_cycle_permissions.rb
|
||||
- lib/open_food_network/order_grouper.rb
|
||||
- lib/open_food_network/orders_and_fulfillments_report.rb
|
||||
- lib/open_food_network/packing_report.rb
|
||||
- lib/open_food_network/payments_report.rb
|
||||
- lib/open_food_network/permissions.rb
|
||||
@@ -671,7 +654,6 @@ Metrics/ClassLength:
|
||||
- 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/orders_and_fulfillments_report.rb
|
||||
- lib/open_food_network/packing_report.rb
|
||||
- lib/open_food_network/payments_report.rb
|
||||
- lib/open_food_network/permissions.rb
|
||||
|
||||
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y curl git build-essential software-prope
|
||||
# Setup ENV variables
|
||||
ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:$PATH
|
||||
ENV RBENV_ROOT /usr/local/src/rbenv
|
||||
ENV RUBY_VERSION 2.1.5
|
||||
ENV RUBY_VERSION 2.1.9
|
||||
ENV CONFIGURE_OPTS --disable-install-doc
|
||||
|
||||
# Rbenv & Ruby part
|
||||
|
||||
@@ -11,7 +11,7 @@ The following guides are located in the wiki and provide more OS-specific step-b
|
||||
### Dependencies
|
||||
|
||||
* Rails 3.2.x
|
||||
* Ruby 2.1.5
|
||||
* Ruby 2.1.9
|
||||
* PostgreSQL database
|
||||
* PhantomJS (for testing)
|
||||
* See Gemfile for a list of gems required
|
||||
|
||||
7
Gemfile
7
Gemfile
@@ -39,7 +39,7 @@ gem 'activemerchant', '~> 1.78'
|
||||
gem 'devise', '~> 2.2.5'
|
||||
gem 'devise-encryptable', '0.2.0'
|
||||
gem 'jwt', '~> 2.2'
|
||||
gem 'oauth2', '~> 1.4.1' # Used for Stripe Connect
|
||||
gem 'oauth2', '~> 1.4.2' # Used for Stripe Connect
|
||||
|
||||
gem 'daemons'
|
||||
gem 'delayed_job_active_record'
|
||||
@@ -104,7 +104,10 @@ group :assets do
|
||||
gem 'coffee-rails', '~> 3.2.1'
|
||||
gem 'compass-rails'
|
||||
|
||||
gem 'therubyracer', '=0.12.0'
|
||||
gem 'mini_racer', '0.1.15'
|
||||
# Previously we found that libv8 6.7.288.46.1 breakis the compilation of mini_racer.
|
||||
# Now we see that we need to set the version explicitly. Nothing else depends on libv8.
|
||||
gem 'libv8', '6.3.292.48.1'
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
|
||||
|
||||
57
Gemfile.lock
57
Gemfile.lock
@@ -223,7 +223,7 @@ GEM
|
||||
activerecord (>= 3.2.0, < 5.0)
|
||||
fog (~> 1.0)
|
||||
rails (>= 3.2.0, < 5.0)
|
||||
ddtrace (0.27.0)
|
||||
ddtrace (0.28.0)
|
||||
msgpack
|
||||
debugger-linecache (1.2.0)
|
||||
deface (1.0.2)
|
||||
@@ -465,7 +465,7 @@ GEM
|
||||
addressable (~> 2.3)
|
||||
letter_opener (1.7.0)
|
||||
launchy (~> 2.2)
|
||||
libv8 (3.16.14.19)
|
||||
libv8 (6.3.292.48.1)
|
||||
listen (3.0.8)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
@@ -476,6 +476,8 @@ GEM
|
||||
mime-types (1.25.1)
|
||||
mini_mime (1.0.1)
|
||||
mini_portile2 (2.1.0)
|
||||
mini_racer (0.1.15)
|
||||
libv8 (~> 6.3)
|
||||
momentjs-rails (2.20.1)
|
||||
railties (>= 3.1)
|
||||
money (5.1.1)
|
||||
@@ -489,8 +491,8 @@ GEM
|
||||
newrelic_rpm (3.18.1.330)
|
||||
nokogiri (1.6.8.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
oauth2 (1.4.1)
|
||||
faraday (>= 0.8, < 0.16.0)
|
||||
oauth2 (1.4.2)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
@@ -579,7 +581,6 @@ GEM
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
redcarpet (3.5.0)
|
||||
ref (2.0.0)
|
||||
request_store (1.4.1)
|
||||
rack (>= 1.4)
|
||||
roadie (3.4.0)
|
||||
@@ -595,29 +596,29 @@ GEM
|
||||
nokogiri
|
||||
roo (>= 2.0.0beta1, < 3)
|
||||
spreadsheet (> 0.9.0)
|
||||
rspec (3.8.0)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-core (3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-expectations (3.8.2)
|
||||
rspec (3.9.0)
|
||||
rspec-core (~> 3.9.0)
|
||||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-core (3.9.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-expectations (3.9.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-mocks (3.8.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-mocks (3.9.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-rails (3.8.2)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-rails (3.9.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-core (~> 3.9.0)
|
||||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-retry (0.6.1)
|
||||
rspec-core (> 3.3)
|
||||
rspec-support (3.8.0)
|
||||
rspec-support (3.9.0)
|
||||
rubocop (0.57.2)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
@@ -629,7 +630,7 @@ GEM
|
||||
ruby-ole (1.2.12.1)
|
||||
ruby-progressbar (1.10.1)
|
||||
ruby-rc4 (0.1.5)
|
||||
rubyzip (1.2.2)
|
||||
rubyzip (1.3.0)
|
||||
safe_yaml (1.0.5)
|
||||
sass (3.3.14)
|
||||
sass-rails (3.2.6)
|
||||
@@ -670,9 +671,6 @@ GEM
|
||||
stripe (4.24.0)
|
||||
faraday (~> 0.13)
|
||||
net-http-persistent (~> 3.0)
|
||||
therubyracer (0.12.0)
|
||||
libv8 (~> 3.16.14.0)
|
||||
ref
|
||||
thor (0.20.3)
|
||||
tilt (1.4.1)
|
||||
timecop (0.9.1)
|
||||
@@ -685,7 +683,7 @@ GEM
|
||||
railties (> 3.2.8, < 4.0.0)
|
||||
sprockets (>= 2.2.0)
|
||||
tzinfo (0.3.55)
|
||||
uglifier (4.1.20)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode-display_width (1.3.2)
|
||||
unicorn (5.5.1)
|
||||
@@ -705,7 +703,7 @@ GEM
|
||||
nokogiri (~> 1.6)
|
||||
rubyzip (~> 1.0)
|
||||
selenium-webdriver (~> 3.0)
|
||||
webmock (3.7.4)
|
||||
webmock (3.7.6)
|
||||
addressable (>= 2.3.6)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
@@ -773,11 +771,13 @@ DEPENDENCIES
|
||||
kaminari (~> 0.14.1)
|
||||
knapsack
|
||||
letter_opener (>= 1.4.1)
|
||||
libv8 (= 6.3.292.48.1)
|
||||
listen (= 3.0.8)
|
||||
mini_racer (= 0.1.15)
|
||||
momentjs-rails
|
||||
newrelic_rpm (~> 3.0)
|
||||
nokogiri (>= 1.6.7.1)
|
||||
oauth2 (~> 1.4.1)
|
||||
oauth2 (~> 1.4.2)
|
||||
ofn-qz!
|
||||
oj
|
||||
order_management!
|
||||
@@ -814,7 +814,6 @@ DEPENDENCIES
|
||||
spring (= 1.7.2)
|
||||
spring-commands-rspec
|
||||
stripe
|
||||
therubyracer (= 0.12.0)
|
||||
timecop
|
||||
truncate_html
|
||||
turbo-sprockets-rails3
|
||||
|
||||
@@ -35,7 +35,7 @@ We use [BrowserStack](https://www.browserstack.com/) as a manual testing tool. B
|
||||
Copyright (c) 2012 - 2019 Open Food Foundation, released under the AGPL licence.
|
||||
|
||||
[survey]: https://docs.google.com/a/eaterprises.com.au/forms/d/1zxR5vSiU9CigJ9cEaC8-eJLgYid8CR8er7PPH9Mc-30/edit#
|
||||
[slack-invite]: https://join.slack.com/t/openfoodnetwork/shared_invite/enQtMzU2Mjk5MDc2MjA5LTM4ZTAzZjIwNzIxMmU5ODFiNWY1MTU2ZWUyNzQwNjdjNTY0N2VhY2UwOGU4ZmVjNzYyZDU2NjY3NzZkZmQwYjk
|
||||
[slack-invite]: https://join.slack.com/t/openfoodnetwork/shared_invite/enQtNzY3NDEwNzM2MDM0LWFmNGRhNDUwYzNmNWNkYmFkMzgxNDg1OTg1ODNjNWY4Y2FhNDIwNmE4ZWI0OThiMGNmZjFkODczNGZiYTJmNWI
|
||||
[contributor-guide]: https://ofn-user-guide.gitbook.io/ofn-contributor-guide/who-are-we
|
||||
[ofn-install]: https://github.com/openfoodfoundation/ofn-install
|
||||
[super-admin-guide]: https://ofn-user-guide.gitbook.io/ofn-super-admin-guide
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
module Api
|
||||
class OrdersController < BaseController
|
||||
def show
|
||||
authorize! :read, order
|
||||
render json: order, serializer: Api::OrderDetailedSerializer, current_order: order
|
||||
end
|
||||
|
||||
def index
|
||||
authorize! :admin, Spree::Order
|
||||
|
||||
@@ -19,5 +24,12 @@ module Api
|
||||
each_serializer: Api::Admin::OrderSerializer
|
||||
)
|
||||
end
|
||||
|
||||
def order
|
||||
@order ||= Spree::Order.
|
||||
where(number: params[:id]).
|
||||
includes(line_items: { variant: [:product, :stock_items, :default_price] }).
|
||||
first!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
9
app/controllers/spree/admin/countries_controller.rb
Normal file
9
app/controllers/spree/admin/countries_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class CountriesController < ResourceController
|
||||
def collection
|
||||
super.order(:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
35
app/controllers/spree/admin/general_settings_controller.rb
Normal file
35
app/controllers/spree/admin/general_settings_controller.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class GeneralSettingsController < Spree::Admin::BaseController
|
||||
def edit
|
||||
@preferences_general = [:site_name, :default_seo_title, :default_meta_keywords,
|
||||
:default_meta_description, :site_url, :bugherd_api_key]
|
||||
@preferences_security = [:allow_ssl_in_production,
|
||||
:allow_ssl_in_staging, :allow_ssl_in_development_and_test,
|
||||
:check_for_spree_alerts]
|
||||
@preferences_currency = [:display_currency, :hide_cents]
|
||||
end
|
||||
|
||||
def update
|
||||
params.each do |name, value|
|
||||
next unless Spree::Config.has_preference? name
|
||||
Spree::Config[name] = value
|
||||
end
|
||||
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:general_settings))
|
||||
|
||||
redirect_to edit_admin_general_settings_path
|
||||
end
|
||||
|
||||
def dismiss_alert
|
||||
return unless request.xhr? && params[:alert_id]
|
||||
dismissed = Spree::Config[:dismissed_spree_alerts] || ''
|
||||
Spree::Config.set(dismissed_spree_alerts: dismissed.
|
||||
split(',').
|
||||
push(params[:alert_id]).
|
||||
join(','))
|
||||
filter_dismissed_alerts
|
||||
render nothing: true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
module Spree
|
||||
module Admin
|
||||
GeneralSettingsController.class_eval do
|
||||
end
|
||||
|
||||
module GeneralSettingsEditPreferences
|
||||
def edit
|
||||
super
|
||||
@preferences_general << :bugherd_api_key
|
||||
end
|
||||
end
|
||||
GeneralSettingsController.prepend(GeneralSettingsEditPreferences)
|
||||
end
|
||||
end
|
||||
79
app/controllers/spree/admin/image_settings_controller.rb
Normal file
79
app/controllers/spree/admin/image_settings_controller.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ImageSettingsController < Spree::Admin::BaseController
|
||||
def edit
|
||||
@styles = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles])
|
||||
@headers = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
|
||||
end
|
||||
|
||||
def update
|
||||
update_styles(params)
|
||||
update_headers(params) if Spree::Config[:use_s3]
|
||||
|
||||
Spree::Config.set(params[:preferences])
|
||||
update_paperclip_settings
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:success] = Spree.t(:image_settings_updated)
|
||||
redirect_to spree.edit_admin_image_settings_path
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_styles(params)
|
||||
if params[:new_attachment_styles].present?
|
||||
params[:new_attachment_styles].each do |_index, style|
|
||||
params[:attachment_styles][style[:name]] = style[:value] unless style[:value].empty?
|
||||
end
|
||||
end
|
||||
|
||||
styles = params[:attachment_styles]
|
||||
|
||||
Spree::Config[:attachment_styles] = ActiveSupport::JSON.encode(styles) unless styles.nil?
|
||||
end
|
||||
|
||||
def update_headers(params)
|
||||
if params[:new_s3_headers].present?
|
||||
params[:new_s3_headers].each do |_index, header|
|
||||
params[:s3_headers][header[:name]] = header[:value] unless header[:value].empty?
|
||||
end
|
||||
end
|
||||
|
||||
headers = params[:s3_headers]
|
||||
|
||||
Spree::Config[:s3_headers] = ActiveSupport::JSON.encode(headers) unless headers.nil?
|
||||
end
|
||||
|
||||
def update_paperclip_settings
|
||||
if Spree::Config[:use_s3]
|
||||
s3_creds = { access_key_id: Spree::Config[:s3_access_key],
|
||||
secret_access_key: Spree::Config[:s3_secret],
|
||||
bucket: Spree::Config[:s3_bucket] }
|
||||
Spree::Image.attachment_definitions[:attachment][:storage] = :s3
|
||||
Spree::Image.attachment_definitions[:attachment][:s3_credentials] = s3_creds
|
||||
Spree::Image.attachment_definitions[:attachment][:s3_headers] =
|
||||
ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
|
||||
Spree::Image.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
|
||||
else
|
||||
Spree::Image.attachment_definitions[:attachment].delete :storage
|
||||
end
|
||||
|
||||
Spree::Image.attachment_definitions[:attachment][:styles] =
|
||||
ActiveSupport::JSON.decode(Spree::Config[:attachment_styles]).symbolize_keys!
|
||||
Spree::Image.attachment_definitions[:attachment][:path] = Spree::Config[:attachment_path]
|
||||
Spree::Image.attachment_definitions[:attachment][:default_url] =
|
||||
Spree::Config[:attachment_default_url]
|
||||
Spree::Image.attachment_definitions[:attachment][:default_style] =
|
||||
Spree::Config[:attachment_default_style]
|
||||
|
||||
# Spree stores attachent definitions in JSON. This converts the style name and format to
|
||||
# strings. However, when paperclip encounters these, it doesn't recognise the format.
|
||||
# Here we solve that problem by converting format and style name to symbols.
|
||||
Spree::Image.reformat_styles
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
Spree::Admin::ImageSettingsController.class_eval do
|
||||
# Spree stores attachent definitions in JSON. This converts the style name and format to
|
||||
# strings. However, when paperclip encounters these, it doesn't recognise the format.
|
||||
# Here we solve that problem by converting format and style name to symbols.
|
||||
def update_paperclip_settings_with_format_styles
|
||||
update_paperclip_settings_without_format_styles
|
||||
Spree::Image.reformat_styles
|
||||
end
|
||||
|
||||
alias_method_chain :update_paperclip_settings, :format_styles
|
||||
end
|
||||
39
app/controllers/spree/admin/mail_methods_controller.rb
Normal file
39
app/controllers/spree/admin/mail_methods_controller.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class MailMethodsController < Spree::Admin::BaseController
|
||||
after_filter :initialize_mail_settings
|
||||
|
||||
def update
|
||||
if params[:smtp_password].blank?
|
||||
params.delete(:smtp_password)
|
||||
end
|
||||
|
||||
params.each do |name, value|
|
||||
next unless Spree::Config.has_preference? name
|
||||
Spree::Config[name] = value
|
||||
end
|
||||
|
||||
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:mail_methods))
|
||||
render :edit
|
||||
end
|
||||
|
||||
def testmail
|
||||
if TestMailer.test_email(try_spree_current_user).deliver
|
||||
flash[:success] = Spree.t('admin.mail_methods.testmail.delivery_success')
|
||||
else
|
||||
flash[:error] = Spree.t('admin.mail_methods.testmail.delivery_error')
|
||||
end
|
||||
rescue StandardError => e
|
||||
flash[:error] = Spree.t('admin.mail_methods.testmail.error') % { e: e }
|
||||
ensure
|
||||
redirect_to edit_admin_mail_method_url
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def initialize_mail_settings
|
||||
Spree::Core::MailSettings.init
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -30,6 +30,11 @@ Spree::Admin::ProductsController.class_eval do
|
||||
@show_latest_import = params[:latest_import] || false
|
||||
end
|
||||
|
||||
def new
|
||||
@object.shipping_category = DefaultShippingCategory.find_or_create
|
||||
super
|
||||
end
|
||||
|
||||
def create
|
||||
delete_stock_params_and_set_after do
|
||||
super
|
||||
@@ -44,8 +49,6 @@ Spree::Admin::ProductsController.class_eval do
|
||||
delete_stock_params_and_set_after do
|
||||
super
|
||||
end
|
||||
|
||||
clear_variants_unit_description if @object.variant_unit == 'items'
|
||||
end
|
||||
|
||||
def bulk_update
|
||||
@@ -190,10 +193,4 @@ Spree::Admin::ProductsController.class_eval do
|
||||
def set_product_master_variant_price_to_zero
|
||||
@product.price = 0 if @product.price.nil?
|
||||
end
|
||||
|
||||
def clear_variants_unit_description
|
||||
@object.variants.each do |variant|
|
||||
variant.update_attribute :unit_description, ''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -126,7 +126,8 @@ Spree::Admin::ReportsController.class_eval do
|
||||
@include_blank = I18n.t(:all)
|
||||
|
||||
# -- Build Report with Order Grouper
|
||||
@report = OpenFoodNetwork::OrdersAndFulfillmentsReport.new spree_current_user, params, render_content?
|
||||
@report = OpenFoodNetwork::OrdersAndFulfillmentsReport.new(permissions,
|
||||
params, render_content?)
|
||||
@table = order_grouper_table
|
||||
csv_file_name = "#{params[:report_type]}_#{timestamp}.csv"
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ShippingCategoriesController < ResourceController
|
||||
end
|
||||
end
|
||||
end
|
||||
84
app/controllers/spree/admin/shipping_methods_controller.rb
Normal file
84
app/controllers/spree/admin/shipping_methods_controller.rb
Normal file
@@ -0,0 +1,84 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ShippingMethodsController < ResourceController
|
||||
before_filter :load_data, except: [:index]
|
||||
before_filter :set_shipping_category, only: [:create, :update]
|
||||
before_filter :set_zones, only: [:create, :update]
|
||||
before_filter :load_hubs, only: [:new, :edit, :create, :update]
|
||||
|
||||
# Sort shipping methods by distributor name
|
||||
def collection
|
||||
collection = super
|
||||
collection = collection.managed_by(spree_current_user).by_name
|
||||
|
||||
if params.key? :enterprise_id
|
||||
distributor = Enterprise.find params[:enterprise_id]
|
||||
collection = collection.for_distributor(distributor)
|
||||
end
|
||||
|
||||
collection
|
||||
end
|
||||
|
||||
def new
|
||||
@object.shipping_categories = [DefaultShippingCategory.find_or_create]
|
||||
super
|
||||
end
|
||||
|
||||
def destroy
|
||||
# Our reports are not adapted to soft deleted shipping_methods so here we prevent
|
||||
# the deletion (even soft) of shipping_methods that are referenced in orders
|
||||
if order = order_referenced_by_shipping_method
|
||||
flash[:error] = I18n.t(:shipping_method_destroy_error, number: order.number)
|
||||
redirect_to(collection_url) && return
|
||||
end
|
||||
|
||||
@object.touch :deleted_at
|
||||
flash[:success] = flash_message_for(@object, :successfully_removed)
|
||||
|
||||
respond_with(@object) do |format|
|
||||
format.html { redirect_to collection_url }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def order_referenced_by_shipping_method
|
||||
Order.joins(shipments: :shipping_rates)
|
||||
.where( spree_shipping_rates: { shipping_method_id: @object } )
|
||||
.first
|
||||
end
|
||||
|
||||
def load_hubs
|
||||
# rubocop:disable Style/TernaryParentheses
|
||||
@hubs = Enterprise.managed_by(spree_current_user).is_distributor.sort_by! do |d|
|
||||
[(@shipping_method.has_distributor? d) ? 0 : 1, d.name]
|
||||
end
|
||||
# rubocop:enable Style/TernaryParentheses
|
||||
end
|
||||
|
||||
def set_shipping_category
|
||||
return true if params["shipping_method"][:shipping_categories] == ""
|
||||
@shipping_method.shipping_categories =
|
||||
Spree::ShippingCategory.where(id: params["shipping_method"][:shipping_categories])
|
||||
@shipping_method.save
|
||||
params[:shipping_method].delete(:shipping_categories)
|
||||
end
|
||||
|
||||
def set_zones
|
||||
return true if params["shipping_method"][:zones] == ""
|
||||
@shipping_method.zones = Spree::Zone.where(id: params["shipping_method"][:zones])
|
||||
@shipping_method.save
|
||||
params[:shipping_method].delete(:zones)
|
||||
end
|
||||
|
||||
def location_after_save
|
||||
edit_admin_shipping_method_path(@shipping_method)
|
||||
end
|
||||
|
||||
def load_data
|
||||
@available_zones = Zone.order(:name)
|
||||
@calculators = ShippingMethod.calculators.sort_by(&:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,42 +0,0 @@
|
||||
module Spree
|
||||
module Admin
|
||||
ShippingMethodsController.class_eval do
|
||||
before_filter :do_not_destroy_referenced_shipping_methods, only: :destroy
|
||||
before_filter :load_hubs, only: [:new, :edit, :create, :update]
|
||||
|
||||
# Sort shipping methods by distributor name
|
||||
def collection
|
||||
collection = super
|
||||
collection = collection.managed_by(spree_current_user).by_name
|
||||
|
||||
if params.key? :enterprise_id
|
||||
distributor = Enterprise.find params[:enterprise_id]
|
||||
collection = collection.for_distributor(distributor)
|
||||
end
|
||||
|
||||
collection
|
||||
end
|
||||
|
||||
# Spree allows soft deletes of shipping_methods but our reports are not adapted to that
|
||||
# Here we prevent the deletion (even soft) of shipping_methods that are referenced in orders
|
||||
def do_not_destroy_referenced_shipping_methods
|
||||
order = Order.joins(shipments: :shipping_rates)
|
||||
.where( spree_shipping_rates: { shipping_method_id: @object } )
|
||||
.first
|
||||
return unless order
|
||||
flash[:error] = I18n.t(:shipping_method_destroy_error, number: order.number)
|
||||
redirect_to(collection_url) && return
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_hubs
|
||||
# rubocop:disable Style/TernaryParentheses
|
||||
@hubs = Enterprise.managed_by(spree_current_user).is_distributor.sort_by! do |d|
|
||||
[(@shipping_method.has_distributor? d) ? 0 : 1, d.name]
|
||||
end
|
||||
# rubocop:enable Style/TernaryParentheses
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
29
app/controllers/spree/admin/states_controller.rb
Normal file
29
app/controllers/spree/admin/states_controller.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class StatesController < ResourceController
|
||||
belongs_to 'spree/country'
|
||||
before_filter :load_data
|
||||
|
||||
def index
|
||||
respond_with(@collection) do |format|
|
||||
format.html
|
||||
format.js { render partial: 'state_list' }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def location_after_save
|
||||
admin_country_states_url(@country)
|
||||
end
|
||||
|
||||
def collection
|
||||
super.order(:name)
|
||||
end
|
||||
|
||||
def load_data
|
||||
@countries = Country.order(:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
19
app/controllers/spree/admin/tax_categories_controller.rb
Normal file
19
app/controllers/spree/admin/tax_categories_controller.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxCategoriesController < ResourceController
|
||||
def destroy
|
||||
if @object.destroy
|
||||
flash[:success] = flash_message_for(@object, :successfully_removed)
|
||||
respond_with(@object) do |format|
|
||||
format.html { redirect_to collection_url }
|
||||
format.js { render partial: "spree/admin/shared/destroy" }
|
||||
end
|
||||
else
|
||||
respond_with(@object) do |format|
|
||||
format.html { redirect_to collection_url }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
26
app/controllers/spree/admin/tax_rates_controller.rb
Normal file
26
app/controllers/spree/admin/tax_rates_controller.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxRatesController < ResourceController
|
||||
before_filter :load_data
|
||||
|
||||
update.after :update_after
|
||||
create.after :create_after
|
||||
|
||||
private
|
||||
|
||||
def load_data
|
||||
@available_zones = Zone.order(:name)
|
||||
@available_categories = TaxCategory.order(:name)
|
||||
@calculators = TaxRate.calculators.sort_by(&:name)
|
||||
end
|
||||
|
||||
def update_after
|
||||
Rails.cache.delete('vat_rates')
|
||||
end
|
||||
|
||||
def create_after
|
||||
Rails.cache.delete('vat_rates')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
15
app/controllers/spree/admin/tax_settings_controller.rb
Normal file
15
app/controllers/spree/admin/tax_settings_controller.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxSettingsController < Spree::Admin::BaseController
|
||||
def update
|
||||
Spree::Config.set(params[:preferences])
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to edit_admin_tax_settings_path
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
21
app/controllers/spree/admin/taxonomies_controller.rb
Normal file
21
app/controllers/spree/admin/taxonomies_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxonomiesController < ResourceController
|
||||
respond_to :json, :only => [:get_children]
|
||||
|
||||
def get_children
|
||||
@taxons = Taxon.find(params[:parent_id]).children
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def location_after_save
|
||||
if @taxonomy.created_at == @taxonomy.updated_at
|
||||
edit_admin_taxonomy_url(@taxonomy)
|
||||
else
|
||||
admin_taxonomies_url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
118
app/controllers/spree/admin/taxons_controller.rb
Normal file
118
app/controllers/spree/admin/taxons_controller.rb
Normal file
@@ -0,0 +1,118 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class TaxonsController < Spree::Admin::BaseController
|
||||
respond_to :html, :json, :js
|
||||
|
||||
def search
|
||||
if params[:ids]
|
||||
@taxons = Spree::Taxon.where(id: params[:ids].split(','))
|
||||
else
|
||||
@taxons = Spree::Taxon.limit(20).search(name_cont: params[:q]).result
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@taxonomy = Taxonomy.find(params[:taxonomy_id])
|
||||
@taxon = @taxonomy.taxons.build(params[:taxon])
|
||||
if @taxon.save
|
||||
respond_with(@taxon) do |format|
|
||||
format.json { render json: @taxon.to_json }
|
||||
end
|
||||
else
|
||||
flash[:error] = Spree.t('errors.messages.could_not_create_taxon')
|
||||
respond_with(@taxon) do |format|
|
||||
format.html do
|
||||
if redirect_to @taxonomy
|
||||
edit_admin_taxonomy_url(@taxonomy)
|
||||
else
|
||||
admin_taxonomies_url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@taxonomy = Taxonomy.find(params[:taxonomy_id])
|
||||
@taxon = @taxonomy.taxons.find(params[:id])
|
||||
@permalink_part = @taxon.permalink.split("/").last
|
||||
end
|
||||
|
||||
def update
|
||||
@taxonomy = Taxonomy.find(params[:taxonomy_id])
|
||||
@taxon = @taxonomy.taxons.find(params[:id])
|
||||
parent_id = params[:taxon][:parent_id]
|
||||
new_position = params[:taxon][:position]
|
||||
|
||||
if parent_id || new_position # taxon is being moved
|
||||
new_parent = parent_id.nil? ? @taxon.parent : Taxon.find(parent_id.to_i)
|
||||
new_position = new_position.nil? ? -1 : new_position.to_i
|
||||
|
||||
# Bellow is a very complicated way of finding where in nested set we
|
||||
# should actually move the taxon to achieve sane results,
|
||||
# JS is giving us the desired position, which was awesome for previous setup,
|
||||
# but now it's quite complicated to find where we should put it as we have
|
||||
# to differenciate between moving to the same branch, up down and into
|
||||
# first position.
|
||||
new_siblings = new_parent.children
|
||||
if new_position <= 0 && new_siblings.empty?
|
||||
@taxon.move_to_child_of(new_parent)
|
||||
elsif new_parent.id != @taxon.parent_id
|
||||
if new_position.zero?
|
||||
@taxon.move_to_left_of(new_siblings.first)
|
||||
else
|
||||
@taxon.move_to_right_of(new_siblings[new_position - 1])
|
||||
end
|
||||
elsif new_position < new_siblings.index(@taxon)
|
||||
@taxon.move_to_left_of(new_siblings[new_position]) # we move up
|
||||
else
|
||||
@taxon.move_to_right_of(new_siblings[new_position - 1]) # we move down
|
||||
end
|
||||
# Reset legacy position, if any extensions still rely on it
|
||||
new_parent.children.reload.each{ |t| t.update_column(:position, t.position) }
|
||||
|
||||
if parent_id
|
||||
@taxon.reload
|
||||
@taxon.set_permalink
|
||||
@taxon.save!
|
||||
@update_children = true
|
||||
end
|
||||
end
|
||||
|
||||
if params.key? "permalink_part"
|
||||
parent_permalink = @taxon.permalink.split("/")[0...-1].join("/")
|
||||
parent_permalink += "/" if parent_permalink.present?
|
||||
params[:taxon][:permalink] = parent_permalink + params[:permalink_part]
|
||||
end
|
||||
# check if we need to rename child taxons if parent name or permalink changes
|
||||
if params[:taxon][:name] != @taxon.name || params[:taxon][:permalink] != @taxon.permalink
|
||||
@update_children = true
|
||||
end
|
||||
|
||||
if @taxon.update_attributes(params[:taxon])
|
||||
flash[:success] = flash_message_for(@taxon, :successfully_updated)
|
||||
end
|
||||
|
||||
# rename child taxons
|
||||
if @update_children
|
||||
@taxon.descendants.each do |taxon|
|
||||
taxon.reload
|
||||
taxon.set_permalink
|
||||
taxon.save!
|
||||
end
|
||||
end
|
||||
|
||||
respond_with(@taxon) do |format|
|
||||
format.html { redirect_to edit_admin_taxonomy_url(@taxonomy) }
|
||||
format.json { render json: @taxon.to_json }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@taxon = Taxon.find(params[:id])
|
||||
@taxon.destroy
|
||||
respond_with(@taxon) { |format| format.json { render json: '' } }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -46,7 +46,12 @@ module Spree
|
||||
@user.spree_roles = roles.reject(&:blank?).collect{ |r| Spree::Role.find(r) }
|
||||
end
|
||||
|
||||
flash.now[:success] = Spree.t(:account_updated)
|
||||
message = if new_email_unconfirmed?
|
||||
Spree.t(:email_updated)
|
||||
else
|
||||
Spree.t(:account_updated)
|
||||
end
|
||||
flash.now[:success] = message
|
||||
end
|
||||
render :edit
|
||||
end
|
||||
@@ -126,6 +131,10 @@ module Spree
|
||||
def load_roles
|
||||
@roles = Spree::Role.scoped
|
||||
end
|
||||
|
||||
def new_email_unconfirmed?
|
||||
params[:user][:email] != @user.email
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
26
app/controllers/spree/admin/zones_controller.rb
Normal file
26
app/controllers/spree/admin/zones_controller.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ZonesController < ResourceController
|
||||
before_filter :load_data, except: [:index]
|
||||
|
||||
def new
|
||||
@zone.zone_members.build
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def collection
|
||||
params[:q] ||= {}
|
||||
params[:q][:s] ||= "ascend_by_name"
|
||||
@search = super.ransack(params[:q])
|
||||
@zones = @search.result.page(params[:page]).per(Spree::Config[:orders_per_page])
|
||||
end
|
||||
|
||||
def load_data
|
||||
@countries = Country.order(:name)
|
||||
@states = State.order(:name)
|
||||
@zones = Zone.order(:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
13
app/helpers/spree/admin/general_settings_helper.rb
Normal file
13
app/helpers/spree/admin/general_settings_helper.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Spree
|
||||
module Admin
|
||||
module GeneralSettingsHelper
|
||||
def currency_options
|
||||
currencies = ::Money::Currency.table.map do |_code, details|
|
||||
iso = details[:iso_code]
|
||||
[iso, "#{details[:name]} (#{iso})"]
|
||||
end
|
||||
options_from_collection_for_select(currencies, :first, :last, Spree::Config[:currency])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
9
app/helpers/spree/admin/taxons_helper.rb
Normal file
9
app/helpers/spree/admin/taxons_helper.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
module Spree
|
||||
module Admin
|
||||
module TaxonsHelper
|
||||
def taxon_path(taxon)
|
||||
taxon.ancestors.reverse.collect(&:name).join( " >> ")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -19,7 +19,7 @@ module OrderShipment
|
||||
#
|
||||
# @return [ShippingMethod]
|
||||
def shipping_method
|
||||
return if shipments.empty?
|
||||
return if shipments.blank?
|
||||
shipments.first.shipping_method
|
||||
end
|
||||
|
||||
|
||||
@@ -25,36 +25,21 @@ module VariantStock
|
||||
#
|
||||
# @return [Float|Integer]
|
||||
def on_hand
|
||||
warn_deprecation(__method__, '#total_on_hand')
|
||||
|
||||
total_on_hand
|
||||
end
|
||||
|
||||
# Sets the stock level of the variant.
|
||||
# This will only work if `track_inventory_levels` config is set
|
||||
# and if there is a stock item for the variant.
|
||||
# This will only work if there is a stock item for the variant.
|
||||
#
|
||||
# @raise [StandardError] when the track_inventory_levels config key is not set
|
||||
# and when the variant has no stock item
|
||||
# @raise [StandardError] when the variant has no stock item
|
||||
def on_hand=(new_level)
|
||||
warn_deprecation(__method__, '#total_on_hand')
|
||||
|
||||
error = 'Cannot set on_hand value when Spree::Config[:track_inventory_levels] is false'
|
||||
raise error unless Spree::Config.track_inventory_levels
|
||||
|
||||
raise_error_if_no_stock_item_available
|
||||
|
||||
overwrite_stock_levels(new_level)
|
||||
end
|
||||
|
||||
# Checks whether this variant is produced on demand.
|
||||
#
|
||||
# In Spree 2.0 this attribute is removed in favour of
|
||||
# track_inventory_levels only. It was initially introduced in
|
||||
# https://github.com/openfoodfoundation/spree/commit/20b5ad9835dca7f41a40ad16c7b45f987eea6dcc
|
||||
def on_demand
|
||||
warn_deprecation(__method__, 'StockItem#backorderable?')
|
||||
|
||||
# A variant that has not been saved yet, doesn't have a stock item
|
||||
# This provides a default value for variant.on_demand using Spree::StockLocation.backorderable_default
|
||||
return Spree::StockLocation.first.backorderable_default if stock_items.empty?
|
||||
@@ -69,8 +54,6 @@ module VariantStock
|
||||
#
|
||||
# @raise [StandardError] when the variant has no stock item yet
|
||||
def on_demand=(new_value)
|
||||
warn_deprecation(__method__, 'StockItem#backorderable=')
|
||||
|
||||
raise_error_if_no_stock_item_available
|
||||
|
||||
# There should be only one at the default stock location.
|
||||
@@ -89,8 +72,6 @@ module VariantStock
|
||||
# Here we depend only on variant.total_on_hand and variant.on_demand.
|
||||
# This way, variant_overrides only need to override variant.total_on_hand and variant.on_demand.
|
||||
def can_supply?(quantity)
|
||||
return true unless Spree::Config[:track_inventory_levels]
|
||||
|
||||
on_demand || total_on_hand >= quantity
|
||||
end
|
||||
|
||||
@@ -158,11 +139,4 @@ module VariantStock
|
||||
def stock_item
|
||||
stock_items.first
|
||||
end
|
||||
|
||||
def warn_deprecation(method_name, new_method_name)
|
||||
ActiveSupport::Deprecation.warn(
|
||||
"`##{method_name}` is deprecated and will be removed. " \
|
||||
"Please use `#{new_method_name}` instead."
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -207,12 +207,15 @@ class AbilityDecorator
|
||||
end
|
||||
|
||||
def add_order_management_abilities(user)
|
||||
# Enterprise User can only access orders that they are a distributor for
|
||||
can [:index, :create], Spree::Order
|
||||
can [:read, :update, :fire, :resend, :invoice, :print, :print_ticket], Spree::Order do |order|
|
||||
# We allow editing orders with a nil distributor as this state occurs
|
||||
# during the order creation process from the admin backend
|
||||
order.distributor.nil? || user.enterprises.include?(order.distributor) || order.order_cycle.andand.coordinated_by?(user)
|
||||
order.distributor.nil? ||
|
||||
# Enterprise User can access orders that they are a distributor for
|
||||
user.enterprises.include?(order.distributor) ||
|
||||
# Enterprise User can access orders that are placed inside a OC they coordinate
|
||||
order.order_cycle.andand.coordinated_by?(user)
|
||||
end
|
||||
can [:admin, :bulk_management, :managed], Spree::Order do
|
||||
user.admin? || user.enterprises.any?(&:is_distributor)
|
||||
|
||||
@@ -32,7 +32,7 @@ module Spree
|
||||
# NOTE: This is an override of spree's method, needed to allow orders
|
||||
# without line items (ie. user invoices) to not have inventory units
|
||||
def require_inventory
|
||||
return false unless Spree::Config[:track_inventory_levels] && line_items.count > 0 # This line altered
|
||||
return false unless line_items.count > 0 # This line altered
|
||||
order.completed? && !order.canceled?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,11 @@ class SubscriptionLineItem < ActiveRecord::Base
|
||||
(price_estimate || 0) * (quantity || 0)
|
||||
end
|
||||
|
||||
# Ensure SubscriptionLineItem always has access to soft-deleted Variant attribute
|
||||
def variant
|
||||
Spree::Variant.unscoped { super }
|
||||
end
|
||||
|
||||
# Used to calculators to estimate fees
|
||||
alias_method :amount, :total_estimate
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<!-- surround_contents 'body' -->
|
||||
|
||||
<div <%= yield(:app_wrapper_attrs).strip.html_safe %>>
|
||||
<%= render_original %>
|
||||
</div>
|
||||
@@ -4,7 +4,11 @@ class Api::AddressSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :id, :zipcode, :city, :state_name, :state_id,
|
||||
:phone, :firstname, :lastname, :address1, :address2, :city, :country_id,
|
||||
:zipcode
|
||||
:zipcode, :country_name
|
||||
|
||||
def country_name
|
||||
object.country.andand.name
|
||||
end
|
||||
|
||||
def state_name
|
||||
object.state.andand.abbr
|
||||
|
||||
8
app/serializers/api/adjustment_serializer.rb
Normal file
8
app/serializers/api/adjustment_serializer.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
module Api
|
||||
class AdjustmentSerializer < ActiveModel::Serializer
|
||||
attributes :id, :amount, :label, :eligible,
|
||||
:source_type, :source_id,
|
||||
:adjustable_type, :adjustable_id,
|
||||
:originator_type, :originator_id
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
class Api::Admin::BasicEnterpriseSerializer < ActiveModel::Serializer
|
||||
attributes :name, :id, :is_primary_producer, :is_distributor, :sells, :category, :payment_method_ids, :shipping_method_ids
|
||||
attributes :producer_profile_only, :permalink
|
||||
attributes :name, :id, :is_primary_producer, :is_distributor, :sells, :category,
|
||||
:payment_method_ids, :shipping_method_ids, :producer_profile_only, :permalink
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::Admin::CustomerSerializer < ActiveModel::Serializer
|
||||
attributes :id, :email, :enterprise_id, :user_id, :code, :tags, :tag_list, :name
|
||||
attributes :allow_charges, :default_card_present?
|
||||
attributes :id, :email, :enterprise_id, :user_id, :code, :tags, :tag_list, :name,
|
||||
:allow_charges, :default_card_present?
|
||||
|
||||
has_one :ship_address, serializer: Api::AddressSerializer
|
||||
has_one :bill_address, serializer: Api::AddressSerializer
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::Admin::EnterpriseFeeSerializer < ActiveModel::Serializer
|
||||
attributes :id, :enterprise_id, :fee_type, :name, :tax_category_id, :inherits_tax_category, :calculator_type
|
||||
attributes :enterprise_name, :calculator_description, :calculator_settings
|
||||
attributes :id, :enterprise_id, :fee_type, :name, :tax_category_id, :inherits_tax_category,
|
||||
:calculator_type, :enterprise_name, :calculator_description, :calculator_settings
|
||||
|
||||
def enterprise_name
|
||||
object.enterprise.andand.name
|
||||
@@ -16,7 +16,9 @@ class Api::Admin::EnterpriseFeeSerializer < ActiveModel::Serializer
|
||||
result = nil
|
||||
|
||||
options[:controller].__send__(:with_format, :html) do
|
||||
result = options[:controller].render_to_string partial: 'admin/enterprise_fees/calculator_settings', locals: { enterprise_fee: object }
|
||||
result = options[:controller].
|
||||
render_to_string(partial: 'admin/enterprise_fees/calculator_settings',
|
||||
locals: { enterprise_fee: object })
|
||||
end
|
||||
|
||||
result.gsub('[0]', '[{{ $index }}]').gsub('_0_', '_{{ $index }}_')
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
class Api::Admin::EnterpriseSerializer < ActiveModel::Serializer
|
||||
attributes :name, :id, :is_primary_producer, :is_distributor, :sells, :category, :payment_method_ids, :shipping_method_ids
|
||||
attributes :producer_profile_only, :long_description, :permalink
|
||||
attributes :preferred_shopfront_message, :preferred_shopfront_closed_message, :preferred_shopfront_taxon_order, :preferred_shopfront_order_cycle_order
|
||||
attributes :preferred_product_selection_from_inventory_only
|
||||
attributes :owner, :contact, :users, :tag_groups, :default_tag_group
|
||||
attributes :require_login, :allow_guest_orders, :allow_order_changes
|
||||
attributes :logo, :promo_image
|
||||
attributes :name, :id, :is_primary_producer, :is_distributor, :sells, :category, :permalink,
|
||||
:payment_method_ids, :shipping_method_ids, :producer_profile_only, :long_description,
|
||||
:preferred_shopfront_message, :preferred_shopfront_closed_message,
|
||||
:preferred_shopfront_taxon_order, :preferred_shopfront_order_cycle_order,
|
||||
:preferred_product_selection_from_inventory_only,
|
||||
:owner, :contact, :users, :tag_groups, :default_tag_group,
|
||||
:require_login, :allow_guest_orders, :allow_order_changes,
|
||||
:logo, :promo_image
|
||||
|
||||
has_one :owner, serializer: Api::Admin::UserSerializer
|
||||
has_many :users, serializer: Api::Admin::UserSerializer
|
||||
@@ -21,7 +22,9 @@ class Api::Admin::EnterpriseSerializer < ActiveModel::Serializer
|
||||
|
||||
def tag_groups
|
||||
object.tag_rules.prioritised.reject(&:is_default).each_with_object([]) do |tag_rule, tag_groups|
|
||||
tag_group = find_match(tag_groups, tag_rule.preferred_customer_tags.split(",").map{ |t| { text: t } })
|
||||
tag_group = find_match(tag_groups, tag_rule.preferred_customer_tags.
|
||||
split(",").
|
||||
map{ |t| { text: t } })
|
||||
if tag_group[:rules].empty?
|
||||
tag_groups << tag_group
|
||||
tag_group[:position] = tag_groups.count
|
||||
@@ -32,13 +35,16 @@ class Api::Admin::EnterpriseSerializer < ActiveModel::Serializer
|
||||
|
||||
def default_tag_group
|
||||
default_rules = object.tag_rules.select(&:is_default)
|
||||
serialized_rules = ActiveModel::ArraySerializer.new(default_rules, each_serializer: Api::Admin::TagRuleSerializer)
|
||||
serialized_rules =
|
||||
ActiveModel::ArraySerializer.new(default_rules,
|
||||
each_serializer: Api::Admin::TagRuleSerializer)
|
||||
{ tags: [], rules: serialized_rules }
|
||||
end
|
||||
|
||||
def find_match(tag_groups, tags)
|
||||
tag_groups.each do |tag_group|
|
||||
return tag_group if tag_group[:tags].length == tags.length && (tag_group[:tags] & tags) == tag_group[:tags]
|
||||
return tag_group if tag_group[:tags].length == tags.length &&
|
||||
(tag_group[:tags] & tags) == tag_group[:tags]
|
||||
end
|
||||
{ tags: tags, rules: [] }
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Api::Admin::ExchangeSerializer < ActiveModel::Serializer
|
||||
attributes :id, :sender_id, :receiver_id, :incoming, :variants, :receival_instructions, :pickup_time, :pickup_instructions
|
||||
attributes :tags, :tag_list
|
||||
attributes :id, :sender_id, :receiver_id, :incoming, :variants,
|
||||
:receival_instructions, :pickup_time, :pickup_instructions,
|
||||
:tags, :tag_list
|
||||
|
||||
has_many :enterprise_fees, serializer: Api::Admin::BasicEnterpriseFeeSerializer
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
require 'open_food_network/enterprise_issue_validator'
|
||||
|
||||
class Api::Admin::ForOrderCycle::EnterpriseSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :managed, :supplied_products
|
||||
attributes :issues_summary_supplier, :issues_summary_distributor
|
||||
attributes :is_primary_producer, :is_distributor, :sells
|
||||
attributes :id, :name, :managed, :supplied_products,
|
||||
:issues_summary_supplier, :issues_summary_distributor,
|
||||
:is_primary_producer, :is_distributor, :sells
|
||||
|
||||
def issues_summary_supplier
|
||||
issues = OpenFoodNetwork::EnterpriseIssueValidator.new(object).issues_summary confirmation_only: true
|
||||
issues =
|
||||
OpenFoodNetwork::EnterpriseIssueValidator.
|
||||
new(object).
|
||||
issues_summary(confirmation_only: true)
|
||||
|
||||
if issues.nil? && products.empty?
|
||||
issues = "no products in inventory"
|
||||
end
|
||||
@@ -23,7 +27,8 @@ class Api::Admin::ForOrderCycle::EnterpriseSerializer < ActiveModel::Serializer
|
||||
|
||||
def supplied_products
|
||||
serializer = Api::Admin::ForOrderCycle::SuppliedProductSerializer
|
||||
ActiveModel::ArraySerializer.new(products, each_serializer: serializer, order_cycle: order_cycle)
|
||||
ActiveModel::ArraySerializer.new(products, each_serializer: serializer,
|
||||
order_cycle: order_cycle)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
require 'open_food_network/enterprise_issue_validator'
|
||||
|
||||
class Api::Admin::IndexEnterpriseSerializer < ActiveModel::Serializer
|
||||
attributes :name, :id, :permalink, :is_primary_producer, :sells, :producer_profile_only, :owned, :edit_path
|
||||
|
||||
attributes :issues, :warnings
|
||||
attributes :name, :id, :permalink, :is_primary_producer, :sells, :producer_profile_only, :owned,
|
||||
:edit_path, :issues, :warnings
|
||||
|
||||
def owned
|
||||
return true if options[:spree_current_user].admin?
|
||||
|
||||
@@ -5,9 +5,9 @@ module Api
|
||||
class IndexOrderCycleSerializer < ActiveModel::Serializer
|
||||
include OrderCyclesHelper
|
||||
|
||||
attributes :id, :name, :orders_open_at, :orders_close_at, :status, :variant_count, :deletable
|
||||
attributes :coordinator, :producers, :shops, :viewing_as_coordinator
|
||||
attributes :edit_path, :clone_path, :delete_path, :subscriptions_count
|
||||
attributes :id, :name, :orders_open_at, :orders_close_at, :status, :variant_count, :deletable,
|
||||
:coordinator, :producers, :shops, :viewing_as_coordinator,
|
||||
:edit_path, :clone_path, :delete_path, :subscriptions_count
|
||||
|
||||
has_many :schedules, serializer: Api::Admin::IdNameSerializer
|
||||
|
||||
@@ -68,7 +68,10 @@ module Api
|
||||
private
|
||||
|
||||
def visible_enterprises
|
||||
@visible_enterprises ||= OpenFoodNetwork::OrderCyclePermissions.new(options[:current_user], object).visible_enterprises
|
||||
@visible_enterprises ||=
|
||||
OpenFoodNetwork::OrderCyclePermissions.
|
||||
new(options[:current_user], object).
|
||||
visible_enterprises
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Api::Admin::LineItemSerializer < ActiveModel::Serializer
|
||||
attributes :id, :quantity, :max_quantity, :price, :supplier, :final_weight_volume, :units_product, :units_variant
|
||||
attributes :id, :quantity, :max_quantity, :price, :supplier, :final_weight_volume,
|
||||
:units_product, :units_variant
|
||||
|
||||
has_one :order, serializer: Api::Admin::IdSerializer
|
||||
|
||||
@@ -20,7 +21,8 @@ class Api::Admin::LineItemSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def max_quantity
|
||||
return object.quantity unless object.max_quantity.present? && object.max_quantity > object.quantity
|
||||
return object.quantity unless object.max_quantity.present? &&
|
||||
object.max_quantity > object.quantity
|
||||
object.max_quantity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
require 'open_food_network/order_cycle_permissions'
|
||||
|
||||
class Api::Admin::OrderCycleSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :orders_open_at, :orders_close_at, :coordinator_id, :exchanges
|
||||
attributes :editable_variants_for_incoming_exchanges, :editable_variants_for_outgoing_exchanges
|
||||
attributes :visible_variants_for_outgoing_exchanges
|
||||
attributes :viewing_as_coordinator, :schedule_ids, :subscriptions_count
|
||||
attributes :id, :name, :orders_open_at, :orders_close_at, :coordinator_id, :exchanges,
|
||||
:editable_variants_for_incoming_exchanges, :editable_variants_for_outgoing_exchanges,
|
||||
:visible_variants_for_outgoing_exchanges,
|
||||
:viewing_as_coordinator, :schedule_ids, :subscriptions_count
|
||||
|
||||
has_many :coordinator_fees, serializer: Api::IdSerializer
|
||||
|
||||
@@ -25,8 +25,14 @@ class Api::Admin::OrderCycleSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def exchanges
|
||||
scoped_exchanges = OpenFoodNetwork::OrderCyclePermissions.new(options[:current_user], object).visible_exchanges.by_enterprise_name
|
||||
ActiveModel::ArraySerializer.new(scoped_exchanges, each_serializer: Api::Admin::ExchangeSerializer, current_user: options[:current_user])
|
||||
scoped_exchanges =
|
||||
OpenFoodNetwork::OrderCyclePermissions.
|
||||
new(options[:current_user], object).
|
||||
visible_exchanges.by_enterprise_name
|
||||
|
||||
ActiveModel::ArraySerializer.
|
||||
new(scoped_exchanges, each_serializer: Api::Admin::ExchangeSerializer,
|
||||
current_user: options[:current_user])
|
||||
end
|
||||
|
||||
def editable_variants_for_incoming_exchanges
|
||||
@@ -66,9 +72,13 @@ class Api::Admin::OrderCycleSerializer < ActiveModel::Serializer
|
||||
# for shops. We need this here to allow hubs to restrict visible variants to only those in
|
||||
# their inventory if they so choose
|
||||
variants = if enterprise.prefers_product_selection_from_inventory_only?
|
||||
permissions.visible_variants_for_outgoing_exchanges_to(enterprise).visible_for(enterprise)
|
||||
permissions.
|
||||
visible_variants_for_outgoing_exchanges_to(enterprise).
|
||||
visible_for(enterprise)
|
||||
else
|
||||
permissions.visible_variants_for_outgoing_exchanges_to(enterprise).not_hidden_for(enterprise)
|
||||
permissions.
|
||||
visible_variants_for_outgoing_exchanges_to(enterprise).
|
||||
not_hidden_for(enterprise)
|
||||
end.pluck(:id)
|
||||
visible[enterprise.id] = variants if variants.any?
|
||||
end
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
class Api::Admin::OrderSerializer < ActiveModel::Serializer
|
||||
attributes :id, :number, :full_name, :email, :phone, :completed_at, :display_total
|
||||
attributes :edit_path, :state, :payment_state, :shipment_state
|
||||
attributes :payments_path, :ship_path, :ready_to_ship, :created_at
|
||||
attributes :distributor_name, :special_instructions, :payment_capture_path
|
||||
attributes :id, :number, :user_id, :full_name, :email, :phone, :completed_at, :display_total,
|
||||
:edit_path, :state, :payment_state, :shipment_state,
|
||||
:payments_path, :ship_path, :ready_to_ship, :created_at,
|
||||
:distributor_name, :special_instructions, :payment_capture_path,
|
||||
:item_total, :adjustment_total, :payment_total, :total
|
||||
|
||||
has_one :distributor, serializer: Api::Admin::IdSerializer
|
||||
has_one :order_cycle, serializer: Api::Admin::IdSerializer
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
module Api
|
||||
module Admin
|
||||
class SubscriptionSerializer < ActiveModel::Serializer
|
||||
attributes :id, :shop_id, :customer_id, :schedule_id, :payment_method_id, :shipping_method_id, :begins_at, :ends_at
|
||||
attributes :customer_email, :schedule_name, :edit_path, :canceled_at, :paused_at, :state
|
||||
attributes :shipping_fee_estimate, :payment_fee_estimate
|
||||
attributes :id, :shop_id, :customer_id, :schedule_id, :payment_method_id, :shipping_method_id,
|
||||
:begins_at, :ends_at,
|
||||
:customer_email, :schedule_name, :edit_path, :canceled_at, :paused_at, :state,
|
||||
:shipping_fee_estimate, :payment_fee_estimate
|
||||
|
||||
has_many :subscription_line_items, serializer: Api::Admin::SubscriptionLineItemSerializer
|
||||
has_many :closed_proxy_orders, serializer: Api::Admin::ProxyOrderSerializer
|
||||
|
||||
@@ -16,7 +16,8 @@ module Api::Admin::TagRule
|
||||
end
|
||||
|
||||
class FilterShippingMethodsSerializer < BaseSerializer
|
||||
attributes :preferred_matched_shipping_methods_visibility, :preferred_shipping_method_tags, :shipping_method_tags
|
||||
attributes :preferred_matched_shipping_methods_visibility, :preferred_shipping_method_tags,
|
||||
:shipping_method_tags
|
||||
|
||||
def shipping_method_tags
|
||||
object.preferred_shipping_method_tags.split(",")
|
||||
@@ -24,7 +25,8 @@ module Api::Admin::TagRule
|
||||
end
|
||||
|
||||
class FilterPaymentMethodsSerializer < BaseSerializer
|
||||
attributes :preferred_matched_payment_methods_visibility, :preferred_payment_method_tags, :payment_method_tags
|
||||
attributes :preferred_matched_payment_methods_visibility, :preferred_payment_method_tags,
|
||||
:payment_method_tags
|
||||
|
||||
def payment_method_tags
|
||||
object.preferred_payment_method_tags.split(",")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::Admin::VariantOverrideSerializer < ActiveModel::Serializer
|
||||
attributes :id, :hub_id, :variant_id, :sku, :price, :count_on_hand, :on_demand, :default_stock, :resettable
|
||||
attributes :tag_list, :tags, :import_date
|
||||
attributes :id, :hub_id, :variant_id, :sku, :price, :count_on_hand, :on_demand, :default_stock,
|
||||
:resettable, :tag_list, :tags, :import_date
|
||||
|
||||
def tag_list
|
||||
object.tag_list.join(",")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Api::Admin::VariantSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :producer_name, :image, :sku, :import_date
|
||||
attributes :options_text, :unit_value, :unit_description, :unit_to_display
|
||||
attributes :display_as, :display_name, :name_to_display
|
||||
attributes :price, :on_demand, :on_hand, :in_stock, :stock_location_id, :stock_location_name
|
||||
attributes :id, :name, :producer_name, :image, :sku, :import_date,
|
||||
:options_text, :unit_value, :unit_description, :unit_to_display,
|
||||
:display_as, :display_name, :name_to_display,
|
||||
:price, :on_demand, :on_hand, :in_stock, :stock_location_id, :stock_location_name
|
||||
|
||||
has_many :variant_overrides
|
||||
|
||||
|
||||
12
app/serializers/api/order_detailed_serializer.rb
Normal file
12
app/serializers/api/order_detailed_serializer.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Api
|
||||
class OrderDetailedSerializer < Api::Admin::OrderSerializer
|
||||
has_one :shipping_method, serializer: Api::ShippingMethodSerializer
|
||||
has_one :ship_address, serializer: Api::AddressSerializer
|
||||
has_one :bill_address, serializer: Api::AddressSerializer
|
||||
|
||||
has_many :line_items, serializer: Api::LineItemSerializer
|
||||
has_many :adjustments, serializer: Api::AdjustmentSerializer
|
||||
|
||||
has_many :payments, serializer: Api::PaymentSerializer
|
||||
end
|
||||
end
|
||||
@@ -1,9 +1,9 @@
|
||||
module Api
|
||||
class OrderSerializer < ActiveModel::Serializer
|
||||
attributes :number, :completed_at, :total, :state, :shipment_state, :payment_state
|
||||
attributes :outstanding_balance, :payments, :path, :cancel_path
|
||||
attributes :changes_allowed, :changes_allowed_until, :item_count
|
||||
attributes :shop_id
|
||||
attributes :number, :completed_at, :total, :state, :shipment_state, :payment_state,
|
||||
:outstanding_balance, :payments, :path, :cancel_path,
|
||||
:changes_allowed, :changes_allowed_until, :item_count,
|
||||
:shop_id
|
||||
|
||||
has_many :payments, serializer: Api::PaymentSerializer
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module Api
|
||||
class PaymentSerializer < ActiveModel::Serializer
|
||||
attributes :amount, :updated_at, :payment_method, :state
|
||||
|
||||
def payment_method
|
||||
object.payment_method.try(:name)
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class Api::VariantSerializer < ActiveModel::Serializer
|
||||
attributes :id, :is_master, :product_name, :sku
|
||||
attributes :options_text, :unit_value, :unit_description, :unit_to_display
|
||||
attributes :display_as, :display_name, :name_to_display
|
||||
attributes :price, :on_demand, :on_hand, :fees, :price_with_fees
|
||||
attributes :tag_list
|
||||
attributes :id, :is_master, :product_name, :sku,
|
||||
:options_text, :unit_value, :unit_description, :unit_to_display,
|
||||
:display_as, :display_name, :name_to_display,
|
||||
:price, :on_demand, :on_hand, :fees, :price_with_fees,
|
||||
:tag_list
|
||||
|
||||
delegate :price, to: :object
|
||||
|
||||
|
||||
13
app/services/default_shipping_category.rb
Normal file
13
app/services/default_shipping_category.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# Encapsulates the concept of default stock location in creation of a product or a shipping method.
|
||||
|
||||
class DefaultShippingCategory
|
||||
NAME = 'Default'.freeze
|
||||
|
||||
def self.create!
|
||||
Spree::ShippingCategory.create!(name: NAME)
|
||||
end
|
||||
|
||||
def self.find_or_create
|
||||
Spree::ShippingCategory.find_or_create_by_name(NAME)
|
||||
end
|
||||
end
|
||||
@@ -73,7 +73,9 @@ class EmbeddedPageService
|
||||
|
||||
def current_referer
|
||||
return if @request.referer.blank?
|
||||
URI(@request.referer).host.downcase
|
||||
uri = URI(@request.referer)
|
||||
return if uri.host.blank?
|
||||
uri.host.downcase
|
||||
end
|
||||
|
||||
def current_referer_without_www
|
||||
|
||||
@@ -1,41 +1,75 @@
|
||||
# Finds valid products distributed by a particular distributor in an order cycle
|
||||
#
|
||||
# If a product without variants is added to an order cycle, and then some
|
||||
# variants are added to that product, but not the order cycle, then the master
|
||||
# variant should not available for customers to purchase. This class filters
|
||||
# out such products so that the customer cannot purchase them.
|
||||
# Returns a (paginatable) AR object for the products or variants in stock for a given shop and OC.
|
||||
# The stock-checking includes on_demand and stock level overrides from variant_overrides.
|
||||
class OrderCycleDistributedProducts
|
||||
def initialize(order_cycle, distributor)
|
||||
@order_cycle = order_cycle
|
||||
def initialize(distributor, order_cycle)
|
||||
@distributor = distributor
|
||||
@order_cycle = order_cycle
|
||||
end
|
||||
|
||||
# Returns an ActiveRecord relation without invalid products. Check
|
||||
# #valid_products_distributed_by for details
|
||||
#
|
||||
# @return [ActiveRecord::Relation<Spree::Product>]
|
||||
def relation
|
||||
variants = order_cycle.variants_distributed_by(distributor)
|
||||
products = variants.map(&:product).uniq
|
||||
def products_relation
|
||||
Spree::Product.where(id: stocked_products)
|
||||
end
|
||||
|
||||
valid_products = products.reject do |product|
|
||||
product_has_only_obsolete_master_in_distribution?(product, variants)
|
||||
end
|
||||
product_ids = valid_products.map(&:id)
|
||||
|
||||
Spree::Product.where(id: product_ids)
|
||||
def variants_relation
|
||||
@order_cycle.
|
||||
variants_distributed_by(@distributor).
|
||||
merge(stocked_variants_and_overrides)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :order_cycle, :distributor
|
||||
def stocked_products
|
||||
@order_cycle.
|
||||
variants_distributed_by(@distributor).
|
||||
merge(stocked_variants_and_overrides).
|
||||
select("DISTINCT spree_variants.product_id")
|
||||
end
|
||||
|
||||
# If a product without variants is added to an order cycle, and then some variants are added
|
||||
# to that product, but not the order cycle, then the master variant should not available for
|
||||
# customers to purchase.
|
||||
def product_has_only_obsolete_master_in_distribution?(product, distributed_variants)
|
||||
product.has_variants? &&
|
||||
distributed_variants.include?(product.master) &&
|
||||
(product.variants & distributed_variants).empty?
|
||||
def stocked_variants_and_overrides
|
||||
Spree::Variant.
|
||||
joins("LEFT OUTER JOIN variant_overrides ON variant_overrides.variant_id = spree_variants.id
|
||||
AND variant_overrides.hub_id = #{@distributor.id}").
|
||||
joins(:stock_items).
|
||||
where(query_stock_with_overrides)
|
||||
end
|
||||
|
||||
def query_stock_with_overrides
|
||||
"( #{variant_not_overriden} AND ( #{variant_on_demand} OR #{variant_in_stock} ) )
|
||||
OR ( #{variant_overriden} AND ( #{override_on_demand} OR #{override_in_stock} ) )
|
||||
OR ( #{variant_overriden} AND ( #{override_on_demand_null} AND #{variant_on_demand} ) )
|
||||
OR ( #{variant_overriden} AND ( #{override_on_demand_null}
|
||||
AND #{variant_not_on_demand} AND #{variant_in_stock} ) )"
|
||||
end
|
||||
|
||||
def variant_not_overriden
|
||||
"variant_overrides.id IS NULL"
|
||||
end
|
||||
|
||||
def variant_overriden
|
||||
"variant_overrides.id IS NOT NULL"
|
||||
end
|
||||
|
||||
def variant_in_stock
|
||||
"spree_stock_items.count_on_hand > 0"
|
||||
end
|
||||
|
||||
def variant_on_demand
|
||||
"spree_stock_items.backorderable IS TRUE"
|
||||
end
|
||||
|
||||
def variant_not_on_demand
|
||||
"spree_stock_items.backorderable IS FALSE"
|
||||
end
|
||||
|
||||
def override_on_demand
|
||||
"variant_overrides.on_demand IS TRUE"
|
||||
end
|
||||
|
||||
def override_in_stock
|
||||
"variant_overrides.count_on_hand > 0"
|
||||
end
|
||||
|
||||
def override_on_demand_null
|
||||
"variant_overrides.on_demand IS NULL"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,8 +9,8 @@ class SubscriptionValidator
|
||||
|
||||
attr_reader :subscription
|
||||
|
||||
validates_presence_of :shop, :customer, :schedule, :shipping_method, :payment_method
|
||||
validates_presence_of :bill_address, :ship_address, :begins_at
|
||||
validates :shop, :customer, :schedule, :shipping_method, :payment_method, presence: true
|
||||
validates :bill_address, :ship_address, :begins_at, presence: true
|
||||
validate :shipping_method_allowed?
|
||||
validate :payment_method_allowed?
|
||||
validate :payment_method_type_allowed?
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
%h1.page-title
|
||||
=t :customers
|
||||
|
||||
- content_for :app_wrapper_attrs do
|
||||
= "ng-app='admin.customers'"
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.customers"
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
= t('.editing')
|
||||
= @enterprise.name
|
||||
|
||||
- content_for :app_wrapper_attrs do
|
||||
= "ng-app='admin.enterprises'"
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.enterprises"
|
||||
|
||||
- content_for :page_actions do
|
||||
%li= select :enterprise, :id, options_for_select(editable_enterprises.collect {|e| [e.name, e.id, {:'data-url' => "#{main_app.edit_admin_enterprise_path(e.permalink)}", :'ng-selected' => "selected==#{e.id}"}]}, @enterprise.id ), {}, {:'enterprise-switcher' => '', 'data-initial' => "#{@enterprise.id}", :'ng-init' => "selected='#{@enterprise.id}'", :'ng-model' => 'selected', :id => 'enterprise_switcher', :class => 'select2'}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
- content_for :page_title do
|
||||
= t('.title')
|
||||
|
||||
- content_for :app_wrapper_attrs do
|
||||
= "ng-app='admin.enterprises'"
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.enterprises"
|
||||
|
||||
- content_for :page_actions do
|
||||
= render 'admin/shared/user_guide_link'
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
- content_for :page_actions do
|
||||
%li= button_link_to t('.back_link'), main_app.admin_enterprises_path, icon: 'icon-arrow-left'
|
||||
|
||||
- content_for :app_wrapper_attrs do
|
||||
= "ng-app='admin.enterprises'"
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.enterprises"
|
||||
|
||||
= admin_inject_available_countries(module: 'admin.enterprises')
|
||||
= admin_inject_json "admin.enterprises", "defaultCountryID", Spree::Config[:default_country_id]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
= content_for :page_title do
|
||||
= t :admin_order_cycles
|
||||
|
||||
- content_for :app_wrapper_attrs do
|
||||
= "ng-app='admin.orderCycles'"
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.orderCycles"
|
||||
|
||||
= content_for :page_actions do
|
||||
- if subscriptions_enabled?
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.subscriptions.subscriptions')
|
||||
|
||||
- content_for :app_wrapper_attrs do
|
||||
= "ng-app='admin.subscriptions'"
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.subscriptions"
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
|
||||
14
app/views/spree/admin/countries/_form.html.haml
Normal file
14
app/views/spree/admin/countries/_form.html.haml
Normal file
@@ -0,0 +1,14 @@
|
||||
.row
|
||||
.alpha.four.columns
|
||||
.field
|
||||
= f.label :name, t("spree.name")
|
||||
= f.text_field :name, class: 'fullwidth'
|
||||
.four.columns
|
||||
.field
|
||||
= f.label :iso_name, t("spree.iso_name")
|
||||
= f.text_field :iso_name, class: 'fullwidth'
|
||||
.omega.four.columns
|
||||
.field.checkbox
|
||||
%label
|
||||
= f.check_box :states_required
|
||||
= t("spree.states_required")
|
||||
16
app/views/spree/admin/countries/edit.html.haml
Normal file
16
app/views/spree/admin/countries/edit.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.editing_country")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
= button_link_to t("spree.back_to_countries_list"), spree.admin_countries_path, icon: 'icon-arrow-left'
|
||||
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @country }
|
||||
|
||||
= form_for [:admin, @country] do |f|
|
||||
%fieldset.no-border-top
|
||||
= render partial: 'form', locals: { f: f }
|
||||
.clear
|
||||
= render partial: 'spree/admin/shared/edit_resource_links'
|
||||
27
app/views/spree/admin/countries/index.html.haml
Normal file
27
app/views/spree/admin/countries/index.html.haml
Normal file
@@ -0,0 +1,27 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.listing_countries")
|
||||
|
||||
%table#listing_countries.index
|
||||
%colgroup
|
||||
%col{style: "width: 35%"}/
|
||||
%col{style: "width: 35%"}/
|
||||
%col{style: "width: 20%"}/
|
||||
%col{style: "width: 10%"}/
|
||||
%thead
|
||||
%tr
|
||||
%th= t("spree.country_name")
|
||||
%th= t("spree.iso_name")
|
||||
%th= t("spree.states_required")
|
||||
%th.actions
|
||||
%tbody
|
||||
- @countries.each do |country|
|
||||
- tr_class = cycle('odd', 'even')
|
||||
- tr_id = spree_dom_id(country)
|
||||
%tr{class: tr_class, id: tr_id}
|
||||
%td= country.name
|
||||
%td= country.iso_name
|
||||
%td.align-center= country.states_required.to_s.titleize
|
||||
%td.actions
|
||||
= link_to_edit country, no_text: true
|
||||
60
app/views/spree/admin/mail_methods/_form.html.haml
Normal file
60
app/views/spree/admin/mail_methods/_form.html.haml
Normal file
@@ -0,0 +1,60 @@
|
||||
%div
|
||||
.row
|
||||
.alpha.six.columns
|
||||
%fieldset.no-border-bottom
|
||||
%legend{align: "center"}= t("spree.general")
|
||||
.field
|
||||
= preference_field_tag("enable_mail_delivery", Spree::Config[:enable_mail_delivery], type: :boolean)
|
||||
= label_tag :enable_mail_delivery, t("spree.enable_mail_delivery")
|
||||
.field
|
||||
= label_tag :mails_from, t("spree.send_mails_as")
|
||||
%br/
|
||||
= text_field_tag :mails_from, Spree::Config[:mails_from], maxlength: 256, class: 'fullwidth'
|
||||
%br/
|
||||
%span.info
|
||||
= t("spree.smtp_send_all_emails_as_from_following_address")
|
||||
.field
|
||||
= label_tag :mail_bcc, t("spree.send_copy_of_all_mails_to")
|
||||
%br/
|
||||
= text_field_tag :mail_bcc, Spree::Config[:mail_bcc], maxlength: 256, class: 'fullwidth'
|
||||
%br/
|
||||
%span.info
|
||||
= t("spree.smtp_send_copy_to_this_addresses")
|
||||
.field
|
||||
= label_tag :intercept_email, t("spree.intercept_email_address")
|
||||
%br/
|
||||
= text_field_tag :intercept_email, Spree::Config[:intercept_email], maxlength: 256, class: 'fullwidth'
|
||||
%br/
|
||||
%span.info
|
||||
= t("spree.intercept_email_instructions")
|
||||
.six.columns.omega
|
||||
%fieldset.no-border-bottom
|
||||
%legend{align: "center"}= t("spree.smtp")
|
||||
.field
|
||||
= label_tag :mail_domain, t("spree.smtp_domain")
|
||||
%br/
|
||||
= text_field_tag :mail_domain, Spree::Config[:mail_domain], class: 'fullwidth'
|
||||
.field
|
||||
= label_tag :mail_host, t("spree.smtp_mail_host")
|
||||
%br/
|
||||
= text_field_tag :mail_host, Spree::Config[:mail_host], class: 'fullwidth'
|
||||
.field
|
||||
= label_tag :mail_port, t("spree.smtp_port")
|
||||
%br/
|
||||
= text_field_tag :mail_port, Spree::Config[:mail_port], class: 'fullwidth'
|
||||
.field
|
||||
= label_tag :secure_connection_type, t("spree.secure_connection_type")
|
||||
%br/
|
||||
= select_tag(:secure_connection_type, options_from_collection_for_select(Spree::Core::MailSettings::SECURE_CONNECTION_TYPES.map{|w| Spree.t(w.downcase.to_sym, default: w)}, :to_s, :to_s, Spree::Config[:secure_connection_type]), class: 'select2 fullwidth')
|
||||
.field
|
||||
= label_tag :mail_auth_type, t("spree.smtp_authentication_type")
|
||||
%br/
|
||||
= select_tag(:mail_auth_type, options_from_collection_for_select(Spree::Core::MailSettings::MAIL_AUTH.map{|w| Spree.t(w.downcase.to_sym, default: w)}, :to_s, :to_s, Spree::Config[:mail_auth_type]), class: 'select2 fullwidth')
|
||||
.field
|
||||
= label_tag :smtp_username, t("spree.smtp_username")
|
||||
%br/
|
||||
= text_field_tag :smtp_username, Spree::Config[:smtp_username], class: 'fullwidth'
|
||||
.field
|
||||
= label_tag :preferred_smtp_password, t("spree.smtp_password")
|
||||
%br/
|
||||
= password_field_tag :smtp_password, Spree::Config[:smtp_password], class: 'fullwidth'
|
||||
15
app/views/spree/admin/mail_methods/edit.html.haml
Normal file
15
app/views/spree/admin/mail_methods/edit.html.haml
Normal file
@@ -0,0 +1,15 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.mail_method_settings")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
= link_to_with_icon 'icon-envelope-alt', t("spree.admin.mail_methods.send_testmail"), testmail_admin_mail_method_path, method: :post, title: t("spree.admin.mail_methods.send_testmail"), class: 'send_mail button no-text'
|
||||
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @mail_method }
|
||||
|
||||
= form_tag admin_mail_method_path, method: :put do |f|
|
||||
%fieldset.no-border-top
|
||||
= render partial: 'form', locals: { f: f }
|
||||
.form-buttons.filter-actions.actions= button t("spree.actions.update"), 'icon-refresh'
|
||||
@@ -1,5 +1,5 @@
|
||||
- content_for :app_wrapper_attrs do
|
||||
= "ng-app='admin.lineItems'"
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.lineItems"
|
||||
|
||||
- content_for :page_title do
|
||||
%h1.page-title
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#select-customer{"data-hook" => ""}
|
||||
%fieldset.no-border-bottom
|
||||
%legend{:align => "center"}= Spree.t(:customer_search)
|
||||
- content_for :app_wrapper_attrs do
|
||||
= 'ng-app=admin.orders'
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.orders"
|
||||
= hidden_field_tag :customer_search_override, nil, distributor_id: @order.distributor_id, :class => 'fullwidth title customer-search-override'
|
||||
= render :partial => "spree/admin/orders/customer_details/autocomplete", :formats => :js
|
||||
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
|
||||
= render partial: 'spree/admin/shared/order_sub_menu'
|
||||
|
||||
- content_for :app_wrapper_attrs do
|
||||
= "ng-app='admin.orders' ng-controller='ordersCtrl'"
|
||||
- content_for :main_ng_app_name do
|
||||
= "admin.orders"
|
||||
|
||||
- content_for :main_ng_ctrl_name do
|
||||
= "ordersCtrl"
|
||||
|
||||
- content_for :table_filter_title do
|
||||
= t(:search)
|
||||
|
||||
@@ -53,18 +53,17 @@
|
||||
= f.label :sku, t(:sku)
|
||||
= f.text_field :sku, :size => 16
|
||||
|
||||
- if Spree::Config[:track_inventory_levels]
|
||||
.alpha.two.columns
|
||||
= f.field_container :on_hand do
|
||||
= f.label :on_hand, t(:on_hand)
|
||||
= f.number_field :on_hand, :min => 0
|
||||
.omega.two.columns
|
||||
= f.field_container :on_demand, :class => ['checkbox'] do
|
||||
%label
|
||||
= f.check_box :on_demand
|
||||
= t(:on_demand)
|
||||
.alpha.two.columns
|
||||
= f.field_container :on_hand do
|
||||
= f.label :on_hand, t(:on_hand)
|
||||
= f.number_field :on_hand, :min => 0
|
||||
.omega.two.columns
|
||||
= f.field_container :on_demand, :class => ['checkbox'] do
|
||||
%label
|
||||
= f.check_box :on_demand
|
||||
= t(:on_demand)
|
||||
|
||||
.clear
|
||||
.clear
|
||||
|
||||
%ul#shipping_specs
|
||||
%li#shipping_specs_weight_field.field.alpha.two.columns
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
= f.field_container :shipping_categories do
|
||||
= f.label :shipping_category_id, t(:shipping_category)
|
||||
= f.collection_select(:shipping_category_id, Spree::ShippingCategory.all, :id, :name, {:include_blank => true}, {:class => 'select2 fullwidth'})
|
||||
= f.collection_select(:shipping_category_id, Spree::ShippingCategory.all, :id, :name, {:include_blank => false}, {:class => 'select2 fullwidth'})
|
||||
= f.error_message_on :shipping_category_id
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
= form_for [:admin, @product], :html => { :multipart => true } do |f|
|
||||
.twelve.columns.alpha
|
||||
%fieldset.no-border-bottom{ id: "new_product" }
|
||||
%legend{align: "center"}= t(:new_product)
|
||||
%legend{align: "center"}= t(".new_product")
|
||||
.twelve.columns.alpha
|
||||
.six.columns.alpha
|
||||
= f.field_container :supplier do
|
||||
= f.label :supplier_id, t(:supplier)
|
||||
= f.label :supplier_id, t(".supplier")
|
||||
%span.required *
|
||||
= f.collection_select(:supplier_id, @producers, :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"})
|
||||
= f.error_message_on :supplier
|
||||
.six.columns.omega
|
||||
= f.field_container :name do
|
||||
= f.label :name, t(:product_name)
|
||||
= f.label :name, t(".product_name")
|
||||
%span.required *
|
||||
%br/
|
||||
= f.text_field :name, :class => 'fullwidth title'
|
||||
@@ -21,7 +21,7 @@
|
||||
.twelve.columns.alpha{ 'ng-controller' => 'unitsCtrl' }
|
||||
.six.columns.alpha
|
||||
= f.field_container :units do
|
||||
= f.label :variant_unit_with_scale, t(:units)
|
||||
= f.label :variant_unit_with_scale, t(".units")
|
||||
%span.required *
|
||||
%select.select2.fullwidth{ id: 'product_variant_unit_with_scale', 'ng-model' => 'product.variant_unit_with_scale', 'ng-options' => 'unit[1] as unit[0] for unit in variant_unit_options' }
|
||||
%option{'value' => '', 'ng-hide' => "hasUnit(product)"}
|
||||
@@ -29,7 +29,7 @@
|
||||
%input{ type: 'hidden', 'ng-value' => 'product.variant_unit_scale', name: 'product[variant_unit_scale]' }
|
||||
.three.columns
|
||||
= f.field_container :unit_value do
|
||||
= f.label :product_unit_value_with_description, t(:value), 'ng-disabled' => "!hasUnit(product)"
|
||||
= f.label :product_unit_value_with_description, t(".value"), 'ng-disabled' => "!hasUnit(product)"
|
||||
%span.required *
|
||||
%input.fullwidth{ id: 'product_unit_value_with_description', 'ng-model' => 'product.master.unit_value_with_description', :type => 'text', placeholder: "eg. 2", 'ng-disabled' => "!hasUnit(product)" }
|
||||
%input{ type: 'hidden', 'ng-value' => 'product.master.unit_value', name: 'product[unit_value]' }
|
||||
@@ -37,28 +37,28 @@
|
||||
= render 'display_as', f: f
|
||||
.three.columns.omega{ 'ng-show' => "product.variant_unit_with_scale == 'items'" }
|
||||
= f.field_container :unit_name do
|
||||
= f.label :product_variant_unit_name, t(:unit_name)
|
||||
= f.label :product_variant_unit_name, t(".unit_name")
|
||||
%input.fullwidth{ id: 'product_variant_unit_name','ng-model' => 'product.variant_unit_name', :name => 'product[variant_unit_name]', :placeholder => t('admin.products.unit_name_placeholder'), :type => 'text' }
|
||||
.twelve.columns.alpha
|
||||
.six.columns.alpha
|
||||
= render 'spree/admin/products/primary_taxon_form', f: f
|
||||
.two.columns
|
||||
= f.field_container :price do
|
||||
= f.label :price, t(:price)
|
||||
= f.label :price, t(".price")
|
||||
%span.required *
|
||||
%br/
|
||||
= f.text_field :price, class: 'fullwidth'
|
||||
= f.error_message_on :price
|
||||
.two.columns
|
||||
= f.field_container :on_hand do
|
||||
= f.label :on_hand, t(:on_hand)
|
||||
= f.label :on_hand, t(".on_hand")
|
||||
%span.required *
|
||||
%br/
|
||||
= f.text_field :on_hand, class: 'fullwidth'
|
||||
= f.error_message_on :on_hand
|
||||
.two.columns.omega
|
||||
= f.field_container :on_demand do
|
||||
= f.label :on_demand, t(:on_demand)
|
||||
= f.label :on_demand, t(".on_demand")
|
||||
%br/
|
||||
= f.check_box :on_demand
|
||||
= f.error_message_on :on_demand
|
||||
@@ -74,13 +74,13 @@
|
||||
|
||||
.twelve.columns.alpha
|
||||
= f.field_container :description do
|
||||
= f.label :product_description, t(:product_description)
|
||||
= f.label :product_description, t(".product_description")
|
||||
%br/
|
||||
%text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', "textangular-links-target-blank" => true, 'ta-toolbar' => "[['bold','italics','underline','clear'],['insertLink']]"}
|
||||
= f.error_message_on :description
|
||||
.four.columns.omega{ style: "text-align: center" }
|
||||
%fieldset.no-border-bottom{ id: "image" }
|
||||
%legend{align: "center"}= t(:image)
|
||||
%legend{align: "center"}= t(".image")
|
||||
.row
|
||||
= image_tag "noimage/product.png", class: "four columns alpha"
|
||||
.row
|
||||
@@ -90,10 +90,10 @@
|
||||
.form-buttons.filter-actions.actions
|
||||
= button t('actions.create'), 'icon-ok', :submit, value: "create"
|
||||
%span.or
|
||||
= t(:or)
|
||||
= t(".or")
|
||||
= button t('actions.create_and_add_another'), 'icon-repeat', :submit, value: 'add_another'
|
||||
%span.or
|
||||
= t(:or)
|
||||
= t(".or")
|
||||
= link_to_with_icon 'icon-remove', t('actions.cancel'), admin_products_path, :class => 'button'
|
||||
|
||||
|
||||
|
||||
9
app/views/spree/admin/states/_form.html.haml
Normal file
9
app/views/spree/admin/states/_form.html.haml
Normal file
@@ -0,0 +1,9 @@
|
||||
.row
|
||||
.alpha.six.columns
|
||||
= f.field_container :name do
|
||||
= f.label :name, t("spree.name")
|
||||
= f.text_field :name, class: 'fullwidth'
|
||||
.omega.six.columns
|
||||
= f.field_container :abbr do
|
||||
= f.label :abbr, t("spree.abbreviation")
|
||||
= f.text_field :abbr, class: 'fullwidth'
|
||||
24
app/views/spree/admin/states/_state_list.html.haml
Normal file
24
app/views/spree/admin/states/_state_list.html.haml
Normal file
@@ -0,0 +1,24 @@
|
||||
#new_state
|
||||
%table#listing_states.index
|
||||
%colgroup
|
||||
%col{style: "width: 70%"}/
|
||||
%col{style: "width: 15%"}/
|
||||
%col{style: "width: 15%"}/
|
||||
%thead
|
||||
%tr
|
||||
%th= t("spree.name")
|
||||
%th= t("spree.abbreviation")
|
||||
%th.actions
|
||||
%tbody
|
||||
- @states.each do |state|
|
||||
- tr_class = cycle('odd', 'even')
|
||||
- tr_id = spree_dom_id(state)
|
||||
%tr{class: tr_class, id: tr_id}
|
||||
%td= state.name
|
||||
%td.align-center= state.abbr
|
||||
%td.actions
|
||||
= link_to_with_icon 'icon-edit', t("spree.edit"), edit_admin_country_state_url(@country, state), no_text: true
|
||||
= link_to_delete state, no_text: true
|
||||
- if @states.empty?
|
||||
%tr
|
||||
%td{colspan: "3"}= t("spree.none")
|
||||
16
app/views/spree/admin/states/edit.html.haml
Normal file
16
app/views/spree/admin/states/edit.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.editing_state")
|
||||
%i.icon-arrow-right
|
||||
= @state.name
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
= button_link_to t("spree.back_to_states_list"), spree.admin_country_states_url(@country), icon: 'icon-arrow-left'
|
||||
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @state }
|
||||
= form_for [:admin, @country, @state] do |f|
|
||||
%fieldset.no-border-top
|
||||
= render partial: 'form', locals: { f: f }
|
||||
= render partial: 'spree/admin/shared/edit_resource_links'
|
||||
16
app/views/spree/admin/states/index.html.haml
Normal file
16
app/views/spree/admin/states/index.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.states")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li#new_state_link
|
||||
= button_link_to t("spree.new_state"), new_admin_country_state_url(@country), { remote: true, icon: 'icon-plus', id: 'new_state_link' }
|
||||
.field.row
|
||||
= label_tag :country, t("spree.country")
|
||||
- databaseurl = "#{admin_states_path(format: :js)}?country_id="
|
||||
%select#country.observe_field.select2.fullwidth{"data-base-url" => databaseurl, "data-update" => "#state-list"}
|
||||
= options_from_collection_for_select(@countries, :id, :name, @country.id)
|
||||
= image_tag 'select2-spinner.gif', plugin: 'spree', style: 'display:none;', id: 'busy_indicator'
|
||||
#state-list
|
||||
= render partial: 'state_list'
|
||||
12
app/views/spree/admin/states/new.html.haml
Normal file
12
app/views/spree/admin/states/new.html.haml
Normal file
@@ -0,0 +1,12 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @state }
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.new_state")
|
||||
|
||||
= form_for [:admin, @country, @state] do |f|
|
||||
%fieldset
|
||||
%legend= t("spree.new_state")
|
||||
= render partial: 'form', locals: { f: f }
|
||||
= render partial: 'spree/admin/shared/new_resource_links'
|
||||
2
app/views/spree/admin/states/new.js.erb
Normal file
2
app/views/spree/admin/states/new.js.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
$("#new_state").html("<%= escape_javascript(render :template => 'spree/admin/states/new', :formats => [:html], :handlers => [:erb]) %>");
|
||||
$("#new_state_link").parent().hide();
|
||||
15
app/views/spree/admin/tax_categories/_form.html.haml
Normal file
15
app/views/spree/admin/tax_categories/_form.html.haml
Normal file
@@ -0,0 +1,15 @@
|
||||
.row
|
||||
.alpha.four.columns
|
||||
= f.field_container :name do
|
||||
= f.label :name, t("spree.name")
|
||||
= f.text_field :name, class: 'fullwidth'
|
||||
.five.columns
|
||||
= f.field_container :description do
|
||||
= f.label :description, t("spree.description")
|
||||
%br/
|
||||
= f.text_field :description, class: 'fullwidth'
|
||||
.three.columns.omega
|
||||
= f.field_container :is_default, class: ['checkbox'] do
|
||||
%label
|
||||
= f.check_box :is_default
|
||||
= t("spree.default")
|
||||
14
app/views/spree/admin/tax_categories/edit.html.haml
Normal file
14
app/views/spree/admin/tax_categories/edit.html.haml
Normal file
@@ -0,0 +1,14 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.editing_tax_category")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li= link_to_with_icon 'icon-arrow-left', t("spree.back_to_tax_categories_list"), admin_tax_categories_path, class: 'button'
|
||||
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @tax_category }
|
||||
|
||||
= form_for [:admin, @tax_category] do |f|
|
||||
%fieldset.no-border-top
|
||||
= render partial: 'form', locals: { f: f }
|
||||
= render partial: 'spree/admin/shared/edit_resource_links'
|
||||
38
app/views/spree/admin/tax_categories/index.html.haml
Normal file
38
app/views/spree/admin/tax_categories/index.html.haml
Normal file
@@ -0,0 +1,38 @@
|
||||
= render :partial => 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.listing_tax_categories")
|
||||
|
||||
- content_for :page_actions do
|
||||
%ul.actions.inline-menu
|
||||
%li
|
||||
= button_link_to t("spree.new_tax_category"), new_object_url, :icon => 'icon-plus', :id => 'admin_new_tax_categories_link'
|
||||
|
||||
%table#listing_tax_categories.index
|
||||
%colgroup
|
||||
%col{style: "width: 30%"}/
|
||||
%col{style: "width: 40%"}/
|
||||
%col{style: "width: 15%"}/
|
||||
%col{style: "width: 15%"}/
|
||||
%thead
|
||||
%tr{"data-hook" => "tax_header"}
|
||||
%th= t("spree.name")
|
||||
%th= t("spree.description")
|
||||
%th= t("spree.default")
|
||||
%th.actions
|
||||
%tbody
|
||||
- @tax_categories.each do |tax_category|
|
||||
- @edit_url = edit_admin_tax_category_path(tax_category)
|
||||
- @delete_url = admin_tax_category_path(tax_category)
|
||||
- tr_class = cycle('odd', 'even')
|
||||
- tr_id = spree_dom_id(tax_category)
|
||||
%tr{class: tr_class, id: tr_id}
|
||||
%td= tax_category.name
|
||||
%td= tax_category.description
|
||||
%td.align-center= tax_category.is_default.to_s.titleize
|
||||
%td.actions
|
||||
= link_to_edit tax_category, no_text: true
|
||||
= link_to_delete tax_category, no_text: true
|
||||
- if @tax_categories.empty?
|
||||
%tr
|
||||
%td{colspan: "4"}= t("spree.none")
|
||||
14
app/views/spree/admin/tax_categories/new.html.haml
Normal file
14
app/views/spree/admin/tax_categories/new.html.haml
Normal file
@@ -0,0 +1,14 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.new_tax_category")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li= link_to_with_icon 'icon-arrow-left', t("spree.back_to_tax_categories_list"), admin_tax_categories_path, class: 'button'
|
||||
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @tax_category }
|
||||
|
||||
= form_for [:admin, @tax_category] do |f|
|
||||
%fieldset.no-border-top
|
||||
= render partial: 'form', locals: { f: f }
|
||||
= render partial: 'spree/admin/shared/new_resource_links'
|
||||
1
app/views/spree/admin/tax_categories/show.html.haml
Normal file
1
app/views/spree/admin/tax_categories/show.html.haml
Normal file
@@ -0,0 +1 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
28
app/views/spree/admin/tax_rates/_form.html.haml
Normal file
28
app/views/spree/admin/tax_rates/_form.html.haml
Normal file
@@ -0,0 +1,28 @@
|
||||
%div
|
||||
.alpha.twelve.columns
|
||||
%fieldset.no-border-bottom
|
||||
%legend{align: "center"}= t("spree.general_settings")
|
||||
.alpha.six.columns
|
||||
.field
|
||||
= f.label :name, t("spree.name")
|
||||
= f.text_field :name, class: 'fullwidth'
|
||||
.field
|
||||
= f.label :amount, t("spree.rate")
|
||||
= f.text_field :amount, class: 'fullwidth'
|
||||
%p
|
||||
%em= t("spree.tax_rate_amount_explanation")
|
||||
.field
|
||||
= f.check_box :included_in_price
|
||||
= f.label :included_in_price, t("spree.included_in_price")
|
||||
.omega.six.columns
|
||||
.field
|
||||
= f.label :zone, t("spree.zone")
|
||||
= f.collection_select(:zone_id, @available_zones, :id, :name, {}, {class: 'select2 fullwidth'})
|
||||
.field
|
||||
= f.label :tax_category_id, t("spree.tax_category")
|
||||
= f.collection_select(:tax_category_id, @available_categories,:id, :name, {}, {class: 'select2 fullwidth'})
|
||||
.field
|
||||
= f.check_box :show_rate_in_label
|
||||
= f.label :show_rate_in_label, t("spree.show_rate_in_label")
|
||||
.clear
|
||||
= render partial: 'spree/admin/shared/calculator_fields', locals: { f: f }
|
||||
16
app/views/spree/admin/tax_rates/edit.html.haml
Normal file
16
app/views/spree/admin/tax_rates/edit.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.editing_tax_rate")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
= button_link_to t("spree.back_to_tax_rates_list"), spree.admin_tax_rates_path, icon: 'icon-arrow-left'
|
||||
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @tax_rate }
|
||||
|
||||
= form_for [:admin, @tax_rate] do |f|
|
||||
%fieldset.no-border-top
|
||||
= render partial: 'form', locals: { f: f }
|
||||
.clear
|
||||
= render partial: 'spree/admin/shared/edit_resource_links'
|
||||
48
app/views/spree/admin/tax_rates/index.html.haml
Normal file
48
app/views/spree/admin/tax_rates/index.html.haml
Normal file
@@ -0,0 +1,48 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.tax_rates")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
= button_link_to t("spree.new_tax_rate"), new_object_url, icon: 'icon-plus'
|
||||
|
||||
- unless @tax_rates.any?
|
||||
.no-objects-found
|
||||
= t("spree.no_results")
|
||||
- else
|
||||
%table.index
|
||||
%colgroup
|
||||
%col{style: "width: 15%"}/
|
||||
%col{style: "width: 15%"}/
|
||||
%col{style: "width: 10%"}/
|
||||
%col{style: "width: 10%"}/
|
||||
%col{style: "width: 10%"}/
|
||||
%col{style: "width: 10%"}/
|
||||
%col{style: "width: 15%"}/
|
||||
%col{style: "width: 15%"}/
|
||||
%thead
|
||||
%tr
|
||||
%th= t("spree.zone")
|
||||
%th= t("spree.name")
|
||||
%th= t("spree.category")
|
||||
%th= t("spree.amount")
|
||||
%th= t("spree.included_in_price")
|
||||
%th= t("spree.show_rate_in_label")
|
||||
%th= t("spree.calculator")
|
||||
%th.actions
|
||||
%tbody
|
||||
- @tax_rates.each do |tax_rate|
|
||||
- tr_class = cycle('odd', 'even')
|
||||
- tr_id = spree_dom_id(tax_rate)
|
||||
%tr{class: tr_class, id: tr_id}
|
||||
%td= tax_rate.zone.try(:name) || t("spree.not_available")
|
||||
%td= tax_rate.name
|
||||
%td= tax_rate.tax_category.try(:name) || t("spree.not_available")
|
||||
%td.align-center= tax_rate.amount
|
||||
%td.align-center= tax_rate.included_in_price
|
||||
%td.align-center= tax_rate.show_rate_in_label
|
||||
%td.align-center= tax_rate.calculator.to_s
|
||||
%td.actions
|
||||
= link_to_edit tax_rate, no_text: true
|
||||
= link_to_delete tax_rate, no_text: true
|
||||
16
app/views/spree/admin/tax_rates/new.html.haml
Normal file
16
app/views/spree/admin/tax_rates/new.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.new_tax_rate")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
= button_link_to t("spree.back_to_tax_rates_list"), spree.admin_tax_rates_path, icon: 'icon-arrow-left'
|
||||
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @tax_rate }
|
||||
|
||||
= form_for [:admin, @tax_rate] do |f|
|
||||
%fieldset.no-border-top
|
||||
= render partial: 'form', locals: { f: f }
|
||||
.clear
|
||||
= render partial: 'spree/admin/shared/new_resource_links'
|
||||
7
app/views/spree/admin/taxonomies/_form.html.haml
Normal file
7
app/views/spree/admin/taxonomies/_form.html.haml
Normal file
@@ -0,0 +1,7 @@
|
||||
.field.align-center
|
||||
= f.field_container :name do
|
||||
= f.label :name, t("spree.name")
|
||||
%span.required *
|
||||
%br/
|
||||
= error_message_on :taxonomy, :name, class: 'fullwidth title'
|
||||
= text_field :taxonomy, :name
|
||||
13
app/views/spree/admin/taxonomies/_js_head.html.erb
Executable file
13
app/views/spree/admin/taxonomies/_js_head.html.erb
Executable file
@@ -0,0 +1,13 @@
|
||||
<% content_for :head do %>
|
||||
<%= javascript_tag "var taxonomy_id = #{@taxonomy.id};
|
||||
var loading = '#{escape_javascript t("spree.loading")}';
|
||||
var new_taxon = '#{escape_javascript t("spree.new_taxon")}';
|
||||
var server_error = '#{escape_javascript t("spree.server_error")}';
|
||||
var taxonomy_tree_error = '#{escape_javascript t("spree.taxonomy_tree_error")}';
|
||||
|
||||
$(document).ready(function(){
|
||||
setup_taxonomy_tree(taxonomy_id);
|
||||
});
|
||||
"
|
||||
%>
|
||||
<% end %>
|
||||
19
app/views/spree/admin/taxonomies/_list.html.haml
Normal file
19
app/views/spree/admin/taxonomies/_list.html.haml
Normal file
@@ -0,0 +1,19 @@
|
||||
%table#listing_taxonomies.index.sortable{"data-sortable-link" => update_positions_admin_taxonomies_url}
|
||||
%colgroup
|
||||
%col{style: "width: 85%"}/
|
||||
%col{style: "width: 15%"}/
|
||||
%thead
|
||||
%tr
|
||||
%th= t("spree.name")
|
||||
%th.actions
|
||||
%tbody
|
||||
- @taxonomies.each do |taxonomy|
|
||||
- tr_class = cycle('odd', 'even')
|
||||
- tr_id = spree_dom_id(taxonomy)
|
||||
%tr{class: tr_class, id: tr_id}
|
||||
%td
|
||||
%span.handle
|
||||
= taxonomy.name
|
||||
%td.actions
|
||||
= link_to_edit taxonomy.id, no_text: true
|
||||
= link_to_delete taxonomy, no_text: true
|
||||
7
app/views/spree/admin/taxonomies/_taxon.html.haml
Normal file
7
app/views/spree/admin/taxonomies/_taxon.html.haml
Normal file
@@ -0,0 +1,7 @@
|
||||
- if taxon.children.length != 0
|
||||
%ul
|
||||
- taxon.children.each do |child|
|
||||
%li{id: "#{child.id}", rel: "taxon"}
|
||||
%a{href: "#", style: "background-image: url(#{child.icon.url});"}= child.name
|
||||
- if child.children.length > 0
|
||||
= render partial: 'taxon', locals: { taxon: child }
|
||||
32
app/views/spree/admin/taxonomies/edit.haml
Executable file
32
app/views/spree/admin/taxonomies/edit.haml
Executable file
@@ -0,0 +1,32 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
= render partial: 'js_head'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.taxonomy_edit")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
= button_link_to t("spree.back_to_taxonomies_list"), spree.admin_taxonomies_path, icon: 'icon-arrow-left'
|
||||
|
||||
#ajax_error.errorExplanation{style: "display:none;"}
|
||||
= form_for [:admin, @taxonomy] do |f|
|
||||
%fieldset.no-border-top
|
||||
= render partial: 'form', locals: { f: f }
|
||||
%div
|
||||
= label_tag nil, t("spree.tree")
|
||||
%br/
|
||||
:javascript
|
||||
Spree.routes.taxonomy_taxons_path = "#{spree.api_taxonomy_taxons_path(@taxonomy)}";
|
||||
Spree.routes.admin_taxonomy_taxons_path = "#{spree.admin_taxonomy_taxons_path(@taxonomy)}";
|
||||
#taxonomy_tree.tree
|
||||
#progress{style: "display:none;"}
|
||||
= image_tag 'select2-spinner.gif', title: 'Spinner', style: "vertical-align:bottom;"
|
||||
= t("spree.updating")
|
||||
\..
|
||||
.info= t("spree.taxonomy_tree_instruction")
|
||||
%br/
|
||||
.filter-actions.actions
|
||||
= button t('spree.actions.update'), 'icon-refresh'
|
||||
%span.or= t("spree.or")
|
||||
= button_link_to t('spree.actions.cancel'), admin_taxonomies_path, icon: 'icon-remove'
|
||||
11
app/views/spree/admin/taxonomies/index.html.haml
Normal file
11
app/views/spree/admin/taxonomies/index.html.haml
Normal file
@@ -0,0 +1,11 @@
|
||||
= render partial: 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t("spree.taxonomies")
|
||||
|
||||
- content_for :page_actions do
|
||||
%li
|
||||
= button_link_to t("spree.new_taxonomy"), spree.new_admin_taxonomy_url, icon: 'icon-plus', id: 'admin_new_taxonomy_link'
|
||||
|
||||
#list-taxonomies
|
||||
= render partial: 'list'
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user