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.
Files changed (96) hide show
  1. data/app/controllers/addresses_controller.rb +22 -22
  2. data/app/controllers/admin/carts_controller.rb +7 -7
  3. data/app/controllers/admin/categories_controller.rb +50 -50
  4. data/app/controllers/admin/customers_controller.rb +12 -12
  5. data/app/controllers/admin/line_items_controller.rb +7 -7
  6. data/app/controllers/admin/products_controller.rb +23 -23
  7. data/app/controllers/carts_controller.rb +110 -110
  8. data/app/controllers/categories_controller.rb +32 -32
  9. data/app/controllers/customers_controller.rb +33 -33
  10. data/app/controllers/line_items_controller.rb +8 -8
  11. data/app/controllers/products_controller.rb +61 -61
  12. data/app/controllers/profiles_controller.rb +36 -36
  13. data/app/helpers/address_helper.rb +20 -20
  14. data/app/helpers/products_helper.rb +41 -33
  15. data/app/models/address.rb +18 -18
  16. data/app/models/cart.rb +54 -54
  17. data/app/models/category.rb +28 -28
  18. data/app/models/customer.rb +32 -32
  19. data/app/models/line_item.rb +28 -28
  20. data/app/models/product.rb +46 -46
  21. data/app/views/addresses/edit.html.erb +42 -42
  22. data/app/views/admin/carts/_actions.html.erb +27 -27
  23. data/app/views/admin/carts/_cart.html.erb +18 -18
  24. data/app/views/admin/carts/_carts.html.erb +1 -1
  25. data/app/views/admin/carts/_form.html.erb +24 -24
  26. data/app/views/admin/carts/_records.html.erb +17 -17
  27. data/app/views/admin/carts/_sortable_list.html.erb +7 -7
  28. data/app/views/admin/carts/edit.html.erb +1 -1
  29. data/app/views/admin/carts/index.html.erb +10 -10
  30. data/app/views/admin/carts/new.html.erb +1 -1
  31. data/app/views/admin/categories/_actions.html.erb +27 -27
  32. data/app/views/admin/categories/_categories.html.erb +1 -1
  33. data/app/views/admin/categories/_category.html.erb +25 -25
  34. data/app/views/admin/categories/_form.html.erb +49 -49
  35. data/app/views/admin/categories/_records.html.erb +17 -17
  36. data/app/views/admin/categories/_sortable_list.html.erb +10 -10
  37. data/app/views/admin/categories/edit.html.erb +1 -1
  38. data/app/views/admin/categories/index.html.erb +12 -12
  39. data/app/views/admin/categories/new.html.erb +1 -1
  40. data/app/views/admin/customers/_actions.html.erb +27 -27
  41. data/app/views/admin/customers/_customer.html.erb +18 -18
  42. data/app/views/admin/customers/_customers.html.erb +1 -1
  43. data/app/views/admin/customers/_form.html.erb +40 -40
  44. data/app/views/admin/customers/_records.html.erb +17 -17
  45. data/app/views/admin/customers/_sortable_list.html.erb +7 -7
  46. data/app/views/admin/customers/edit.html.erb +1 -1
  47. data/app/views/admin/customers/index.html.erb +10 -10
  48. data/app/views/admin/customers/new.html.erb +1 -1
  49. data/app/views/admin/customers/show.html.erb +59 -59
  50. data/app/views/admin/line_items/_actions.html.erb +27 -27
  51. data/app/views/admin/line_items/_form.html.erb +29 -29
  52. data/app/views/admin/line_items/_line_item.html.erb +18 -18
  53. data/app/views/admin/line_items/_line_items.html.erb +1 -1
  54. data/app/views/admin/line_items/_records.html.erb +17 -17
  55. data/app/views/admin/line_items/_sortable_list.html.erb +7 -7
  56. data/app/views/admin/line_items/edit.html.erb +1 -1
  57. data/app/views/admin/line_items/index.html.erb +10 -10
  58. data/app/views/admin/line_items/new.html.erb +1 -1
  59. data/app/views/admin/products/_actions.html.erb +42 -42
  60. data/app/views/admin/products/_form.html.erb +120 -120
  61. data/app/views/admin/products/_product.html.erb +23 -23
  62. data/app/views/admin/products/_products.html.erb +1 -1
  63. data/app/views/admin/products/_records.html.erb +17 -17
  64. data/app/views/admin/products/_sortable_list.html.erb +13 -13
  65. data/app/views/admin/products/edit.html.erb +1 -1
  66. data/app/views/admin/products/index.html.erb +12 -12
  67. data/app/views/admin/products/new.html.erb +1 -1
  68. data/app/views/carts/show.html.erb +56 -56
  69. data/app/views/categories/index.html.erb +11 -11
  70. data/app/views/categories/show.html.erb +33 -33
  71. data/app/views/customers/index.html.erb +11 -11
  72. data/app/views/customers/show.html.erb +52 -52
  73. data/app/views/line_items/index.html.erb +11 -11
  74. data/app/views/line_items/show.html.erb +39 -39
  75. data/app/views/products/index.html.erb +33 -33
  76. data/app/views/products/show.html.erb +65 -65
  77. data/app/views/profiles/_order_history.html.erb +23 -23
  78. data/app/views/profiles/_show_address.html.erb +3 -3
  79. data/app/views/profiles/account_details.html.erb +31 -31
  80. data/app/views/profiles/address_details.html.erb +9 -9
  81. data/app/views/profiles/index.html.erb +75 -75
  82. data/app/views/profiles/order_history_details.html.erb +39 -39
  83. data/config/locales/en.yml +97 -97
  84. data/config/locales/fr.yml +25 -25
  85. data/config/locales/lolcat.yml +25 -25
  86. data/config/locales/nb.yml +21 -21
  87. data/config/locales/nl.yml +21 -21
  88. data/config/routes.rb +58 -58
  89. data/lib/generators/refinerycms_products_generator.rb +5 -5
  90. data/lib/refinerycms-carts.rb +31 -31
  91. data/lib/refinerycms-categories.rb +30 -30
  92. data/lib/refinerycms-customers.rb +34 -34
  93. data/lib/refinerycms-line_items.rb +30 -30
  94. data/lib/refinerycms-products.rb +65 -65
  95. data/lib/tasks/products.rake +12 -12
  96. metadata +95 -98
