spree_multi_vendor 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +44 -0
  5. data/Appraisals +11 -0
  6. data/Gemfile +7 -0
  7. data/LICENSE +26 -0
  8. data/README.md +166 -0
  9. data/Rakefile +21 -0
  10. data/app/controllers/spree/admin/vendor_settings_controller.rb +34 -0
  11. data/app/controllers/spree/admin/vendors_controller.rb +60 -0
  12. data/app/controllers/spree/api/v2/storefront/vendors_controller.rb +28 -0
  13. data/app/controllers/spree_multi_vendor/spree/admin/base_controller_decorator.rb +10 -0
  14. data/app/controllers/spree_multi_vendor/spree/admin/option_types_controller_decorator.rb +7 -0
  15. data/app/controllers/spree_multi_vendor/spree/admin/products_controller_decorator.rb +24 -0
  16. data/app/controllers/spree_multi_vendor/spree/admin/properties_controller_decorator.rb +7 -0
  17. data/app/controllers/spree_multi_vendor/spree/admin/resource_controller_decorator.rb +8 -0
  18. data/app/controllers/spree_multi_vendor/spree/admin/shipping_methods_controller_decorator.rb +7 -0
  19. data/app/controllers/spree_multi_vendor/spree/admin/stock_locations_controller_decorator.rb +7 -0
  20. data/app/controllers/spree_multi_vendor/spree/admin/users_controller_decorator.rb +13 -0
  21. data/app/controllers/spree_multi_vendor/spree/admin/variants_controller_decorator.rb +7 -0
  22. data/app/controllers/spree_multi_vendor/spree/api/v1/variants_controller_decorator.rb +22 -0
  23. data/app/finders/spree_multi_vendor/products_finder_decorator.rb +31 -0
  24. data/app/helpers/spree/admin/vendor_helper.rb +15 -0
  25. data/app/mailers/spree/vendor_mailer.rb +15 -0
  26. data/app/models/concerns/spree/vendor_concern.rb +11 -0
  27. data/app/models/spree/order_commission.rb +11 -0
  28. data/app/models/spree/vendor.rb +77 -0
  29. data/app/models/spree/vendor_ability.rb +140 -0
  30. data/app/models/spree/vendor_image.rb +18 -0
  31. data/app/models/spree/vendor_order_totals.rb +28 -0
  32. data/app/models/spree/vendor_user.rb +16 -0
  33. data/app/models/spree_multi_vendor/configuration.rb +10 -0
  34. data/app/models/spree_multi_vendor/spree/ability_decorator.rb +9 -0
  35. data/app/models/spree_multi_vendor/spree/base_decorator.rb +13 -0
  36. data/app/models/spree_multi_vendor/spree/line_item_decorator.rb +48 -0
  37. data/app/models/spree_multi_vendor/spree/order_decorator.rb +105 -0
  38. data/app/models/spree_multi_vendor/spree/shipment_decorator.rb +8 -0
  39. data/app/models/spree_multi_vendor/spree/stock/package_decorator.rb +14 -0
  40. data/app/models/spree_multi_vendor/spree/user_decorator.rb +8 -0
  41. data/app/models/spree_multi_vendor/spree/variant_decorator.rb +41 -0
  42. data/app/overrides/spree/admin/orders/_form.rb +13 -0
  43. data/app/overrides/spree/admin/orders/_line_items.rb +6 -0
  44. data/app/overrides/spree/admin/orders/_line_items_edit_form.rb +6 -0
  45. data/app/overrides/spree/admin/orders/index.rb +6 -0
  46. data/app/overrides/spree/admin/products/form.rb +29 -0
  47. data/app/overrides/spree/admin/products/new.rb +16 -0
  48. data/app/overrides/spree/admin/shared/_main_menu.rb +23 -0
  49. data/app/overrides/spree/admin/shared/_order_summary.rb +35 -0
  50. data/app/overrides/spree/admin/users/_form.rb +13 -0
  51. data/app/serializers/spree/v2/storefront/vendor_image_serializer.rb +11 -0
  52. data/app/serializers/spree/v2/storefront/vendor_order_totals_serializer.rb +18 -0
  53. data/app/serializers/spree/v2/storefront/vendor_serializer.rb +14 -0
  54. data/app/serializers/spree_multi_vendor/cart_serializer_decorator.rb +19 -0
  55. data/app/serializers/spree_multi_vendor/serializer_decorator.rb +23 -0
  56. data/app/services/spree/orders/generate_commissions.rb +34 -0
  57. data/app/views/spree/admin/translations/vendor.html.erb +21 -0
  58. data/app/views/spree/admin/vendor_settings/edit.html.erb +47 -0
  59. data/app/views/spree/admin/vendors/_form.html.erb +36 -0
  60. data/app/views/spree/admin/vendors/edit.html.erb +11 -0
  61. data/app/views/spree/admin/vendors/index.html.erb +83 -0
  62. data/app/views/spree/admin/vendors/new.html.erb +11 -0
  63. data/app/views/spree/vendor_mailer/vendor_notification_email.html.erb +81 -0
  64. data/app/views/spree/vendor_mailer/vendor_notification_email.text.erb +36 -0
  65. data/bin/rails +7 -0
  66. data/config/initializers/spree_permitted_attributes.rb +10 -0
  67. data/config/locales/en.yml +34 -0
  68. data/config/locales/es.yml +33 -0
  69. data/config/locales/fr.yml +33 -0
  70. data/config/routes.rb +19 -0
  71. data/db/default/vendors.rb +13 -0
  72. data/db/migrate/20170406102250_create_spree_vendors.rb +9 -0
  73. data/db/migrate/20170406102944_add_vendor_id_to_spree_models.rb +10 -0
  74. data/db/migrate/20170410111150_add_state_to_vendors.rb +6 -0
  75. data/db/migrate/20170412124925_add_deleted_at_to_spree_vendors.rb +6 -0
  76. data/db/migrate/20170413094447_create_spree_vendor_users.rb +11 -0
  77. data/db/migrate/20190212161426_add_slug_to_spree_vendors.rb +6 -0
  78. data/db/migrate/20190214120226_add_about_us_to_spree_vendors.rb +5 -0
  79. data/db/migrate/20190214142526_add_contact_us_to_spree_vendors.rb +5 -0
  80. data/db/migrate/20190305120337_add_commission_to_spree_vendors.rb +5 -0
  81. data/db/migrate/20190308091546_add_priority_to_vendor.rb +8 -0
  82. data/db/migrate/20190312130754_create_spree_order_commissions.rb +14 -0
  83. data/db/migrate/20190322133128_add_notification_email_to_vendors.rb +5 -0
  84. data/db/migrate/20200416030721_add_translations_to_vendor.rb +19 -0
  85. data/gemfiles/spree_4_2.gemfile +9 -0
  86. data/gemfiles/spree_master.gemfile +9 -0
  87. data/lib/generators/spree_multi_vendor/install/install_generator.rb +21 -0
  88. data/lib/generators/spree_multi_vendor/mailers_preview/mailers_preview_generator.rb +22 -0
  89. data/lib/generators/spree_multi_vendor/mailers_preview/templates/mailers/previews/vendor_notification_preview.rb +5 -0
  90. data/lib/spree_multi_vendor.rb +14 -0
  91. data/lib/spree_multi_vendor/engine.rb +24 -0
  92. data/lib/spree_multi_vendor/factories.rb +7 -0
  93. data/lib/spree_multi_vendor/version.rb +11 -0
  94. data/lib/tasks/vendors.rake +8 -0
  95. data/spec/factories/spree/vendor_factory.rb +22 -0
  96. data/spec/factories/spree/vendor_image_factory.rb +5 -0
  97. data/spec/factories/spree/vendor_user_factory.rb +6 -0
  98. data/spec/features/spree/admin/orders_spec.rb +36 -0
  99. data/spec/features/spree/admin/product_spec.rb +177 -0
  100. data/spec/features/spree/admin/shipping_method_spec.rb +72 -0
  101. data/spec/features/spree/admin/stock_location_spec.rb +90 -0
  102. data/spec/features/spree/admin/vendor_settings_spec.rb +76 -0
  103. data/spec/features/spree/admin/vendor_spec.rb +125 -0
  104. data/spec/fixtures/thinking-cat.jpg +0 -0
  105. data/spec/mailers/vendor_mailer_spec.rb +45 -0
  106. data/spec/models/spree/line_item_spec.rb +32 -0
  107. data/spec/models/spree/order_commission_spec.rb +8 -0
  108. data/spec/models/spree/order_spec.rb +179 -0
  109. data/spec/models/spree/product_spec.rb +19 -0
  110. data/spec/models/spree/variant_spec.rb +104 -0
  111. data/spec/models/spree/vendor_order_totals_spec.rb +33 -0
  112. data/spec/models/spree/vendor_spec.rb +57 -0
  113. data/spec/models/spree/vendor_user_spec.rb +12 -0
  114. data/spec/requests/spree/api/v2/storefront/cart_spec.rb +67 -0
  115. data/spec/requests/spree/api/v2/storefront/products_spec.rb +93 -0
  116. data/spec/requests/spree/api/v2/storefront/vendors_spec.rb +52 -0
  117. data/spec/serializers/spree/v2/storefront/stock_location_serializer_spec.rb +32 -0
  118. data/spec/serializers/spree/v2/storefront/vendor_image_serializer_spec.rb +18 -0
  119. data/spec/serializers/spree/v2/storefront/vendor_order_totals_serializer_spec.rb +54 -0
  120. data/spec/serializers/spree/v2/storefront/vendor_serializer_spec.rb +34 -0
  121. data/spec/spec_helper.rb +11 -0
  122. data/spec/support/shoulda_matchers.rb +6 -0
  123. data/spree_multi_vendor.gemspec +41 -0
  124. metadata +313 -0
