radiant-shop-extension 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/VERSION +1 -1
- data/app/controllers/admin/shop/categories_controller.rb +32 -65
- data/app/controllers/admin/shop/customers_controller.rb +8 -7
- data/app/controllers/admin/shop/orders_controller.rb +37 -159
- data/app/controllers/admin/shop/packages/packings_controller.rb +90 -0
- data/app/controllers/admin/shop/packages_controller.rb +65 -0
- data/app/controllers/admin/shop/products/images_controller.rb +5 -8
- 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/products_controller.rb +67 -64
- data/app/controllers/admin/shop/variants_controller.rb +49 -0
- data/app/helpers/shop_helper.rb +5 -0
- data/app/models/form_address.rb +144 -0
- data/app/models/form_checkout.rb +200 -307
- data/app/models/form_line_item.rb +60 -0
- data/app/models/shop_address.rb +2 -2
- data/app/models/shop_category.rb +48 -51
- data/app/models/shop_customer.rb +25 -5
- data/app/models/shop_group.rb +15 -0
- data/app/models/shop_grouping.rb +6 -0
- data/app/models/shop_line_item.rb +7 -6
- data/app/models/shop_order.rb +44 -16
- data/app/models/shop_package.rb +74 -0
- data/app/models/shop_packing.rb +22 -0
- data/app/models/shop_page.rb +7 -0
- data/app/models/shop_payment.rb +5 -1
- data/app/models/shop_product.rb +86 -48
- data/app/models/shop_product_attachment.rb +5 -2
- data/app/models/shop_product_variant.rb +31 -0
- data/app/models/shop_variant.rb +25 -0
- data/app/views/admin/shop/categories/edit.html.haml +9 -10
- data/app/views/admin/shop/categories/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/categories/edit/_form.html.haml +14 -0
- data/app/views/admin/shop/categories/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/categories/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/categories/edit/_meta.html.haml +8 -7
- data/app/views/admin/shop/categories/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/categories/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/categories/edit/inputs/_name.html.haml +4 -0
- data/app/views/admin/shop/categories/edit/meta/_handle.html.haml +6 -5
- data/app/views/admin/shop/categories/edit/meta/_layouts.html.haml +6 -5
- data/app/views/admin/shop/categories/edit/meta/_page.html.haml +3 -0
- data/app/views/admin/shop/categories/edit/parts/_description.html.haml +4 -1
- data/app/views/admin/shop/categories/index/_category.html.haml +11 -10
- data/app/views/admin/shop/categories/new.html.haml +10 -9
- data/app/views/admin/shop/customers/edit.html.haml +8 -10
- data/app/views/admin/shop/customers/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/customers/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/customers/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/customers/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/customers/edit/_parts.html.haml +9 -4
- data/app/views/admin/shop/customers/edit/inputs/_email.html.haml +3 -0
- data/app/views/admin/shop/customers/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/customers/edit/parts/_orders.html.haml +10 -6
- data/app/views/admin/shop/customers/index.html.haml +4 -1
- data/app/views/admin/shop/customers/index/_customer.html.haml +3 -3
- data/app/views/admin/shop/customers/index/_foot.html.haml +4 -0
- data/app/views/admin/shop/customers/index/_head.html.haml +4 -0
- data/app/views/admin/shop/customers/new.html.haml +9 -9
- data/app/views/admin/shop/orders/edit.html.haml +11 -0
- data/app/views/admin/shop/orders/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/orders/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/orders/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/orders/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/orders/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/orders/edit/parts/_address.html.haml +7 -0
- data/app/views/admin/shop/orders/edit/parts/_addresses.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/parts/_customer.html.haml +3 -0
- data/app/views/admin/shop/orders/edit/parts/_items.html.haml +8 -0
- data/app/views/admin/shop/orders/index.html.haml +10 -30
- data/app/views/admin/shop/orders/index/_foot.html.haml +3 -0
- data/app/views/admin/shop/orders/index/_head.html.haml +4 -0
- data/app/views/admin/shop/orders/index/_order.html.haml +13 -0
- data/app/views/admin/shop/orders/index/buttons/_all.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_new.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_paid.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_shipped.html.haml +1 -0
- data/app/views/admin/shop/packages/edit.html.haml +11 -0
- data/app/views/admin/shop/packages/edit/_foot.html.haml +17 -0
- data/app/views/admin/shop/packages/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/packages/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/packages/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/packages/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/packages/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/packages/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +1 -0
- data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +5 -0
- data/app/views/admin/shop/packages/edit/parts/_description.html.haml +1 -0
- data/app/views/admin/shop/packages/edit/parts/_products.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +7 -0
- data/app/views/admin/shop/packages/edit/shared/_product.html.haml +8 -0
- data/app/views/admin/shop/packages/index.html.haml +13 -0
- data/app/views/admin/shop/packages/index/_foot.html.haml +7 -0
- data/app/views/admin/shop/packages/index/_head.html.haml +4 -0
- data/app/views/admin/shop/packages/index/_package.html.haml +9 -0
- data/app/views/admin/shop/packages/new.html.haml +11 -0
- data/app/views/admin/shop/packages/remove.html.haml +12 -0
- data/app/views/admin/shop/products/edit.html.haml +9 -12
- data/app/views/admin/shop/products/edit/_foot.html.haml +19 -0
- data/app/views/admin/shop/products/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/products/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/products/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/products/edit/_meta.html.haml +8 -8
- data/app/views/admin/shop/products/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/products/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/products/edit/buttons/_browse_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +1 -0
- data/app/views/admin/shop/products/edit/buttons/_new_image.html.haml +1 -1
- data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +1 -0
- data/app/views/admin/shop/products/edit/inputs/_name.html.haml +4 -0
- data/app/views/admin/shop/products/edit/inputs/_price.html.haml +3 -0
- data/app/views/admin/shop/products/edit/meta/_category.html.haml +6 -5
- data/app/views/admin/shop/products/edit/meta/_page.html.haml +2 -0
- data/app/views/admin/shop/products/edit/meta/_sku.html.haml +6 -5
- data/app/views/admin/shop/products/edit/parts/_customers.html.haml +5 -0
- data/app/views/admin/shop/products/edit/parts/_description.html.haml +4 -1
- data/app/views/admin/shop/products/edit/parts/_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/parts/_variants.html.haml +3 -0
- data/app/views/admin/shop/products/edit/popups/_browse_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +6 -0
- data/app/views/admin/shop/products/edit/popups/_new_image.html.haml +4 -4
- data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +16 -0
- data/app/views/admin/shop/products/edit/{_image.html.haml → shared/_image.html.haml} +0 -0
- data/app/views/admin/shop/products/edit/shared/_template.html.haml +6 -0
- data/app/views/admin/shop/products/edit/shared/_variant.html.haml +10 -0
- data/app/views/admin/shop/products/index.html.haml +6 -3
- data/app/views/admin/shop/products/index/_foot.html.haml +10 -0
- data/app/views/admin/shop/products/index/_head.html.haml +4 -0
- data/app/views/admin/shop/products/index/_product.html.haml +18 -10
- data/app/views/admin/shop/products/index/buttons/_discounts.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_packages.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +1 -0
- data/app/views/admin/shop/products/new.html.haml +10 -9
- data/app/views/admin/shop/variants/edit.html.haml +11 -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/index.html.haml +13 -0
- data/app/views/admin/shop/variants/index/_foot.html.haml +4 -0
- data/app/views/admin/shop/variants/index/_head.html.haml +4 -0
- data/app/views/admin/shop/variants/index/_variant.html.haml +9 -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 +8 -1
- data/config/routes.rb +11 -22
- data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +101 -0
- data/db/migrate/20100929011607_drop_shop_addressables.rb +25 -0
- data/db/migrate/20100929030510_create_shop_groups.rb +19 -0
- data/db/migrate/20100929080301_shop_groups_change_add_description.rb +11 -0
- data/db/migrate/20100929081200_create_variants.rb +20 -0
- data/db/migrate/20100929143531_change_variants_add_updated_by.rb +25 -0
- data/db/migrate/20100929145641_change_created_by_to_id.rb +75 -0
- data/db/migrate/20100929235221_change_category_add_variant_id.rb +9 -0
- data/db/migrate/20100930235221_create_packages.rb +31 -0
- data/db/migrate/20101005231713_create_page_ids.rb +11 -0
- data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +73 -0
- data/db/migrate/20101007111845_add_default_position_to_attachment.rb +9 -0
- data/lib/shop/controllers/application_controller.rb +1 -1
- data/lib/shop/interface/categories.rb +29 -0
- data/lib/shop/interface/customers.rb +15 -15
- data/lib/shop/interface/orders.rb +34 -0
- data/lib/shop/interface/packages.rb +34 -0
- data/lib/shop/interface/products.rb +18 -31
- data/lib/shop/interface/variants.rb +34 -0
- data/lib/shop/models/form_extension.rb +23 -0
- data/lib/shop/models/page.rb +3 -2
- data/lib/shop/tags/address.rb +3 -3
- data/lib/shop/tags/cart.rb +12 -16
- data/lib/shop/tags/category.rb +4 -6
- data/lib/shop/tags/helpers.rb +131 -30
- data/lib/shop/tags/item.rb +16 -33
- data/lib/shop/tags/package.rb +95 -0
- data/lib/shop/tags/product.rb +11 -16
- data/lib/shop/tags/product_variant.rb +52 -0
- data/mockups/discounts/new-edit.bmml +492 -0
- data/public/javascripts/admin/extensions/shop/edit.js +20 -0
- data/public/javascripts/admin/extensions/shop/packages/edit.js +109 -0
- data/public/javascripts/admin/extensions/shop/products/edit.js +64 -65
- data/public/javascripts/admin/extensions/shop/products/index.js +31 -36
- data/public/stylesheets/sass/admin/extensions/shop/edit.sass +58 -11
- data/public/stylesheets/sass/admin/extensions/shop/index.sass +104 -53
- data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +162 -0
- data/public/stylesheets/sass/admin/extensions/shop/products/edit.sass +115 -36
- data/public/stylesheets/sass/admin/extensions/shop/products/index.sass +12 -20
- data/radiant-shop-extension.gemspec +182 -38
- data/shop_extension.rb +29 -25
- data/spec/controllers/admin/shop/categories_controller_spec.rb +76 -191
- data/spec/controllers/admin/shop/customers_controller_spec.rb +67 -0
- data/spec/controllers/admin/shop/orders_controller_spec.rb +85 -0
- data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +188 -0
- data/spec/controllers/admin/shop/packages_controller_spec.rb +32 -0
- data/spec/controllers/admin/shop/products/images_controller_spec.rb +10 -15
- 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/products_controller_spec.rb +80 -148
- data/spec/controllers/admin/shop/variants_controller_spec.rb +67 -0
- data/spec/datasets/forms.rb +23 -8
- data/spec/datasets/shop_addresses.rb +1 -4
- data/spec/datasets/shop_categories.rb +25 -4
- data/spec/datasets/shop_groups.rb +15 -0
- data/spec/datasets/shop_line_items.rb +4 -3
- data/spec/datasets/shop_orders.rb +6 -15
- data/spec/datasets/shop_packages.rb +25 -0
- data/spec/datasets/shop_payments.rb +12 -0
- data/spec/datasets/{images.rb → shop_product_attachments.rb} +9 -1
- data/spec/datasets/shop_product_variants.rb +22 -0
- data/spec/datasets/shop_products.rb +28 -18
- data/spec/datasets/shop_variants.rb +17 -0
- data/spec/lib/shop/models/image_spec.rb +4 -4
- data/spec/lib/shop/tags/address_spec.rb +3 -3
- data/spec/lib/shop/tags/cart_spec.rb +32 -43
- data/spec/lib/shop/tags/category_spec.rb +58 -93
- data/spec/lib/shop/tags/helpers_spec.rb +162 -69
- data/spec/lib/shop/tags/item_spec.rb +116 -158
- data/spec/lib/shop/tags/package_spec.rb +342 -0
- data/spec/lib/shop/tags/product_spec.rb +29 -26
- data/spec/lib/shop/tags/product_variant_spec.rb +175 -0
- data/spec/models/form_address_spec.rb +166 -0
- data/spec/models/form_checkout_spec.rb +27 -157
- data/spec/models/shop_address_spec.rb +81 -0
- data/spec/models/shop_category_spec.rb +114 -31
- data/spec/models/shop_customer_spec.rb +105 -0
- data/spec/models/shop_group_spec.rb +38 -0
- data/spec/models/shop_line_item_spec.rb +5 -5
- data/spec/models/shop_order_spec.rb +89 -83
- data/spec/models/shop_package_spec.rb +117 -0
- data/spec/models/shop_packing_spec.rb +67 -0
- data/spec/models/shop_payment_spec.rb +19 -0
- data/spec/models/shop_product_attachment_spec.rb +4 -3
- data/spec/models/shop_product_spec.rb +171 -92
- data/spec/models/shop_product_variant_spec.rb +92 -0
- data/spec/models/shop_variant_spec.rb +47 -0
- metadata +183 -39
- data/app/controllers/shop/categories_controller.rb +0 -45
- data/app/controllers/shop/line_items_controller.rb +0 -165
- data/app/controllers/shop/orders_controller.rb +0 -16
- data/app/controllers/shop/products_controller.rb +0 -48
- data/app/models/shop_addressable.rb +0 -11
- data/app/views/admin/shop/categories/edit/_fields.html.haml +0 -28
- data/app/views/admin/shop/categories/edit/_part.html.haml +0 -3
- data/app/views/admin/shop/categories/edit/_popup.html.haml +0 -3
- data/app/views/admin/shop/customers/edit/_fields.html.haml +0 -33
- data/app/views/admin/shop/customers/index/_bottom.html.haml +0 -4
- data/app/views/admin/shop/products/edit/_fields.html.haml +0 -38
- data/app/views/admin/shop/products/edit/_part.html.haml +0 -3
- data/app/views/admin/shop/products/edit/_popup.html.haml +0 -3
- data/app/views/admin/shop/products/index/_bottom.html.haml +0 -5
- data/spec/controllers/shop/categories_controller_spec.rb +0 -42
- data/spec/controllers/shop/line_items_controller_spec.rb +0 -256
- data/spec/controllers/shop/orders_controller_specs.rb +0 -37
- data/spec/controllers/shop/products_controller_spec.rb +0 -51
- data/vendor/plugins/json_fields/.gitignore +0 -3
- data/vendor/plugins/json_fields/MIT-LICENSE +0 -20
- data/vendor/plugins/json_fields/README.rdoc +0 -65
- data/vendor/plugins/json_fields/Rakefile +0 -55
- data/vendor/plugins/json_fields/init.rb +0 -2
- data/vendor/plugins/json_fields/lib/json_fields.rb +0 -99
- data/vendor/plugins/json_fields/spec/lib/json_fields_spec.rb +0 -124
- data/vendor/plugins/json_fields/spec/spec.opts +0 -6
- data/vendor/plugins/json_fields/spec/spec_helper.rb +0 -29
- data/vendor/plugins/json_fields/spec/test_models.rb +0 -12
@@ -1,45 +0,0 @@
|
|
1
|
-
class Shop::CategoriesController < ApplicationController
|
2
|
-
|
3
|
-
skip_before_filter :verify_authenticity_token
|
4
|
-
no_login_required
|
5
|
-
|
6
|
-
radiant_layout Radiant::Config['shop.category_layout']
|
7
|
-
|
8
|
-
rescue_from ActiveRecord::RecordNotFound do |exception|
|
9
|
-
render :template => 'site/not_found', :status => :unprocessable_entity
|
10
|
-
end
|
11
|
-
|
12
|
-
# GET /shop/categories/:query
|
13
|
-
# GET /shop/categories/:query.js
|
14
|
-
# GET /shop/categories/:query.json AJAX and HTML
|
15
|
-
#----------------------------------------------------------------------------
|
16
|
-
def index
|
17
|
-
@shop_categories = ShopCategory.search(params[:query])
|
18
|
-
|
19
|
-
respond_to do |format|
|
20
|
-
format.html { render }
|
21
|
-
format.js { render :partial => '/shop/categories/categories', :collection => @shop_categories }
|
22
|
-
format.json { render :json => @shop_categories.to_json(ShopCategory.params) }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# GET /shop/:handle
|
27
|
-
# GET /shop/:handle.js
|
28
|
-
# GET /shop/:handle.json AJAX and HTML
|
29
|
-
#----------------------------------------------------------------------------
|
30
|
-
def show
|
31
|
-
if @shop_category = ShopCategory.find(:first, :conditions => { :handle => params[:handle] })
|
32
|
-
@title = @shop_category.name
|
33
|
-
@radiant_layout = @shop_category.layout.name rescue (raise "Couldn't find Layout with id #{@shop_category.layout_id}")
|
34
|
-
|
35
|
-
respond_to do |format|
|
36
|
-
format.html { render }
|
37
|
-
format.js { render :partial => '/shop/categories/category', :locals => { :category => @shop_category } }
|
38
|
-
format.json { render :json => @shop_category.to_json(ShopCategory.params) }
|
39
|
-
end
|
40
|
-
else
|
41
|
-
raise ActiveRecord::RecordNotFound
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
@@ -1,165 +0,0 @@
|
|
1
|
-
class Shop::LineItemsController < ApplicationController
|
2
|
-
|
3
|
-
no_login_required
|
4
|
-
skip_before_filter :verify_authenticity_token
|
5
|
-
|
6
|
-
# GET /shop/line_items
|
7
|
-
# GET /shop/line_items.js
|
8
|
-
# GET /shop/line_items.json AJAX and HTML
|
9
|
-
#----------------------------------------------------------------------------
|
10
|
-
def index
|
11
|
-
attr_hash = {
|
12
|
-
:include => :product,
|
13
|
-
:only => ShopLineItem.params
|
14
|
-
}
|
15
|
-
|
16
|
-
@shop_line_items = find_or_create_shop_order.line_items.all
|
17
|
-
|
18
|
-
respond_to do |format|
|
19
|
-
format.html { render :index }
|
20
|
-
format.js { render :partial => '/shop/line_items/line_item', :collection => @shop_line_items }
|
21
|
-
format.json { render :json => @shop_line_items.to_json(attr_hash) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# GET /shop/line_items/1
|
26
|
-
# GET /shop/line_items/1.js
|
27
|
-
# GET /shop/line_items/1.json AJAX and HTML
|
28
|
-
#----------------------------------------------------------------------------
|
29
|
-
def show
|
30
|
-
attr_hash = {
|
31
|
-
:include => :product,
|
32
|
-
:only => ShopLineItem.params
|
33
|
-
}
|
34
|
-
|
35
|
-
@shop_line_item = find_or_create_shop_order.line_items.find(params[:id])
|
36
|
-
|
37
|
-
respond_to do |format|
|
38
|
-
format.html { render :show }
|
39
|
-
format.js { render :partial => '/shop/line_items/line_item', :locals => { :line_item => @shop_line_item } }
|
40
|
-
format.json { render :json => @shop_line_item.to_json(attr_hash) }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# POST /shop/line_items/1
|
45
|
-
# POST /shop/line_items/1.js
|
46
|
-
# POST /shop/line_items/1.xml
|
47
|
-
# POST /shop/line_items/1.json AJAX and HTML
|
48
|
-
#----------------------------------------------------------------------------
|
49
|
-
def create
|
50
|
-
notice = 'Item added to Cart.'
|
51
|
-
error = 'Could not add Item to Cart.'
|
52
|
-
|
53
|
-
attr_hash = {
|
54
|
-
:include => :item,
|
55
|
-
:only => ShopLineItem.params
|
56
|
-
}
|
57
|
-
|
58
|
-
begin
|
59
|
-
id = params[:line_item][:item_id]
|
60
|
-
type = params[:line_item][:item_type]
|
61
|
-
quantity = params[:line_item][:quantity]
|
62
|
-
|
63
|
-
@shop_line_item = find_or_create_shop_order.add!(id, quantity, type)
|
64
|
-
|
65
|
-
respond_to do |format|
|
66
|
-
format.html {
|
67
|
-
flash[:notice] = notice
|
68
|
-
redirect_to :back
|
69
|
-
}
|
70
|
-
format.js { render :partial => '/shop/line_items/line_item', :locals => { :line_item => @shop_line_item } }
|
71
|
-
format.json { render :json => @shop_line_item.to_json(attr_hash) }
|
72
|
-
end
|
73
|
-
rescue Exception => e
|
74
|
-
raise e.inspect if RAILS_ENV['development']
|
75
|
-
|
76
|
-
respond_to do |format|
|
77
|
-
format.html {
|
78
|
-
flash[:error] = error
|
79
|
-
redirect_to :back
|
80
|
-
}
|
81
|
-
format.js { render :text => error, :status => :unprocessable_entity }
|
82
|
-
format.json { render :json => { :error => error }, :status => :unprocessable_entity }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# PUT /shop/line_items/1
|
88
|
-
# PUT /shop/line_items/1.js
|
89
|
-
# PUT /shop/line_items/1.xml
|
90
|
-
# PUT /shop/line_items/1.json AJAX and HTML
|
91
|
-
#----------------------------------------------------------------------------
|
92
|
-
def update
|
93
|
-
notice = 'Item updated successfully.'
|
94
|
-
error = 'Could not update Item.'
|
95
|
-
|
96
|
-
attr_hash = {
|
97
|
-
:include => :product,
|
98
|
-
:only => ShopLineItem.params
|
99
|
-
}
|
100
|
-
|
101
|
-
begin
|
102
|
-
id = params[:line_item][:id]
|
103
|
-
|
104
|
-
quantity = params[:line_item][:quantity] || 1
|
105
|
-
|
106
|
-
@shop_line_item = find_or_create_shop_order.update!(id, quantity)
|
107
|
-
|
108
|
-
respond_to do |format|
|
109
|
-
format.html {
|
110
|
-
flash[:notice] = notice
|
111
|
-
redirect_to :back
|
112
|
-
}
|
113
|
-
format.js { render :partial => '/shop/line_items/line_item', :locals => { :line_item => @shop_line_item } }
|
114
|
-
format.json { render :json => @shop_line_item.to_json(attr_hash) }
|
115
|
-
end
|
116
|
-
rescue Exception => e
|
117
|
-
raise e.inspect if RAILS_ENV['development']
|
118
|
-
|
119
|
-
respond_to do |format|
|
120
|
-
format.html {
|
121
|
-
flash[:error] = error
|
122
|
-
redirect_to :back
|
123
|
-
}
|
124
|
-
format.js { render :text => error, :status => :unprocessable_entity }
|
125
|
-
format.json { render :json => { :error => error }, :status => :unprocessable_entity }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# DELETE /shop/line_items/1
|
131
|
-
# DELETE /shop/line_items/1.js
|
132
|
-
# DELETE /shop/line_items/1.xml
|
133
|
-
# DELETE /shop/line_items/1.json AJAX and HTML
|
134
|
-
#----------------------------------------------------------------------------
|
135
|
-
def destroy
|
136
|
-
notice = 'Item removed from Cart.'
|
137
|
-
error = 'Could not remove Item from Cart.'
|
138
|
-
|
139
|
-
begin
|
140
|
-
# Expects the product it, not the line item
|
141
|
-
find_or_create_shop_order.remove!(params[:id])
|
142
|
-
|
143
|
-
respond_to do |format|
|
144
|
-
format.html {
|
145
|
-
flash[:notice] = notice
|
146
|
-
redirect_to :back
|
147
|
-
}
|
148
|
-
format.js { render :text => notice, :status => :ok }
|
149
|
-
format.json { render :json => { :notice => notice }, :status => :ok }
|
150
|
-
end
|
151
|
-
rescue Exception => e
|
152
|
-
raise e.inspect if RAILS_ENV['development']
|
153
|
-
|
154
|
-
respond_to do |format|
|
155
|
-
format.html {
|
156
|
-
flash[:error] = error
|
157
|
-
redirect_to :back
|
158
|
-
}
|
159
|
-
format.js { render :text => error, :status => :unprocessable_entity }
|
160
|
-
format.json { render :json => { :error => error }, :status => :unprocessable_entity }
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Shop::OrdersController < ApplicationController
|
2
|
-
|
3
|
-
no_login_required
|
4
|
-
|
5
|
-
def finalize
|
6
|
-
@order = current_shop_order
|
7
|
-
|
8
|
-
if @order.present? and !@order.new?
|
9
|
-
request.session[:shop_order] = nil
|
10
|
-
redirect_to "/#{Radiant::Config['shop.cart_thanks_path']}"
|
11
|
-
else
|
12
|
-
redirect_to "/#{Radiant::Config['shop.cart_path']}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
class Shop::ProductsController < ApplicationController
|
2
|
-
|
3
|
-
skip_before_filter :verify_authenticity_token
|
4
|
-
no_login_required
|
5
|
-
|
6
|
-
radiant_layout Radiant::Config['shop.product_layout']
|
7
|
-
|
8
|
-
rescue_from ActiveRecord::RecordNotFound do |exception|
|
9
|
-
render :template => 'site/not_found', :status => :unprocessable_entity
|
10
|
-
end
|
11
|
-
|
12
|
-
# GET /shop/search/:query
|
13
|
-
# GET /shop/search/:query.js
|
14
|
-
# GET /shop/search/:query.json AJAX and HTML
|
15
|
-
#----------------------------------------------------------------------------
|
16
|
-
def index
|
17
|
-
@shop_products = ShopProduct.search(params[:query])
|
18
|
-
@radiant_layout = Radiant::Config['shop.category_layout']
|
19
|
-
|
20
|
-
respond_to do |format|
|
21
|
-
format.html { render }
|
22
|
-
format.js { render :partial => '/shop/products/index/product', :collection => @shop_products }
|
23
|
-
format.json { render :json => @shop_products.to_json(ShopProduct.params) }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# GET /shop/:category_handle/:handle
|
28
|
-
# GET /shop/:category_handle/:handle.js
|
29
|
-
# GET /shop/:category_handle/:handle.json AJAX and HTML
|
30
|
-
#----------------------------------------------------------------------------
|
31
|
-
def show
|
32
|
-
if @shop_product = ShopProduct.find(:first, :conditions => { :sku => params[:sku] })
|
33
|
-
@shop_category = @shop_product.category unless @shop_product.nil?
|
34
|
-
|
35
|
-
@radiant_layout = @shop_product.layout.name rescue (raise "Couldn't find Layout with id #{@shop_product.layout_id}")
|
36
|
-
@title = @shop_product.name
|
37
|
-
|
38
|
-
respond_to do |format|
|
39
|
-
format.html { render }
|
40
|
-
format.js { render :partial => '/shop/products/index/product', :locals => { :product => @shop_product } }
|
41
|
-
format.json { render :json => @shop_product.to_json(ShopProduct.params) }
|
42
|
-
end
|
43
|
-
else
|
44
|
-
raise ActiveRecord::RecordNotFound
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class ShopAddressable < ActiveRecord::Base
|
2
|
-
|
3
|
-
belongs_to :address, :polymorphic => true
|
4
|
-
belongs_to :addresser, :polymorphic => true
|
5
|
-
|
6
|
-
validates_presence_of :address_id
|
7
|
-
validates_presence_of :address_type
|
8
|
-
validates_presence_of :addresser_id
|
9
|
-
validates_presence_of :addresser_type
|
10
|
-
|
11
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
= render_region :form_top
|
2
|
-
|
3
|
-
- render_region :form do |form|
|
4
|
-
- form.edit_name do
|
5
|
-
%p.title
|
6
|
-
%label{:for => 'shop_category_name'}= t('name')
|
7
|
-
= fields.text_field :name, :class => 'textbox', :maxlenth => 255
|
8
|
-
|
9
|
-
- form.edit_extended_metadata do
|
10
|
-
= render :partial => 'admin/shop/categories/edit/meta', :locals => { :fields => fields }
|
11
|
-
|
12
|
-
- form.edit_content do
|
13
|
-
#tab_control
|
14
|
-
#tabs.tabs
|
15
|
-
#tab_toolbar
|
16
|
-
#pages.pages
|
17
|
-
= hidden_field_tag 'page_part_index_field' #important
|
18
|
-
= render :partial => 'admin/shop/categories/edit/part', :collection => @parts
|
19
|
-
|
20
|
-
- render_region :form_bottom do |form_bottom|
|
21
|
-
- form_bottom.edit_buttons do
|
22
|
-
%p.buttons{:style=>"clear: left"}
|
23
|
-
= save_model_button(@shop_category)
|
24
|
-
= save_model_and_continue_editing_button(@shop_category)
|
25
|
-
= t('or')
|
26
|
-
= link_to t('cancel'), admin_shop_products_url
|
27
|
-
- form_bottom.edit_timestamp do
|
28
|
-
= updated_stamp @shop_category
|
@@ -1,33 +0,0 @@
|
|
1
|
-
- render_region :top
|
2
|
-
|
3
|
-
- render_region :form do |form|
|
4
|
-
- form.name do
|
5
|
-
%p.title
|
6
|
-
%label{:for => 'shop_customer_name'}= t('name')
|
7
|
-
= f.text_field :name, :class => 'textbox', :maxlenth => 255
|
8
|
-
|
9
|
-
- form.email do
|
10
|
-
%p.title
|
11
|
-
%label{:for => 'shop_customer_email'}= t('email')
|
12
|
-
= f.text_field :email, :class => 'textbox', :maxlenth => 255
|
13
|
-
|
14
|
-
- form.meta do
|
15
|
-
= render :partial => '/admin/shop/customers/edit/meta', :locals => { :f => f }
|
16
|
-
|
17
|
-
- form.parts do
|
18
|
-
#tab_control
|
19
|
-
#tabs.tabs
|
20
|
-
#tab_toolbar
|
21
|
-
#pages.pages
|
22
|
-
= hidden_field_tag 'page_part_index_field' #important
|
23
|
-
= render :partial => '/admin/shop/customers/edit/parts', :locals => { :f => f }
|
24
|
-
|
25
|
-
- render_region :bottom do |bottom|
|
26
|
-
- bottom.buttons do
|
27
|
-
%p.buttons{:style=>"clear: left"}
|
28
|
-
= save_model_button(@shop_customer)
|
29
|
-
= save_model_and_continue_editing_button(@shop_customer)
|
30
|
-
= t('or')
|
31
|
-
= link_to t('cancel'), admin_shop_customers_path
|
32
|
-
- bottom.timestamp do
|
33
|
-
= updated_stamp @shop_customer
|
@@ -1,38 +0,0 @@
|
|
1
|
-
= render_region :form_top
|
2
|
-
|
3
|
-
- render_region :form do |form|
|
4
|
-
- form.edit_name do
|
5
|
-
%p.title
|
6
|
-
%label{:for => 'shop_product_name'}= t('name')
|
7
|
-
= fields.text_field :name, :class => 'textbox', :maxlenth => 255
|
8
|
-
|
9
|
-
- form.edit_price do
|
10
|
-
%p.title
|
11
|
-
%label{:for => 'shop_product_price'}= t('price')
|
12
|
-
= fields.text_field :price, :class => 'textbox', :maxlenth => 255, :value => number_to_currency(@shop_product.price, :unit => '', :delimiter => '')
|
13
|
-
|
14
|
-
- form.edit_extended_metadata do
|
15
|
-
= render :partial => '/admin/shop/products/edit/meta', :locals => { :fields => fields }
|
16
|
-
|
17
|
-
- form.edit_content do
|
18
|
-
#tab_control
|
19
|
-
#tabs.tabs
|
20
|
-
#tab_toolbar
|
21
|
-
#pages.pages
|
22
|
-
= hidden_field_tag 'page_part_index_field' #important
|
23
|
-
= render :partial => '/admin/shop/products/edit/part', :collection => @parts
|
24
|
-
|
25
|
-
- render_region :form_bottom do |form_bottom|
|
26
|
-
- form_bottom.edit_buttons do
|
27
|
-
%p.buttons{:style=>"clear: left"}
|
28
|
-
= save_model_button(@shop_product)
|
29
|
-
= save_model_and_continue_editing_button(@shop_product)
|
30
|
-
= t('or')
|
31
|
-
= link_to t('cancel'), admin_shop_products_url
|
32
|
-
- form_bottom.edit_timestamp do
|
33
|
-
= updated_stamp @shop_product
|
34
|
-
|
35
|
-
#routes{:style => 'display:none'}
|
36
|
-
|
37
|
-
= hidden_field_tag 'admin_shop_product_images_path', admin_shop_product_images_path(@shop_product)
|
38
|
-
= hidden_field_tag 'sort_admin_shop_product_images_path', sort_admin_shop_product_images_path(@shop_product)
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe Shop::CategoriesController do
|
4
|
-
before(:each) do
|
5
|
-
@shop_category = Object.new
|
6
|
-
stub(@shop_category).handle { 'a' }
|
7
|
-
stub(@shop_category).layout.stub!.name { 'Layout' }
|
8
|
-
stub(@shop_category).name { 'Bob' }
|
9
|
-
@shop_categories = []
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'index' do
|
13
|
-
it 'should expose categories list' do
|
14
|
-
mock(ShopCategory).search(nil).returns(@shop_categories)
|
15
|
-
get :index
|
16
|
-
|
17
|
-
response.should be_success
|
18
|
-
assigns(:shop_categories).should === @shop_categories
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#show' do
|
23
|
-
it 'should expose category' do
|
24
|
-
mock(ShopCategory).find(:first, :conditions => { :handle => @shop_category.handle}) { @shop_category }
|
25
|
-
|
26
|
-
get :show, :handle => @shop_category.handle
|
27
|
-
|
28
|
-
response.should be_success
|
29
|
-
assigns(:shop_category).should === @shop_category
|
30
|
-
assigns(:title).should === 'Bob'
|
31
|
-
assigns(:radiant_layout).should === 'Layout'
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should return 404 if product empty' do
|
35
|
-
mock(ShopCategory).find(:first, :conditions => { :handle => @shop_category.handle}) { false }
|
36
|
-
get :show, :handle => @shop_category.handle
|
37
|
-
|
38
|
-
response.should render_template('site/not_found')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|