From 1071e9841afb8a261935ac83b41401e7ae2da3df Mon Sep 17 00:00:00 2001 From: Denis 'jumph4x Date: Thu, 23 Feb 2012 15:01:16 -0500 Subject: [PATCH] Spree 1-0 initial --- .gitignore | 18 +- .rspec | 4 + Gemfile | 13 + Gemfile.lock | 243 ++++++++++++++++++ Rakefile | 22 +- Versionfile | 9 +- app/controllers/admin/stores_controller.rb | 8 - .../products_controller_decorator.rb | 12 - .../admin/products_controller_decorator.rb | 6 +- .../spree/admin/stores_controller.rb | 3 + .../spree/products_controller_decorator.rb | 12 + app/mailers/{ => spree}/order_mailer.rb | 2 +- app/mailers/{ => spree}/shipment_mailer.rb | 2 +- app/models/models_decorator.rb | 22 -- app/models/spree/order_decorator.rb | 4 + app/models/spree/product_decorator.rb | 4 + app/models/spree/store.rb | 21 ++ app/models/spree/taxonomy_decorator.rb | 3 + app/models/spree/tracker_decorator.rb | 7 + app/models/store.rb | 15 -- .../decorate_admin_configurations_index.rb | 6 + app/overrides/decorate_admin_products_form.rb | 6 + .../decorate_admin_products_index.rb | 20 ++ app/overrides/decorate_admin_trackers_form.rb | 6 + .../decorate_admin_trackers_index.rb | 13 + .../products/_index_search_fields.html.erb | 4 - .../admin/products/_index_headers.html.erb | 0 .../admin/products/_index_rows.html.erb | 0 .../products/_index_search_fields.html.erb | 4 + .../admin/products/_stores.html.erb | 0 .../{ => spree}/admin/stores/_form.html.erb | 0 .../{ => spree}/admin/stores/edit.html.erb | 2 +- .../{ => spree}/admin/stores/index.html.erb | 2 +- .../{ => spree}/admin/stores/new.html.erb | 2 +- .../admin/taxonomies/_form.html.erb | 0 .../admin/trackers/_index_rows.html.erb | 0 .../admin/trackers/_store.html.erb | 0 .../shared/_google_analytics.html.erb | 0 config/routes.rb | 4 +- db/migrate/20091202123245_add_order_store.rb | 14 +- .../20100114020535_add_store_to_tracker.rb | 26 +- .../20100227175140_add_default_store.rb | 2 +- .../20100616204303_store_id_for_taxonomies.rb | 17 +- db/migrate/20120223183401_namespace.rb | 12 + .../install/install_generator.rb | 27 ++ lib/spree/search/multi_domain.rb | 4 +- lib/spree_multi_domain.rb | 116 +-------- lib/spree_multi_domain/engine.rb | 90 +++++++ lib/spree_multi_domain_hooks.rb | 55 ---- lib/tasks/multi_domain_extension_tasks.rake | 2 + script/rails | 5 + .../spree/admin/products_controller_spec.rb | 44 ++++ .../spree/admin/stores_controller_spec.rb | 14 + .../spree/products_controller_spec.rb | 36 +++ spec/factories.rb | 5 + spec/models/spree/order_spec.rb | 18 ++ spec/models/spree/product_spec.rb | 18 ++ spec/models/spree/store_spec.rb | 17 ++ spec/models/spree/tracker_spec.rb | 15 ++ spec/requests/global_controller_helpers.rb | 27 ++ spec/spec_helper.rb | 33 +++ spree_multi_domain.gemspec | 11 +- 62 files changed, 819 insertions(+), 288 deletions(-) create mode 100644 .rspec create mode 100644 Gemfile create mode 100644 Gemfile.lock delete mode 100644 app/controllers/admin/stores_controller.rb delete mode 100644 app/controllers/products_controller_decorator.rb rename app/controllers/{ => spree}/admin/products_controller_decorator.rb (56%) create mode 100644 app/controllers/spree/admin/stores_controller.rb create mode 100644 app/controllers/spree/products_controller_decorator.rb rename app/mailers/{ => spree}/order_mailer.rb (93%) rename app/mailers/{ => spree}/shipment_mailer.rb (89%) delete mode 100644 app/models/models_decorator.rb create mode 100644 app/models/spree/order_decorator.rb create mode 100644 app/models/spree/product_decorator.rb create mode 100644 app/models/spree/store.rb create mode 100644 app/models/spree/taxonomy_decorator.rb create mode 100644 app/models/spree/tracker_decorator.rb delete mode 100644 app/models/store.rb create mode 100644 app/overrides/decorate_admin_configurations_index.rb create mode 100644 app/overrides/decorate_admin_products_form.rb create mode 100644 app/overrides/decorate_admin_products_index.rb create mode 100644 app/overrides/decorate_admin_trackers_form.rb create mode 100644 app/overrides/decorate_admin_trackers_index.rb delete mode 100644 app/views/admin/products/_index_search_fields.html.erb rename app/views/{ => spree}/admin/products/_index_headers.html.erb (100%) rename app/views/{ => spree}/admin/products/_index_rows.html.erb (100%) create mode 100644 app/views/spree/admin/products/_index_search_fields.html.erb rename app/views/{ => spree}/admin/products/_stores.html.erb (100%) rename app/views/{ => spree}/admin/stores/_form.html.erb (100%) rename app/views/{ => spree}/admin/stores/edit.html.erb (85%) rename app/views/{ => spree}/admin/stores/index.html.erb (92%) rename app/views/{ => spree}/admin/stores/new.html.erb (84%) rename app/views/{ => spree}/admin/taxonomies/_form.html.erb (100%) rename app/views/{ => spree}/admin/trackers/_index_rows.html.erb (100%) rename app/views/{ => spree}/admin/trackers/_store.html.erb (100%) rename app/views/{ => spree}/shared/_google_analytics.html.erb (100%) create mode 100644 db/migrate/20120223183401_namespace.rb create mode 100644 lib/generators/spree_multi_domain/install/install_generator.rb create mode 100644 lib/spree_multi_domain/engine.rb delete mode 100644 lib/spree_multi_domain_hooks.rb create mode 100644 lib/tasks/multi_domain_extension_tasks.rake create mode 100644 script/rails create mode 100644 spec/controllers/spree/admin/products_controller_spec.rb create mode 100644 spec/controllers/spree/admin/stores_controller_spec.rb create mode 100644 spec/controllers/spree/products_controller_spec.rb create mode 100644 spec/factories.rb create mode 100644 spec/models/spree/order_spec.rb create mode 100644 spec/models/spree/product_spec.rb create mode 100644 spec/models/spree/store_spec.rb create mode 100644 spec/models/spree/tracker_spec.rb create mode 100644 spec/requests/global_controller_helpers.rb create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore index 8b7bf944..00481b75 100644 --- a/.gitignore +++ b/.gitignore @@ -8,11 +8,7 @@ .loadpath .project *.swp -public/dispatch.cgi -public/dispatch.fcgi -public/dispatch.rb -httpd -pgsql +spec/dummy config/*-public.asc config/database.yml config/mongrel_cluster.yml @@ -20,26 +16,14 @@ db/*.sql db/*.sqlite3* db/schema.rb doc/**/* -lib/products_index_profiler.rb log/*.log -pkg public/assets -public/attachments -public/blank_iframe.html public/images public/javascripts public/stylesheets -public/ckeditora -spree.gemspec -spree_dev -spree_test tmp vendor/rails vendor/extensions/google_base public/google_base.xml public/template_google_base.xml coverage/* -var -TAGS -nbproject -vendor/extensions/theme_default/app/stylesheets/*.css diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..7ab5f55c --- /dev/null +++ b/.rspec @@ -0,0 +1,4 @@ +--color +--format +progress +--backtrace diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..af4e3ace --- /dev/null +++ b/Gemfile @@ -0,0 +1,13 @@ +source 'http://rubygems.org' + +gem 'rails' + +if RUBY_VERSION < "1.9" + gem "ruby-debug" +else + gem "ruby-debug19" +end + +gemspec +gem 'spree' +gem 'ffaker' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..47338063 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,243 @@ +PATH + remote: . + specs: + spree_multi_domain (1.3.05) + spree_core (~> 1.0.3) + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.1.4) + actionpack (= 3.1.4) + mail (~> 2.3.0) + actionpack (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + builder (~> 3.0.0) + erubis (~> 2.7.0) + i18n (~> 0.6) + rack (~> 1.3.6) + rack-cache (~> 1.1) + rack-mount (~> 0.8.2) + rack-test (~> 0.6.1) + sprockets (~> 2.0.3) + active_utils (1.0.3) + activesupport (>= 2.3.11) + i18n + activemerchant (1.20.1) + active_utils (>= 1.0.1) + activesupport (>= 2.3.11) + braintree (>= 2.0.0) + builder (>= 2.0.0) + i18n + json (>= 1.5.1) + money (<= 3.7.1) + activemodel (3.1.4) + activesupport (= 3.1.4) + builder (~> 3.0.0) + i18n (~> 0.6) + activerecord (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + arel (~> 2.2.3) + tzinfo (~> 0.3.29) + activeresource (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + activesupport (3.1.4) + multi_json (~> 1.0) + acts_as_list (0.1.4) + archive-tar-minitar (0.5.2) + arel (2.2.3) + bcrypt-ruby (3.0.1) + braintree (2.14.0) + builder (>= 2.0.0) + builder (3.0.0) + cancan (1.6.7) + capybara (1.0.1) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 0.1.4) + childprocess (0.3.1) + ffi (~> 1.0.6) + cocaine (0.2.1) + columnize (0.3.6) + deface (0.8.0) + nokogiri (~> 1.5.0) + rails (>= 3.0.9) + devise (1.4.8) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.0.3) + warden (~> 1.0.3) + diff-lcs (1.1.3) + erubis (2.7.0) + factory_girl (2.6.4) + activesupport (>= 2.3.9) + ffaker (1.12.1) + ffi (1.0.11) + highline (1.6.8) + hike (1.2.1) + i18n (0.6.0) + jquery-rails (1.0.19) + railties (~> 3.0) + thor (~> 0.14) + json (1.6.5) + kaminari (0.13.0) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) + railties (>= 3.0.0) + linecache19 (0.5.12) + ruby_core_source (>= 0.1.4) + mail (2.3.3) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + meta_search (1.1.1) + actionpack (~> 3.1.0) + activerecord (~> 3.1.0) + activesupport (~> 3.1.0) + polyamorous (~> 0.5.0) + mime-types (1.18) + money (3.7.1) + i18n (~> 0.4) + multi_json (1.1.0) + nested_set (1.6.8) + activerecord (>= 3.0.0) + railties (>= 3.0.0) + nokogiri (1.5.2) + orm_adapter (0.0.6) + paperclip (2.5.0) + activerecord (>= 2.3.0) + activesupport (>= 2.3.2) + cocaine (>= 0.0.2) + mime-types + polyamorous (0.5.0) + activerecord (~> 3.0) + polyglot (0.3.3) + rack (1.3.6) + rack-cache (1.2) + rack (>= 0.4) + rack-mount (0.8.3) + rack (>= 1.0.0) + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.1.4) + actionmailer (= 3.1.4) + actionpack (= 3.1.4) + activerecord (= 3.1.4) + activeresource (= 3.1.4) + activesupport (= 3.1.4) + bundler (~> 1.0) + railties (= 3.1.4) + railties (3.1.4) + actionpack (= 3.1.4) + activesupport (= 3.1.4) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.6) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + rspec (2.9.0) + rspec-core (~> 2.9.0) + rspec-expectations (~> 2.9.0) + rspec-mocks (~> 2.9.0) + rspec-core (2.9.0) + rspec-expectations (2.9.0) + diff-lcs (~> 1.1.3) + rspec-mocks (2.9.0) + rspec-rails (2.9.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec (~> 2.9.0) + ruby-debug-base19 (0.11.25) + columnize (>= 0.3.1) + linecache19 (>= 0.5.11) + ruby_core_source (>= 0.1.4) + ruby-debug19 (0.11.6) + columnize (>= 0.3.1) + linecache19 (>= 0.5.11) + ruby-debug-base19 (>= 0.11.19) + ruby_core_source (0.1.5) + archive-tar-minitar (>= 0.5.2) + rubyzip (0.9.6.1) + selenium-webdriver (2.20.0) + childprocess (>= 0.2.5) + ffi (~> 1.0) + multi_json (~> 1.0) + rubyzip + spree (1.0.3) + spree_api (= 1.0.3) + spree_auth (= 1.0.3) + spree_cmd (= 1.0.3) + spree_core (= 1.0.3) + spree_dash (= 1.0.3) + spree_promo (= 1.0.3) + spree_sample (= 1.0.3) + spree_api (1.0.3) + spree_auth (= 1.0.3) + spree_core (= 1.0.3) + spree_auth (1.0.3) + cancan (= 1.6.7) + devise (= 1.4.8) + spree_core (= 1.0.3) + spree_cmd (1.0.3) + spree_core (1.0.3) + activemerchant (= 1.20.1) + acts_as_list (= 0.1.4) + deface (>= 0.7.2) + ffaker (~> 1.12.0) + highline (= 1.6.8) + jquery-rails (>= 1.0.18, <= 1.0.19) + kaminari (>= 0.13.0) + meta_search (= 1.1.1) + nested_set (= 1.6.8) + paperclip (= 2.5.0) + rails (>= 3.1.1, <= 3.1.4) + state_machine (= 1.1.1) + stringex (~> 1.3.0) + spree_dash (1.0.3) + spree_core (= 1.0.3) + spree_promo (1.0.3) + spree_auth (= 1.0.3) + spree_core (= 1.0.3) + spree_sample (1.0.3) + spree_core (= 1.0.3) + sprockets (2.0.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sqlite3 (1.3.5) + state_machine (1.1.1) + stringex (1.3.2) + thor (0.14.6) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.32) + warden (1.0.6) + rack (>= 1.0) + xpath (0.1.4) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + capybara (= 1.0.1) + factory_girl + ffaker + rails + rspec-rails (~> 2.7) + ruby-debug19 + spree + spree_multi_domain! + sqlite3 diff --git a/Rakefile b/Rakefile index 53c9f745..c433257c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,20 @@ -require 'rubygems' +# encoding: utf-8 +ENV['LIB_NAME'] = 'spree_multi_domain' + require 'rake' require 'rake/testtask' require 'rake/packagetask' -require 'rake/gempackagetask' +require 'rubygems/package_task' +require 'rspec/core/rake_task' +require 'spree/core/testing_support/common_rake' + +RSpec::Core::RakeTask.new + +task :default => [:spec] spec = eval(File.read('spree_multi_domain.gemspec')) -Rake::GemPackageTask.new(spec) do |p| +Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end @@ -15,4 +23,10 @@ task :release => :package do require 'rake/gemcutter' Rake::Gemcutter::Tasks.new(spec).define Rake::Task['gem:push'].invoke -end \ No newline at end of file +end + +desc "Generates a dummy app for testing" +task :test_app do + ENV['LIB_NAME'] = 'spree_multi_domain' + Rake::Task['common:test_app'].invoke +end diff --git a/Versionfile b/Versionfile index 8ce599ae..3214b0ec 100644 --- a/Versionfile +++ b/Versionfile @@ -1,5 +1,6 @@ -"0.30.x" => { :branch => "0-30-x" } -"0.40.x" => { :branch => "0-40-stable" } -"0.50.x" => { :branch => "0-40-stable" } +"1.0.x" => { :branch => "master"} +"0.70.x" => { :branch => "0-60-stable" } "0.60.x" => { :branch => "0-60-stable" } -"0.70.x" => { :branch => "master" } +"0.50.x" => { :branch => "0-40-stable" } +"0.40.x" => { :branch => "0-40-stable" } +"0.30.x" => { :branch => "0-30-x" } diff --git a/app/controllers/admin/stores_controller.rb b/app/controllers/admin/stores_controller.rb deleted file mode 100644 index 64ce7f3e..00000000 --- a/app/controllers/admin/stores_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Admin::StoresController < Admin::BaseController - resource_controller - ssl_required - - update.wants.html { redirect_to collection_url } - create.wants.html { redirect_to collection_url } - destroy.success.wants.js { render_js_for_destroy } -end diff --git a/app/controllers/products_controller_decorator.rb b/app/controllers/products_controller_decorator.rb deleted file mode 100644 index 4c9895d5..00000000 --- a/app/controllers/products_controller_decorator.rb +++ /dev/null @@ -1,12 +0,0 @@ -ProductsController.class_eval do - before_filter :can_show_product, :only => :show - - private - def can_show_product - @product ||= Product.find_by_permalink!(params[:id]) - if @product.stores.empty? || @product.stores.include?(@site) - render :file => "public/404.html", :status => 404 - end - end - -end diff --git a/app/controllers/admin/products_controller_decorator.rb b/app/controllers/spree/admin/products_controller_decorator.rb similarity index 56% rename from app/controllers/admin/products_controller_decorator.rb rename to app/controllers/spree/admin/products_controller_decorator.rb index a92f36e7..e642e575 100644 --- a/app/controllers/admin/products_controller_decorator.rb +++ b/app/controllers/spree/admin/products_controller_decorator.rb @@ -1,13 +1,9 @@ -Admin::ProductsController.class_eval do +Spree::Admin::ProductsController.class_eval do update.before :set_stores - create.before :add_to_all_stores - private def set_stores @product.store_ids = nil unless params[:product].key? :store_ids end - def add_to_all_stores - end end diff --git a/app/controllers/spree/admin/stores_controller.rb b/app/controllers/spree/admin/stores_controller.rb new file mode 100644 index 00000000..9a25d2f5 --- /dev/null +++ b/app/controllers/spree/admin/stores_controller.rb @@ -0,0 +1,3 @@ +class Spree::Admin::StoresController < Spree::Admin::ResourceController + +end diff --git a/app/controllers/spree/products_controller_decorator.rb b/app/controllers/spree/products_controller_decorator.rb new file mode 100644 index 00000000..137948db --- /dev/null +++ b/app/controllers/spree/products_controller_decorator.rb @@ -0,0 +1,12 @@ +Spree::ProductsController.class_eval do + before_filter :can_show_product, :only => :show + + private + def can_show_product + @product ||= Spree::Product.find_by_permalink!(params[:id]) + if @product.stores.empty? || @product.stores.include?(@site) + render :file => "#{::Rails.root}/public/404.html", :status => 404 + end + end + +end diff --git a/app/mailers/order_mailer.rb b/app/mailers/spree/order_mailer.rb similarity index 93% rename from app/mailers/order_mailer.rb rename to app/mailers/spree/order_mailer.rb index 9b758988..a07ab658 100644 --- a/app/mailers/order_mailer.rb +++ b/app/mailers/spree/order_mailer.rb @@ -1,4 +1,4 @@ -class OrderMailer < ActionMailer::Base +class Spree::OrderMailer < ActionMailer::Base helper "spree/base" def confirm_email(order, resend=false) diff --git a/app/mailers/shipment_mailer.rb b/app/mailers/spree/shipment_mailer.rb similarity index 89% rename from app/mailers/shipment_mailer.rb rename to app/mailers/spree/shipment_mailer.rb index a2be6a26..b749d4a1 100644 --- a/app/mailers/shipment_mailer.rb +++ b/app/mailers/spree/shipment_mailer.rb @@ -1,4 +1,4 @@ -class ShipmentMailer < ActionMailer::Base +class Spree::ShipmentMailer < ActionMailer::Base helper "spree/base" def shipped_email(shipment, resend=false) diff --git a/app/models/models_decorator.rb b/app/models/models_decorator.rb deleted file mode 100644 index f90b7347..00000000 --- a/app/models/models_decorator.rb +++ /dev/null @@ -1,22 +0,0 @@ -Product.class_eval do - has_and_belongs_to_many :stores - scope :by_store, lambda {|store| joins(:stores).where("products_stores.store_id = ?", store)} -end - -Order.class_eval do - belongs_to :store - scope :by_store, lambda { |store| where(:store_id => store.id) } -end - -Taxonomy.class_eval do - belongs_to :store -end - -Tracker.class_eval do - belongs_to :store - - def self.current(domain) - trackers = Tracker.find(:all, :conditions => {:active => true, :environment => ENV['RAILS_ENV']}) - trackers.select { |t| t.store_id == Store.current(domain).try(:id) }.first - end -end diff --git a/app/models/spree/order_decorator.rb b/app/models/spree/order_decorator.rb new file mode 100644 index 00000000..71f08906 --- /dev/null +++ b/app/models/spree/order_decorator.rb @@ -0,0 +1,4 @@ +Spree::Order.class_eval do + belongs_to :store + scope :by_store, lambda { |store| where(:store_id => store.id) } +end diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb new file mode 100644 index 00000000..63013d2f --- /dev/null +++ b/app/models/spree/product_decorator.rb @@ -0,0 +1,4 @@ +Spree::Product.class_eval do + has_and_belongs_to_many :stores, :join_table => 'spree_products_stores' + scope :by_store, lambda {|store| joins(:stores).where("spree_products_stores.store_id = ?", store)} +end diff --git a/app/models/spree/store.rb b/app/models/spree/store.rb new file mode 100644 index 00000000..8efdc87c --- /dev/null +++ b/app/models/spree/store.rb @@ -0,0 +1,21 @@ +module Spree + class Store < ActiveRecord::Base + has_and_belongs_to_many :products + has_many :taxonomies + has_many :orders + + validates_presence_of :name, :code, :domains + + scope :default, where(:default => true) + scope :by_domain, lambda { |domain| where("domains like ?", "%#{domain}%") } + + def self.current(domain = nil) + current_store = domain ? Store.by_domain(domain).first : nil + current_store || first_found_default + end + + def self.first_found_default + @cached_default ||= Store.default.first + end + end +end diff --git a/app/models/spree/taxonomy_decorator.rb b/app/models/spree/taxonomy_decorator.rb new file mode 100644 index 00000000..2bd427e2 --- /dev/null +++ b/app/models/spree/taxonomy_decorator.rb @@ -0,0 +1,3 @@ +Spree::Taxonomy.class_eval do + belongs_to :store +end diff --git a/app/models/spree/tracker_decorator.rb b/app/models/spree/tracker_decorator.rb new file mode 100644 index 00000000..70482617 --- /dev/null +++ b/app/models/spree/tracker_decorator.rb @@ -0,0 +1,7 @@ +Spree::Tracker.class_eval do + belongs_to :store + + def self.current(domain) + Spree::Tracker.where(:active => true, :environment => ENV['RAILS_ENV']).joins(:store).where("spree_stores.domains LIKE '%#{domain}%'").first + end +end diff --git a/app/models/store.rb b/app/models/store.rb deleted file mode 100644 index c6bc37dc..00000000 --- a/app/models/store.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Store < ActiveRecord::Base - has_and_belongs_to_many :products - has_many :taxonomies - has_many :orders - - validates_presence_of :name, :code, :domains - - scope :default, where(:default => true) - scope :by_domain, lambda { |domain| where("domains like ?", "%#{domain}%") } - - def self.current(domain = nil) - current_store = domain ? Store.by_domain(domain).first : nil - current_store || Store.default.first - end -end diff --git a/app/overrides/decorate_admin_configurations_index.rb b/app/overrides/decorate_admin_configurations_index.rb new file mode 100644 index 00000000..ff0e98f1 --- /dev/null +++ b/app/overrides/decorate_admin_configurations_index.rb @@ -0,0 +1,6 @@ +Deface::Override.new( + :virtual_path => "spree/admin/configurations/index", + :name => "multi_domain_admin_configurations_menu", + :insert_bottom => "[data-hook='admin_configurations_menu']", + :text => "<%= configurations_menu_item(I18n.t('stores_admin'), admin_stores_url, I18n.t('manage_stores')) %>", + :disabled => false) diff --git a/app/overrides/decorate_admin_products_form.rb b/app/overrides/decorate_admin_products_form.rb new file mode 100644 index 00000000..11d03f16 --- /dev/null +++ b/app/overrides/decorate_admin_products_form.rb @@ -0,0 +1,6 @@ +Deface::Override.new( + :virtual_path => "spree/admin/products/_form", + :name => "multi_domain_admin_product_form_meta", + :insert_bottom => "[data-hook='admin_product_form_meta']", + :partial => "spree/admin/products/stores", + :disabled => false) diff --git a/app/overrides/decorate_admin_products_index.rb b/app/overrides/decorate_admin_products_index.rb new file mode 100644 index 00000000..b8ba7a54 --- /dev/null +++ b/app/overrides/decorate_admin_products_index.rb @@ -0,0 +1,20 @@ +Deface::Override.new( + :virtual_path => "spree/admin/products/index", + :name => "multi_domain_admin_products_index_headers", + :insert_before => "[data-hook='admin_products_index_header_actions']", + :partial => "spree/admin/products/index_headers", + :disabled => false) + +Deface::Override.new( + :virtual_path => "spree/admin/products/index", + :name => "multi_domain_admin_products_index_rows", + :insert_before => "[data-hook='admin_products_index_row_actions']", + :partial => "spree/admin/products/index_rows", + :disabled => false) + +Deface::Override.new( + :virtual_path => "spree/admin/products/index", + :name => "multi_domain_admin_products_index_search", + :insert_top => "[data-hook='admin_products_index_search']", + :partial => "spree/admin/products/index_search_fields", + :disabled => false) diff --git a/app/overrides/decorate_admin_trackers_form.rb b/app/overrides/decorate_admin_trackers_form.rb new file mode 100644 index 00000000..3f7cc316 --- /dev/null +++ b/app/overrides/decorate_admin_trackers_form.rb @@ -0,0 +1,6 @@ +Deface::Override.new( + :virtual_path => "spree/admin/trackers/_form", + :name => "multi_domain_additional_tracker_fields", + :replace => "[data-hook='additional_tracker_fields']", + :partial => "spree/admin/trackers/store", + :disabled => false) diff --git a/app/overrides/decorate_admin_trackers_index.rb b/app/overrides/decorate_admin_trackers_index.rb new file mode 100644 index 00000000..b1459779 --- /dev/null +++ b/app/overrides/decorate_admin_trackers_index.rb @@ -0,0 +1,13 @@ +Deface::Override.new( + :virtual_path => "spree/admin/trackers/index", + :name => "multi_domain_admin_trackers_index_headers", + :insert_before => "[data-hook='admin_trackers_index_headers'] th:last", + :text => "<%= I18n.t(:store) %>", + :disabled => false) + +Deface::Override.new( + :virtual_path => "spree/admin/trackers/index", + :name => "multi_domain_admin_trackers_index_rows", + :insert_before => "[data-hook='admin_trackers_index_rows'] td:last", + :partial => "spree/admin/trackers/index_rows", + :disabled => false) diff --git a/app/views/admin/products/_index_search_fields.html.erb b/app/views/admin/products/_index_search_fields.html.erb deleted file mode 100644 index d2cc9cc4..00000000 --- a/app/views/admin/products/_index_search_fields.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -

