mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Compare commits
3 Commits
v1.9
...
v1.8.12-tr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c3c3394a5 | ||
|
|
5b3816fa9e | ||
|
|
3507bae002 |
@@ -1,7 +1,6 @@
|
||||
engines:
|
||||
rubocop:
|
||||
enabled: true
|
||||
channel: rubocop-0-48
|
||||
scss-lint:
|
||||
enabled: false
|
||||
ratings:
|
||||
|
||||
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,28 +0,0 @@
|
||||
#### What? Why?
|
||||
|
||||
[Explain why is this change needed and the solution you propose. Provide
|
||||
context for others to understand it]
|
||||
|
||||
#### What should we test?
|
||||
|
||||
[List which features should be tested and how]
|
||||
|
||||
#### Release notes
|
||||
|
||||
[In case this should be present in the release notes, please write them or
|
||||
remove this section otherwise]
|
||||
|
||||
#### How is this related to the Spree upgrade?
|
||||
|
||||
[Any known conflicts with the Spree Upgrade? explain them or remove this section
|
||||
otherwise]
|
||||
|
||||
#### Discourse thread
|
||||
|
||||
[Is there a discussion about this in Discourse? add the link if so or remove
|
||||
this section otherwise]
|
||||
|
||||
#### Dependencies
|
||||
|
||||
[Does this PR depend on another one? add the link of so or remove this section
|
||||
otherwise]
|
||||
@@ -11,8 +11,6 @@ AllCops:
|
||||
- 'db/**/*'
|
||||
- 'config/**/*'
|
||||
- 'script/**/*'
|
||||
- 'vendor/**/*'
|
||||
- 'node_modules/**/*'
|
||||
- !ruby/regexp /old_and_unused\.rb$/
|
||||
|
||||
# OFN SETTINGS
|
||||
@@ -27,10 +25,6 @@ Style/Documentation:
|
||||
Style/StringLiterals:
|
||||
Enabled: false
|
||||
|
||||
Layout/MultilineMethodCallIndentation:
|
||||
Enabled: true
|
||||
EnforcedStyle: indented
|
||||
|
||||
# TEMPORARY/CONTESTED SETTINGS
|
||||
# These are still to be decided upon, but recommended for inclusion by
|
||||
# oeoeaio after scrutinising offenses the codebase
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --exclude-limit 100`
|
||||
# on 2017-07-12 10:36:44 +0200 using RuboCop version 0.49.1.
|
||||
# on 2017-06-29 08:50:47 +1000 using RuboCop version 0.49.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
@@ -455,6 +455,7 @@ Layout/LeadingCommentSpace:
|
||||
- 'spec/factories.rb'
|
||||
- 'spec/features/admin/products_spec.rb'
|
||||
- 'spec/features/admin/reports_spec.rb'
|
||||
- 'spec/features/consumer/shops_spec.rb'
|
||||
- 'spec/jobs/finalize_account_invoices_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_and_distributor_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_grouper_spec.rb'
|
||||
@@ -525,6 +526,54 @@ Layout/MultilineMethodCallBraceLayout:
|
||||
- 'lib/open_food_network/products_renderer.rb'
|
||||
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
|
||||
|
||||
# Offense count: 191
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
||||
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
||||
Layout/MultilineMethodCallIndentation:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/order_cycles_controller.rb'
|
||||
- 'app/controllers/admin/variant_overrides_controller.rb'
|
||||
- 'app/controllers/api/order_cycles_controller.rb'
|
||||
- 'app/controllers/base_controller.rb'
|
||||
- 'app/controllers/checkout_controller.rb'
|
||||
- 'app/controllers/spree/admin/orders_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/products_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/reports_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/search_controller_decorator.rb'
|
||||
- 'app/controllers/spree/api/products_controller_decorator.rb'
|
||||
- 'app/controllers/spree/orders_controller_decorator.rb'
|
||||
- 'app/jobs/update_billable_periods.rb'
|
||||
- 'app/models/column_preference.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/exchange.rb'
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/product_importer.rb'
|
||||
- 'app/models/spree/ability_decorator.rb'
|
||||
- 'app/models/spree/calculator/default_tax_decorator.rb'
|
||||
- 'app/models/spree/line_item_decorator.rb'
|
||||
- 'app/models/spree/order_decorator.rb'
|
||||
- 'app/models/spree/payment_method_decorator.rb'
|
||||
- 'app/models/spree/product_decorator.rb'
|
||||
- 'app/models/spree/shipping_method_decorator.rb'
|
||||
- 'app/models/spree/taxon_decorator.rb'
|
||||
- 'app/models/spree/user_decorator.rb'
|
||||
- 'app/models/spree/variant_decorator.rb'
|
||||
- 'app/serializers/api/admin/exchange_serializer.rb'
|
||||
- 'lib/open_food_network/lettuce_share_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/open_food_network/permissions.rb'
|
||||
- 'lib/open_food_network/products_cache.rb'
|
||||
- 'spec/controllers/spree/admin/reports_controller_spec.rb'
|
||||
- 'spec/helpers/order_cycles_helper_spec.rb'
|
||||
- 'spec/jobs/update_account_invoices_spec.rb'
|
||||
- 'spec/jobs/update_billable_periods_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
|
||||
- 'spec/mailers/producer_mailer_spec.rb'
|
||||
- 'spec/support/matchers/table_matchers.rb'
|
||||
|
||||
# Offense count: 34
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
||||
@@ -1015,70 +1064,7 @@ Lint/UselessAccessModifier:
|
||||
Lint/Void:
|
||||
Exclude:
|
||||
- 'app/serializers/api/enterprise_serializer.rb'
|
||||
- 'spec/archive/features/consumer/checkout_spec.rb'
|
||||
- 'spec/controllers/api/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/base_controller_spec.rb'
|
||||
- 'spec/controllers/cart_controller_spec.rb'
|
||||
- 'spec/controllers/checkout_controller_spec.rb'
|
||||
- 'spec/controllers/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/adjustments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/line_items_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/variants_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/products_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/variants_controller_spec.rb'
|
||||
- 'spec/controllers/spree/checkout_controller_spec.rb'
|
||||
- 'spec/controllers/spree/orders_controller_spec.rb'
|
||||
- 'spec/controllers/user_passwords_controller_spec.rb'
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
- 'spec/features/admin/enterprise_fees_spec.rb'
|
||||
- 'spec/features/admin/enterprise_groups_spec.rb'
|
||||
- 'spec/features/admin/enterprise_user_spec.rb'
|
||||
- 'spec/features/admin/enterprises/index_spec.rb'
|
||||
- 'spec/features/admin/enterprises_spec.rb'
|
||||
- 'spec/features/admin/order_cycles_spec.rb'
|
||||
- 'spec/features/admin/orders_spec.rb'
|
||||
- 'spec/features/admin/payment_method_spec.rb'
|
||||
- 'spec/features/admin/product_import_spec.rb'
|
||||
- 'spec/features/admin/products_spec.rb'
|
||||
- 'spec/features/admin/reports_spec.rb'
|
||||
- 'spec/features/admin/shipping_methods_spec.rb'
|
||||
- 'spec/features/admin/variant_overrides_spec.rb'
|
||||
- 'spec/features/admin/variants_spec.rb'
|
||||
- 'spec/features/consumer/shopping/checkout_spec.rb'
|
||||
- 'spec/features/consumer/shopping/shopping_spec.rb'
|
||||
- 'spec/features/consumer/shopping/variant_overrides_spec.rb'
|
||||
- 'spec/helpers/html_helper_spec.rb'
|
||||
- 'spec/helpers/products_helper_spec.rb'
|
||||
- 'spec/lib/open_food_network/bulk_coop_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_issue_validator_spec.rb'
|
||||
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/packing_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/reports/report_spec.rb'
|
||||
- 'spec/lib/open_food_network/reports/rule_spec.rb'
|
||||
- 'spec/mailers/enterprise_mailer_spec.rb'
|
||||
- 'spec/mailers/order_mailer_spec.rb'
|
||||
- 'spec/models/cart_spec.rb'
|
||||
- 'spec/models/enterprise_relationship_spec.rb'
|
||||
- 'spec/models/enterprise_spec.rb'
|
||||
- 'spec/models/exchange_spec.rb'
|
||||
- 'spec/models/order_cycle_spec.rb'
|
||||
- 'spec/models/product_distribution_spec.rb'
|
||||
- 'spec/models/spree/adjustment_spec.rb'
|
||||
- 'spec/models/spree/line_item_spec.rb'
|
||||
- 'spec/models/spree/order_populator_spec.rb'
|
||||
- 'spec/models/spree/order_spec.rb'
|
||||
- 'spec/models/spree/payment_method_spec.rb'
|
||||
- 'spec/models/spree/payment_spec.rb'
|
||||
- 'spec/models/spree/product_spec.rb'
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
- 'spec/models/variant_override_spec.rb'
|
||||
- 'spec/serializers/enterprise_serializer_spec.rb'
|
||||
- 'spec/support/request/web_helper.rb'
|
||||
- 'spec/**/*'
|
||||
|
||||
# Offense count: 706
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
|
||||
@@ -22,9 +22,6 @@ env:
|
||||
- CI_NODE_INDEX=3
|
||||
- CI_NODE_INDEX=4 KARMA="true" GITHUB_DEPLOY="true"
|
||||
|
||||
before_install:
|
||||
- ./script/upgrade_bundler.sh
|
||||
|
||||
before_script:
|
||||
- cp config/database.travis.yml config/database.yml
|
||||
- cp config/application.yml.example config/application.yml
|
||||
|
||||
13
Gemfile
13
Gemfile
@@ -4,20 +4,19 @@ ruby "2.1.5"
|
||||
gem 'rails', '3.2.21'
|
||||
gem 'rails-i18n', '~> 3.0.0'
|
||||
gem 'i18n', '~> 0.6.11'
|
||||
gem 'i18n-js', '~> 3.0.0'
|
||||
|
||||
# Patched version. See http://rubysec.com/advisories/CVE-2015-5312/.
|
||||
gem 'nokogiri', '>= 1.6.7.1'
|
||||
|
||||
gem 'pg'
|
||||
gem 'spree', github: 'openfoodfoundation/spree', branch: 'step-6-adjustment-state-migration', ref: '48febb2'
|
||||
gem 'spree', github: 'openfoodfoundation/spree', branch: 'spree-upgrade-step1c'
|
||||
gem 'spree_i18n', github: 'spree/spree_i18n', branch: '1-3-stable'
|
||||
gem 'spree_auth_devise', github: 'openfoodfoundation/spree_auth_devise', branch: 'spree-upgrade-intermediate'
|
||||
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '1-3-stable'
|
||||
|
||||
# Our branch contains two changes
|
||||
# - Pass customer email and phone number to PayPal (merged to upstream master)
|
||||
# - Change type of password from string to password to hide it in the form
|
||||
gem 'spree_paypal_express', :github => "openfoodfoundation/better_spree_paypal_express", :branch => "spree-upgrade-intermediate"
|
||||
gem 'spree_paypal_express', :github => "openfoodfoundation/better_spree_paypal_express", :branch => "hide-password"
|
||||
#gem 'spree_paypal_express', :github => "spree-contrib/better_spree_paypal_express", :branch => "1-3-stable"
|
||||
|
||||
gem 'delayed_job_active_record'
|
||||
@@ -127,12 +126,8 @@ group :development do
|
||||
gem 'guard-livereload'
|
||||
gem 'rack-livereload'
|
||||
gem 'guard-rails'
|
||||
gem 'guard-zeus'
|
||||
gem 'guard-rspec'
|
||||
gem 'parallel_tests'
|
||||
gem 'rubocop', '>= 0.49.1'
|
||||
|
||||
# 1.0.9 fixed openssl issues on macOS https://github.com/eventmachine/eventmachine/issues/602
|
||||
# While we don't require this gem directly, no dependents forced the upgrade to a version
|
||||
# greater than 1.0.9, so we just required the latest available version here.
|
||||
gem 'eventmachine', '>= 1.2.3'
|
||||
end
|
||||
|
||||
143
Gemfile.lock
143
Gemfile.lock
@@ -14,12 +14,12 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: git://github.com/openfoodfoundation/better_spree_paypal_express.git
|
||||
revision: 8d95f4544c682634812becaf50999fba0cd04df0
|
||||
branch: spree-upgrade-intermediate
|
||||
revision: 840d973cd5bd3250b17674a624dad494aeb09eb3
|
||||
branch: hide-password
|
||||
specs:
|
||||
spree_paypal_express (2.0.3)
|
||||
paypal-sdk-merchant (= 1.106.1)
|
||||
spree_core (~> 1.3.99)
|
||||
spree_core (~> 1.3.4)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/openfoodfoundation/ofn-qz.git
|
||||
@@ -30,78 +30,49 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: git://github.com/openfoodfoundation/spree.git
|
||||
revision: 48febb250a3b1eb2d42812b27b93457e89cde589
|
||||
ref: 48febb2
|
||||
branch: step-6-adjustment-state-migration
|
||||
revision: a4c439570b77afa50f9e36299811f293232bd281
|
||||
branch: spree-upgrade-step1c
|
||||
specs:
|
||||
spree (1.3.99)
|
||||
spree_api (= 1.3.99)
|
||||
spree_backend (= 1.3.99)
|
||||
spree_cmd (= 1.3.99)
|
||||
spree_core (= 1.3.99)
|
||||
spree_dash (= 1.3.99)
|
||||
spree_frontend (= 1.3.99)
|
||||
spree_promo (= 1.3.99)
|
||||
spree_sample (= 1.3.99)
|
||||
spree_api (1.3.99)
|
||||
rabl (= 0.7.2)
|
||||
spree_core (= 1.3.99)
|
||||
versioncake (= 0.4.0)
|
||||
spree_backend (1.3.99)
|
||||
deface (>= 0.9.0)
|
||||
jquery-rails (~> 2.0)
|
||||
rails (~> 3.2.8)
|
||||
select2-rails (~> 3.2)
|
||||
spree_api (= 1.3.99)
|
||||
spree_core (= 1.3.99)
|
||||
stringex (~> 1.3.2)
|
||||
spree_cmd (1.3.99)
|
||||
thor (>= 0.14.6)
|
||||
spree_core (1.3.99)
|
||||
activemerchant (~> 1.50.0)
|
||||
acts_as_list (= 0.1.9)
|
||||
acts_as_list (= 0.1.4)
|
||||
awesome_nested_set (= 2.1.5)
|
||||
aws-sdk (~> 1.11.1)
|
||||
cancan (= 1.6.8)
|
||||
deface (>= 0.9.0)
|
||||
ffaker (~> 1.15.0)
|
||||
highline (= 1.6.15)
|
||||
httparty (= 0.9.0)
|
||||
highline (= 1.6.11)
|
||||
jquery-rails (~> 2.0)
|
||||
json (>= 1.5.5)
|
||||
kaminari (= 0.13.0)
|
||||
money (= 5.1.0)
|
||||
money (= 5.0.0)
|
||||
paperclip (~> 3.0)
|
||||
rabl (= 0.7.2)
|
||||
rails (~> 3.2.13)
|
||||
ransack (= 0.7.2)
|
||||
select2-rails (~> 3.2)
|
||||
state_machine (= 1.2.0)
|
||||
stringex (~> 1.3.2)
|
||||
truncate_html (= 0.9.2)
|
||||
spree_dash (1.3.99)
|
||||
httparty (~> 0.9.0)
|
||||
spree_backend (= 1.3.99)
|
||||
spree_frontend (= 1.3.99)
|
||||
spree_frontend (1.3.99)
|
||||
deface (>= 0.9.0)
|
||||
jquery-rails (~> 2.2.1)
|
||||
rails (~> 3.2.8)
|
||||
select2-rails (~> 3.2)
|
||||
spree_api (= 1.3.99)
|
||||
httparty (~> 0.8.1)
|
||||
spree_core (= 1.3.99)
|
||||
spree_promo (1.3.99)
|
||||
spree_core (= 1.3.99)
|
||||
stringex (~> 1.3.2)
|
||||
spree_sample (1.3.99)
|
||||
spree_core (= 1.3.99)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/openfoodfoundation/spree_auth_devise.git
|
||||
revision: da9eecefc6fe13dedf4c6f3febec79caad839ec3
|
||||
branch: spree-upgrade-intermediate
|
||||
specs:
|
||||
spree_auth_devise (2.0.0)
|
||||
devise (~> 2.2.5)
|
||||
devise-encryptable (= 0.1.2)
|
||||
spree_backend (~> 1.3.6)
|
||||
spree_core (~> 1.3.6)
|
||||
spree_frontend (~> 1.3.6)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/spree/deface.git
|
||||
revision: 1110a1336252109bce7f98f9182042e0bc2930ae
|
||||
@@ -112,6 +83,17 @@ GIT
|
||||
nokogiri (~> 1.6.0)
|
||||
rails (>= 3.1)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/spree/spree_auth_devise.git
|
||||
revision: ba95589a85368297c844f096c2a0c121e5b08138
|
||||
branch: 1-3-stable
|
||||
specs:
|
||||
spree_auth_devise (1.3.0)
|
||||
cancan (~> 1.6.7)
|
||||
devise (~> 2.2.3)
|
||||
devise-encryptable (= 0.1.2)
|
||||
spree_core
|
||||
|
||||
GIT
|
||||
remote: git://github.com/spree/spree_i18n.git
|
||||
revision: 752eb67204e9c5a4e22b62591a8fd55fe2285e43
|
||||
@@ -172,8 +154,8 @@ GEM
|
||||
multi_json (~> 1.0)
|
||||
acts-as-taggable-on (3.5.0)
|
||||
activerecord (>= 3.2, < 5)
|
||||
acts_as_list (0.1.9)
|
||||
addressable (2.4.0)
|
||||
acts_as_list (0.1.4)
|
||||
addressable (2.3.3)
|
||||
andand (1.3.3)
|
||||
angular-rails-templates (0.2.0)
|
||||
railties (>= 3.1)
|
||||
@@ -192,7 +174,7 @@ GEM
|
||||
json (~> 1.4)
|
||||
nokogiri (>= 1.4.4)
|
||||
uuidtools (~> 2.1)
|
||||
bcrypt (3.1.11)
|
||||
bcrypt (3.1.7)
|
||||
bcrypt-ruby (3.1.5)
|
||||
bcrypt (>= 3.1.3)
|
||||
blockenspiel (0.4.5)
|
||||
@@ -213,7 +195,8 @@ GEM
|
||||
timers (~> 1.1.0)
|
||||
chronic (0.10.2)
|
||||
chunky_png (1.3.4)
|
||||
climate_control (0.1.0)
|
||||
climate_control (0.0.3)
|
||||
activesupport (>= 3.0)
|
||||
cliver (0.3.2)
|
||||
cocaine (0.5.8)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
@@ -225,7 +208,7 @@ GEM
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.10.0)
|
||||
colorize (0.8.1)
|
||||
colorize (0.7.7)
|
||||
columnize (0.9.0)
|
||||
compass (1.0.3)
|
||||
chunky_png (~> 1.2)
|
||||
@@ -243,8 +226,8 @@ GEM
|
||||
compass (~> 1.0.0)
|
||||
sass-rails (<= 5.0.1)
|
||||
sprockets (< 2.13)
|
||||
crack (0.4.3)
|
||||
safe_yaml (~> 1.0.0)
|
||||
crack (0.4.1)
|
||||
safe_yaml (~> 0.9.0)
|
||||
css_parser (1.3.5)
|
||||
addressable
|
||||
css_splitter (0.4.5)
|
||||
@@ -275,7 +258,7 @@ GEM
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0.5.3)
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.2.3)
|
||||
eventmachine (1.0.8)
|
||||
excon (0.45.4)
|
||||
execjs (2.6.0)
|
||||
factory_girl (3.3.0)
|
||||
@@ -425,17 +408,18 @@ GEM
|
||||
guard-rspec (4.0.4)
|
||||
guard (>= 2.1.1)
|
||||
rspec (~> 2.14)
|
||||
guard-zeus (0.0.1)
|
||||
guard
|
||||
zeus
|
||||
haml (4.0.4)
|
||||
tilt
|
||||
highline (1.6.15)
|
||||
highline (1.6.11)
|
||||
hike (1.2.3)
|
||||
http_parser.rb (0.5.3)
|
||||
httparty (0.9.0)
|
||||
httparty (0.8.3)
|
||||
multi_json (~> 1.0)
|
||||
multi_xml
|
||||
i18n (0.6.11)
|
||||
i18n-js (3.0.0)
|
||||
i18n (~> 0.6, >= 0.6.6)
|
||||
immigrant (0.1.6)
|
||||
activerecord (>= 3.0)
|
||||
foreigner (>= 1.2.1)
|
||||
@@ -443,10 +427,10 @@ GEM
|
||||
ipaddress (0.8.0)
|
||||
journey (1.0.4)
|
||||
jquery-migrate-rails (1.2.1)
|
||||
jquery-rails (2.2.2)
|
||||
jquery-rails (2.3.0)
|
||||
railties (>= 3.0, < 5.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (1.8.6)
|
||||
json (1.8.3)
|
||||
json_spec (1.1.1)
|
||||
multi_json (~> 1.0)
|
||||
rspec (~> 2.0)
|
||||
@@ -473,16 +457,17 @@ GEM
|
||||
treetop (~> 1.4.8)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile2 (2.1.0)
|
||||
mini_portile2 (2.0.0)
|
||||
momentjs-rails (2.5.1)
|
||||
railties (>= 3.1)
|
||||
money (5.1.0)
|
||||
i18n (~> 0.6.0)
|
||||
money (5.0.0)
|
||||
i18n (~> 0.4)
|
||||
json
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multi_xml (0.5.5)
|
||||
newrelic_rpm (3.12.0.288)
|
||||
nokogiri (1.6.8.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
nokogiri (1.6.7.2)
|
||||
mini_portile2 (~> 2.0.0.rc2)
|
||||
oj (2.1.2)
|
||||
orm_adapter (0.5.0)
|
||||
paper_trail (3.0.8)
|
||||
@@ -524,7 +509,7 @@ GEM
|
||||
activesupport (>= 2.3.14)
|
||||
multi_json (~> 1.0)
|
||||
rack (1.4.7)
|
||||
rack-cache (1.7.0)
|
||||
rack-cache (1.6.1)
|
||||
rack (>= 0.4)
|
||||
rack-livereload (0.3.15)
|
||||
rack
|
||||
@@ -553,7 +538,7 @@ GEM
|
||||
rainbow (2.2.2)
|
||||
rake
|
||||
raindrops (0.13.0)
|
||||
rake (10.5.0)
|
||||
rake (11.3.0)
|
||||
ransack (0.7.2)
|
||||
actionpack (~> 3.0)
|
||||
activerecord (~> 3.0)
|
||||
@@ -590,9 +575,8 @@ GEM
|
||||
rspec-expectations (2.14.0)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.14.2)
|
||||
rspec-rails (2.14.2)
|
||||
rspec-rails (2.14.0)
|
||||
actionpack (>= 3.0)
|
||||
activemodel (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 2.14.0)
|
||||
@@ -609,7 +593,7 @@ GEM
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
ruby-progressbar (1.8.1)
|
||||
rubyzip (1.2.0)
|
||||
safe_yaml (1.0.4)
|
||||
safe_yaml (0.9.5)
|
||||
sass (3.3.14)
|
||||
sass-rails (3.2.6)
|
||||
railties (~> 3.2.0)
|
||||
@@ -632,20 +616,20 @@ GEM
|
||||
therubyracer (0.12.0)
|
||||
libv8 (~> 3.16.14.0)
|
||||
ref
|
||||
thor (0.19.4)
|
||||
thor (0.19.1)
|
||||
tilt (1.4.1)
|
||||
timecop (0.8.1)
|
||||
timers (1.1.0)
|
||||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
truncate_html (0.9.2)
|
||||
truncate_html (0.5.5)
|
||||
turbo-sprockets-rails3 (0.3.6)
|
||||
railties (> 3.2.8, < 4.0.0)
|
||||
sprockets (>= 2.0.0)
|
||||
turn (0.8.3)
|
||||
ansi
|
||||
tzinfo (0.3.53)
|
||||
tzinfo (0.3.49)
|
||||
uglifier (2.7.1)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
@@ -662,11 +646,11 @@ GEM
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
warden (1.2.6)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
webmock (1.8.11)
|
||||
webmock (1.13.0)
|
||||
addressable (>= 2.2.7)
|
||||
crack (>= 0.1.7)
|
||||
crack (>= 0.3.2)
|
||||
websocket-driver (0.6.3)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
@@ -675,9 +659,11 @@ GEM
|
||||
chronic (>= 0.6.3)
|
||||
wicked_pdf (1.1.0)
|
||||
wkhtmltopdf-binary (0.12.3.1)
|
||||
xml-simple (1.1.5)
|
||||
xml-simple (1.1.4)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
zeus (0.15.4)
|
||||
method_source (>= 0.6.7)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -707,7 +693,6 @@ DEPENDENCIES
|
||||
deface!
|
||||
delayed_job_active_record
|
||||
diffy
|
||||
eventmachine (>= 1.2.3)
|
||||
factory_girl_rails
|
||||
figaro
|
||||
foreigner
|
||||
@@ -721,9 +706,9 @@ DEPENDENCIES
|
||||
guard-livereload
|
||||
guard-rails
|
||||
guard-rspec
|
||||
guard-zeus
|
||||
haml
|
||||
i18n (~> 0.6.11)
|
||||
i18n-js (~> 3.0.0)
|
||||
immigrant
|
||||
jquery-migrate-rails
|
||||
jquery-rails
|
||||
@@ -779,4 +764,4 @@ RUBY VERSION
|
||||
ruby 2.1.5p273
|
||||
|
||||
BUNDLED WITH
|
||||
1.15.4
|
||||
1.15.1
|
||||
|
||||
@@ -54,7 +54,6 @@ First, check your dependencies: Ensure that you have Ruby 2.1.5 installed:
|
||||
Install the project's gem dependencies:
|
||||
|
||||
cd openfoodnetwork
|
||||
./script/upgrade_bundler.sh
|
||||
bundle install
|
||||
|
||||
Configure the site:
|
||||
@@ -108,9 +107,6 @@ If you want karma to automatically rerun the tests on file modification, use:
|
||||
|
||||
./script/karma start
|
||||
|
||||
### Multilingual
|
||||
Do not forget to run `rake tmp:cache:clear` after locales are updated to reload I18n js translations.
|
||||
|
||||
## Credits
|
||||
|
||||
* Andrew Spinks (http://github.com/andrewspinks)
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
//= require angular-resource
|
||||
//= require angular-animate
|
||||
//= require angular-sanitize
|
||||
//= require admin/spree_backend
|
||||
//= require admin/spree_core
|
||||
//= require admin/spree_auth
|
||||
//= require admin/spree_promo
|
||||
//= require admin/spree_paypal_express
|
||||
//= require ../shared/ng-infinite-scroll.min.js
|
||||
//= require ../shared/ng-tags-input.min.js
|
||||
@@ -47,7 +48,7 @@
|
||||
//= require textAngular-rangy.min.js
|
||||
//= require textAngular-sanitize.min.js
|
||||
//= require textAngular.min.js
|
||||
//= require i18n/translations
|
||||
//= require darkswarm/i18n.js
|
||||
//= require darkswarm/i18n.translate.js
|
||||
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ angular.module("admin.businessModelConfiguration").controller "BusinessModelConf
|
||||
$scope.cappedBill()
|
||||
|
||||
$scope.capReached = ->
|
||||
return t('no') if !$scope.cap? || Number($scope.cap) == 0
|
||||
if $scope.bill() >= Number($scope.cap) then t('yes') else t('no')
|
||||
return "No" if !$scope.cap? || Number($scope.cap) == 0
|
||||
if $scope.bill() >= Number($scope.cap) then "Yes" else "No"
|
||||
|
||||
$scope.includedTax = ->
|
||||
return 0 if !$scope.taxRate? || Number($scope.taxRate) == 0
|
||||
|
||||
@@ -21,7 +21,7 @@ angular.module("admin.customers").directive 'newCustomerDialog', ($compile, $tem
|
||||
if response.data.errors
|
||||
scope.errors.push(error) for error in response.data.errors
|
||||
else
|
||||
scope.errors.push(t('js.customers.could_not_create') + " '#{scope.email}'")
|
||||
scope.errors.push("Sorry! Could not create '#{scope.email}'")
|
||||
return
|
||||
|
||||
# Compile modal template
|
||||
@@ -35,4 +35,4 @@ angular.module("admin.customers").directive 'newCustomerDialog', ($compile, $tem
|
||||
if CurrentShop.shop.id
|
||||
template.dialog('open')
|
||||
else
|
||||
alert(t('js.customers.select_shop'))
|
||||
alert('Please select a shop first')
|
||||
|
||||
@@ -2,7 +2,7 @@ angular.module('admin.enterpriseFees').directive 'spreeDeleteResource', ->
|
||||
(scope, element, attrs) ->
|
||||
if scope.enterprise_fee.id
|
||||
url = '/admin/enterprise_fees/' + scope.enterprise_fee.id
|
||||
html = '<a href="' + url + '" class="delete-resource icon_link icon-trash no-text" data-action="remove" data-confirm="' + t('are_you_sure') + '" url="' + url + '"></a>'
|
||||
html = '<a href="' + url + '" class="delete-resource icon_link icon-trash no-text" data-action="remove" data-confirm="Are you sure?" url="' + url + '"></a>'
|
||||
#var html = '<a href="'+url+'" class="delete-resource" data-confirm="Are you sure?"><img alt="Delete" src="/assets/admin/icons/delete.png" /> Delete</a>';
|
||||
element.append html
|
||||
return
|
||||
|
||||
@@ -30,27 +30,27 @@ angular.module("admin.enterprises").controller 'enterprisesCtrl', ($scope, $q, E
|
||||
$scope.producerTextFor = (enterprise) ->
|
||||
switch enterprise.is_primary_producer
|
||||
when true
|
||||
t('js.enterprises.producer')
|
||||
"Producer"
|
||||
else
|
||||
t('js.enterprises.non_producer')
|
||||
"Non-Producer"
|
||||
|
||||
$scope.packageTextFor = (enterprise) ->
|
||||
switch enterprise.is_primary_producer
|
||||
when true
|
||||
switch enterprise.sells
|
||||
when "none"
|
||||
t('js.profile')
|
||||
"Profile"
|
||||
when "own"
|
||||
t('js.shop')
|
||||
"Shop"
|
||||
when "any"
|
||||
t('js.hub')
|
||||
"Hub"
|
||||
else
|
||||
t('js.choose')
|
||||
"Choose"
|
||||
else
|
||||
switch enterprise.sells
|
||||
when "none"
|
||||
t('js.profile')
|
||||
"Profile"
|
||||
when "any"
|
||||
t('js.hub')
|
||||
"Hub"
|
||||
else
|
||||
t('js.choose')
|
||||
"Choose"
|
||||
|
||||
@@ -14,7 +14,7 @@ angular.module("admin.enterprises").controller 'indexPanelCtrl', ($scope, Enterp
|
||||
, (response) ->
|
||||
$scope.saving = false
|
||||
if response.status == 422 && response.data.errors?
|
||||
message = t('js.resolve_errors') + ':\n'
|
||||
message = 'Please resolve the following errors:\n'
|
||||
for attr, msg of response.data.errors
|
||||
message += "#{attr} #{msg}\n"
|
||||
alert(message)
|
||||
|
||||
@@ -19,16 +19,16 @@ angular.module("admin.enterprises").factory 'PermalinkChecker', ($q, $http) ->
|
||||
if data.length > @MAX_PERMALINK_LENGTH || !data.match(/^[\w-]+$/)
|
||||
deferredRequest.resolve
|
||||
permalink: permalink
|
||||
available: t('js.error')
|
||||
available: "Error"
|
||||
else
|
||||
deferredRequest.resolve
|
||||
permalink: data
|
||||
available: t('available')
|
||||
available: "Available"
|
||||
).error (data,status) =>
|
||||
if status == 409
|
||||
deferredRequest.resolve
|
||||
permalink: data
|
||||
available: t('js.unavailable')
|
||||
available: "Unavailable"
|
||||
else
|
||||
# Something went wrong or request was aborted
|
||||
deferredRequest.reject()
|
||||
|
||||
@@ -21,16 +21,16 @@ angular.module("admin.indexUtils").factory "pendingChanges", ($q, resources, Sta
|
||||
submitAll: (form=null) =>
|
||||
all = []
|
||||
@errors = []
|
||||
StatusMessage.display('progress', t('js.saving'))
|
||||
StatusMessage.display('progress', "Saving...")
|
||||
for id, objectChanges of @pendingChanges
|
||||
for attrName, change of objectChanges
|
||||
all.push @submit(change)
|
||||
$q.all(all).then =>
|
||||
if @errors.length == 0
|
||||
StatusMessage.display('success', t('js.all_changes_saved_successfully'))
|
||||
StatusMessage.display('success', "All changes saved successfully")
|
||||
form.$setPristine() if form?
|
||||
else
|
||||
StatusMessage.display('failure', t('js.oh_no'))
|
||||
StatusMessage.display('failure', "Oh no! I was unable to save your changes")
|
||||
all
|
||||
|
||||
submit: (change) ->
|
||||
|
||||
@@ -10,7 +10,7 @@ angular.module("admin.indexUtils").factory "SpreeApiAuth", ($q, $http, SpreeApiK
|
||||
deferred.resolve()
|
||||
|
||||
.error (response) ->
|
||||
error = response?.error || t('js.unauthorized')
|
||||
error = response?.error || "You are unauthorised to access this page."
|
||||
deferred.reject(error)
|
||||
|
||||
deferred.promise
|
||||
|
||||
@@ -51,13 +51,13 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
|
||||
|
||||
$scope.$watch 'bulk_order_form.$dirty', (newVal, oldVal) ->
|
||||
if newVal == true
|
||||
StatusMessage.display 'notice', t('js.unsaved_changes')
|
||||
StatusMessage.display 'notice', "You have unsaved changes"
|
||||
|
||||
$scope.submit = ->
|
||||
if $scope.bulk_order_form.$valid
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
StatusMessage.display 'progress', "Saving..."
|
||||
$q.all(LineItems.saveAll()).then(->
|
||||
StatusMessage.display 'success', t('js.all_changes_saved')
|
||||
StatusMessage.display 'success', "All changes saved"
|
||||
$scope.bulk_order_form.$setPristine()
|
||||
).catch ->
|
||||
StatusMessage.display 'failure', t "unsaved_changes_error"
|
||||
|
||||
@@ -84,7 +84,7 @@ angular.module('admin.orderCycles')
|
||||
|
||||
$scope.submit = ($event, destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
StatusMessage.display 'progress', "Saving..."
|
||||
OrderCycle.create(destination)
|
||||
|
||||
$scope.cancel = (destination) ->
|
||||
|
||||
@@ -87,11 +87,11 @@ angular.module('admin.orderCycles')
|
||||
|
||||
$scope.submit = (destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
StatusMessage.display 'progress', "Saving..."
|
||||
|
||||
$scope.submit = ($event, destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
StatusMessage.display 'progress', "Saving..."
|
||||
OrderCycle.update(destination, $scope.order_cycle_form)
|
||||
|
||||
$scope.cancel = (destination) ->
|
||||
|
||||
@@ -49,7 +49,7 @@ angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl"
|
||||
|
||||
$scope.submit = ($event, destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
StatusMessage.display 'progress', "Saving..."
|
||||
OrderCycle.mirrorIncomingToOutgoingProducts()
|
||||
OrderCycle.create(destination)
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl",
|
||||
|
||||
$scope.submit = ($event, destination) ->
|
||||
$event.preventDefault()
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
StatusMessage.display 'progress', "Saving..."
|
||||
OrderCycle.mirrorIncomingToOutgoingProducts()
|
||||
OrderCycle.update(destination, $scope.order_cycle_form)
|
||||
|
||||
|
||||
@@ -165,13 +165,13 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
|
||||
if destination?
|
||||
$window.location = destination
|
||||
else
|
||||
StatusMessage.display 'success', t('js.order_cycles.update_success')
|
||||
StatusMessage.display 'success', 'Your order cycle has been updated.'
|
||||
else
|
||||
console.log('Failed to update order cycle')
|
||||
|
||||
confirmNoDistributors: ->
|
||||
if @order_cycle.outgoing_exchanges.length == 0
|
||||
confirm t('js.order_cycles.no_distributors')
|
||||
confirm 'There are no distributors in this order cycle. This order cycle will not be visible to customers until you add one. Would you like to continue saving this order cycle?'
|
||||
else
|
||||
true
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
angular.module("ofn.admin").controller "ImportOptionsFormCtrl", ($scope, $rootScope, ProductImportService) ->
|
||||
|
||||
$scope.toggleResetAbsent = () ->
|
||||
confirmed = confirm t('js.product_import.confirmation') if $scope.resetAbsent
|
||||
confirmed = confirm 'This will set stock level to zero on all products for this \n' +
|
||||
'enterprise that are not present in the uploaded file.' if $scope.resetAbsent
|
||||
|
||||
if confirmed or !$scope.resetAbsent
|
||||
ProductImportService.updateResetAbsent($scope.supplierId, $scope.resetCount, $scope.resetAbsent)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
angular.module("admin.resources").factory 'LineItemResource', ($resource) ->
|
||||
$resource('/admin/bulk_line_items/:id.json', {}, {
|
||||
$resource('/admin/:orders/:order_number/line_items/:id.json', {}, {
|
||||
'index':
|
||||
method: 'GET'
|
||||
isArray: true
|
||||
|
||||
@@ -24,7 +24,7 @@ angular.module("admin.resources").factory "Customers", ($q, InfoDialog, RequestM
|
||||
if errors?
|
||||
InfoDialog.open 'error', errors[0]
|
||||
else
|
||||
InfoDialog.open 'error', t('js.resources.could_not_delete_customer') + ": #{customer.email}"
|
||||
InfoDialog.open 'error', "Could not delete customer: #{customer.email}"
|
||||
|
||||
index: (params) ->
|
||||
@clear()
|
||||
|
||||
@@ -26,7 +26,7 @@ angular.module("admin.resources").factory 'LineItems', ($q, LineItemResource) ->
|
||||
save: (lineItem) ->
|
||||
deferred = $q.defer()
|
||||
lineItem.errors = {}
|
||||
lineItem.$update({id: lineItem.id})
|
||||
lineItem.$update({id: lineItem.id, orders: "orders", order_number: lineItem.order.number})
|
||||
.then( (data) =>
|
||||
@pristineByID[lineItem.id] = angular.copy(lineItem)
|
||||
deferred.resolve(data)
|
||||
@@ -54,7 +54,7 @@ angular.module("admin.resources").factory 'LineItems', ($q, LineItemResource) ->
|
||||
|
||||
delete: (lineItem, callback=null) ->
|
||||
deferred = $q.defer()
|
||||
lineItem.$delete({id: lineItem.id})
|
||||
lineItem.$delete({id: lineItem.id, orders: "orders", order_number: lineItem.order.number})
|
||||
.then( (data) =>
|
||||
delete @byID[lineItem.id]
|
||||
delete @pristineByID[lineItem.id]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
angular.module("ofn.admin").factory "BulkProducts", (PagedFetcher, dataFetcher, $http) ->
|
||||
angular.module("ofn.admin").factory "BulkProducts", (PagedFetcher, dataFetcher) ->
|
||||
new class BulkProducts
|
||||
products: []
|
||||
|
||||
@@ -11,8 +11,14 @@ angular.module("ofn.admin").factory "BulkProducts", (PagedFetcher, dataFetcher,
|
||||
PagedFetcher.fetch url, (data) => @addProducts data.products
|
||||
|
||||
cloneProduct: (product) ->
|
||||
$http.post("/api/products/" + product.id + "/clone").success (data) =>
|
||||
dataFetcher("/api/products/" + data.id + "?template=bulk_show").then (newProduct) =>
|
||||
dataFetcher("/admin/products/" + product.permalink_live + "/clone.json").then (data) =>
|
||||
# Ideally we would use Spree's built in respond_override helper here to redirect the
|
||||
# user after a successful clone with .json in the accept headers
|
||||
# However, at the time of writing there appears to be an issue which causes the
|
||||
# respond_with block in the destroy action of Spree::Admin::Product to break
|
||||
# when a respond_overrride for the clone action is used.
|
||||
id = data.product.id
|
||||
dataFetcher("/api/products/" + id + "?template=bulk_show").then (newProduct) =>
|
||||
@unpackProduct newProduct
|
||||
@insertProductAfter(product, newProduct)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
angular.module("ofn.admin").factory "ofnConfirmHandler", (pendingChanges, $compile, $q) ->
|
||||
return (scope, callback) ->
|
||||
template = "<div id='dialog-div' style='padding: 10px'><h6>" + t('js.services.unsaved_changes_message') + "</h6></div>"
|
||||
template = "<div id='dialog-div' style='padding: 10px'><h6>Unsaved changes currently exist, save now or ignore?</h6></div>"
|
||||
dialogDiv = $compile(template)(scope)
|
||||
return ->
|
||||
if pendingChanges.changeCount(pendingChanges.pendingChanges) > 0
|
||||
|
||||
@@ -26,7 +26,7 @@ angular.module("ofn.admin").factory 'EnterpriseRelationships', ($http, enterpris
|
||||
|
||||
permission_presentation: (permission) ->
|
||||
switch permission
|
||||
when "add_to_order_cycle" then t('js.services.add_to_order_cycle')
|
||||
when "manage_products" then t('js.services.manage_products')
|
||||
when "edit_profile" then t('js.services.edit_profile')
|
||||
when "create_variant_overrides" then t('js.services.add_products_to_inventory')
|
||||
when "add_to_order_cycle" then "add to order cycle"
|
||||
when "manage_products" then "manage products"
|
||||
when "edit_profile" then "edit profile"
|
||||
when "create_variant_overrides" then "add products to inventory"
|
||||
|
||||
@@ -2,7 +2,7 @@ angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, $fil
|
||||
$scope.tagGroups = enterprise.tag_groups
|
||||
$scope.defaultTagGroup = enterprise.default_tag_group
|
||||
|
||||
$scope.visibilityOptions = [ { id: "visible", name: t('js.tag_rules.visible') }, { id: "hidden", name: t('js.tag_rules.not_visible') } ]
|
||||
$scope.visibilityOptions = [ { id: "visible", name: "VISIBLE" }, { id: "hidden", name: "NOT VISIBLE" } ]
|
||||
|
||||
$scope.updateRuleCounts = ->
|
||||
index = $scope.defaultTagGroup.rules.length
|
||||
@@ -57,4 +57,4 @@ angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, $fil
|
||||
.success ->
|
||||
tagGroup.rules.splice(index, 1)
|
||||
$scope.updateRuleCounts()
|
||||
$scope.enterprise_form.$setDirty()
|
||||
$scope.enterprise_form.$setDirty()
|
||||
@@ -9,10 +9,10 @@ angular.module("admin.tagRules").directive 'newTagRuleDialog', ($compile, $templ
|
||||
|
||||
scope.ruleTypes = [
|
||||
# { id: "DiscountOrder", name: 'Apply a discount to orders' }
|
||||
{ id: "FilterProducts", name: t('js.tag_rules.show_hide_variants') }
|
||||
{ id: "FilterShippingMethods", name: t('js.tag_rules.show_hide_shipping') }
|
||||
{ id: "FilterPaymentMethods", name: t('js.tag_rules.show_hide_payment') }
|
||||
{ id: "FilterOrderCycles", name: t('js.tag_rules.show_hide_order_cycles') }
|
||||
{ id: "FilterProducts", name: 'Show or Hide variants in my shopfront' }
|
||||
{ id: "FilterShippingMethods", name: 'Show or Hide shipping methods at checkout' }
|
||||
{ id: "FilterPaymentMethods", name: 'Show or Hide payment methods at checkout' }
|
||||
{ id: "FilterOrderCycles", name: 'Show or Hide order cycles in my shopfront' }
|
||||
]
|
||||
|
||||
scope.ruleType = scope.ruleTypes[0].id
|
||||
|
||||
@@ -15,11 +15,11 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
|
||||
$scope.currentView = -> Views.currentView
|
||||
|
||||
$scope.views = Views.setViews
|
||||
inventory: { name: t('js.variant_overrides.inventory_products'), visible: true }
|
||||
hidden: { name: t('js.variant_overrides.hidden_products'), visible: false }
|
||||
new: { name: t('js.variant_overrides.new_products'), visible: false }
|
||||
inventory: { name: "Inventory Products", visible: true }
|
||||
hidden: { name: "Hidden Products", visible: false }
|
||||
new: { name: "New Products", visible: false }
|
||||
|
||||
$scope.bulkActions = [ name: t('js.variant_overrides.reset_stock_levels'), callback: 'resetStock' ]
|
||||
$scope.bulkActions = [ name: "Reset Stock Levels To Defaults", callback: 'resetStock' ]
|
||||
|
||||
$scope.columns = Columns.columns
|
||||
|
||||
@@ -52,22 +52,22 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
|
||||
|
||||
$scope.displayDirty = ->
|
||||
if DirtyVariantOverrides.count() > 0
|
||||
num = if DirtyVariantOverrides.count() == 1 then t('js.variant_overrides.one_override') else "#{DirtyVariantOverrides.count()} " + t('js.variant_overrides.overrides')
|
||||
StatusMessage.display 'notice', t('js.variant_overrides.changes_to') + ' ' + num + ' ' + t('js.variant_overrides.remain_unsaved')
|
||||
num = if DirtyVariantOverrides.count() == 1 then "one override" else "#{DirtyVariantOverrides.count()} overrides"
|
||||
StatusMessage.display 'notice', "Changes to #{num} remain unsaved."
|
||||
else
|
||||
StatusMessage.clear()
|
||||
|
||||
$scope.update = ->
|
||||
if DirtyVariantOverrides.count() == 0
|
||||
StatusMessage.display 'alert', t('js.variant_overrides.no_changes_to_save')
|
||||
StatusMessage.display 'alert', 'No changes to save.'
|
||||
else
|
||||
StatusMessage.display 'progress', t('js.saving')
|
||||
StatusMessage.display 'progress', 'Saving...'
|
||||
DirtyVariantOverrides.save()
|
||||
.success (updatedVos) ->
|
||||
DirtyVariantOverrides.clear()
|
||||
VariantOverrides.updateIds updatedVos
|
||||
$scope.variant_overrides_form.$setPristine()
|
||||
StatusMessage.display 'success', t('js.changes_saved')
|
||||
StatusMessage.display 'success', 'Changes saved.'
|
||||
VariantOverrides.updateData updatedVos # Refresh page data
|
||||
.error (data, status) ->
|
||||
StatusMessage.display 'failure', $scope.updateError(data, status)
|
||||
@@ -75,32 +75,32 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
|
||||
|
||||
$scope.updateError = (data, status) ->
|
||||
if status == 401
|
||||
t('js.variant_overrides.no_authorisation')
|
||||
"I couldn't get authorisation to save those changes, so they remain unsaved."
|
||||
|
||||
else if status == 400 && data.errors?
|
||||
errors = []
|
||||
for field, field_errors of data.errors
|
||||
errors = errors.concat field_errors
|
||||
errors = errors.join ', '
|
||||
t('js.variant_overrides.some_trouble', {errors: errors})
|
||||
"I had some trouble saving: #{errors}"
|
||||
else
|
||||
t('js.oh_no')
|
||||
"Oh no! I was unable to save your changes."
|
||||
|
||||
$scope.resetStock = ->
|
||||
if DirtyVariantOverrides.count() > 0
|
||||
StatusMessage.display 'alert', t('js.save_changes_first')
|
||||
StatusMessage.display 'alert', 'Save changes first.'
|
||||
$timeout ->
|
||||
$scope.displayDirty()
|
||||
, 3000 # 3 second delay
|
||||
else
|
||||
return unless $scope.hub_id?
|
||||
StatusMessage.display 'progress', t('js.variant_overrides.changing_on_hand_stock')
|
||||
StatusMessage.display 'progress', 'Changing on hand stock levels...'
|
||||
$http
|
||||
method: "POST"
|
||||
url: "/admin/variant_overrides/bulk_reset"
|
||||
data: { hub_id: $scope.hub_id }
|
||||
.success (updatedVos) ->
|
||||
VariantOverrides.updateData updatedVos
|
||||
StatusMessage.display 'success', t('js.variant_overrides.stock_reset')
|
||||
StatusMessage.display 'success', 'Stocks reset to defaults.'
|
||||
.error (data, status) ->
|
||||
$timeout -> StatusMessage.display 'failure', $scope.updateError(data, status)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#= require ../shared/angular-local-storage.js
|
||||
#= require ../shared/angular-slideables.js
|
||||
#= require angularjs-file-upload
|
||||
#= require i18n/translations
|
||||
|
||||
|
||||
#= require angular-rails-templates
|
||||
#= require_tree ../templates
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
Darkswarm.controller "SignupCtrl", ($scope, $http, $window, $location, Redirections, AuthenticationService) ->
|
||||
$scope.path = "/signup"
|
||||
|
||||
$scope.spree_user.password_confirmation = ''
|
||||
|
||||
$scope.errors =
|
||||
email: null
|
||||
password: null
|
||||
|
||||
@@ -3,23 +3,23 @@ Darkswarm.controller "AccordionCtrl", ($scope, localStorageService, $timeout, $d
|
||||
value = if localStorageService.get(key) then {} else { details: true, billing: false, shipping: false, payment: false }
|
||||
localStorageService.bind $scope, "accordion", value, key
|
||||
$scope.accordionSections = ["details", "billing", "shipping", "payment"]
|
||||
# Scrolling is confused by our position:fixed top bar - add an offset to scroll
|
||||
# to the correct location, plus 5px buffer
|
||||
offset_height = $("nav.top-bar").height() + 5
|
||||
|
||||
$scope.show = (section)->
|
||||
$scope.accordion[section] = true
|
||||
# If we call scrollTo() directly after show(), when one of the accordions above the
|
||||
# scroll location is closed by show(), scrollTo() will scroll to the old location of
|
||||
# the element. Putting this in a 50 ms timeout is enough delay for the DOM to
|
||||
# have updated.
|
||||
$timeout ->
|
||||
$document.scrollTo($("##{section}"), offset_height, 500)
|
||||
, 50
|
||||
|
||||
$scope.$on 'purchaseFormInvalid', (event, form) ->
|
||||
# Scroll to first invalid section
|
||||
for section in $scope.accordionSections
|
||||
if not form[section].$valid
|
||||
$scope.show section
|
||||
|
||||
# If we call scrollTo() directly after show(), when one of the accordions above the
|
||||
# scroll location is closed by show(), scrollTo() will scroll to the old location of
|
||||
# the element. Putting this in a zero-length timeout is enough delay for the DOM to
|
||||
# have updated.
|
||||
$timeout ->
|
||||
# Scrolling is confused by our position:fixed top bar - add an offset to scroll
|
||||
# to the correct location, plus 5px buffer
|
||||
offset_height = $("nav.top-bar").height() + 5
|
||||
$document.scrollTo $("##{section}"), offset_height, 500
|
||||
break
|
||||
|
||||
@@ -6,9 +6,10 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, $location
|
||||
$scope.openModal = EnterpriseModal.open
|
||||
$scope.activeTaxons = []
|
||||
$scope.show_profiles = false
|
||||
$scope.show_closed = false
|
||||
$scope.filtersActive = false
|
||||
$scope.distanceMatchesShown = false
|
||||
$scope.filterExpression = {active: true}
|
||||
|
||||
|
||||
$scope.$watch "query", (query)->
|
||||
Enterprises.flagMatching query
|
||||
@@ -35,7 +36,7 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, $location
|
||||
# When filter settings change, this could change which name match is at the top, or even
|
||||
# result in no matches. This affects the reference point that the distance matches are
|
||||
# calculated from, so we need to recalculate distances.
|
||||
$scope.$watch '[activeTaxons, activeProperties, shippingTypes, show_profiles, show_closed]', ->
|
||||
$scope.$watch '[activeTaxons, activeProperties, shippingTypes, show_profiles]', ->
|
||||
$timeout ->
|
||||
Enterprises.calculateDistance $scope.query, $scope.firstNameMatch()
|
||||
$rootScope.$broadcast 'enterprisesChanged'
|
||||
@@ -73,9 +74,9 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, $location
|
||||
undefined
|
||||
|
||||
$scope.showClosedShops = ->
|
||||
$scope.show_closed = true
|
||||
delete $scope.filterExpression['active']
|
||||
$location.search('show_closed', '1')
|
||||
|
||||
$scope.hideClosedShops = ->
|
||||
$scope.show_closed = false
|
||||
$scope.filterExpression['active'] = true
|
||||
$location.search('show_closed', null)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
Darkswarm.filter 'closedShops', ->
|
||||
(enterprises, show_closed) ->
|
||||
enterprises ||= []
|
||||
show_closed ?= false
|
||||
|
||||
enterprises.filter (enterprise) =>
|
||||
show_closed or enterprise.active or !enterprise.is_distributor
|
||||
9
app/assets/javascripts/darkswarm/i18n.js.erb
Normal file
9
app/assets/javascripts/darkswarm/i18n.js.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<%# Defines a global I18n object containing the language of the current locale %>
|
||||
<%
|
||||
# Invalidate this asset if locale changes.
|
||||
Dir[Rails.root.join('config', 'locales', "#{I18n.default_locale}.yml").to_s].each do |f|
|
||||
depend_on(f)
|
||||
end
|
||||
%>
|
||||
<%- I18n.backend.send(:init_translations) unless I18n.backend.initialized? %>
|
||||
window.I18n = <%= I18n.backend.send(:translations)[I18n.default_locale].with_indifferent_access.to_json.html_safe %>
|
||||
@@ -1,11 +1,17 @@
|
||||
# Old aliases before i18n-js was introduced.
|
||||
# TODO - delete it after everything is moved to i18n-js
|
||||
|
||||
# Declares the translation function t.
|
||||
# You can use translate('login') or t('login') in Javascript.
|
||||
window.translate = (key, options = {}) ->
|
||||
unless 'I18n' of window
|
||||
console.log 'The I18n object is undefined. Cannot translate text.'
|
||||
return key
|
||||
I18n.t(key, options)
|
||||
dict = I18n
|
||||
parts = key.split '.'
|
||||
while (parts.length)
|
||||
part = parts.shift()
|
||||
return key unless part of dict
|
||||
dict = dict[part]
|
||||
text = dict
|
||||
for name, value of options
|
||||
text = text.split("%{#{name}}").join(value)
|
||||
text
|
||||
window.t = window.translate
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
window.FieldsetMixin = ($scope)->
|
||||
$scope.next = (event = false)->
|
||||
event.preventDefault() if event
|
||||
return unless $scope.nextPanel
|
||||
$scope.show $scope.nextPanel
|
||||
|
||||
$scope.onTimeout = ->
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
Darkswarm.factory 'RailsFlashLoader', (flash, railsFlash)->
|
||||
new class RailsFlashLoader
|
||||
# The 'flash' service requires type key to
|
||||
# be one of: success, info, warn, error
|
||||
typePairings:
|
||||
success: 'success'
|
||||
error: 'error'
|
||||
notice: 'success'
|
||||
info: 'info'
|
||||
warn: 'warn'
|
||||
|
||||
initFlash: ->
|
||||
@loadFlash railsFlash
|
||||
|
||||
loadFlash: (rails_flash)->
|
||||
for type, message of rails_flash
|
||||
type = @typePairings[type]
|
||||
flash[type] = message
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
//
|
||||
|
||||
//= require 'jquery'
|
||||
//= require store/spree_frontend
|
||||
//= require store/spree_core
|
||||
//= require store/spree_auth
|
||||
//= require store/spree_promo
|
||||
|
||||
//= require_tree .
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
{{ message }}
|
||||
.action-buttons.text-center
|
||||
%button{ ng: { click: "close()" } }
|
||||
= t(:ok)
|
||||
OK
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
'ng-model' => 'exchange.select_all_variants',
|
||||
'ng-change' => 'setExchangeVariants(exchange, incomingExchangeVariantsFor(exchange.enterprise_id), exchange.select_all_variants)',
|
||||
'id' => 'order_cycle_outgoing_exchange_{{ $parent.$index }}_select_all_variants' }
|
||||
= t('admin.select_all')
|
||||
Select all
|
||||
|
||||
.exchange-products
|
||||
-# Scope product list based on permissions the current user has to view variants in this exchange
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
'ng-model' => 'exchange.select_all_variants',
|
||||
'ng-change' => 'setExchangeVariants(exchange, suppliedVariants(exchange.enterprise_id), exchange.select_all_variants)',
|
||||
'id' => 'order_cycle_incoming_exchange_{{ $index }}_select_all_variants' }
|
||||
= t('admin.select_all')
|
||||
Select all
|
||||
|
||||
.exchange-products
|
||||
-# No need to scope product list based on permissions, because if an incoming exchange is visible,
|
||||
@@ -36,7 +36,7 @@
|
||||
'ofn-sync-distributions' => '{{ product.master_id }}',
|
||||
'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
'ng-disabled' => '!order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(product.master_id) < 0' }
|
||||
= t('admin.obsolete_master')
|
||||
Obsolete master
|
||||
|
||||
.exchange-product-variant{'ng-repeat' => 'variant in product.variants'}
|
||||
%label
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
.row.exchange-tags
|
||||
.sixteen.columns.alpha.omega
|
||||
%span.text-normal
|
||||
= t('admin.tags')
|
||||
%span.text-normal Tags
|
||||
%br
|
||||
%tags-with-translation.fullwidth{ object: 'object' }
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
id: "enterprise_tag_rules_attributes_{{tagGroup.startIndex + $index}}_preferred_matched_order_cycles_visibility",
|
||||
name: "enterprise[tag_rules_attributes][{{tagGroup.startIndex + $index}}][preferred_matched_order_cycles_visibility]",
|
||||
ng: { value: "'hidden'", if: "rule.is_default" } }
|
||||
%span.text-normal{ ng: { if: "rule.is_default" } }
|
||||
=t(:not_visible)
|
||||
%span.text-normal{ ng: { if: "rule.is_default" } } not visible
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
id: "enterprise_tag_rules_attributes_{{tagGroup.startIndex + $index}}_preferred_matched_payment_methods_visibility",
|
||||
name: "enterprise[tag_rules_attributes][{{tagGroup.startIndex + $index}}][preferred_matched_payment_methods_visibility]",
|
||||
ng: { value: "'hidden'", if: "rule.is_default" } }
|
||||
%span.text-normal{ ng: { if: "rule.is_default" } }
|
||||
= t(:not_visible)
|
||||
%span.text-normal{ ng: { if: "rule.is_default" } } not visible
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
id: "enterprise_tag_rules_attributes_{{tagGroup.startIndex + $index}}_preferred_matched_variants_visibility",
|
||||
name: "enterprise[tag_rules_attributes][{{tagGroup.startIndex + $index}}][preferred_matched_variants_visibility]",
|
||||
ng: { value: "'hidden'", if: "rule.is_default" } }
|
||||
%span.text-normal{ ng: { if: "rule.is_default" } }
|
||||
= t(:not_visible)
|
||||
%span.text-normal{ ng: { if: "rule.is_default" } } not visible
|
||||
|
||||
@@ -7,6 +7,4 @@
|
||||
id: "enterprise_tag_rules_attributes_{{tagGroup.startIndex + $index}}_preferred_matched_shipping_methods_visibility",
|
||||
name: "enterprise[tag_rules_attributes][{{tagGroup.startIndex + $index}}][preferred_matched_shipping_methods_visibility]",
|
||||
ng: { value: "'hidden'", if: "rule.is_default" } }
|
||||
%span.text-normal{ ng: { if: "rule.is_default" } }
|
||||
= t(:not_visible)
|
||||
|
||||
%span.text-normal{ ng: { if: "rule.is_default" } } not visible
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
%span.filter-shopfront.property-selectors.pad-top
|
||||
%ul.inline-block
|
||||
%li{"ng-repeat" => "property in enterprise.supplied_properties"}
|
||||
%a.button.tiny.disabled{"ng-bind" => "property.presentation"}
|
||||
%a.button.tiny{"ng-bind" => "property.presentation"}
|
||||
|
||||
.about-container.pad-top
|
||||
%img.enterprise-logo{"ng-src" => "{{::enterprise.logo}}", "ng-if" => "::enterprise.logo"}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
%li.more
|
||||
%a.dropdown{ data: { dropdown: "{{ 'show-more-' + selectorName }}" }, ng: { class: "{active: selectedOverFlowSelectors().length > 0}" } }
|
||||
%span
|
||||
= t('js.more_items', count: "{{ overFlowSelectors().length }}")
|
||||
+ {{ overFlowSelectors().length }} more
|
||||
%i.ofn-i_052-point-down
|
||||
.f-dropdown.text-right.content{ ng: { attr: { id: "{{ 'show-more-' + selectorName }}" } } }
|
||||
%ul
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
||||
*
|
||||
|
||||
*= require admin/spree_backend
|
||||
*= require admin/spree_core
|
||||
*= require admin/spree_auth
|
||||
*= require admin/spree_promo
|
||||
|
||||
*= require shared/jquery-ui-timepicker-addon
|
||||
*= require shared/textAngular
|
||||
|
||||
@@ -28,8 +28,8 @@ text-angular .ta-editor {
|
||||
left: 275px;
|
||||
}
|
||||
|
||||
span.error, div.error:not(.flash) {
|
||||
color: #DA5354;
|
||||
span.error, div.error {
|
||||
color: #DA5354;
|
||||
}
|
||||
|
||||
/* Fix conflict between Spree and elRTE's styles */
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
body.embedded {
|
||||
nav.top-bar {
|
||||
ul.left, ul.center, ul.right li.current_hub {
|
||||
display: none;
|
||||
}
|
||||
|
||||
ul.right {
|
||||
width: auto !important;
|
||||
li {
|
||||
float: left;
|
||||
line-height: 4.6875rem;
|
||||
height: 4.6875rem;
|
||||
vertical-align: top;
|
||||
}
|
||||
li.powered-by {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
&.show-for-large-up {
|
||||
display: inherit !important;
|
||||
}
|
||||
&.show-for-medium-down {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
nav.top-bar ul.right li.powered-by {
|
||||
display: none;
|
||||
margin-right: 0.4rem;
|
||||
opacity: 0.6;
|
||||
|
||||
img {
|
||||
height: 1.8em;
|
||||
margin: 0px 0.4em 0.4em 0px;
|
||||
}
|
||||
span, a {
|
||||
font-family: "Oswald", sans-serif;
|
||||
font-size: 1rem;
|
||||
font-weight: 300;
|
||||
color: #555;
|
||||
padding: 0 !important;
|
||||
}
|
||||
a:hover {
|
||||
color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
.blocked-cookies {
|
||||
text-align: center;
|
||||
margin-bottom: 0 !important;
|
||||
|
||||
&.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
a.button.allow {
|
||||
background-color: rgba(0,0,0,0.25);
|
||||
margin-bottom: 0.4em;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(0,0,0,0.35);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,10 +15,6 @@
|
||||
@mixin panepadding {
|
||||
padding-top: 100px;
|
||||
padding-bottom: 100px;
|
||||
|
||||
@media all and (max-width: 640px) {
|
||||
padding-top: 25px;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin paneWhiteText {
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
||||
*
|
||||
|
||||
*= require store/spree_frontend
|
||||
*= require store/spree_core
|
||||
*= require store/spree_auth
|
||||
*= require store/spree_promo
|
||||
|
||||
*= require_self
|
||||
*= require_tree .
|
||||
|
||||
@@ -15,11 +15,11 @@ class Admin::AccountsAndBillingSettingsController < Spree::Admin::BaseController
|
||||
|
||||
def start_job
|
||||
if @update_account_invoices_job || @finalize_account_invoices_job
|
||||
flash[:error] = I18n.t(:accounts_and_billing_task_already_running_error)
|
||||
flash[:error] = "A task is already running, please wait until it has finished"
|
||||
else
|
||||
new_job = "#{params[:job][:name]}".camelize.constantize.new
|
||||
Delayed::Job.enqueue new_job
|
||||
flash[:success] = I18n.t(:accounts_and_billing_start_task_notice)
|
||||
flash[:success] = "Task Queued"
|
||||
end
|
||||
|
||||
redirect_to_edit
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
module Admin
|
||||
class BulkLineItemsController < Spree::Admin::BaseController
|
||||
# GET /admin/bulk_line_items.json
|
||||
#
|
||||
def index
|
||||
order_params = params[:q].andand.delete :order
|
||||
orders = OpenFoodNetwork::Permissions.new(spree_current_user).editable_orders.ransack(order_params).result
|
||||
line_items = OpenFoodNetwork::Permissions.new(spree_current_user).editable_line_items.where(order_id: orders).ransack(params[:q])
|
||||
render_as_json line_items.result.reorder('order_id ASC, id ASC')
|
||||
end
|
||||
|
||||
# PUT /admin/bulk_line_items/:id.json
|
||||
#
|
||||
def update
|
||||
load_line_item
|
||||
authorize_update!
|
||||
|
||||
# `with_lock` acquires an exclusive row lock on order so no other
|
||||
# requests can update it until the transaction is commited.
|
||||
# See https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/locking/pessimistic.rb#L69
|
||||
# and https://www.postgresql.org/docs/current/static/sql-select.html#SQL-FOR-UPDATE-SHARE
|
||||
order.with_lock do
|
||||
if @line_item.update_attributes(params[:line_item])
|
||||
order.update_distribution_charge!
|
||||
render nothing: true, status: 204 # No Content, does not trigger ng resource auto-update
|
||||
else
|
||||
render json: { errors: @line_item.errors }, status: 412
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /admin/bulk_line_items/:id.json
|
||||
#
|
||||
def destroy
|
||||
load_line_item
|
||||
authorize! :update, order
|
||||
|
||||
@line_item.destroy
|
||||
render nothing: true, status: 204 # No Content, does not trigger ng resource auto-update
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_line_item
|
||||
@line_item = Spree::LineItem.find(params[:id])
|
||||
end
|
||||
|
||||
def model_class
|
||||
Spree::LineItem
|
||||
end
|
||||
|
||||
# Returns the appropriate serializer for this controller
|
||||
#
|
||||
# @return [Api::Admin::LineItemSerializer]
|
||||
def serializer(_ams_prefix)
|
||||
Api::Admin::LineItemSerializer
|
||||
end
|
||||
|
||||
def authorize_update!
|
||||
authorize! :update, order
|
||||
authorize! :read, order
|
||||
end
|
||||
|
||||
def order
|
||||
@line_item.order
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,12 +1,12 @@
|
||||
module Admin
|
||||
class ContentsController < Spree::Admin::BaseController
|
||||
def edit
|
||||
@preference_sections = [{name: I18n.t('admin.contents.edit.header'), preferences: [:logo, :logo_mobile, :logo_mobile_svg]},
|
||||
{name: I18n.t('admin.contents.edit.home_page'), preferences: [:home_hero, :home_show_stats]},
|
||||
{name: I18n.t('admin.contents.edit.producer_signup_page'), preferences: [:producer_signup_pricing_table_html, :producer_signup_case_studies_html, :producer_signup_detail_html]},
|
||||
{name: I18n.t('admin.contents.edit.hub_signup_page'), preferences: [:hub_signup_pricing_table_html, :hub_signup_case_studies_html, :hub_signup_detail_html]},
|
||||
{name: I18n.t('admin.contents.edit.group_signup_page'), preferences: [:group_signup_pricing_table_html, :group_signup_case_studies_html, :group_signup_detail_html]},
|
||||
{name: I18n.t('admin.contents.edit.footer_and_external_links'), preferences: [:footer_logo,
|
||||
@preference_sections = [{name: 'Header', preferences: [:logo, :logo_mobile, :logo_mobile_svg]},
|
||||
{name: 'Home page', preferences: [:home_hero, :home_show_stats]},
|
||||
{name: 'Producer signup page', preferences: [:producer_signup_pricing_table_html, :producer_signup_case_studies_html, :producer_signup_detail_html]},
|
||||
{name: 'Hub signup page', preferences: [:hub_signup_pricing_table_html, :hub_signup_case_studies_html, :hub_signup_detail_html]},
|
||||
{name: 'Group signup page', preferences: [:group_signup_pricing_table_html, :group_signup_case_studies_html, :group_signup_detail_html]},
|
||||
{name: 'Footer and External Links', preferences: [:footer_logo,
|
||||
:footer_facebook_url, :footer_twitter_url, :footer_instagram_url, :footer_linkedin_url, :footer_googleplus_url, :footer_pinterest_url,
|
||||
:footer_email, :community_forum_url, :footer_links_md, :footer_about_url, :footer_tos_url]}]
|
||||
end
|
||||
@@ -21,7 +21,7 @@ module Admin
|
||||
# Save any uploaded images
|
||||
ContentConfig.save
|
||||
|
||||
flash[:success] = t(:successfully_updated, :resource => I18n.t('admin.contents.edit.your_content'))
|
||||
flash[:success] = t(:successfully_updated, :resource => "Your content")
|
||||
|
||||
redirect_to main_app.edit_admin_content_path
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ module Admin
|
||||
if params.key? :enterprise_id
|
||||
redirect_path = main_app.admin_enterprise_fees_path(enterprise_id: params[:enterprise_id])
|
||||
end
|
||||
redirect_to redirect_path, :notice => I18n.t(:enterprise_fees_update_notice)
|
||||
redirect_to redirect_path, :notice => 'Your enterprise fees have been updated.'
|
||||
|
||||
else
|
||||
render :index
|
||||
@@ -49,7 +49,7 @@ module Admin
|
||||
product_distribution = ProductDistribution.where(:enterprise_fee_id => @object).first
|
||||
if product_distribution
|
||||
p = product_distribution.product
|
||||
error = I18n.t(:enterprise_fees_destroy_error, id: p.id, name: p.name)
|
||||
error = "That enterprise fee cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}."
|
||||
|
||||
respond_with(@object) do |format|
|
||||
format.html do
|
||||
|
||||
@@ -57,7 +57,7 @@ module Admin
|
||||
|
||||
def register
|
||||
if params[:sells] == 'unspecified'
|
||||
flash[:error] = I18n.t(:enterprise_register_package_error)
|
||||
flash[:error] = "Please select a package"
|
||||
return render :welcome, layout: "spree/layouts/bare_admin"
|
||||
end
|
||||
|
||||
@@ -68,10 +68,10 @@ module Admin
|
||||
end
|
||||
|
||||
if @enterprise.update_attributes(attributes)
|
||||
flash[:success] = I18n.t(:enterprise_register_success_notice, enterprise: @enterprise.name)
|
||||
flash[:success] = "Congratulations! Registration for #{@enterprise.name} is complete!"
|
||||
redirect_to admin_path
|
||||
else
|
||||
flash[:error] = I18n.t(:enterprise_register_error, enterprise: @enterprise.name)
|
||||
flash[:error] = "Could not complete registration for #{@enterprise.name}"
|
||||
render :welcome, layout: "spree/layouts/bare_admin"
|
||||
end
|
||||
end
|
||||
@@ -80,19 +80,19 @@ module Admin
|
||||
@enterprise_set = EnterpriseSet.new(collection, params[:enterprise_set])
|
||||
touched_enterprises = @enterprise_set.collection.select(&:changed?)
|
||||
if @enterprise_set.save
|
||||
flash[:success] = I18n.t(:enterprise_bulk_update_success_notice)
|
||||
flash[:success] = "Enterprises updated successfully"
|
||||
|
||||
# 18-3-2015: It seems that the form for this action sometimes loads bogus values for
|
||||
# the 'sells' field, and submitting that form results in a bunch of enterprises with
|
||||
# values that have mysteriously changed. This statement is here to help debug that
|
||||
# issue, and should be removed (along with its display in index.html.haml) when the
|
||||
# issue has been resolved.
|
||||
flash[:action] = "#{I18n.t(:updated)} #{pluralize(touched_enterprises.count, 'enterprise')}: #{touched_enterprises.map(&:name).join(', ')}"
|
||||
flash[:action] = "Updated #{pluralize(touched_enterprises.count, 'enterprise')}: #{touched_enterprises.map(&:name).join(', ')}"
|
||||
|
||||
redirect_to main_app.admin_enterprises_path
|
||||
else
|
||||
@enterprise_set.collection.select! { |e| touched_enterprises.include? e }
|
||||
flash[:error] = I18n.t(:enterprise_bulk_update_error)
|
||||
flash[:error] = 'Update failed'
|
||||
render :index
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,7 +45,7 @@ module Admin
|
||||
if @order_cycle.save
|
||||
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle, spree_current_user).go!
|
||||
|
||||
flash[:notice] = I18n.t(:order_cycles_create_notice)
|
||||
flash[:notice] = 'Your order cycle has been created.'
|
||||
format.html { redirect_to admin_order_cycles_path }
|
||||
format.json { render :json => {:success => true} }
|
||||
else
|
||||
@@ -64,7 +64,7 @@ module Admin
|
||||
# Only update apply exchange information if it is actually submmitted
|
||||
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle, spree_current_user).go!
|
||||
end
|
||||
flash[:notice] = I18n.t(:order_cycles_update_notice) if params[:reloading] == '1'
|
||||
flash[:notice] = 'Your order cycle has been updated.' if params[:reloading] == '1'
|
||||
format.html { redirect_to main_app.edit_admin_order_cycle_path(@order_cycle) }
|
||||
format.json { render :json => {:success => true} }
|
||||
else
|
||||
@@ -76,7 +76,7 @@ module Admin
|
||||
def bulk_update
|
||||
@order_cycle_set = params[:order_cycle_set] && OrderCycleSet.new(params[:order_cycle_set])
|
||||
if @order_cycle_set.andand.save
|
||||
redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_bulk_update_notice)
|
||||
redirect_to main_app.admin_order_cycles_path, :notice => 'Order cycles have been updated.'
|
||||
else
|
||||
render :index
|
||||
end
|
||||
@@ -85,14 +85,14 @@ module Admin
|
||||
def clone
|
||||
@order_cycle = OrderCycle.find params[:id]
|
||||
@order_cycle.clone!
|
||||
redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_clone_notice, name: @order_cycle.name)
|
||||
redirect_to main_app.admin_order_cycles_path, :notice => "Your order cycle #{@order_cycle.name} has been cloned."
|
||||
end
|
||||
|
||||
# Send notifications to all producers who are part of the order cycle
|
||||
def notify_producers
|
||||
Delayed::Job.enqueue OrderCycleNotificationJob.new(params[:id].to_i)
|
||||
|
||||
redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_email_to_producers_notice)
|
||||
redirect_to main_app.admin_order_cycles_path, :notice => 'Emails to be sent to producers have been queued for sending.'
|
||||
end
|
||||
|
||||
|
||||
@@ -100,10 +100,10 @@ module Admin
|
||||
def collection
|
||||
ocs = if params[:as] == "distributor"
|
||||
OrderCycle.ransack(params[:q]).result.
|
||||
involving_managed_distributors_of(spree_current_user).order('updated_at DESC')
|
||||
involving_managed_distributors_of(spree_current_user).order('updated_at DESC')
|
||||
elsif params[:as] == "producer"
|
||||
OrderCycle.ransack(params[:q]).result.
|
||||
involving_managed_producers_of(spree_current_user).order('updated_at DESC')
|
||||
involving_managed_producers_of(spree_current_user).order('updated_at DESC')
|
||||
else
|
||||
OrderCycle.ransack(params[:q]).result.accessible_by(spree_current_user)
|
||||
end
|
||||
@@ -138,12 +138,12 @@ module Admin
|
||||
available_coordinators = permitted_coordinating_enterprises_for(@order_cycle).select(&:confirmed?)
|
||||
case available_coordinators.count
|
||||
when 0
|
||||
flash[:error] = I18n.t(:order_cycles_no_permission_to_coordinate_error)
|
||||
flash[:error] = "None of your enterprises have permission to coordinate an order cycle"
|
||||
redirect_to main_app.admin_order_cycles_path
|
||||
when 1
|
||||
@order_cycle.coordinator = available_coordinators.first
|
||||
else
|
||||
flash[:error] = I18n.t(:order_cycles_no_permission_to_create_error) if params[:coordinator_id]
|
||||
flash[:error] = "You don't have permission to create an order cycle coordinated by that enterprise" if params[:coordinator_id]
|
||||
render :set_coordinator
|
||||
end
|
||||
end
|
||||
@@ -153,7 +153,7 @@ module Admin
|
||||
yield
|
||||
rescue ActiveRecord::InvalidForeignKey
|
||||
redirect_to main_app.admin_order_cycles_url
|
||||
flash[:error] = I18n.t(:order_cycles_no_permission_to_delete_error)
|
||||
flash[:error] = "That order cycle has been selected by a customer and cannot be deleted. To prevent customers from accessing it, please close it instead."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class Admin::ProductImportController < Spree::Admin::BaseController
|
||||
|
||||
def validate_upload_presence
|
||||
unless params[:file] || (params[:filepath] && File.exist?(params[:filepath]))
|
||||
redirect_to '/admin/product_import', notice: I18n.t(:product_import_file_not_found_notice)
|
||||
redirect_to '/admin/product_import', notice: 'File not found or could not be opened'
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -39,7 +39,7 @@ class Admin::ProductImportController < Spree::Admin::BaseController
|
||||
|
||||
def check_spreadsheet_has_data(importer)
|
||||
unless importer.item_count
|
||||
redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
|
||||
redirect_to '/admin/product_import', notice: 'No data found in spreadsheet'
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,10 +11,10 @@ module Api
|
||||
def accessible
|
||||
@order_cycles = if params[:as] == "distributor"
|
||||
OrderCycle.ransack(params[:q]).result.
|
||||
involving_managed_distributors_of(current_api_user).order('updated_at DESC')
|
||||
involving_managed_distributors_of(current_api_user).order('updated_at DESC')
|
||||
elsif params[:as] == "producer"
|
||||
OrderCycle.ransack(params[:q]).result.
|
||||
involving_managed_producers_of(current_api_user).order('updated_at DESC')
|
||||
involving_managed_producers_of(current_api_user).order('updated_at DESC')
|
||||
else
|
||||
OrderCycle.ransack(params[:q]).result.accessible_by(current_api_user)
|
||||
end
|
||||
|
||||
@@ -3,8 +3,6 @@ require 'open_food_network/referer_parser'
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
prepend_before_filter :restrict_iframes
|
||||
|
||||
include EnterprisesHelper
|
||||
helper CssSplitter::ApplicationHelper
|
||||
|
||||
@@ -20,70 +18,8 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def shopfront_session
|
||||
session[:safari_fix] = true
|
||||
render 'shop/shopfront_session', layout: false
|
||||
end
|
||||
|
||||
def enable_embedded_styles
|
||||
session[:embedded_shopfront] = true
|
||||
render json: {}, status: 200
|
||||
end
|
||||
|
||||
def disable_embedded_styles
|
||||
session.delete :embedded_shopfront
|
||||
session.delete :shopfront_redirect
|
||||
render json: {}, status: 200
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def after_sign_in_path_for(resource_or_scope)
|
||||
return session[:shopfront_redirect] if session[:shopfront_redirect]
|
||||
stored_location_for(resource_or_scope) || signed_in_root_path(resource_or_scope)
|
||||
end
|
||||
|
||||
def after_sign_out_path_for(_resource_or_scope)
|
||||
session[:shopfront_redirect] ? session[:shopfront_redirect] : root_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def restrict_iframes
|
||||
response.headers['X-Frame-Options'] = 'DENY'
|
||||
response.headers['Content-Security-Policy'] = "frame-ancestors 'none'"
|
||||
end
|
||||
|
||||
def enable_embedded_shopfront
|
||||
whitelist = Spree::Config[:embedded_shopfronts_whitelist]
|
||||
return unless Spree::Config[:enable_embedded_shopfronts] && whitelist.present?
|
||||
return if request.referer && URI(request.referer).scheme != 'https' && !Rails.env.test?
|
||||
|
||||
response.headers.delete 'X-Frame-Options'
|
||||
response.headers['Content-Security-Policy'] = "frame-ancestors #{whitelist}"
|
||||
|
||||
check_embedded_request
|
||||
set_embedded_layout
|
||||
end
|
||||
|
||||
def check_embedded_request
|
||||
return unless params[:embedded_shopfront]
|
||||
|
||||
# Show embedded shopfront CSS
|
||||
session[:embedded_shopfront] = true
|
||||
|
||||
# Get shopfront slug and set redirect path
|
||||
if params[:controller] == 'enterprises' && params[:action] == 'shop' && params[:id]
|
||||
slug = params[:id]
|
||||
session[:shopfront_redirect] = '/' + slug + '/shop?embedded_shopfront=true'
|
||||
end
|
||||
end
|
||||
|
||||
def set_embedded_layout
|
||||
return unless session[:embedded_shopfront]
|
||||
@shopfront_layout = 'embedded'
|
||||
end
|
||||
|
||||
def action
|
||||
params[:action].to_sym
|
||||
end
|
||||
|
||||
@@ -8,7 +8,6 @@ class BaseController < ApplicationController
|
||||
include Spree::Core::ControllerHelpers::Order
|
||||
include Spree::Core::ControllerHelpers::RespondWith
|
||||
|
||||
include I18nHelper
|
||||
include EnterprisesHelper
|
||||
include OrderCyclesHelper
|
||||
|
||||
@@ -18,9 +17,9 @@ class BaseController < ApplicationController
|
||||
# include Spree::ProductsHelper so that method is available on the controller
|
||||
include Spree::ProductsHelper
|
||||
|
||||
before_filter :set_locale
|
||||
before_filter :check_order_cycle_expiry
|
||||
|
||||
|
||||
private
|
||||
|
||||
def set_order_cycles
|
||||
@@ -30,7 +29,7 @@ class BaseController < ApplicationController
|
||||
end
|
||||
|
||||
@order_cycles = OrderCycle.with_distributor(@distributor).active
|
||||
.order(@distributor.preferred_shopfront_order_cycle_order)
|
||||
.order(@distributor.preferred_shopfront_order_cycle_order)
|
||||
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(@distributor, "FilterOrderCycles", current_customer.andand.tag_list)
|
||||
applicator.filter!(@order_cycles)
|
||||
|
||||
@@ -9,7 +9,6 @@ class CheckoutController < Spree::CheckoutController
|
||||
prepend_before_filter :require_distributor_chosen
|
||||
|
||||
skip_before_filter :check_registration
|
||||
before_filter :enable_embedded_shopfront
|
||||
|
||||
include OrderCyclesHelper
|
||||
include EnterprisesHelper
|
||||
@@ -26,24 +25,23 @@ class CheckoutController < Spree::CheckoutController
|
||||
return if redirect_to_paypal_express_form_if_needed
|
||||
end
|
||||
|
||||
next if advance_order_state(@order)
|
||||
|
||||
if @order.errors.present?
|
||||
flash[:error] = @order.errors.full_messages.to_sentence
|
||||
if advance_order_state(@order)
|
||||
state_callback(:after)
|
||||
else
|
||||
flash[:error] = t(:payment_processing_failed)
|
||||
if @order.errors.present?
|
||||
flash[:error] = @order.errors.full_messages.to_sentence
|
||||
else
|
||||
flash[:error] = t(:payment_processing_failed)
|
||||
end
|
||||
update_failed
|
||||
return
|
||||
end
|
||||
update_failed
|
||||
return
|
||||
end
|
||||
if @order.state == "complete" || @order.completed?
|
||||
set_default_bill_address
|
||||
set_default_ship_address
|
||||
|
||||
ResetOrderService.new(self, current_order).call
|
||||
session[:access_token] = current_order.token
|
||||
|
||||
flash[:notice] = t(:order_processed_successfully)
|
||||
flash[:success] = t(:order_processed_successfully)
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
respond_with(@order, :location => order_path(@order))
|
||||
@@ -60,13 +58,6 @@ class CheckoutController < Spree::CheckoutController
|
||||
end
|
||||
end
|
||||
|
||||
# Clears the cached order. Required for #current_order to return a new order
|
||||
# to serve as cart. See https://github.com/spree/spree/blob/1-3-stable/core/lib/spree/core/controller_helpers/order.rb#L14
|
||||
# for details.
|
||||
def expire_current_order
|
||||
session[:order_id] = nil
|
||||
@current_order = nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -97,7 +88,7 @@ class CheckoutController < Spree::CheckoutController
|
||||
|
||||
def check_order_for_phantom_fees
|
||||
phantom_fees = @order.adjustments.joins('LEFT OUTER JOIN spree_line_items ON spree_line_items.id = spree_adjustments.source_id').
|
||||
where("originator_type = 'EnterpriseFee' AND source_type = 'Spree::LineItem' AND spree_line_items.id IS NULL")
|
||||
where("originator_type = 'EnterpriseFee' AND source_type = 'Spree::LineItem' AND spree_line_items.id IS NULL")
|
||||
|
||||
if phantom_fees.any?
|
||||
Bugsnag.notify(RuntimeError.new("Phantom Fees"), {
|
||||
@@ -162,7 +153,7 @@ class CheckoutController < Spree::CheckoutController
|
||||
raise_insufficient_quantity and return if @order.insufficient_stock_lines.present?
|
||||
redirect_to main_app.shop_path and return if @order.completed?
|
||||
before_address
|
||||
setup_for_current_state
|
||||
state_callback(:before)
|
||||
end
|
||||
|
||||
def before_address
|
||||
@@ -180,6 +171,14 @@ class CheckoutController < Spree::CheckoutController
|
||||
@order.ship_address ||= customer_preferred_ship_address || preferred_ship_address || last_used_ship_address || Spree::Address.default
|
||||
end
|
||||
|
||||
def after_payment
|
||||
# object_params sets the payment amount to the order total, but it does this before
|
||||
# the shipping method is set. This results in the customer not being charged for their
|
||||
# order's shipping. To fix this, we refresh the payment amount here.
|
||||
@order.update_totals
|
||||
@order.payments.first.update_attribute :amount, @order.total
|
||||
end
|
||||
|
||||
# Overriding Spree's methods
|
||||
def raise_insufficient_quantity
|
||||
respond_to do |format|
|
||||
|
||||
@@ -10,7 +10,6 @@ class EnterprisesController < BaseController
|
||||
before_filter :check_stock_levels, only: :shop
|
||||
|
||||
before_filter :clean_permalink, only: :check_permalink
|
||||
before_filter :enable_embedded_shopfront
|
||||
|
||||
respond_to :js, only: :permalink_checker
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class HomeController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
before_filter :enable_embedded_shopfront
|
||||
|
||||
def index
|
||||
if ContentConfig.home_show_stats
|
||||
@num_distributors = Enterprise.is_distributor.activated.visible.count
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class ProducersController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
before_filter :enable_embedded_shopfront
|
||||
|
||||
def index
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ require 'open_food_network/cached_products_renderer'
|
||||
|
||||
class ShopController < BaseController
|
||||
layout "darkswarm"
|
||||
before_filter :require_distributor_chosen, :set_order_cycles, except: :changeable_orders_alert
|
||||
before_filter :enable_embedded_shopfront
|
||||
before_filter :require_distributor_chosen
|
||||
before_filter :set_order_cycles
|
||||
|
||||
def show
|
||||
redirect_to main_app.enterprise_shop_path(current_distributor)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class ShopsController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
before_filter :enable_embedded_shopfront
|
||||
|
||||
def index
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ module Spree
|
||||
@tax_rate_id = tr_yielding_matching_tax || tr_valid_for_order
|
||||
|
||||
if tr_yielding_matching_tax.nil?
|
||||
@adjustment.errors.add :tax_rate_id, I18n.t(:adjustments_tax_rate_error)
|
||||
@adjustment.errors.add :tax_rate_id, "^Please check that the tax rate for this adjustment is correct."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
require 'spree/core/controller_helpers/respond_with_decorator'
|
||||
|
||||
Spree::Admin::BaseController.class_eval do
|
||||
include I18nHelper
|
||||
|
||||
before_filter :set_locale
|
||||
before_filter :warn_invalid_order_cycles
|
||||
|
||||
# Warn the user when they have an active order cycle with hubs that are not ready
|
||||
@@ -54,9 +51,13 @@ Spree::Admin::BaseController.class_eval do
|
||||
distributor_names = distributors.map(&:name).join ', '
|
||||
|
||||
if distributors.count > 1
|
||||
I18n.t(:active_distributors_not_ready_for_checkout_message_plural, distributor_names: distributor_names)
|
||||
"The hubs #{distributor_names} are listed in an active order cycle, " +
|
||||
"but do not have valid shipping and payment methods. " +
|
||||
"Until you set these up, customers will not be able to shop at these hubs."
|
||||
else
|
||||
I18n.t(:active_distributors_not_ready_for_checkout_message_singular, distributor_names: distributor_names)
|
||||
"The hub #{distributor_names} is listed in an active order cycle, " +
|
||||
"but does not have valid shipping and payment methods. " +
|
||||
"Until you set these up, customers will not be able to shop at this hub."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2,6 +2,21 @@ Spree::Admin::LineItemsController.class_eval do
|
||||
prepend_before_filter :load_order, except: :index
|
||||
around_filter :apply_enterprise_fees_with_lock, only: :update
|
||||
|
||||
respond_to :json
|
||||
|
||||
# TODO make updating line items faster by creating a bulk update method
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
order_params = params[:q].andand.delete :order
|
||||
orders = OpenFoodNetwork::Permissions.new(spree_current_user).editable_orders.ransack(order_params).result
|
||||
line_items = OpenFoodNetwork::Permissions.new(spree_current_user).editable_line_items.where(order_id: orders).ransack(params[:q])
|
||||
render_as_json line_items.result.reorder('order_id ASC, id ASC')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
variant = Spree::Variant.find(params[:line_item][:variant_id])
|
||||
OpenFoodNetwork::ScopeVariantToHub.new(@order.distributor).scope(variant)
|
||||
@@ -19,30 +34,9 @@ Spree::Admin::LineItemsController.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: simplify this, 3 formats per action is too much
|
||||
# we need `js` format for admin/orders/edit (jquery-rails gem)
|
||||
# we don't know if `html` format is needed
|
||||
def update
|
||||
respond_to do |format|
|
||||
format.html { render_order_form }
|
||||
format.js {
|
||||
if @line_item.update_attributes(params[:line_item])
|
||||
render nothing: true, status: 204 # No Content, does not trigger ng resource auto-update
|
||||
else
|
||||
render json: { errors: @line_item.errors }, status: 412
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def render_order_form
|
||||
respond_to do |format|
|
||||
format.html { render partial: 'spree/admin/orders/form', locals: {order: @order.reload} }
|
||||
end
|
||||
end
|
||||
|
||||
def load_order
|
||||
@order = Spree::Order.find_by_number!(params[:order_id])
|
||||
authorize! :update, @order
|
||||
|
||||
@@ -4,7 +4,11 @@ Spree::Admin::OrdersController.class_eval do
|
||||
include OpenFoodNetwork::SpreeApiKeyLoader
|
||||
helper CheckoutHelper
|
||||
before_filter :load_spree_api_key, :only => :bulk_management
|
||||
before_filter :load_order, only: %i[show edit update fire resend invoice print]
|
||||
|
||||
# We need to add expections for collection actions other than :index here
|
||||
# because spree_auth_devise causes load_order to be called, which results
|
||||
# in an auth failure as the @order object is nil for collection actions
|
||||
before_filter :check_authorization, except: [:bulk_management, :managed]
|
||||
|
||||
before_filter :load_distribution_choices, only: [:new, :edit, :update]
|
||||
|
||||
@@ -79,7 +83,7 @@ Spree::Admin::OrdersController.class_eval do
|
||||
template = if Spree::Config.invoice_style2? then "spree/admin/orders/invoice2" else "spree/admin/orders/invoice" end
|
||||
pdf = render_to_string pdf: "invoice-#{@order.number}.pdf", template: template, formats: [:html], encoding: "UTF-8"
|
||||
Spree::OrderMailer.invoice_email(@order.id, pdf).deliver
|
||||
flash[:success] = t('admin.orders.invoice_email_sent')
|
||||
flash[:success] = t(:invoice_email_sent)
|
||||
|
||||
respond_with(@order) { |format| format.html { redirect_to edit_admin_order_path(@order) } }
|
||||
end
|
||||
@@ -108,9 +112,9 @@ Spree::Admin::OrdersController.class_eval do
|
||||
|
||||
# Replaced this search to filter orders to only show those distributed by current user (or all for admin user)
|
||||
@search.result.includes([:user, :shipments, :payments]).
|
||||
distributed_by_user(spree_current_user).
|
||||
page(params[:page]).
|
||||
per(params[:per_page] || Spree::Config[:orders_per_page])
|
||||
distributed_by_user(spree_current_user).
|
||||
page(params[:page]).
|
||||
per(params[:per_page] || Spree::Config[:orders_per_page])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,32 +1,21 @@
|
||||
Spree::Admin::PaymentsController.class_eval do
|
||||
append_before_filter :filter_payment_methods
|
||||
|
||||
|
||||
# When a user fires an event, take them back to where they came from
|
||||
# (we can't use respond_override because Spree no longer uses respond_with)
|
||||
def fire
|
||||
event = params[:e]
|
||||
return unless event && @payment.payment_source
|
||||
# Responder: http://guides.spreecommerce.com/developer/logic.html#overriding-controller-action-responses
|
||||
|
||||
# Because we have a transition method also called void, we do this to avoid conflicts.
|
||||
event = "void_transaction" if event == "void"
|
||||
if @payment.send("#{event}!")
|
||||
flash[:success] = t(:payment_updated)
|
||||
else
|
||||
flash[:error] = t(:cannot_perform_operation)
|
||||
end
|
||||
rescue Spree::Core::GatewayError => ge
|
||||
flash[:error] = ge.message
|
||||
ensure
|
||||
redirect_to request.referer
|
||||
end
|
||||
# For some strange reason, adding PaymentsController.class_eval will cause gems/spree/app/controllers/spree/admin/payments_controller.rb:37 to error:
|
||||
# payments_url not defined.
|
||||
# This could be fixed by replacing line 37 with:
|
||||
# respond_with(@payment, location: admin_order_payments_url) { |format| format.html { redirect_to admin_order_payments_path(@order) } }
|
||||
respond_override :fire => { :html => { :success => lambda {
|
||||
redirect_to request.referer # Keeps any filter and sort prefs
|
||||
} } }
|
||||
|
||||
|
||||
private
|
||||
append_before_filter :filter_payment_methods
|
||||
|
||||
# Only show payments for the order's distributor
|
||||
def filter_payment_methods
|
||||
@payment_methods = @payment_methods.select{ |pm| pm.has_distributor? @order.distributor}
|
||||
@payment_method ||= @payment_methods.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,6 +8,9 @@ Spree::Admin::ProductsController.class_eval do
|
||||
before_filter :load_spree_api_key, :only => [:bulk_edit, :variant_overrides]
|
||||
before_filter :strip_new_properties, only: [:create, :update]
|
||||
|
||||
|
||||
respond_to :json, :only => :clone
|
||||
|
||||
respond_override create: { html: {
|
||||
success: lambda {
|
||||
if params[:button] == "add_another"
|
||||
@@ -19,6 +22,7 @@ Spree::Admin::ProductsController.class_eval do
|
||||
failure: lambda {
|
||||
render :new
|
||||
} } }
|
||||
#respond_override :clone => { :json => {:success => lambda { redirect_to bulk_index_admin_products_url+"?q[id_eq]=#{@new.id}" } } }
|
||||
|
||||
def product_distributions
|
||||
end
|
||||
|
||||
@@ -18,40 +18,55 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
include Spree::ReportsHelper
|
||||
|
||||
REPORT_TYPES = {
|
||||
orders_and_fulfillment: [
|
||||
['Order Cycle Supplier Totals',:order_cycle_supplier_totals],
|
||||
['Order Cycle Supplier Totals by Distributor',:order_cycle_supplier_totals_by_distributor],
|
||||
['Order Cycle Distributor Totals by Supplier',:order_cycle_distributor_totals_by_supplier],
|
||||
['Order Cycle Customer Totals',:order_cycle_customer_totals]
|
||||
],
|
||||
products_and_inventory: [
|
||||
['All products', :all_products],
|
||||
['Inventory (on hand)', :inventory],
|
||||
['LettuceShare', :lettuce_share]
|
||||
],
|
||||
customers: [
|
||||
["Mailing List", :mailing_list],
|
||||
["Addresses", :addresses]
|
||||
],
|
||||
order_cycle_management: [
|
||||
["Payment Methods Report", :payment_methods],
|
||||
["Delivery Report", :delivery]
|
||||
],
|
||||
sales_tax: [
|
||||
["Tax Types", :tax_types],
|
||||
["Tax Rates", :tax_rates]
|
||||
],
|
||||
packing: [
|
||||
["Pack By Customer", :pack_by_customer],
|
||||
["Pack By Supplier", :pack_by_supplier]
|
||||
]
|
||||
}
|
||||
|
||||
# Fetches user's distributors, suppliers and order_cycles
|
||||
before_filter :load_data, only: [:customers, :products_and_inventory, :order_cycle_management, :packing]
|
||||
|
||||
def report_types
|
||||
{
|
||||
orders_and_fulfillment: [
|
||||
[I18n.t('admin.reports.supplier_totals'), :order_cycle_supplier_totals],
|
||||
[I18n.t('admin.reports.supplier_totals_by_distributor'), :order_cycle_supplier_totals_by_distributor],
|
||||
[I18n.t('admin.reports.totals_by_supplier'), :order_cycle_distributor_totals_by_supplier],
|
||||
[I18n.t('admin.reports.customer_totals'), :order_cycle_customer_totals]
|
||||
],
|
||||
products_and_inventory: [
|
||||
[I18n.t('admin.reports.all_products'), :all_products],
|
||||
[I18n.t('admin.reports.inventory'), :inventory],
|
||||
[I18n.t('admin.reports.lettuce_share'), :lettuce_share]
|
||||
],
|
||||
customers: [
|
||||
[I18n.t('admin.reports.mailing_list'), :mailing_list],
|
||||
[I18n.t('admin.reports.addresses'), :addresses]
|
||||
],
|
||||
order_cycle_management: [
|
||||
[I18n.t('admin.reports.payment_methods'), :payment_methods],
|
||||
[I18n.t('admin.reports.delivery'), :delivery]
|
||||
],
|
||||
sales_tax: [
|
||||
[I18n.t('admin.reports.tax_types'), :tax_types],
|
||||
[I18n.t('admin.reports.tax_rates'), :tax_rates]
|
||||
],
|
||||
packing: [
|
||||
[I18n.t('admin.reports.pack_by_customer'), :pack_by_customer],
|
||||
[I18n.t('admin.reports.pack_by_supplier'), :pack_by_supplier]
|
||||
]
|
||||
}
|
||||
end
|
||||
# Render a partial for orders and fulfillment description
|
||||
respond_override :index => { :html => { :success => lambda {
|
||||
@reports[:orders_and_fulfillment][:description] =
|
||||
render_to_string(partial: 'orders_and_fulfillment_description', layout: false, locals: {report_types: REPORT_TYPES[:orders_and_fulfillment]}).html_safe
|
||||
@reports[:products_and_inventory][:description] =
|
||||
render_to_string(partial: 'products_and_inventory_description', layout: false, locals: {report_types: REPORT_TYPES[:products_and_inventory]}).html_safe
|
||||
@reports[:customers][:description] =
|
||||
render_to_string(partial: 'customers_description', layout: false, locals: {report_types: REPORT_TYPES[:customers]}).html_safe
|
||||
@reports[:order_cycle_management][:description] =
|
||||
render_to_string(partial: 'order_cycle_management_description', layout: false, locals: {report_types: REPORT_TYPES[:order_cycle_management]}).html_safe
|
||||
@reports[:packing][:description] =
|
||||
render_to_string(partial: 'packing_description', layout: false, locals: {report_types: REPORT_TYPES[:packing]}).html_safe
|
||||
@reports[:sales_tax][:description] =
|
||||
render_to_string(partial: 'sales_tax_description', layout: false, locals: {report_types: REPORT_TYPES[:sales_tax]}).html_safe
|
||||
} } }
|
||||
|
||||
|
||||
# Overide spree reports list.
|
||||
def index
|
||||
@@ -61,7 +76,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
# This action is short because we refactored it like bosses
|
||||
def customers
|
||||
@report_types = report_types[:customers]
|
||||
@report_types = REPORT_TYPES[:customers]
|
||||
@report_type = params[:report_type]
|
||||
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, params
|
||||
render_report(@report.header, @report.table, params[:csv], "customers_#{timestamp}.csv")
|
||||
@@ -80,7 +95,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
@suppliers = my_suppliers | my_distributors.map { |d| Spree::Product.in_distributor(d) }.flatten.map(&:supplier).uniq
|
||||
@order_cycles = OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
|
||||
|
||||
@report_types = report_types[:order_cycle_management]
|
||||
@report_types = REPORT_TYPES[:order_cycle_management]
|
||||
@report_type = params[:report_type]
|
||||
|
||||
# -- Build Report with Order Grouper
|
||||
@@ -103,7 +118,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
# My suppliers and any suppliers supplying products I distribute
|
||||
@suppliers = my_suppliers | my_distributors.map { |d| Spree::Product.in_distributor(d) }.flatten.map(&:supplier).uniq
|
||||
@order_cycles = OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
|
||||
@report_types = report_types[:packing]
|
||||
@report_types = REPORT_TYPES[:packing]
|
||||
@report_type = params[:report_type]
|
||||
|
||||
# -- Build Report with Order Grouper
|
||||
@@ -128,9 +143,9 @@ Spree::Admin::ReportsController.class_eval do
|
||||
orders.select{ |order| orders_with_hidden_details.include? order }.each do |order|
|
||||
# TODO We should really be hiding customer code here too, but until we
|
||||
# have an actual association between order and customer, it's a bit tricky
|
||||
order.bill_address.andand.assign_attributes(firstname: I18n.t('admin.reports.hidden'), lastname: "", phone: "", address1: "", address2: "", city: "", zipcode: "", state: nil)
|
||||
order.ship_address.andand.assign_attributes(firstname: I18n.t('admin.reports.hidden'), lastname: "", phone: "", address1: "", address2: "", city: "", zipcode: "", state: nil)
|
||||
order.assign_attributes(email: I18n.t('admin.reports.hidden'))
|
||||
order.bill_address.andand.assign_attributes(firstname: "HIDDEN", lastname: "", phone: "", address1: "", address2: "", city: "", zipcode: "", state: nil)
|
||||
order.ship_address.andand.assign_attributes(firstname: "HIDDEN", lastname: "", phone: "", address1: "", address2: "", city: "", zipcode: "", state: nil)
|
||||
order.assign_attributes(email: "HIDDEN")
|
||||
end
|
||||
|
||||
@report = OpenFoodNetwork::OrderAndDistributorReport.new orders
|
||||
@@ -209,9 +224,9 @@ Spree::Admin::ReportsController.class_eval do
|
||||
@suppliers = permissions.visible_enterprises_for_order_reports.is_primary_producer
|
||||
|
||||
@order_cycles = OrderCycle.active_or_complete.
|
||||
involving_managed_distributors_of(spree_current_user).order('orders_close_at DESC')
|
||||
involving_managed_distributors_of(spree_current_user).order('orders_close_at DESC')
|
||||
|
||||
@report_types = report_types[:orders_and_fulfillment]
|
||||
@report_types = REPORT_TYPES[:orders_and_fulfillment]
|
||||
@report_type = params[:report_type]
|
||||
|
||||
@include_blank = I18n.t(:all)
|
||||
@@ -227,7 +242,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
end
|
||||
|
||||
def products_and_inventory
|
||||
@report_types = report_types[:products_and_inventory]
|
||||
@report_types = REPORT_TYPES[:products_and_inventory]
|
||||
if params[:report_type] != 'lettuce_share'
|
||||
@report = OpenFoodNetwork::ProductsAndInventoryReport.new spree_current_user, params
|
||||
else
|
||||
@@ -237,7 +252,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
end
|
||||
|
||||
def users_and_enterprises
|
||||
# @report_types = report_types[:users_and_enterprises]
|
||||
# @report_types = REPORT_TYPES[:users_and_enterprises]
|
||||
@report = OpenFoodNetwork::UsersAndEnterprisesReport.new params
|
||||
render_report(@report.header, @report.table, params[:csv], "users_and_enterprises_#{timestamp}.csv")
|
||||
end
|
||||
@@ -298,33 +313,19 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
def authorized_reports
|
||||
reports = {
|
||||
:orders_and_distributors => {:name => I18n.t('admin.reports.orders_and_distributors.name'), :description => I18n.t('admin.reports.orders_and_distributors.description')},
|
||||
:bulk_coop => {:name => I18n.t('admin.reports.bulk_coop.name'), :description => I18n.t('admin.reports.bulk_coop.description')},
|
||||
:payments => {:name => I18n.t('admin.reports.payments.name'), :description => I18n.t('admin.reports.payments.description')},
|
||||
:orders_and_fulfillment => {:name => I18n.t('admin.reports.orders_and_fulfillment.name'), :description => ''},
|
||||
:customers => {:name => I18n.t('admin.reports.customers.name'), :description => ''},
|
||||
:products_and_inventory => {:name => I18n.t('admin.reports.products_and_inventory.name'), :description => ''},
|
||||
:sales_total => {:name => I18n.t('admin.reports.sales_total.name'), :description => I18n.t('admin.reports.sales_total.description')},
|
||||
:users_and_enterprises => {:name => I18n.t('admin.reports.users_and_enterprises.name'), :description => I18n.t('admin.reports.users_and_enterprises.description')},
|
||||
:order_cycle_management => {:name => I18n.t('admin.reports.order_cycle_management.name'), :description => ''},
|
||||
:sales_tax => {:name => I18n.t('admin.reports.sales_tax.name'), :description => ''},
|
||||
:xero_invoices => {:name => I18n.t('admin.reports.xero_invoices.name'), :description => I18n.t('admin.reports.xero_invoices.description')},
|
||||
:packing => {:name => I18n.t('admin.reports.packing.name'), :description => ''}
|
||||
:orders_and_distributors => {:name => "Orders And Distributors", :description => "Orders with distributor details"},
|
||||
:bulk_coop => {:name => "Bulk Co-Op", :description => "Reports for Bulk Co-Op orders"},
|
||||
:payments => {:name => "Payment Reports", :description => "Reports for Payments"},
|
||||
:orders_and_fulfillment => {:name => "Orders & Fulfillment Reports", :description => ''},
|
||||
:customers => {:name => "Customers", :description => 'Customer details'},
|
||||
:products_and_inventory => {:name => "Products & Inventory", :description => ''},
|
||||
:sales_total => { :name => "Sales Total", :description => "Sales Total For All Orders" },
|
||||
:users_and_enterprises => { :name => "Users & Enterprises", :description => "Enterprise Ownership & Status" },
|
||||
:order_cycle_management => {:name => "Order Cycle Management", :description => ''},
|
||||
:sales_tax => { :name => "Sales Tax", :description => "Sales Tax For Orders" },
|
||||
:xero_invoices => { :name => "Xero Invoices", :description => 'Invoices for import into Xero' },
|
||||
:packing => { :name => "Packing Reports", :description => '' }
|
||||
}
|
||||
|
||||
reports[:orders_and_fulfillment][:description] =
|
||||
render_to_string(partial: 'orders_and_fulfillment_description', layout: false, locals: {report_types: report_types[:orders_and_fulfillment]}).html_safe
|
||||
reports[:products_and_inventory][:description] =
|
||||
render_to_string(partial: 'products_and_inventory_description', layout: false, locals: {report_types: report_types[:products_and_inventory]}).html_safe
|
||||
reports[:customers][:description] =
|
||||
render_to_string(partial: 'customers_description', layout: false, locals: {report_types: report_types[:customers]}).html_safe
|
||||
reports[:order_cycle_management][:description] =
|
||||
render_to_string(partial: 'order_cycle_management_description', layout: false, locals: {report_types: report_types[:order_cycle_management]}).html_safe
|
||||
reports[:packing][:description] =
|
||||
render_to_string(partial: 'packing_description', layout: false, locals: {report_types: report_types[:packing]}).html_safe
|
||||
reports[:sales_tax][:description] =
|
||||
render_to_string(partial: 'sales_tax_description', layout: false, locals: {report_types: report_types[:sales_tax]}).html_safe
|
||||
|
||||
# Return only reports the user is authorized to view.
|
||||
reports.select { |action| can? action, :report }
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ Spree::Admin::SearchController.class_eval do
|
||||
def customers
|
||||
if spree_current_user.enterprises.pluck(:id).include? params[:distributor_id].to_i
|
||||
@customers = Customer.ransack({m: 'or', email_start: params[:q], name_start: params[:q]})
|
||||
.result.where(enterprise_id: params[:distributor_id])
|
||||
.result.where(enterprise_id: params[:distributor_id])
|
||||
else
|
||||
@customers = []
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ module Spree
|
||||
def do_not_destroy_referenced_shipping_methods
|
||||
order = Order.where(:shipping_method_id => @object).first
|
||||
if order
|
||||
flash[:error] = I18n.t(:shipping_method_destroy_error, number: order.number)
|
||||
flash[:error] = "That shipping method cannot be deleted as it is referenced by an order: #{order.number}."
|
||||
redirect_to collection_url and return
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,17 +37,6 @@ Spree::Api::ProductsController.class_eval do
|
||||
respond_with(@product, :status => 204)
|
||||
end
|
||||
|
||||
# POST /api/products/:product_id/clone
|
||||
#
|
||||
def clone
|
||||
authorize! :create, Spree::Product
|
||||
original_product = find_product(params[:product_id])
|
||||
authorize! :update, original_product
|
||||
|
||||
@product = original_product.duplicate
|
||||
|
||||
respond_with(@product, status: 201, default_template: :show)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ Spree::CheckoutController.class_eval do
|
||||
|
||||
include CheckoutHelper
|
||||
|
||||
before_filter :enable_embedded_shopfront
|
||||
|
||||
def edit
|
||||
flash.keep
|
||||
redirect_to main_app.checkout_path
|
||||
@@ -32,4 +30,8 @@ Spree::CheckoutController.class_eval do
|
||||
@order.bill_address ||= preferred_bill_address || last_used_bill_address || Spree::Address.default
|
||||
@order.ship_address ||= preferred_ship_address || last_used_ship_address || nil
|
||||
end
|
||||
|
||||
def after_complete
|
||||
reset_order
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,6 @@ Spree::OrdersController.class_eval do
|
||||
after_filter :populate_variant_attributes, only: :populate
|
||||
before_filter :update_distribution, only: :update
|
||||
before_filter :filter_order_params, only: :update
|
||||
before_filter :enable_embedded_shopfront
|
||||
|
||||
prepend_before_filter :require_order_cycle, only: :edit
|
||||
prepend_before_filter :require_distributor_chosen, only: :edit
|
||||
@@ -133,7 +132,7 @@ Spree::OrdersController.class_eval do
|
||||
distributor = Enterprise.is_distributor.find params[:order][:distributor_id]
|
||||
@order.set_distributor! distributor
|
||||
|
||||
flash[:notice] = I18n.t(:order_choosing_hub_notice)
|
||||
flash[:notice] = 'Your hub has been selected.'
|
||||
redirect_to request.referer
|
||||
|
||||
elsif params[:commit] == 'Choose Order Cycle'
|
||||
@@ -141,7 +140,7 @@ Spree::OrdersController.class_eval do
|
||||
order_cycle = OrderCycle.active.find params[:order][:order_cycle_id]
|
||||
@order.set_order_cycle! order_cycle
|
||||
|
||||
flash[:notice] = I18n.t(:order_choosing_hub_notice)
|
||||
flash[:notice] = 'Your order cycle has been selected.'
|
||||
redirect_to request.referer
|
||||
end
|
||||
end
|
||||
@@ -240,7 +239,7 @@ Spree::OrdersController.class_eval do
|
||||
return unless order_to_update.andand.complete?
|
||||
|
||||
items = params[:order][:line_items_attributes]
|
||||
.andand.select{ |k,attrs| attrs["quantity"].to_i > 0 }
|
||||
.andand.select{ |k,attrs| attrs["quantity"].to_i > 0 }
|
||||
|
||||
if items.empty?
|
||||
flash[:error] = I18n.t(:orders_cannot_remove_the_final_item)
|
||||
|
||||
@@ -1,44 +1,20 @@
|
||||
Spree::PaypalController.class_eval do
|
||||
before_filter :enable_embedded_shopfront
|
||||
before_filter :destroy_orphaned_paypal_payments, only: :confirm
|
||||
include CheckoutHelper
|
||||
|
||||
after_filter :reset_order_when_complete, only: :confirm
|
||||
|
||||
def cancel
|
||||
flash[:notice] = Spree.t('flash.cancel', :scope => 'paypal')
|
||||
flash[:notice] = t('flash.cancel', :scope => 'paypal')
|
||||
redirect_to main_app.checkout_path
|
||||
end
|
||||
|
||||
# Clears the cached order. Required for #current_order to return a new order
|
||||
# to serve as cart. See https://github.com/spree/spree/blob/1-3-stable/core/lib/spree/core/controller_helpers/order.rb#L14
|
||||
# for details.
|
||||
def expire_current_order
|
||||
session[:order_id] = nil
|
||||
@current_order = nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def reset_order_when_complete
|
||||
if current_order.complete?
|
||||
flash[:notice] = t(:order_processed_successfully)
|
||||
|
||||
ResetOrderService.new(self, current_order).call
|
||||
session[:access_token] = current_order.token
|
||||
flash[:success] = t(:order_processed_successfully)
|
||||
reset_order
|
||||
end
|
||||
end
|
||||
|
||||
# See #1074 and #1837 for more detail on why we need this
|
||||
# An 'orphaned' Spree::Payment is created for every call to CheckoutController#update
|
||||
# for orders that are processed using a Spree::Gateway::PayPalExpress payment method
|
||||
# These payments are 'orphaned' because they are never used by the spree_paypal_express gem
|
||||
# which creates a brand new Spree::Payment from scratch in PayPalController#confirm
|
||||
# However, the 'orphaned' payments are useful when applying a transaction fee, because the fees
|
||||
# need to be calculated before the order details are sent to PayPal for confirmation
|
||||
# This is our best hook for removing the orphaned payments at an appropriate time. ie. after
|
||||
# the payment details have been confirmed, but before any payments have been processed
|
||||
def destroy_orphaned_paypal_payments
|
||||
return unless payment_method.is_a?(Spree::Gateway::PayPalExpress)
|
||||
orphaned_payments = current_order.payments.where(payment_method_id: payment_method.id, source_id: nil)
|
||||
orphaned_payments.each(&:destroy)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
Spree::UsersController.class_eval do
|
||||
layout 'darkswarm'
|
||||
|
||||
before_filter :enable_embedded_shopfront
|
||||
end
|
||||
|
||||
@@ -104,6 +104,20 @@ module CheckoutHelper
|
||||
render "shared/validated_select", name: name, path: path, options: options, attributes: attributes
|
||||
end
|
||||
|
||||
def reset_order
|
||||
distributor = current_order.distributor
|
||||
token = current_order.token
|
||||
|
||||
session[:order_id] = nil
|
||||
@current_order = nil
|
||||
current_order(true)
|
||||
|
||||
current_order.set_distributor!(distributor)
|
||||
current_order.tokenized_permission.token = token
|
||||
current_order.tokenized_permission.save!
|
||||
session[:access_token] = token
|
||||
end
|
||||
|
||||
def payment_method_price(method, order)
|
||||
price = method.compute_amount(order)
|
||||
if price == 0
|
||||
|
||||
@@ -48,7 +48,7 @@ module EnterprisesHelper
|
||||
|
||||
def enterprise_type_name(enterprise)
|
||||
if enterprise.sells == 'none'
|
||||
enterprise.producer_profile_only ? I18n.t(:profile) : I18n.t(:supplier_only)
|
||||
enterprise.producer_profile_only ? 'Profile' : 'Supplier Only'
|
||||
else
|
||||
"Has Shopfront"
|
||||
end
|
||||
@@ -56,7 +56,7 @@ module EnterprisesHelper
|
||||
|
||||
def enterprise_confirm_delete_message(enterprise)
|
||||
if enterprise.supplied_products.present?
|
||||
I18n.t(:enterprise_confirm_delete_message, product: pluralize(enterprise.supplied_products.count, 'product'))
|
||||
"This will also delete the #{pluralize enterprise.supplied_products.count, 'product'} that this enterprise supplies. Are you sure you want to continue?"
|
||||
else
|
||||
t(:are_you_sure)
|
||||
end
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
module I18nHelper
|
||||
def set_locale
|
||||
# Save a given locale
|
||||
if params[:locale] && Rails.application.config.i18n.available_locales.include?(params[:locale])
|
||||
spree_current_user.update_attributes!(locale: params[:locale]) if spree_current_user
|
||||
cookies[:locale] = params[:locale]
|
||||
end
|
||||
|
||||
# After logging in, check if the user chose a locale before
|
||||
if spree_current_user && spree_current_user.locale.nil? && cookies[:locale]
|
||||
spree_current_user.update_attributes!(locale: params[:locale])
|
||||
end
|
||||
|
||||
I18n.locale = spree_current_user.andand.locale || cookies[:locale] || I18n.default_locale
|
||||
end
|
||||
end
|
||||
@@ -85,14 +85,14 @@ module OrderCyclesHelper
|
||||
disabled_message = nil
|
||||
if options[:shipping_and_payment_methods] && (e.shipping_methods.empty? || e.payment_methods.available.empty?)
|
||||
if e.shipping_methods.empty? && e.payment_methods.available.empty?
|
||||
disabled_message = I18n.t(:no_shipping_or_payment)
|
||||
disabled_message = 'no shipping or payment methods'
|
||||
elsif e.shipping_methods.empty?
|
||||
disabled_message = I18n.t(:no_shipping)
|
||||
disabled_message = 'no shipping methods'
|
||||
elsif e.payment_methods.available.empty?
|
||||
disabled_message = I18n.t(:no_payment)
|
||||
disabled_message = 'no payment methods'
|
||||
end
|
||||
elsif options[:confirmed] && !e.confirmed?
|
||||
disabled_message = I18n.t(:unconfirmed)
|
||||
disabled_message = 'unconfirmed'
|
||||
end
|
||||
|
||||
if disabled_message
|
||||
|
||||
@@ -22,6 +22,7 @@ module Spree
|
||||
|
||||
link_to_with_icon('icon-trash', name, '#', html_options) + f.hidden_field(:_destroy)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,9 +15,9 @@ module Spree
|
||||
end
|
||||
|
||||
def product_variant_unit_options
|
||||
[[I18n.t(:weight), 'weight'],
|
||||
[I18n.t(:volume), 'volume'],
|
||||
[I18n.t(:items), 'items']]
|
||||
[['Weight', 'weight'],
|
||||
['Volume', 'volume'],
|
||||
['Items', 'items']]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,8 +25,8 @@ module Spree
|
||||
end
|
||||
|
||||
def xero_report_types
|
||||
[[I18n.t(:summary), 'summary'],
|
||||
[I18n.t(:detailed), 'detailed']]
|
||||
[['Summary', 'summary'],
|
||||
['Detailed', 'detailed']]
|
||||
end
|
||||
|
||||
def currency_symbol
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
# This class is part of the system that charges hubs for using OFN. It does so
|
||||
# by creating orders. These are not orders for food that customers place, but
|
||||
# instead are orders for OFN usage, so to speak. Thus, they're technically not
|
||||
# "shipped" anywhere, so they're just given a default shipping method.
|
||||
#
|
||||
# The "orders" used by this class are not real orders, they are basically
|
||||
# "invoices" that enterprise owners need to pay for use of an open food network
|
||||
# instance. The amount that the enterprise owner is charged is configurable by
|
||||
# the instance, and can be based on a combination of a percentage of their
|
||||
# turnover, fixed fees, caps and floors and trial periods. This "orders" hold
|
||||
# the billing information for a particular enterprise owner for a given month.
|
||||
#
|
||||
# We assign them also a default shipping method because there is a validation
|
||||
# on Spree::Shipment that requires it.
|
||||
class FinalizeAccountInvoices
|
||||
attr_reader :year, :month, :start_date, :end_date
|
||||
|
||||
|
||||
@@ -106,8 +106,8 @@ class UpdateBillablePeriods
|
||||
end
|
||||
|
||||
obsolete_billable_periods.includes({ account_invoice: :order}).
|
||||
where('spree_orders.state <> \'complete\' OR account_invoices.order_id IS NULL').
|
||||
each(&:delete)
|
||||
where('spree_orders.state <> \'complete\' OR account_invoices.order_id IS NULL').
|
||||
each(&:delete)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -10,7 +10,7 @@ class ProducerMailer < Spree::BaseMailer
|
||||
@total = total_from_line_items(line_items)
|
||||
@tax_total = tax_total_from_line_items(line_items)
|
||||
|
||||
subject = "[#{Spree::Config.site_name}] #{I18n.t('producer_mailer.order_cycle.subject', producer: producer.name)}"
|
||||
subject = "[#{Spree::Config.site_name}] Order cycle report for #{producer.name}"
|
||||
|
||||
if has_orders? order_cycle, producer
|
||||
mail(to: @producer.email,
|
||||
|
||||
@@ -25,7 +25,7 @@ class BillablePeriod < ActiveRecord::Base
|
||||
def label
|
||||
enterprise_version = enterprise.version_at(begins_at)
|
||||
category = enterprise_version.category.to_s.titleize
|
||||
category += (trial ? " #{I18n.t(:trial)}" : "")
|
||||
category += (trial ? " Trial" : "")
|
||||
|
||||
"#{enterprise_version.name} (#{category})"
|
||||
end
|
||||
@@ -71,7 +71,7 @@ class BillablePeriod < ActiveRecord::Base
|
||||
source: self,
|
||||
originator: nil, # enterprise.package
|
||||
mandatory: true,
|
||||
state: 'closed'
|
||||
locked: false
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,19 +17,19 @@ class ContentConfiguration < Spree::Preferences::FileConfiguration
|
||||
has_attached_file :home_hero, default_url: "/assets/home/home.jpg"
|
||||
|
||||
# Producer sign-up page
|
||||
preference :producer_signup_pricing_table_html, :text, default: I18n.t(:content_configuration_pricing_table)
|
||||
preference :producer_signup_case_studies_html, :text, default: I18n.t(:content_configuration_case_studies)
|
||||
preference :producer_signup_detail_html, :text, default: I18n.t(:content_configuration_detail)
|
||||
preference :producer_signup_pricing_table_html, :text, default: "(TODO: Pricing table)"
|
||||
preference :producer_signup_case_studies_html, :text, default: "(TODO: Case studies)"
|
||||
preference :producer_signup_detail_html, :text, default: "(TODO: Detail)"
|
||||
|
||||
# Hubs sign-up page
|
||||
preference :hub_signup_pricing_table_html, :text, default: I18n.t(:content_configuration_pricing_table)
|
||||
preference :hub_signup_case_studies_html, :text, default: I18n.t(:content_configuration_case_studies)
|
||||
preference :hub_signup_detail_html, :text, default: I18n.t(:content_configuration_detail)
|
||||
preference :hub_signup_pricing_table_html, :text, default: "(TODO: Pricing table)"
|
||||
preference :hub_signup_case_studies_html, :text, default: "(TODO: Case studies)"
|
||||
preference :hub_signup_detail_html, :text, default: "(TODO: Detail)"
|
||||
|
||||
# Groups sign-up page
|
||||
preference :group_signup_pricing_table_html, :text, default: I18n.t(:content_configuration_pricing_table)
|
||||
preference :group_signup_case_studies_html, :text, default: I18n.t(:content_configuration_case_studies)
|
||||
preference :group_signup_detail_html, :text, default: I18n.t(:content_configuration_detail)
|
||||
preference :group_signup_pricing_table_html, :text, default: "(TODO: Pricing table)"
|
||||
preference :group_signup_case_studies_html, :text, default: "(TODO: Case studies)"
|
||||
preference :group_signup_detail_html, :text, default: "(TODO: Detail)"
|
||||
|
||||
# Footer
|
||||
preference :footer_logo, :file
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user