refinerycms-products 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/addresses_controller.rb +22 -22
- data/app/controllers/admin/carts_controller.rb +7 -7
- data/app/controllers/admin/categories_controller.rb +50 -50
- data/app/controllers/admin/customers_controller.rb +12 -12
- data/app/controllers/admin/line_items_controller.rb +7 -7
- data/app/controllers/admin/products_controller.rb +23 -23
- data/app/controllers/carts_controller.rb +110 -110
- data/app/controllers/categories_controller.rb +32 -32
- data/app/controllers/customers_controller.rb +33 -33
- data/app/controllers/line_items_controller.rb +8 -8
- data/app/controllers/products_controller.rb +61 -61
- data/app/controllers/profiles_controller.rb +36 -36
- data/app/helpers/address_helper.rb +20 -20
- data/app/helpers/products_helper.rb +41 -33
- data/app/models/address.rb +18 -18
- data/app/models/cart.rb +54 -54
- data/app/models/category.rb +28 -28
- data/app/models/customer.rb +32 -32
- data/app/models/line_item.rb +28 -28
- data/app/models/product.rb +46 -46
- data/app/views/addresses/edit.html.erb +42 -42
- data/app/views/admin/carts/_actions.html.erb +27 -27
- data/app/views/admin/carts/_cart.html.erb +18 -18
- data/app/views/admin/carts/_carts.html.erb +1 -1
- data/app/views/admin/carts/_form.html.erb +24 -24
- data/app/views/admin/carts/_records.html.erb +17 -17
- data/app/views/admin/carts/_sortable_list.html.erb +7 -7
- data/app/views/admin/carts/edit.html.erb +1 -1
- data/app/views/admin/carts/index.html.erb +10 -10
- data/app/views/admin/carts/new.html.erb +1 -1
- data/app/views/admin/categories/_actions.html.erb +27 -27
- data/app/views/admin/categories/_categories.html.erb +1 -1
- data/app/views/admin/categories/_category.html.erb +25 -25
- data/app/views/admin/categories/_form.html.erb +49 -49
- data/app/views/admin/categories/_records.html.erb +17 -17
- data/app/views/admin/categories/_sortable_list.html.erb +10 -10
- data/app/views/admin/categories/edit.html.erb +1 -1
- data/app/views/admin/categories/index.html.erb +12 -12
- data/app/views/admin/categories/new.html.erb +1 -1
- data/app/views/admin/customers/_actions.html.erb +27 -27
- data/app/views/admin/customers/_customer.html.erb +18 -18
- data/app/views/admin/customers/_customers.html.erb +1 -1
- data/app/views/admin/customers/_form.html.erb +40 -40
- data/app/views/admin/customers/_records.html.erb +17 -17
- data/app/views/admin/customers/_sortable_list.html.erb +7 -7
- data/app/views/admin/customers/edit.html.erb +1 -1
- data/app/views/admin/customers/index.html.erb +10 -10
- data/app/views/admin/customers/new.html.erb +1 -1
- data/app/views/admin/customers/show.html.erb +59 -59
- data/app/views/admin/line_items/_actions.html.erb +27 -27
- data/app/views/admin/line_items/_form.html.erb +29 -29
- data/app/views/admin/line_items/_line_item.html.erb +18 -18
- data/app/views/admin/line_items/_line_items.html.erb +1 -1
- data/app/views/admin/line_items/_records.html.erb +17 -17
- data/app/views/admin/line_items/_sortable_list.html.erb +7 -7
- data/app/views/admin/line_items/edit.html.erb +1 -1
- data/app/views/admin/line_items/index.html.erb +10 -10
- data/app/views/admin/line_items/new.html.erb +1 -1
- data/app/views/admin/products/_actions.html.erb +42 -42
- data/app/views/admin/products/_form.html.erb +120 -120
- data/app/views/admin/products/_product.html.erb +23 -23
- data/app/views/admin/products/_products.html.erb +1 -1
- data/app/views/admin/products/_records.html.erb +17 -17
- data/app/views/admin/products/_sortable_list.html.erb +13 -13
- data/app/views/admin/products/edit.html.erb +1 -1
- data/app/views/admin/products/index.html.erb +12 -12
- data/app/views/admin/products/new.html.erb +1 -1
- data/app/views/carts/show.html.erb +56 -56
- data/app/views/categories/index.html.erb +11 -11
- data/app/views/categories/show.html.erb +33 -33
- data/app/views/customers/index.html.erb +11 -11
- data/app/views/customers/show.html.erb +52 -52
- data/app/views/line_items/index.html.erb +11 -11
- data/app/views/line_items/show.html.erb +39 -39
- data/app/views/products/index.html.erb +33 -33
- data/app/views/products/show.html.erb +65 -65
- data/app/views/profiles/_order_history.html.erb +23 -23
- data/app/views/profiles/_show_address.html.erb +3 -3
- data/app/views/profiles/account_details.html.erb +31 -31
- data/app/views/profiles/address_details.html.erb +9 -9
- data/app/views/profiles/index.html.erb +75 -75
- data/app/views/profiles/order_history_details.html.erb +39 -39
- data/config/locales/en.yml +97 -97
- data/config/locales/fr.yml +25 -25
- data/config/locales/lolcat.yml +25 -25
- data/config/locales/nb.yml +21 -21
- data/config/locales/nl.yml +21 -21
- data/config/routes.rb +58 -58
- data/lib/generators/refinerycms_products_generator.rb +5 -5
- data/lib/refinerycms-carts.rb +31 -31
- data/lib/refinerycms-categories.rb +30 -30
- data/lib/refinerycms-customers.rb +34 -34
- data/lib/refinerycms-line_items.rb +30 -30
- data/lib/refinerycms-products.rb +65 -65
- data/lib/tasks/products.rake +12 -12
- metadata +95 -98
@@ -1,32 +1,32 @@
|
|
1
|
-
class CategoriesController < ApplicationController
|
2
|
-
|
3
|
-
before_filter :find_all_categories
|
4
|
-
before_filter :find_page
|
5
|
-
|
6
|
-
def index
|
7
|
-
# you can use meta fields from your model instead (e.g. browser_title)
|
8
|
-
# by swapping @page for @category in the line below:
|
9
|
-
present(@page)
|
10
|
-
end
|
11
|
-
|
12
|
-
def show
|
13
|
-
@category = Category.find(params[:id])
|
14
|
-
|
15
|
-
# redirect_to category_products_path(@category)
|
16
|
-
|
17
|
-
# you can use meta fields from your model instead (e.g. browser_title)
|
18
|
-
# by swapping @page for @category in the line below:
|
19
|
-
present(@page)
|
20
|
-
end
|
21
|
-
|
22
|
-
protected
|
23
|
-
|
24
|
-
def find_all_categories
|
25
|
-
@categories = Category.order('position ASC')
|
26
|
-
end
|
27
|
-
|
28
|
-
def find_page
|
29
|
-
@page = Page.where(:link_url => "/categories").first
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
1
|
+
class CategoriesController < ApplicationController
|
2
|
+
|
3
|
+
before_filter :find_all_categories
|
4
|
+
before_filter :find_page
|
5
|
+
|
6
|
+
def index
|
7
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
8
|
+
# by swapping @page for @category in the line below:
|
9
|
+
present(@page)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
@category = Category.find(params[:id])
|
14
|
+
|
15
|
+
# redirect_to category_products_path(@category)
|
16
|
+
|
17
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
18
|
+
# by swapping @page for @category in the line below:
|
19
|
+
present(@page)
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def find_all_categories
|
25
|
+
@categories = Category.order('position ASC')
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_page
|
29
|
+
@page = Page.where(:link_url => "/categories").first
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -1,33 +1,33 @@
|
|
1
|
-
class CustomersController < ApplicationController
|
2
|
-
|
3
|
-
#before_filter :find_all_customers
|
4
|
-
before_filter :find_page
|
5
|
-
helper :all
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
#def index
|
10
|
-
# # you can use meta fields from your model instead (e.g. browser_title)
|
11
|
-
# # by swapping @page for @customer in the line below:
|
12
|
-
# present(@page)
|
13
|
-
#end
|
14
|
-
|
15
|
-
def show
|
16
|
-
@customer = Customer.find(params[:id])
|
17
|
-
|
18
|
-
# you can use meta fields from your model instead (e.g. browser_title)
|
19
|
-
# by swapping @page for @customer in the line below:
|
20
|
-
present(@page)
|
21
|
-
end
|
22
|
-
|
23
|
-
protected
|
24
|
-
|
25
|
-
#def find_all_customers
|
26
|
-
# @customers = Customer.order('surname ASC')
|
27
|
-
#end
|
28
|
-
|
29
|
-
def find_page
|
30
|
-
@page = Page.where(:link_url => "/customers").first
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
1
|
+
class CustomersController < ApplicationController
|
2
|
+
|
3
|
+
#before_filter :find_all_customers
|
4
|
+
before_filter :find_page
|
5
|
+
helper :all
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
#def index
|
10
|
+
# # you can use meta fields from your model instead (e.g. browser_title)
|
11
|
+
# # by swapping @page for @customer in the line below:
|
12
|
+
# present(@page)
|
13
|
+
#end
|
14
|
+
|
15
|
+
def show
|
16
|
+
@customer = Customer.find(params[:id])
|
17
|
+
|
18
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
19
|
+
# by swapping @page for @customer in the line below:
|
20
|
+
present(@page)
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
#def find_all_customers
|
26
|
+
# @customers = Customer.order('surname ASC')
|
27
|
+
#end
|
28
|
+
|
29
|
+
def find_page
|
30
|
+
@page = Page.where(:link_url => "/customers").first
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class LineItemsController < ApplicationController
|
2
|
-
|
3
|
-
def destroy
|
4
|
-
LineItem.destroy(params[:id])
|
5
|
-
redirect_to show_cart_path
|
6
|
-
end
|
7
|
-
|
8
|
-
end
|
1
|
+
class LineItemsController < ApplicationController
|
2
|
+
|
3
|
+
def destroy
|
4
|
+
LineItem.destroy(params[:id])
|
5
|
+
redirect_to show_cart_path
|
6
|
+
end
|
7
|
+
|
8
|
+
end
|
@@ -1,61 +1,61 @@
|
|
1
|
-
class ProductsController < ApplicationController
|
2
|
-
include ActionView::Helpers::NumberHelper
|
3
|
-
before_filter :find_all_products, :only => :index
|
4
|
-
before_filter :find_page
|
5
|
-
|
6
|
-
def index
|
7
|
-
# you can use meta fields from your model instead (e.g. browser_title)
|
8
|
-
# by swapping @page for @product in the line below:
|
9
|
-
present(@page)
|
10
|
-
end
|
11
|
-
|
12
|
-
def show
|
13
|
-
@product = Product.find(params[:id])
|
14
|
-
|
15
|
-
|
16
|
-
@tagged_products = Product.tagged_with(@product.tag_list, :any => :true).order('position ASC')
|
17
|
-
|
18
|
-
# you can use meta fields from your model instead (e.g. browser_title)
|
19
|
-
# by swapping @page for @product in the line below:
|
20
|
-
present(@page)
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_variant_image
|
24
|
-
if params[:variant_id].present?
|
25
|
-
variant_url = Variant.find(params[:variant_id]).image.url
|
26
|
-
end
|
27
|
-
render :text => variant_url
|
28
|
-
end
|
29
|
-
|
30
|
-
def get_variant_price
|
31
|
-
if params[:variant_id].present?
|
32
|
-
variant_price = Variant.find(params[:variant_id]).price
|
33
|
-
end
|
34
|
-
render :text => number_to_currency(variant_price, :unit => 'R')
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
def find_all_products
|
40
|
-
|
41
|
-
if params[:category_id].present?
|
42
|
-
@category = Category.find(params[:category_id])
|
43
|
-
@products = Product.by_category(@category.id).order('position ASC')
|
44
|
-
@page_title = @category.name
|
45
|
-
elsif params[:upper].present? and params[:lower].present?
|
46
|
-
@products = Product.greater_than(params[:lower]).less_than(params[:upper])
|
47
|
-
@page_title = "By Price"
|
48
|
-
elsif params[:tag].present?
|
49
|
-
@products = Product.tagged_with(params[:tag]).order('position ASC')
|
50
|
-
@page_title = params[:tag].capitalize
|
51
|
-
else
|
52
|
-
@products = Product.all
|
53
|
-
@page_title = "All Products"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def find_page
|
58
|
-
@page = Page.where(:link_url => "/products").first
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
1
|
+
class ProductsController < ApplicationController
|
2
|
+
include ActionView::Helpers::NumberHelper
|
3
|
+
before_filter :find_all_products, :only => :index
|
4
|
+
before_filter :find_page
|
5
|
+
|
6
|
+
def index
|
7
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
8
|
+
# by swapping @page for @product in the line below:
|
9
|
+
present(@page)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
@product = Product.find(params[:id])
|
14
|
+
|
15
|
+
|
16
|
+
@tagged_products = Product.tagged_with(@product.tag_list, :any => :true).order('position ASC')
|
17
|
+
|
18
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
19
|
+
# by swapping @page for @product in the line below:
|
20
|
+
present(@page)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_variant_image
|
24
|
+
if params[:variant_id].present?
|
25
|
+
variant_url = Variant.find(params[:variant_id]).image.url
|
26
|
+
end
|
27
|
+
render :text => variant_url
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_variant_price
|
31
|
+
if params[:variant_id].present?
|
32
|
+
variant_price = Variant.find(params[:variant_id]).price
|
33
|
+
end
|
34
|
+
render :text => number_to_currency(variant_price, :unit => 'R')
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def find_all_products
|
40
|
+
|
41
|
+
if params[:category_id].present?
|
42
|
+
@category = Category.find(params[:category_id])
|
43
|
+
@products = Product.by_category(@category.id).order('position ASC')
|
44
|
+
@page_title = @category.name
|
45
|
+
elsif params[:upper].present? and params[:lower].present?
|
46
|
+
@products = Product.greater_than(params[:lower]).less_than(params[:upper])
|
47
|
+
@page_title = "By Price"
|
48
|
+
elsif params[:tag].present?
|
49
|
+
@products = Product.tagged_with(params[:tag]).order('position ASC')
|
50
|
+
@page_title = params[:tag].capitalize
|
51
|
+
else
|
52
|
+
@products = Product.all
|
53
|
+
@page_title = "All Products"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def find_page
|
58
|
+
@page = Page.where(:link_url => "/products").first
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
class ProfilesController < ApplicationController
|
2
|
-
before_filter :authenticate_customer!
|
3
|
-
|
4
|
-
def index
|
5
|
-
@current_customer = current_customer
|
6
|
-
if @current_customer.present?
|
7
|
-
@delivery_addresses = Address.where(:customer_id => current_customer.id).all
|
8
|
-
end
|
9
|
-
if @current_customer.present?
|
10
|
-
@orders = Order.where(:customer_id => current_customer.id).limit(5)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def account_details
|
15
|
-
@current_customer = current_customer
|
16
|
-
end
|
17
|
-
|
18
|
-
def address_details
|
19
|
-
if current_customer.present?
|
20
|
-
@delivery_addresses = Address.where(:customer_id => current_customer.id).all
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
if defined?(OrdersController)
|
25
|
-
def order_history
|
26
|
-
if current_customer.present?
|
27
|
-
@orders = Order.where(:customer_id => current_customer.id).all
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def order_history_details
|
32
|
-
@current_order = Order.where(:order_number => params[:order_number]).first
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
1
|
+
class ProfilesController < ApplicationController
|
2
|
+
before_filter :authenticate_customer!
|
3
|
+
|
4
|
+
def index
|
5
|
+
@current_customer = current_customer
|
6
|
+
if @current_customer.present?
|
7
|
+
@delivery_addresses = Address.where(:customer_id => current_customer.id).all
|
8
|
+
end
|
9
|
+
if @current_customer.present?
|
10
|
+
@orders = Order.where(:customer_id => current_customer.id).limit(5)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def account_details
|
15
|
+
@current_customer = current_customer
|
16
|
+
end
|
17
|
+
|
18
|
+
def address_details
|
19
|
+
if current_customer.present?
|
20
|
+
@delivery_addresses = Address.where(:customer_id => current_customer.id).all
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if defined?(OrdersController)
|
25
|
+
def order_history
|
26
|
+
if current_customer.present?
|
27
|
+
@orders = Order.where(:customer_id => current_customer.id).all
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def order_history_details
|
32
|
+
@current_order = Order.where(:order_number => params[:order_number]).first
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
37
|
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
module AddressHelper
|
2
|
-
|
3
|
-
def address_html(address)
|
4
|
-
if address.present?
|
5
|
-
items = []
|
6
|
-
items << address.address_line_1 if address.address_line_1.present?
|
7
|
-
items << address.address_line_2 if address.address_line_2.present?
|
8
|
-
items << address.suburb if address.suburb.present?
|
9
|
-
items << address.city if address.city.present?
|
10
|
-
items << address.postal_code if address.postal_code.present?
|
11
|
-
|
12
|
-
items.join("<br />")
|
13
|
-
else
|
14
|
-
nil
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
1
|
+
module AddressHelper
|
2
|
+
|
3
|
+
def address_html(address)
|
4
|
+
if address.present?
|
5
|
+
items = []
|
6
|
+
items << address.address_line_1 if address.address_line_1.present?
|
7
|
+
items << address.address_line_2 if address.address_line_2.present?
|
8
|
+
items << address.suburb if address.suburb.present?
|
9
|
+
items << address.city if address.city.present?
|
10
|
+
items << address.postal_code if address.postal_code.present?
|
11
|
+
|
12
|
+
items.join("<br />")
|
13
|
+
else
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
end
|
@@ -1,34 +1,42 @@
|
|
1
|
-
require 'acts-as-taggable-on'
|
2
|
-
|
3
|
-
module ProductsHelper
|
4
|
-
include ActsAsTaggableOn::TagsHelper
|
5
|
-
|
6
|
-
def rands(amount)
|
7
|
-
number_to_currency(amount, :unit => 'R')
|
8
|
-
end
|
9
|
-
|
10
|
-
def rands_nocents(amount)
|
11
|
-
number_to_currency(amount, :unit => 'R', :precision => 0)
|
12
|
-
end
|
13
|
-
|
14
|
-
def product_or_variant_name(cart_item)
|
15
|
-
if variant_exists?(cart_item)
|
16
|
-
"#{cart_item.product.name}: #{cart_item.variant.name}"
|
17
|
-
else
|
18
|
-
cart_item.product.name
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def product_or_variant_price(cart_item)
|
23
|
-
if variant_exists?(cart_item)
|
24
|
-
rands(cart_item.variant.price)
|
25
|
-
else
|
26
|
-
rands(cart_item.product.price)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def
|
31
|
-
cart_item.
|
32
|
-
|
33
|
-
|
1
|
+
require 'acts-as-taggable-on'
|
2
|
+
|
3
|
+
module ProductsHelper
|
4
|
+
include ActsAsTaggableOn::TagsHelper
|
5
|
+
|
6
|
+
def rands(amount)
|
7
|
+
number_to_currency(amount, :unit => 'R')
|
8
|
+
end
|
9
|
+
|
10
|
+
def rands_nocents(amount)
|
11
|
+
number_to_currency(amount, :unit => 'R', :precision => 0)
|
12
|
+
end
|
13
|
+
|
14
|
+
def product_or_variant_name(cart_item)
|
15
|
+
if variant_exists?(cart_item)
|
16
|
+
"#{cart_item.product.name}: #{cart_item.variant.name}"
|
17
|
+
else
|
18
|
+
cart_item.product.name
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def product_or_variant_price(cart_item)
|
23
|
+
if variant_exists?(cart_item)
|
24
|
+
rands(cart_item.variant.price)
|
25
|
+
else
|
26
|
+
rands(cart_item.product.price)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def cart_item_total(cart_item)
|
31
|
+
if variant_exists?(cart_item) and cart_item.variant.price.present?
|
32
|
+
rands(cart_item.variant.price * cart_item.quantity)
|
33
|
+
else
|
34
|
+
rands(cart_item.product.price * cart_item.quantity)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def variant_exists?(cart_item)
|
39
|
+
cart_item.variant_id.present? and defined?(Variant)
|
40
|
+
end
|
41
|
+
|
34
42
|
end
|