@@ -0,0 +1,36 @@
1
+ <%= Spree.t('order_mailer.vendor_notification_email.dear_vendor') %>
2
+
3
+ ============================================================
4
+ <%= Spree.t('order_mailer.vendor_notification_email.order_summary', number: @order.number) %>
5
+ ============================================================
6
+ <% @line_items.each do |item| %>
7
+ <%= item.variant.sku %> <%= raw(item.variant.product.name) %> <%= raw(item.variant.options_text) -%> (<%=item.quantity%>) <%= Spree.t('at_symbol') %> <%= item.single_money %> = <%= item.display_amount %>
8
+ <% end %>
9
+ ============================================================
10
+ <%= Spree.t('order_mailer.subtotal') %> <%= Spree::Money.new(@subtotal, currency: @order.currency) %>
11
+ <% if @order.line_item_adjustments.exists? %>
12
+ <% if @order.all_adjustments.promotion.eligible.exists? %>
13
+ <% @order.all_adjustments.promotion.eligible.group_by(&:label).each do |label, adjustments| %>
14
+ <%= Spree.t(:promotion) %>: <%= label %> <%= Spree::Money.new(adjustments.sum(&:amount), currency: @order.currency) %>
15
+ <% end %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <% @order.shipments.group_by { |s| s.selected_shipping_rate.try(:name) }.each do |name, shipments| %>
20
+ <%= Spree.t(:shipping) %>: <%= name %> <%= Spree::Money.new(shipments.sum(&:discounted_cost), currency: @order.currency) %>
21
+ <% end %>
22
+
23
+ <% if @order.all_adjustments.eligible.tax.exists? %>
24
+ <% @order.all_adjustments.eligible.tax.group_by(&:label).each do |label, adjustments| %>
25
+ <%= Spree.t(:tax) %>: <%= label %> <%= Spree::Money.new(adjustments.sum(&:amount), currency: @order.currency) %>
26
+ <% end %>
27
+ <% end %>
28
+
29
+ <% @order.adjustments.eligible.each do |adjustment| %>
30
+ <% next if (adjustment.source_type == 'Spree::TaxRate') and (adjustment.amount == 0) %>
31
+ <%= adjustment.label %> <%= adjustment.display_amount %>
32
+ <% end %>
33
+ ============================================================
34
+ <%= Spree.t('order_mailer.total') %> <%= Spree::Money.new(@total, currency: @order.currency) %>
35
+
36
+ <%= Spree.t('order_mailer.vendor_notification_email.thanks') %>
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree_multi_vendor/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ module PermittedAttributes
3
+ ATTRIBUTES << :vendor_attributes
4
+
5
+ mattr_reader *ATTRIBUTES
6
+
7
+ @@vendor_attributes = [:name, :about_us, :contact_us, :notification_email]
8
+ @@vendor_attributes << :image if Spree.version.to_f >= 3.6
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ spree/vendor:
5
+ one: Vendor
6
+ other: Vendors
7
+ attributes:
8
+ spree/vendor:
9
+ about_us: About us
10
+ contact_us: Contact us
11
+ image: Image
12
+ name: name
13
+ state: state
14
+ created_at: created at
15
+ priority: priority
16
+ spree:
17
+ back_to_vendors_list: Back To Vendors List
18
+ blocked: Blocked
19
+ edit_vendor: Edit Vendor
20
+ new_vendor: New Vendor
21
+ only_alphanumeric_chars: should contain only letters and digits
22
+ order_mailer:
23
+ vendor_notification_email:
24
+ dear_vendor: Dear Vendor,
25
+ subject: Vendor notification
26
+ thanks: Thanks
27
+ vendor: Vendor
28
+ vendor_name: Vendor Name
29
+ vendor_states:
30
+ active: Active
31
+ blocked: Blocked
32
+ pending: Pending
33
+ admin:
34
+ commission: Commission
@@ -0,0 +1,33 @@
1
+ es:
2
+ activerecord:
3
+ models:
4
+ spree/vendor:
5
+ one: Vendedor
6
+ other: Vendedores
7
+ attributes:
8
+ spree/vendor:
9
+ about_us: Acerca de
10
+ contact_us: Contáctanos
11
+ image: Imagen
12
+ name: Nombre
13
+ state: estado
14
+ created_at: creado en
15
+ priority: prioridad
16
+ spree:
17
+ back_to_vendors_list: Volver a la lista de vendedores
18
+ edit_vendor: Editar vendedor
19
+ new_vendor: Nuevo vendedor
20
+ only_alphanumeric_chars: Debería contener solo letras y dígitos
21
+ order_mailer:
22
+ vendor_notification_email:
23
+ dear_vendor: Estimado vendedor,
24
+ subject: Notificación de vendedor
25
+ thanks: Gracias
26
+ vendor: Vendedor
27
+ vendor_name: Nombre del vendedor
28
+ vendor_states:
29
+ active: Activo
30
+ blocked: Bloqueado
31
+ pending: Pendiente
32
+ admin:
33
+ commission: Comisión
@@ -0,0 +1,33 @@
1
+ fr:
2
+ activerecord:
3
+ models:
4
+ spree/vendor:
5
+ one: Vendeur
6
+ other: Vendeurs
7
+ attributes:
8
+ spree/vendor:
9
+ about_us: A propos
10
+ contact_us: Contact
11
+ image: Image
12
+ name: Nom
13
+ state: Status
14
+ created_at: créé le
15
+ priority: priorité
16
+ spree:
17
+ back_to_vendors_list: Retour à la liste des vendeurs
18
+ edit_vendor: Modifier vendeur
19
+ new_vendor: Nouveau vendeur
20
+ only_alphanumeric_chars: ne doit contenir que des caractères alphanumériques
21
+ order_mailer:
22
+ vendor_notification_email:
23
+ dear_vendor: Cher vendeur,
24
+ subject: Notification vendeur
25
+ thanks: Merci
26
+ vendor: Vendeur
27
+ vendor_name: Nom du vendeur
28
+ vendor_states:
29
+ active: Actif
30
+ blocked: Bloqué
31
+ pending: En attente
32
+ admin:
33
+ commission: Commission
data/config/routes.rb ADDED
@@ -0,0 +1,19 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ namespace :admin do
3
+ resources :vendors do
4
+ collection do
5
+ post :update_positions
6
+ end
7
+ end
8
+ get 'vendor_settings' => 'vendor_settings#edit'
9
+ patch 'vendor_settings' => 'vendor_settings#update'
10
+ end
11
+
12
+ namespace :api, defaults: { format: 'json' } do
13
+ namespace :v2 do
14
+ namespace :storefront do
15
+ resources :vendors, only: [:show]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ vendor = Spree::Vendor.first_or_initialize do |v|
2
+ v.name = 'Test Vendor'
3
+ end
4
+ vendor.save!
5
+
6
+ puts "Created Vendor with the name \"#{vendor.name}\"!"
7
+
8
+ user = Spree.user_class.where(email: 'user@vendor.com').first_or_initialize do |u|
9
+ u.password = u.password_confirmation = 'vendor123'
10
+ end
11
+
12
+ vendor.users << user unless vendor.users.include?(user)
13
+ puts "Created Vendor Admin User with an email \"#{user.email}\" and password \"#{user.password}\"!"
@@ -0,0 +1,9 @@
1
+ class CreateSpreeVendors < SpreeExtension::Migration[4.2]
2
+ def change
3
+ create_table :spree_vendors do |t|
4
+ t.string :name
5
+ t.timestamps
6
+ end
7
+ add_index :spree_vendors, :name, unique: true
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class AddVendorIdToSpreeModels < SpreeExtension::Migration[4.2]
2
+ def change
3
+ SpreeMultiVendor.vendorized_models.each do |klass|
4
+ add_reference klass.table_name, :vendor, index: true
5
+ rescue
6
+ message = "Could not add vendor_id column to spree_#{klass}"
7
+ Rails.logger.error message
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ class AddStateToVendors < SpreeExtension::Migration[4.2]
2
+ def change
3
+ add_column :spree_vendors, :state, :string
4
+ add_index :spree_vendors, :state
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddDeletedAtToSpreeVendors < SpreeExtension::Migration[4.2]
2
+ def change
3
+ add_column :spree_vendors, :deleted_at, :datetime
4
+ add_index :spree_vendors, :deleted_at
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ class CreateSpreeVendorUsers < SpreeExtension::Migration[4.2]
2
+ def change
3
+ create_table :spree_vendor_users do |t|
4
+ t.references :vendor
5
+ t.references :user
6
+ end
7
+ add_index :spree_vendor_users, [:vendor_id, :user_id], unique: true
8
+ add_index :spree_vendor_users, :vendor_id
9
+ add_index :spree_vendor_users, :user_id
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class AddSlugToSpreeVendors < SpreeExtension::Migration[4.2]
2
+ def change
3
+ add_column :spree_vendors, :slug, :string
4
+ add_index :spree_vendors, :slug, unique: true
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddAboutUsToSpreeVendors < SpreeExtension::Migration[4.2]
2
+ def change
3
+ add_column :spree_vendors, :about_us, :text
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddContactUsToSpreeVendors < SpreeExtension::Migration[4.2]
2
+ def change
3
+ add_column :spree_vendors, :contact_us, :text
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddCommissionToSpreeVendors < SpreeExtension::Migration[4.2]
2
+ def change
3
+ add_column :spree_vendors, :commission_rate, :float, default: '5.0'
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ class AddPriorityToVendor < SpreeExtension::Migration[4.2]
2
+ def change
3
+ add_column :spree_vendors, :priority, :integer
4
+ Spree::Vendor.order(:updated_at).each.with_index(1) do |vendor, index|
5
+ vendor.update_column :priority, index
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ class CreateSpreeOrderCommissions < SpreeExtension::Migration[4.2]
2
+ def change
3
+ create_table :spree_order_commissions do |t|
4
+ t.references :order
5
+ t.references :vendor
6
+ t.float :amount
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :spree_order_commissions, [:order_id, :vendor_id], unique: true
11
+ add_index :spree_order_commissions, :order_id
12
+ add_index :spree_order_commissions, :vendor_id
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class AddNotificationEmailToVendors < SpreeExtension::Migration[4.2]
2
+ def change
3
+ add_column :spree_vendors, :notification_email, :string
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Based on issue https://github.com/spree-contrib/spree_multi_vendor/issues/104
4
+ # This is a patch for Spree globalize to be friendly with the gem
5
+
6
+ class AddTranslationsToVendor < ActiveRecord::Migration[4.2]
7
+ def up
8
+ params = { name: :string, about_us: :text, contact_us: :text, slug: :string }
9
+ if defined?(SpreeGlobalize)
10
+ Spree::Vendor.create_translation_table!(params, { migrate_data: true })
11
+ end
12
+ end
13
+
14
+ def down
15
+ if defined?(SpreeGlobalize)
16
+ Spree::Vendor.drop_translation_table! migrate_data: true
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "spree", "~> 4.2.0.rc4"
6
+ gem "spree_auth_devise", "~> 4.3"
7
+ gem "rails-controller-testing"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "spree", github: "spree/spree", branch: "master"
6
+ gem "spree_auth_devise", github: "spree/spree_auth_devise", branch: "master"
7
+ gem "rails-controller-testing"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,21 @@
1
+ module SpreeMultiVendor
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ class_option :auto_run_migrations, type: :boolean, default: false
6
+
7
+ def add_migrations
8
+ run 'bundle exec rake railties:install:migrations FROM=spree_multi_vendor'
9
+ end
10
+
11
+ def run_migrations
12
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
13
+ if run_migrations
14
+ run 'bundle exec rake db:migrate'
15
+ else
16
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails/generators'
2
+ require 'spree/core'
3
+
4
+ module SpreeMultiVendor
5
+ module Generators
6
+ class MailersPreviewGenerator < Rails::Generators::Base
7
+ desc 'Generates mailers preview for development proposes'
8
+
9
+ def self.source_paths
10
+ [
11
+ File.expand_path('templates', __dir__)
12
+ ]
13
+ end
14
+
15
+ def copy_mailers_previews
16
+ preview_path = Rails.application.config.action_mailer.preview_path || 'test/mailers/previews'
17
+
18
+ template 'mailers/previews/vendor_notification_preview.rb', "#{preview_path}/vendor_notification_preview.rb"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ class VendorNotificationPreview < ActionMailer::Preview
2
+ def vendor_notification_email
3
+ Spree::VendorMailer.vendor_notification_email(Spree::Order.complete.first.id, Spree::Vendor.first.id)
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ require 'spree_core'
2
+ require 'spree_multi_vendor/engine'
3
+ require 'spree_multi_vendor/version'
4
+ require 'spree_extension'
5
+ require 'deface'
6
+
7
+ module SpreeMultiVendor
8
+ # TODO: this should be moved into preferences
9
+ def self.vendorized_models
10
+ SpreeMultiVendor::Config[:vendorized_models].map(&:classify).map do |class_name|
11
+ "Spree::#{class_name}".safe_constantize
12
+ end.compact.uniq
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ module SpreeMultiVendor
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_multi_vendor'
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ initializer 'spree_multi_vendor.environment', before: :load_config_initializers do |_app|
13
+ SpreeMultiVendor::Config = SpreeMultiVendor::Configuration.new
14
+ end
15
+
16
+ def self.activate
17
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
18
+ Rails.configuration.cache_classes ? require(c) : load(c)
19
+ end
20
+ end
21
+
22
+ config.to_prepare &method(:activate).to_proc
23
+ end
24
+ end