radiant-shop_variants-extension 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/README +3 -0
- data/Rakefile +138 -0
- data/VERSION +1 -0
- data/app/controllers/admin/shop/products/variant_templates_controller.rb +27 -0
- data/app/controllers/admin/shop/products/variants_controller.rb +60 -0
- data/app/controllers/admin/shop/variants_controller.rb +48 -0
- data/app/models/shop_product_variant.rb +36 -0
- data/app/models/shop_variant.rb +23 -0
- data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +1 -0
- data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +1 -0
- data/app/views/admin/shop/products/edit/parts/_variants.html.haml +3 -0
- data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +6 -0
- data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +16 -0
- data/app/views/admin/shop/products/edit/shared/_variant.html.haml +10 -0
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +1 -0
- data/app/views/admin/shop/variants/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/variants/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/variants/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/variants/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/variants/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/variants/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/variants/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +3 -0
- data/app/views/admin/shop/variants/edit.html.haml +11 -0
- data/app/views/admin/shop/variants/index/_foot.html.haml +5 -0
- data/app/views/admin/shop/variants/index/_head.html.haml +2 -0
- data/app/views/admin/shop/variants/index/_variant.html.haml +9 -0
- data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +1 -0
- data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +1 -0
- data/app/views/admin/shop/variants/index.html.haml +13 -0
- data/app/views/admin/shop/variants/new.html.haml +11 -0
- data/app/views/admin/shop/variants/remove.html.haml +12 -0
- data/config/locales/en.yml +14 -0
- data/config/routes.rb +16 -0
- data/cucumber.yml +1 -0
- data/db/migrate/20101015162238_setup_shop_variants.rb +21 -0
- data/features/support/env.rb +16 -0
- data/features/support/paths.rb +14 -0
- data/lib/shop_variants/controllers/products_controller.rb +44 -0
- data/lib/shop_variants/interface/variants.rb +34 -0
- data/lib/shop_variants/models/product.rb +15 -0
- data/lib/shop_variants/tags/helpers.rb +29 -0
- data/lib/shop_variants/tags/product_variant.rb +52 -0
- data/lib/tasks/shop_variants_extension_tasks.rake +55 -0
- data/public/javascripts/admin/extensions/shop/variants/edit.js +38 -0
- data/public/stylesheets/sass/admin/extensions/shop/variants/edit.sass +0 -0
- data/radiant-shop_variants-extension.gemspec +114 -0
- data/shop_variants_extension.rb +21 -0
- data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +53 -0
- data/spec/controllers/admin/shop/products/variants_controller_spec.rb +116 -0
- data/spec/controllers/admin/shop/variants_controller_spec.rb +67 -0
- data/spec/datasets/shop_product_variants.rb +22 -0
- data/spec/datasets/shop_variants.rb +17 -0
- data/spec/lib/shop_variants/tags/helpers_spec.rb +59 -0
- data/spec/lib/shop_variants/tags/product_variant_spec.rb +175 -0
- data/spec/models/shop_product_spec.rb +15 -0
- data/spec/models/shop_product_variant_spec.rb +92 -0
- data/spec/models/shop_variant_spec.rb +32 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +23 -0
- metadata +151 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gem|
|
4
|
+
gem.name = "radiant-shop_variants-extension"
|
5
|
+
gem.summary = %Q{Shop Variants Extension for Radiant CMS}
|
6
|
+
gem.description = %Q{RadiantShop: Create variants of products, with alternative prices}
|
7
|
+
gem.email = "dk@dirkkelly.com"
|
8
|
+
gem.homepage = "http://github.com/thefrontiergroup/shop_variants"
|
9
|
+
gem.authors = ["Dirk Kelly"]
|
10
|
+
gem.add_dependency 'radiant-shop-extension'
|
11
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
12
|
+
end
|
13
|
+
Jeweler::GemcutterTasks.new
|
14
|
+
rescue LoadError
|
15
|
+
puts "Jeweler (or a dependency) not available. This is only required if you plan to package shop_variants as a gem."
|
16
|
+
end
|
17
|
+
|
18
|
+
# In rails 1.2, plugins aren't available in the path until they're loaded.
|
19
|
+
# Check to see if the rspec plugin is installed first and require
|
20
|
+
# it if it is. If not, use the gem version.
|
21
|
+
|
22
|
+
# Determine where the RSpec plugin is by loading the boot
|
23
|
+
unless defined? RADIANT_ROOT
|
24
|
+
ENV["RAILS_ENV"] = "test"
|
25
|
+
case
|
26
|
+
when ENV["RADIANT_ENV_FILE"]
|
27
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
28
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
29
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
30
|
+
else
|
31
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rake'
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
require 'rake/testtask'
|
38
|
+
|
39
|
+
rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
|
40
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
41
|
+
require 'spec/rake/spectask'
|
42
|
+
require 'cucumber'
|
43
|
+
require 'cucumber/rake/task'
|
44
|
+
|
45
|
+
# Cleanup the RADIANT_ROOT constant so specs will load the environment
|
46
|
+
Object.send(:remove_const, :RADIANT_ROOT)
|
47
|
+
|
48
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
49
|
+
|
50
|
+
task :default => :spec
|
51
|
+
task :stats => "spec:statsetup"
|
52
|
+
|
53
|
+
desc "Run all specs in spec directory"
|
54
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
55
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
56
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
57
|
+
end
|
58
|
+
|
59
|
+
task :features => 'spec:integration'
|
60
|
+
|
61
|
+
namespace :spec do
|
62
|
+
desc "Run all specs in spec directory with RCov"
|
63
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
64
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
65
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
66
|
+
t.rcov = true
|
67
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Print Specdoc for all specs"
|
71
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
72
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
73
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
74
|
+
end
|
75
|
+
|
76
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
77
|
+
desc "Run the specs under spec/#{sub}"
|
78
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
79
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
80
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "Run the Cucumber features"
|
85
|
+
Cucumber::Rake::Task.new(:integration) do |t|
|
86
|
+
t.fork = true
|
87
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
|
88
|
+
# t.feature_pattern = "#{extension_root}/features/**/*.feature"
|
89
|
+
t.profile = "default"
|
90
|
+
end
|
91
|
+
|
92
|
+
# Setup specs for stats
|
93
|
+
task :statsetup do
|
94
|
+
require 'code_statistics'
|
95
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
96
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
97
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
98
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
99
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
100
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
101
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
102
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
103
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
104
|
+
end
|
105
|
+
|
106
|
+
namespace :db do
|
107
|
+
namespace :fixtures do
|
108
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
109
|
+
task :load => :environment do
|
110
|
+
require 'active_record/fixtures'
|
111
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
112
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
113
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
desc 'Generate documentation for the shop_variants extension.'
|
121
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
122
|
+
rdoc.rdoc_dir = 'rdoc'
|
123
|
+
rdoc.title = 'ShopVariantsExtension'
|
124
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
125
|
+
rdoc.rdoc_files.include('README')
|
126
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
127
|
+
end
|
128
|
+
|
129
|
+
# For extensions that are in transition
|
130
|
+
desc 'Test the shop_variants extension.'
|
131
|
+
Rake::TestTask.new(:test) do |t|
|
132
|
+
t.libs << 'lib'
|
133
|
+
t.pattern = 'test/**/*_test.rb'
|
134
|
+
t.verbose = true
|
135
|
+
end
|
136
|
+
|
137
|
+
# Load any custom rakefiles for extension
|
138
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Admin::Shop::Products::VariantTemplatesController < Admin::ResourceController
|
2
|
+
|
3
|
+
model_class ShopVariant
|
4
|
+
|
5
|
+
def update
|
6
|
+
error = 'Could not attach all Variants to Product.'
|
7
|
+
|
8
|
+
@shop_product = ShopProduct.find(params[:product_id])
|
9
|
+
|
10
|
+
if @shop_product.apply_variant_template(@shop_variant)
|
11
|
+
respond_to do |format|
|
12
|
+
format.html {
|
13
|
+
redirect_to [ :edit_admin, @shop_product ]
|
14
|
+
}
|
15
|
+
end
|
16
|
+
else
|
17
|
+
respond_to do |format|
|
18
|
+
format.html {
|
19
|
+
flash[:error] = error
|
20
|
+
redirect_to [ :edit_admin, @shop_product ]
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Admin::Shop::Products::VariantsController < Admin::ResourceController
|
2
|
+
|
3
|
+
model_class ShopProductVariant
|
4
|
+
|
5
|
+
before_filter :find_product
|
6
|
+
|
7
|
+
def create
|
8
|
+
notice = 'Successfully created variant.'
|
9
|
+
error = 'Could not create variant.'
|
10
|
+
|
11
|
+
begin
|
12
|
+
@shop_product_variant.attributes = params[:shop_product_variant]
|
13
|
+
@shop_product_variant.save!
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html {
|
17
|
+
redirect_to edit_admin_shop_product_path(@shop_product)
|
18
|
+
}
|
19
|
+
format.js { render :partial => '/admin/shop/products/edit/shared/variant', :locals => { :variant => @shop_product_variant } }
|
20
|
+
end
|
21
|
+
rescue
|
22
|
+
respond_to do |format|
|
23
|
+
format.html {
|
24
|
+
flash[:error] = error
|
25
|
+
redirect_to edit_admin_shop_product_path(@shop_product)
|
26
|
+
}
|
27
|
+
format.js { render :text => error, :status => :unprocessable_entity }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy
|
33
|
+
notice = 'Successfully destroyed variant.'
|
34
|
+
error = 'Could not destroy variant.'
|
35
|
+
|
36
|
+
if @shop_product_variant.destroy
|
37
|
+
respond_to do |format|
|
38
|
+
format.html {
|
39
|
+
redirect_to edit_admin_shop_product_path(@shop_product)
|
40
|
+
}
|
41
|
+
format.js { render :text => notice, :status => :ok }
|
42
|
+
end
|
43
|
+
else
|
44
|
+
respond_to do |format|
|
45
|
+
format.html {
|
46
|
+
flash[:error] = error
|
47
|
+
redirect_to edit_admin_shop_product_path(@shop_product)
|
48
|
+
}
|
49
|
+
format.js { render :text => error, :status => :unprocessable_entity }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def find_product
|
57
|
+
@shop_product = @shop_product_variant.product || ShopProduct.find(params[:product_id])
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Admin::Shop::VariantsController < Admin::ResourceController
|
2
|
+
|
3
|
+
model_class ShopVariant
|
4
|
+
|
5
|
+
before_filter :config_global
|
6
|
+
before_filter :config_index, :only => [ :index ]
|
7
|
+
before_filter :config_new, :only => [ :new, :create ]
|
8
|
+
before_filter :config_edit, :only => [ :edit, :update ]
|
9
|
+
before_filter :assets_global
|
10
|
+
before_filter :assets_index, :only => [ :index ]
|
11
|
+
before_filter :assets_edit, :only => [ :edit, :update ]
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def config_global
|
16
|
+
@inputs ||= []
|
17
|
+
@meta ||= []
|
18
|
+
@buttons ||= []
|
19
|
+
@parts ||= []
|
20
|
+
@popups ||= []
|
21
|
+
|
22
|
+
@inputs << 'name'
|
23
|
+
@inputs << 'options'
|
24
|
+
end
|
25
|
+
|
26
|
+
def config_index
|
27
|
+
@buttons << 'add_variant'
|
28
|
+
@buttons << 'categories'
|
29
|
+
end
|
30
|
+
|
31
|
+
def config_new
|
32
|
+
end
|
33
|
+
|
34
|
+
def config_edit
|
35
|
+
end
|
36
|
+
|
37
|
+
def assets_global
|
38
|
+
include_stylesheet 'admin/extensions/shop/edit'
|
39
|
+
include_stylesheet 'admin/extensions/shop/index'
|
40
|
+
end
|
41
|
+
|
42
|
+
def assets_index
|
43
|
+
end
|
44
|
+
|
45
|
+
def assets_edit
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class ShopProductVariant < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :product, :class_name => 'ShopProduct', :foreign_key => :product_id
|
4
|
+
|
5
|
+
validates_presence_of :product
|
6
|
+
validates_presence_of :name
|
7
|
+
validates_uniqueness_of :name, :scope => :product_id
|
8
|
+
|
9
|
+
belongs_to :created_by, :class_name => 'User'
|
10
|
+
belongs_to :updated_by, :class_name => 'User'
|
11
|
+
|
12
|
+
has_many :line_items, :class_name => 'ShopLineItem', :foreign_key => :item_id, :dependent => :destroy
|
13
|
+
has_many :orders, :class_name => 'ShopOrder', :through => :line_items, :uniq => true
|
14
|
+
has_many :discountables, :class_name => 'ShopDiscountable', :foreign_key => :discounted_id
|
15
|
+
has_many :discounts, :class_name => 'ShopDiscount', :through => :discountables
|
16
|
+
|
17
|
+
# Returns the price of the variant plus the product price
|
18
|
+
def price
|
19
|
+
price = product.price
|
20
|
+
if read_attribute(:price).present?
|
21
|
+
price = read_attribute(:price) + product.price
|
22
|
+
end
|
23
|
+
price
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns a mixed sku of product and variant name
|
27
|
+
def sku
|
28
|
+
%{#{product.sku}-#{ShopProduct.to_sku(name)}}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns slug of the product
|
32
|
+
def slug
|
33
|
+
product.slug
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ShopVariant < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :created_by, :class_name => 'User'
|
4
|
+
belongs_to :updated_by, :class_name => 'User'
|
5
|
+
|
6
|
+
validates_presence_of :name
|
7
|
+
validates_uniqueness_of :name
|
8
|
+
validates_presence_of :options_json
|
9
|
+
|
10
|
+
def options
|
11
|
+
options = {}
|
12
|
+
if self.options_json.present?
|
13
|
+
options = ActiveSupport::JSON.decode(self.options_json)
|
14
|
+
options = Forms::Config.deep_symbolize_keys(options)
|
15
|
+
end
|
16
|
+
options
|
17
|
+
end
|
18
|
+
|
19
|
+
def options=(options)
|
20
|
+
self.options_json = ActiveSupport::JSON.encode(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
= link_to t('apply_template'), '#browse_templates_popup', :class => 'popup button'
|
@@ -0,0 +1 @@
|
|
1
|
+
= link_to "#{image('plus')} #{t('new_variant')}", '#new_variant_popup', :class => 'popup button'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
%h3.title New Variant
|
2
|
+
|
3
|
+
.popup_content
|
4
|
+
- form_for :shop_product_variant, :url => admin_shop_product_variants_path(@shop_product.id) do |f|
|
5
|
+
= f.hidden_field :product_id, :value => @shop_product.id
|
6
|
+
%ol
|
7
|
+
%li.name
|
8
|
+
= f.label :name
|
9
|
+
= f.text_field :name
|
10
|
+
%li.price
|
11
|
+
= f.label :price, t('price_variation')
|
12
|
+
= f.text_field :price
|
13
|
+
%li.submit
|
14
|
+
= f.submit 'Create'
|
15
|
+
|
16
|
+
%a#new_variant_popup.close{ :href => '#new_variant_popup' }
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%li.variant{ :id => "product_#{@shop_product.id}_variant_#{vf.object.id}", :'data-variant_id' => vf.object.id }
|
2
|
+
%span.name
|
3
|
+
= vf.text_field :name
|
4
|
+
%span.price
|
5
|
+
= vf.label :price, '$'
|
6
|
+
= vf.text_field :price, :value => input_currency(vf.object.read_attribute(:price))
|
7
|
+
%span.value
|
8
|
+
= number_to_currency(vf.object.price)
|
9
|
+
%span.actions
|
10
|
+
%span.delete
|
@@ -0,0 +1 @@
|
|
1
|
+
= link_to t("variants"), admin_shop_variants_path
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- render_region :foot do |foot|
|
2
|
+
- foot.buttons do
|
3
|
+
%p.buttons
|
4
|
+
= save_model_button(@shop_variant)
|
5
|
+
= save_model_and_continue_editing_button(@shop_variant)
|
6
|
+
= t('or')
|
7
|
+
= link_to t('cancel'), admin_shop_variants_path
|
8
|
+
- foot.timestamp do
|
9
|
+
= updated_stamp @shop_variant
|
@@ -0,0 +1,13 @@
|
|
1
|
+
- form_for [:admin, @shop_variant], :html => {'data-onsubmit_status'=>"Saving Changes…"} do |f|
|
2
|
+
- render_region :form do |form|
|
3
|
+
- form.inputs do
|
4
|
+
= render :partial => '/admin/shop/variants/edit/inputs', :locals => { :f => f }
|
5
|
+
|
6
|
+
- form.meta do
|
7
|
+
= render :partial => '/admin/shop/variants/edit/meta', :locals => { :f => f }
|
8
|
+
|
9
|
+
- form.parts do
|
10
|
+
= render :partial => '/admin/shop/variants/edit/parts', :locals => { :f => f }
|
11
|
+
|
12
|
+
- form.foot do
|
13
|
+
= render :partial => 'admin/shop/variants/edit/foot', :locals => { :f => f }
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- if @meta.present?
|
2
|
+
.drawer
|
3
|
+
.drawer_contents#attributes
|
4
|
+
%table.fieldset
|
5
|
+
- @meta.each do |meta|
|
6
|
+
= render :partial => "admin/shop/variants/edit/meta/#{meta}", :locals => { :f => f }
|
7
|
+
.drawer_handle
|
8
|
+
%a.toggle{:href=>'#attributes', :rel=>"toggle[attributes]", :class=>"#{(meta_errors? ? 'less' : 'more')}"}= meta_label
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#tab_control
|
2
|
+
#tabs.tabs
|
3
|
+
#tab_toolbar
|
4
|
+
#pages.pages
|
5
|
+
= hidden_field_tag 'page_part_index_field' #important
|
6
|
+
- @parts.each do |part|
|
7
|
+
.page{:id => "variant_page_#{part}", 'data-caption'=>h(part)}
|
8
|
+
.part{:id => "variant_part_#{part}"}
|
9
|
+
= render :partial => "admin/shop/variants/edit/parts/#{part}", :locals => { :f => f }
|
@@ -0,0 +1,11 @@
|
|
1
|
+
- @page_title = @shop_variant.name
|
2
|
+
|
3
|
+
- render_region :main do |main|
|
4
|
+
- main.head do
|
5
|
+
= render 'admin/shop/variants/edit/head'
|
6
|
+
|
7
|
+
- main.popups do
|
8
|
+
= render 'admin/shop/variants/edit/popups'
|
9
|
+
|
10
|
+
- main.form do
|
11
|
+
= render 'admin/shop/variants/edit/form'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
%li.variant.object{:id => "variant_#{variant.id}", :'data-id' => variant.id}
|
2
|
+
.attributes
|
3
|
+
%span.name.attribute
|
4
|
+
- render_region :body do |body|
|
5
|
+
- body.name do
|
6
|
+
%span.name.attribute= link_to variant.name, edit_admin_shop_variant_path(variant)
|
7
|
+
- body.modify do
|
8
|
+
.modify
|
9
|
+
%span.remove= link_to t('remove'), remove_admin_shop_variant_path(variant)
|
@@ -0,0 +1 @@
|
|
1
|
+
= link_to image('plus') + " " + t("add_variant"), new_admin_shop_variant_path
|
@@ -0,0 +1 @@
|
|
1
|
+
= link_to t("products"), admin_shop_products_path
|
@@ -0,0 +1,13 @@
|
|
1
|
+
- @page_title = t('variants') + ' - ' + default_page_title
|
2
|
+
|
3
|
+
.outset
|
4
|
+
|
5
|
+
#head.min
|
6
|
+
= render :partial => '/admin/shop/variants/index/head'
|
7
|
+
|
8
|
+
#variants_map.map
|
9
|
+
%ul#variants
|
10
|
+
= render :partial => '/admin/shop/variants/index/variant', :collection => @shop_variants
|
11
|
+
|
12
|
+
#actions
|
13
|
+
= render :partial => '/admin/shop/variants/index/foot'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%h1
|
2
|
+
= t('remove_variant')
|
3
|
+
|
4
|
+
%p
|
5
|
+
= t('text.remove_variant.warning')
|
6
|
+
|
7
|
+
- form_for [:admin, @shop_variant.becomes(ShopVariant)], :html => {:method => :delete, 'data-onsubmit_status'=>"Removing Variant…"} do
|
8
|
+
|
9
|
+
%p.buttons
|
10
|
+
%input.button{:type=>"submit", :value => t('delete_variant') }/
|
11
|
+
= t('or')
|
12
|
+
= link_to t('cancel'), admin_shop_variants_path
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
shop variants: Shop Variants
|
4
|
+
variants: Variants
|
5
|
+
add_variant: Add Variant
|
6
|
+
new_variant: New Variant
|
7
|
+
options: Options
|
8
|
+
remove_variant: Remove Variant
|
9
|
+
text:
|
10
|
+
remove_variant:
|
11
|
+
warning: Removing a variant is irreversible
|
12
|
+
delete_variant: Delete Variant
|
13
|
+
price_variation: Price Variant
|
14
|
+
apply_template: Apply Template
|
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
|
3
|
+
|
4
|
+
map.namespace :admin do |admin|
|
5
|
+
admin.namespace :shop, :member => { :remove => :get } do |shop|
|
6
|
+
|
7
|
+
shop.resources :products, :except => :new, :collection => { :sort => :put } do |product|
|
8
|
+
product.resources :variants, :controller => 'products/variants', :only => [ :create, :destroy]
|
9
|
+
product.resources :variant_templates, :controller => 'products/variant_templates', :only => [ :update ]
|
10
|
+
end
|
11
|
+
shop.resources :variants
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --format progress features --tags ~@proposed,~@in_progress
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class SetupShopVariants < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "shop_variants", :force => true do |t|
|
4
|
+
t.string "name"
|
5
|
+
t.text "options_json"
|
6
|
+
t.integer "created_by_id"
|
7
|
+
t.integer "updated_by_id"
|
8
|
+
t.datetime "created_at"
|
9
|
+
t.datetime "updated_at"
|
10
|
+
end
|
11
|
+
|
12
|
+
create_table "shop_product_variants", :force => true do |t|
|
13
|
+
t.string "name"
|
14
|
+
t.decimal "price"
|
15
|
+
t.integer "product_id"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Sets up the Rails environment for Cucumber
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
# Extension root
|
4
|
+
extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
|
5
|
+
require extension_env+'.rb'
|
6
|
+
|
7
|
+
Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step}
|
8
|
+
|
9
|
+
Cucumber::Rails::World.class_eval do
|
10
|
+
include Dataset
|
11
|
+
datasets_directory "#{RADIANT_ROOT}/spec/datasets"
|
12
|
+
Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets')
|
13
|
+
self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
|
14
|
+
|
15
|
+
# dataset :shop_variants
|
16
|
+
end
|