@@ -1,22 +1,22 @@
1
- class AddressesController < ApplicationController
2
-
3
- def edit
4
-
5
- @address = Address.find(params[:id])
6
-
7
- end
8
-
9
- def update
10
-
11
- @address = Address.find(params[:id])
12
-
13
- if @address.update_attributes(params[:address])
14
- flash[:success] = 'Address was successfully updated.'
15
- redirect_to profiles_path
16
- else
17
- render :action => "edit"
18
- end
19
-
20
- end
21
-
22
- end
1
+ class AddressesController < ApplicationController
2
+
3
+ def edit
4
+
5
+ @address = Address.find(params[:id])
6
+
7
+ end
8
+
9
+ def update
10
+
11
+ @address = Address.find(params[:id])
12
+
13
+ if @address.update_attributes(params[:address])
14
+ flash[:success] = 'Address was successfully updated.'
15
+ redirect_to profiles_path
16
+ else
17
+ render :action => "edit"
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -1,7 +1,7 @@
1
- module Admin
2
- class CartsController < Admin::BaseController
3
-
4
- crudify :cart, :xhr_paging => true
5
-
6
- end
7
- end
1
+ module Admin
2
+ class CartsController < Admin::BaseController
3
+
4
+ crudify :cart, :xhr_paging => true
5
+
6
+ end
7
+ end
@@ -1,50 +1,50 @@
1
- module Admin
2
- class CategoriesController < Admin::BaseController
3
-
4
- crudify :category,
5
- :conditions => nil,
6
- :include => [:parent],
7
- :title_attribute => 'name', :xhr_paging => true
8
-
9
- def create
10
- # if the position field exists, set this object as last object, given the conditions of this class.
11
- if Category.column_names.include?("position")
12
- params[:category].merge!({
13
- :position => ((Category.maximum(:position)||-1) + 1)
14
- })
15
- end
16
-
17
- if (@category = Category.create(params[:category])).valid?
18
-
19
- flash[:notice] = t('refinery.crudify.created', :what => @category.name)
20
-
21
- if @category.parent.present?
22
- if @category.parent.products.present?
23
- flash[:notice] += " Please be aware that the '#{@category.parent.name}' category has products attached to it. Please re-assign these."
24
- end
25
- end
26
-
27
- redirect_to admin_categories_path
28
-
29
- else
30
- render :action => 'new'
31
- end
32
- end
33
-
34
- def update
35
-
36
- if @category.update_attributes(params[:category])
37
-
38
- if @category.parent.present?
39
- if @category.parent.products.present?
40
- flash[:notice] = "Please be aware that the '#{@category.parent.name}' category has products attached to it. Please re-assign these."
41
- end
42
- end
43
-
44
- redirect_to admin_categories_path
45
- end
46
-
47
- end
48
-
49
- end
50
- end
1
+ module Admin
2
+ class CategoriesController < Admin::BaseController
3
+
4
+ crudify :category,
5
+ :conditions => nil,
6
+ :include => [:parent],
7
+ :title_attribute => 'name', :xhr_paging => true
8
+
9
+ def create
10
+ # if the position field exists, set this object as last object, given the conditions of this class.
11
+ if Category.column_names.include?("position")
12
+ params[:category].merge!({
13
+ :position => ((Category.maximum(:position)||-1) + 1)
14
+ })
15
+ end
16
+
17
+ if (@category = Category.create(params[:category])).valid?
18
+
19
+ flash[:notice] = t('refinery.crudify.created', :what => @category.name)
20
+
21
+ if @category.parent.present?
22
+ if @category.parent.products.present?
23
+ flash[:notice] += " Please be aware that the '#{@category.parent.name}' category has products attached to it. Please re-assign these."
24
+ end
25
+ end
26
+
27
+ redirect_to admin_categories_path
28
+
29
+ else
30
+ render :action => 'new'
31
+ end
32
+ end
33
+
34
+ def update
35
+
36
+ if @category.update_attributes(params[:category])
37
+
38
+ if @category.parent.present?
39
+ if @category.parent.products.present?
40
+ flash[:notice] = "Please be aware that the '#{@category.parent.name}' category has products attached to it. Please re-assign these."
41
+ end
42
+ end
43
+
44
+ redirect_to admin_categories_path
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+ end
@@ -1,12 +1,12 @@
1
- module Admin
2
- class CustomersController < Admin::BaseController
3
-
4
- crudify :customer,
5
- :title_attribute => 'name', :xhr_paging => true
6
-
7
- def show
8
- @customer = Customer.find(params[:id])
9
- end
10
-
11
- end
12
- end
1
+ module Admin
2
+ class CustomersController < Admin::BaseController
3
+
4
+ crudify :customer,
5
+ :title_attribute => 'name', :xhr_paging => true
6
+
7
+ def show
8
+ @customer = Customer.find(params[:id])
9
+ end
10
+
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
- module Admin
2
- class LineItemsController < Admin::BaseController
3
-
4
- crudify :line_item, :xhr_paging => true
5
-
6
- end
7
- end
1
+ module Admin
2
+ class LineItemsController < Admin::BaseController
3
+
4
+ crudify :line_item, :xhr_paging => true
5
+
6
+ end
7
+ end
@@ -1,23 +1,23 @@
1
- module Admin
2
- class ProductsController < Admin::BaseController
3
-
4
- crudify :product,
5
- :title_attribute => 'name', :xhr_paging => true
6
-
7
- def index
8
- if params[:category_id].present?
9
- @category = Category.find(params[:category_id])
10
- @products = Product.by_category(@category.id).order('position ASC').paginate(:page => params[:page])
11
- else
12
- paginate_all_products
13
- end
14
- end
15
-
16
- def update_prices
17
- Product.update(params[:products].keys, params[:products].values)
18
- flash[:notice] = 'Prices were successfully updated.'
19
- redirect_to :action => "index"
20
- end
21
-
22
- end
23
- end
1
+ module Admin
2
+ class ProductsController < Admin::BaseController
3
+
4
+ crudify :product,
5
+ :title_attribute => 'name', :xhr_paging => true
6
+
7
+ def index
8
+ if params[:category_id].present?
9
+ @category = Category.find(params[:category_id])
10
+ @products = Product.by_category(@category.id).order('position ASC').paginate(:page => params[:page])
11
+ else
12
+ paginate_all_products
13
+ end
14
+ end
15
+
16
+ def update_prices
17
+ Product.update(params[:products].keys, params[:products].values)
18
+ flash[:notice] = 'Prices were successfully updated.'
19
+ redirect_to :action => "index"
20
+ end
21
+
22
+ end
23
+ end
@@ -1,110 +1,110 @@
1
- class CartsController < ApplicationController
2
-
3
- before_filter :initialize_cart
4
-
5
- def add_to_cart
6
- check_quantity_then_update_cart
7
-
8
- # redirect_to_products("Product added to Cart")
9
- redirect_to show_cart_path
10
- end
11
-
12
- # Here for backwards compatibility
13
- def show_cart
14
- render :action => 'show'
15
- end
16
-
17
- def show
18
-
19
- end
20
-
21
- def check_quantity_then_update_cart
22
-
23
- #logger.info("****************** the variant = #{params[:variant][:id]}")
24
-
25
- if params[:quantity].present?
26
- if params[:variant].present?
27
- @current_cart.add_to_the_cart(params[:product_id], params[:quantity], params[:variant][:id])
28
- else
29
- @current_cart.add_to_the_cart(params[:product_id], params[:quantity])
30
- end
31
- else
32
- if params[:variant].present?
33
- @current_cart.add_to_the_cart(params[:product_id], 1, params[:variant][:id])
34
- else
35
- @current_cart.add_to_the_cart(params[:product_id])
36
- end
37
- end
38
-
39
- end
40
-
41
- def increment_cart
42
- check_quantity_then_update_cart
43
-
44
- redirect_to show_cart_path
45
- end
46
-
47
- private
48
-
49
- def redirect_to_products(msg)
50
- flash[:notice] = msg
51
-
52
- if params[:category_id].present?
53
- if params[:category_id] == "0"
54
- redirect_to "/"
55
- else
56
- redirect_to category_products_path(params[:category_id])
57
- end
58
- else
59
- redirect_to product_path(params[:product_id])
60
- end
61
- end
62
-
63
- def initialize_cart
64
- @current_cart = get_cart
65
- end
66
-
67
- # Get the current customer's cart
68
- def get_cart
69
- if customer_signed_in?
70
-
71
- if session[:cart_id].present?
72
- cart = Cart.find(session[:cart_id])
73
- if cart.customer_id.blank?
74
- cart.customer_id = current_customer.id
75
- cart.is_current = true
76
- cart.save
77
- end
78
- return cart
79
- else
80
- cart = Cart.where(:is_current => true, :customer_id => current_customer.id).first
81
- if cart.blank?
82
- cart = Cart.create(:is_current => true, :customer_id => current_customer.id)
83
- end
84
-
85
- session[:cart_id] = cart.id
86
- return cart
87
- end
88
-
89
- else
90
- if session[:cart_id].present?
91
- # logger.info("*************** signed OUT and session was present")
92
- cart = Cart.find_by_id(session[:cart_id])
93
- if cart.blank?
94
- cart = Cart.create(:is_current => true)
95
- session[:cart_id] = cart.id
96
- return cart
97
- else
98
- cart.is_current = true
99
- cart.save
100
- return cart
101
- end
102
- else
103
- # logger.info("*************** signed OUT and session was NOT present")
104
- cart = Cart.create(:is_current => true)
105
- session[:cart_id] = cart.id
106
- return cart
107
- end
108
- end
109
- end
110
- end
1
+ class CartsController < ApplicationController
2
+
3
+ before_filter :initialize_cart
4
+
5
+ def add_to_cart
6
+ check_quantity_then_update_cart
7
+
8
+ # redirect_to_products("Product added to Cart")
9
+ redirect_to show_cart_path
10
+ end
11
+
12
+ # Here for backwards compatibility
13
+ def show_cart
14
+ render :action => 'show'
15
+ end
16
+
17
+ def show
18
+
19
+ end
20
+
21
+ def check_quantity_then_update_cart
22
+
23
+ #logger.info("****************** the variant = #{params[:variant][:id]}")
24
+
25
+ if params[:quantity].present?
26
+ if params[:variant].present?
27
+ @current_cart.add_to_the_cart(params[:product_id], params[:quantity], params[:variant][:id])
28
+ else
29
+ @current_cart.add_to_the_cart(params[:product_id], params[:quantity])
30
+ end
31
+ else
32
+ if params[:variant].present?
33
+ @current_cart.add_to_the_cart(params[:product_id], 1, params[:variant][:id])
34
+ else
35
+ @current_cart.add_to_the_cart(params[:product_id])
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ def increment_cart
42
+ check_quantity_then_update_cart
43
+
44
+ redirect_to show_cart_path
45
+ end
46
+
47
+ private
48
+
49
+ def redirect_to_products(msg)
50
+ flash[:notice] = msg
51
+
52
+ if params[:category_id].present?
53
+ if params[:category_id] == "0"
54
+ redirect_to "/"
55
+ else
56
+ redirect_to category_products_path(params[:category_id])
57
+ end
58
+ else
59
+ redirect_to product_path(params[:product_id])
60
+ end
61
+ end
62
+
63
+ def initialize_cart
64
+ @current_cart = get_cart
65
+ end
66
+
67
+ # Get the current customer's cart
68
+ def get_cart
69
+ if customer_signed_in?
70
+
71
+ if session[:cart_id].present?
72
+ cart = Cart.find(session[:cart_id])
73
+ if cart.customer_id.blank?
74
+ cart.customer_id = current_customer.id
75
+ cart.is_current = true
76
+ cart.save
77
+ end
78
+ return cart
79
+ else
80
+ cart = Cart.where(:is_current => true, :customer_id => current_customer.id).first
81
+ if cart.blank?
82
+ cart = Cart.create(:is_current => true, :customer_id => current_customer.id)
83
+ end
84
+
85
+ session[:cart_id] = cart.id
86
+ return cart
87
+ end
88
+
89
+ else
90
+ if session[:cart_id].present?
91
+ # logger.info("*************** signed OUT and session was present")
92
+ cart = Cart.find_by_id(session[:cart_id])
93
+ if cart.blank?
94
+ cart = Cart.create(:is_current => true)
95
+ session[:cart_id] = cart.id
96
+ return cart
97
+ else
98
+ cart.is_current = true
99
+ cart.save
100
+ return cart
101
+ end
102
+ else
103
+ # logger.info("*************** signed OUT and session was NOT present")
104
+ cart = Cart.create(:is_current => true)
105
+ session[:cart_id] = cart.id
106
+ return cart
107
+ end
108
+ end
109
+ end
110
+ end