-
- <%= f.select :stores_id_equals, Store.all.collect {|s| [s.name, s.id ] }, {:include_blank => true} %>

-

\ No newline at end of file diff --git a/app/views/admin/products/_index_headers.html.erb b/app/views/spree/admin/products/_index_headers.html.erb similarity index 100% rename from app/views/admin/products/_index_headers.html.erb rename to app/views/spree/admin/products/_index_headers.html.erb diff --git a/app/views/admin/products/_index_rows.html.erb b/app/views/spree/admin/products/_index_rows.html.erb similarity index 100% rename from app/views/admin/products/_index_rows.html.erb rename to app/views/spree/admin/products/_index_rows.html.erb diff --git a/app/views/spree/admin/products/_index_search_fields.html.erb b/app/views/spree/admin/products/_index_search_fields.html.erb new file mode 100644 index 00000000..20cbd6d7 --- /dev/null +++ b/app/views/spree/admin/products/_index_search_fields.html.erb @@ -0,0 +1,4 @@ +

+
+ <%= f.select :stores_id_equals, Spree::Store.all.collect {|s| [s.name, s.id ] }, {:include_blank => true} %>

+

diff --git a/app/views/admin/products/_stores.html.erb b/app/views/spree/admin/products/_stores.html.erb similarity index 100% rename from app/views/admin/products/_stores.html.erb rename to app/views/spree/admin/products/_stores.html.erb diff --git a/app/views/admin/stores/_form.html.erb b/app/views/spree/admin/stores/_form.html.erb similarity index 100% rename from app/views/admin/stores/_form.html.erb rename to app/views/spree/admin/stores/_form.html.erb diff --git a/app/views/admin/stores/edit.html.erb b/app/views/spree/admin/stores/edit.html.erb similarity index 85% rename from app/views/admin/stores/edit.html.erb rename to app/views/spree/admin/stores/edit.html.erb index 0f4e7bef..771324aa 100644 --- a/app/views/admin/stores/edit.html.erb +++ b/app/views/spree/admin/stores/edit.html.erb @@ -1,4 +1,4 @@ -<%= render :partial => 'admin/shared/configuration_menu' %> +<%= render :partial => 'spree/admin/shared/configuration_menu' %>

<%= t("editing_store") %>

<%= render "shared/error_messages", :target => @store %> diff --git a/app/views/admin/stores/index.html.erb b/app/views/spree/admin/stores/index.html.erb similarity index 92% rename from app/views/admin/stores/index.html.erb rename to app/views/spree/admin/stores/index.html.erb index 45ffd414..96f07b54 100644 --- a/app/views/admin/stores/index.html.erb +++ b/app/views/spree/admin/stores/index.html.erb @@ -1,4 +1,4 @@ -<%= render :partial => 'admin/shared/configuration_menu' %> +<%= render :partial => 'spree/admin/shared/configuration_menu' %>