caboose-cms 0.5.129 → 0.5.130
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/caboose/products_controller.rb +30 -11
- data/app/models/caboose/line_item.rb +17 -12
- data/app/models/caboose/order.rb +19 -7
- data/app/models/caboose/product.rb +30 -20
- data/app/models/caboose/schema.rb +11 -4
- data/app/views/caboose/blocks/_product_sales.html.erb +2 -0
- data/app/views/caboose/blocks/_products.html.erb +7 -1
- data/app/views/caboose/products/admin_edit_general.html.erb +15 -11
- data/app/views/caboose/products/sales.html.erb +0 -0
- data/config/routes.rb +1 -1
- data/lib/caboose/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWEzYzcwNzIxOGRiMmZkZjJhYzg3Y2I2YjQ5NDkwOWE3N2RmNTA5OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWVmNzkyNGQ2OWZmZTY4ZGViYTFlMWFmOTcyMzE2NWEyZDE3OWQyMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDBmZWIxYWIyODY5OTExMDMzNjA1OWQ3OWNhNzU4MDQ2ZTI3MzRhMzA3NWU4
|
10
|
+
ZTA4OTY0ODIyMTA2ZWViYmY4OWFhOTc1NzE2ZTU0ZmE1NjU1YTA0OTAwYjBk
|
11
|
+
NjA2YzEyMzM2Mzg1MWU3Y2NiNDllNjZlOGY3MDc5YThiY2MzYTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTgxMzE2YWQ4NjA4MmM4OWJkYjlmMzM1NDE5NTBlYjkyYzBhNTE0NmJjNjdi
|
14
|
+
MDI3NDNjYWZiODBhZjQxYzgwYWU5ZmIzMzgzMmZmNDhiNjNhMzdjZDBiZTI5
|
15
|
+
YWMzMjdjMWYyZjUwOWMwMWNiMjY1MmVhMjg5OTc4YTFmYTU4MDM=
|
@@ -13,16 +13,33 @@ module Caboose
|
|
13
13
|
def index
|
14
14
|
|
15
15
|
# If id exists, is an integer and a product exists with the specified id then get the product
|
16
|
-
if params[:id]
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
if params[:id]
|
17
|
+
if params[:id] == 'sales'
|
18
|
+
products = Caboose::Product.where(:site_id => @site.id, :status => Caboose::Product::STATUS_ACTIVE, :on_sale => true).all
|
19
|
+
@sale_categories = {}
|
20
|
+
products.each do |p|
|
21
|
+
cat = 'Uncategorized'
|
22
|
+
if p.categories.count > 0
|
23
|
+
cats = p.categories.last.ancestry.collect{ |a| a.name }
|
24
|
+
cats.shift
|
25
|
+
cat = cats.join(' > ')
|
26
|
+
end
|
27
|
+
@sale_categories[cat] = [] if @sale_categories[cat].nil?
|
28
|
+
@sale_categories[cat] << p
|
29
|
+
end
|
30
|
+
render 'caboose/products/sales' and return
|
31
|
+
|
32
|
+
elsif params[:id].to_i > 0 && Product.exists?(params[:id])
|
33
|
+
@product = Product.find(params[:id])
|
34
|
+
render 'product/not_available' and return if @product.status == 'Inactive'
|
35
|
+
|
36
|
+
@category = @product.categories.first
|
37
|
+
@review = Review.new
|
38
|
+
@reviews = Review.where(:product_id => @product.id).limit(10).order("id DESC") || nil
|
39
|
+
@logged_in_user = logged_in_user
|
40
|
+
|
41
|
+
render 'caboose/products/details' and return
|
42
|
+
end
|
26
43
|
end
|
27
44
|
|
28
45
|
# Filter params from url
|
@@ -327,7 +344,9 @@ module Caboose
|
|
327
344
|
when 'seo_description' then product.seo_description = value
|
328
345
|
when 'status' then product.status = value
|
329
346
|
when 'category_id' then product.toggle_category(value[0], value[1])
|
330
|
-
when 'stackable_group_id' then product.stackable_group_id = value
|
347
|
+
when 'stackable_group_id' then product.stackable_group_id = value
|
348
|
+
when 'allow_gift_wrap' then product.allow_gift_wrap = value
|
349
|
+
when 'gift_wrap_price' then product.gift_wrap_price = value
|
331
350
|
when 'option1' then product.option1 = value
|
332
351
|
when 'option2' then product.option2 = value
|
333
352
|
when 'option3' then product.option3 = value
|
@@ -8,18 +8,23 @@ module Caboose
|
|
8
8
|
belongs_to :parent, :class_name => 'LineItem', :foreign_key => 'parent_id'
|
9
9
|
has_many :children, :class_name => 'LineItem', :foreign_key => 'parent_id'
|
10
10
|
|
11
|
-
attr_accessible :id,
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:status,
|
20
|
-
:custom1,
|
21
|
-
:custom2,
|
22
|
-
:custom3
|
11
|
+
attr_accessible :id ,
|
12
|
+
:order_id ,
|
13
|
+
:order_package_id ,
|
14
|
+
:variant_id ,
|
15
|
+
:unit_price ,
|
16
|
+
:quantity ,
|
17
|
+
:subtotal ,
|
18
|
+
:notes ,
|
19
|
+
:status ,
|
20
|
+
:custom1 ,
|
21
|
+
:custom2 ,
|
22
|
+
:custom3 ,
|
23
|
+
:is_gift ,
|
24
|
+
:include_gift_message ,
|
25
|
+
:gift_message ,
|
26
|
+
:gift_wrap ,
|
27
|
+
:hide_prices
|
23
28
|
|
24
29
|
#
|
25
30
|
# Scopes
|
data/app/models/caboose/order.rb
CHANGED
@@ -23,6 +23,7 @@ module Caboose
|
|
23
23
|
:tax,
|
24
24
|
:shipping,
|
25
25
|
:handling,
|
26
|
+
:gift_wrap,
|
26
27
|
:custom_discount,
|
27
28
|
:discount,
|
28
29
|
:total,
|
@@ -139,12 +140,13 @@ module Caboose
|
|
139
140
|
end
|
140
141
|
|
141
142
|
def calculate
|
142
|
-
self.update_column(:subtotal
|
143
|
-
self.update_column(:tax
|
144
|
-
self.update_column(:shipping
|
145
|
-
self.update_column(:handling
|
146
|
-
self.update_column(:
|
147
|
-
self.update_column(:
|
143
|
+
self.update_column(:subtotal , self.calculate_subtotal )
|
144
|
+
self.update_column(:tax , self.calculate_tax )
|
145
|
+
self.update_column(:shipping , self.calculate_shipping )
|
146
|
+
self.update_column(:handling , self.calculate_handling )
|
147
|
+
self.update_column(:gift_wrap , self.calculate_gift_wrap )
|
148
|
+
self.update_column(:discount , self.calculate_discount )
|
149
|
+
self.update_column(:total , self.calculate_total )
|
148
150
|
end
|
149
151
|
|
150
152
|
def calculate_subtotal
|
@@ -172,6 +174,16 @@ module Caboose
|
|
172
174
|
self.subtotal * self.site.store_config.handling_percentage.to_f
|
173
175
|
end
|
174
176
|
|
177
|
+
def calculate_gift_wrap
|
178
|
+
x = 0.0
|
179
|
+
self.line_items.each do |li|
|
180
|
+
next if !li.gift_wrap
|
181
|
+
next if !li.product.allow_gift_wrap
|
182
|
+
x = x + li.product.gift_wrap_price * li.quantity
|
183
|
+
end
|
184
|
+
return x
|
185
|
+
end
|
186
|
+
|
175
187
|
def calculate_discount
|
176
188
|
return 0.0 if self.discounts.nil? || self.discounts.count == 0
|
177
189
|
x = 0.0
|
@@ -181,7 +193,7 @@ module Caboose
|
|
181
193
|
end
|
182
194
|
|
183
195
|
def calculate_total
|
184
|
-
return (self.subtotal + self.tax + self.shipping + self.handling) - self.discount
|
196
|
+
return (self.subtotal + self.tax + self.shipping + self.handling + self.gift_wrap) - self.discount
|
185
197
|
end
|
186
198
|
|
187
199
|
def shipping_and_handling
|
@@ -17,26 +17,36 @@ module Caboose
|
|
17
17
|
|
18
18
|
#default_scope order('store_products.sort_order')
|
19
19
|
|
20
|
-
attr_accessible :id,
|
21
|
-
:site_id,
|
22
|
-
:alternate_id,
|
23
|
-
:title,
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:handle,
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:option1,
|
31
|
-
:option2,
|
32
|
-
:option3,
|
33
|
-
:default1,
|
34
|
-
:default2,
|
35
|
-
:default3,
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
|
20
|
+
attr_accessible :id ,
|
21
|
+
:site_id ,
|
22
|
+
:alternate_id ,
|
23
|
+
:title ,
|
24
|
+
:caption ,
|
25
|
+
:description ,
|
26
|
+
:handle ,
|
27
|
+
:status ,
|
28
|
+
:vendor_id ,
|
29
|
+
:category_id ,
|
30
|
+
:option1 ,
|
31
|
+
:option2 ,
|
32
|
+
:option3 ,
|
33
|
+
:default1 ,
|
34
|
+
:default2 ,
|
35
|
+
:default3 ,
|
36
|
+
:seo_title ,
|
37
|
+
:seo_description ,
|
38
|
+
:alternate_id ,
|
39
|
+
:date_available ,
|
40
|
+
:custom_input ,
|
41
|
+
:sort_order ,
|
42
|
+
:featured ,
|
43
|
+
:stackable_group_id ,
|
44
|
+
:on_sale ,
|
45
|
+
:allow_gift_wrap ,
|
46
|
+
:gift_wrap_price
|
47
|
+
|
48
|
+
STATUS_ACTIVE = 'Active'
|
49
|
+
STATUS_INACTIVE = 'Inactive'
|
40
50
|
|
41
51
|
#
|
42
52
|
# Scopes
|
@@ -285,15 +285,19 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
285
285
|
[ :order_package_id , :integer ],
|
286
286
|
[ :variant_id , :integer ],
|
287
287
|
[ :parent_id , :integer ],
|
288
|
-
[ :status , :string ],
|
289
|
-
[ :tracking_number , :string ],
|
288
|
+
[ :status , :string ],
|
290
289
|
[ :quantity , :integer , :default => 0 ],
|
291
290
|
[ :unit_price , :decimal , { :precision => 8, :scale => 2 }],
|
292
291
|
[ :subtotal , :decimal , { :precision => 8, :scale => 2 }],
|
293
292
|
[ :notes , :text ],
|
294
293
|
[ :custom1 , :string ],
|
295
294
|
[ :custom2 , :string ],
|
296
|
-
[ :custom3 , :string ]
|
295
|
+
[ :custom3 , :string ],
|
296
|
+
[ :is_gift , :boolean , { :default => false }],
|
297
|
+
[ :include_gift_message , :boolean , { :default => false }],
|
298
|
+
[ :gift_message , :text ],
|
299
|
+
[ :gift_wrap , :boolean , { :default => false }],
|
300
|
+
[ :hide_prices , :boolean , { :default => false }]
|
297
301
|
],
|
298
302
|
Caboose::MediaCategory => [
|
299
303
|
[ :parent_id , :integer ],
|
@@ -342,6 +346,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
342
346
|
[ :tax , :decimal , { :precision => 8, :scale => 2 }],
|
343
347
|
[ :shipping , :decimal , { :precision => 8, :scale => 2 }],
|
344
348
|
[ :handling , :decimal , { :precision => 8, :scale => 2 }],
|
349
|
+
[ :gift_wrap , :decimal , { :precision => 8, :scale => 2 }],
|
345
350
|
[ :custom_discount , :decimal , { :precision => 8, :scale => 2 }],
|
346
351
|
[ :discount , :decimal , { :precision => 8, :scale => 2 }],
|
347
352
|
[ :total , :decimal , { :precision => 8, :scale => 2 }],
|
@@ -471,7 +476,9 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
471
476
|
[ :sort_order , :integer ],
|
472
477
|
[ :featured , :boolean , :default => false ],
|
473
478
|
[ :stackable_group_id , :integer ],
|
474
|
-
[ :on_sale , :boolean , { :default => false }]
|
479
|
+
[ :on_sale , :boolean , { :default => false }],
|
480
|
+
[ :allow_gift_wrap , :boolean , { :default => false }],
|
481
|
+
[ :gift_wrap_price , :decimal , { :precision => 8, :scale => 2 }]
|
475
482
|
],
|
476
483
|
Caboose::ProductImage => [
|
477
484
|
[ :product_id , :integer ],
|
@@ -1,6 +1,12 @@
|
|
1
|
+
<%
|
2
|
+
# Note: This block is in the content area for the /products pages.
|
3
|
+
# It's set up like this so that each site can have custom views.
|
4
|
+
%>
|
1
5
|
<div id='block_<%= block.id %>'>
|
2
6
|
|
3
|
-
<%= block.partial('product_crumbtrail', local_assigns) %>
|
7
|
+
<%= block.partial('product_crumbtrail', local_assigns) %>
|
8
|
+
<% if @sale_categories %>
|
9
|
+
<%= block.partial('product_sales', local_assigns) %>
|
4
10
|
<% if @product %>
|
5
11
|
<%= block.partial('product_details', local_assigns) %>
|
6
12
|
<% else %>
|
@@ -3,16 +3,18 @@ p = @product
|
|
3
3
|
%>
|
4
4
|
<%= render :partial => 'caboose/products/admin_header' %>
|
5
5
|
|
6
|
-
<p><div id='product_<%= p.id %>_vendor_id'></div></p>
|
7
|
-
<p><div id='product_<%= p.id %>_title'></div></p>
|
8
|
-
<p><div id='product_<%= p.id %>_caption'></div></p>
|
9
|
-
<p><div id='product_<%= p.id %>_handle'></div></p>
|
10
|
-
<p><div id='product_<%= p.id %>_featured'></div></p>
|
11
|
-
<p><div id='product_<%= p.id %>_seo_title'></div></p>
|
12
|
-
<p><div id='product_<%= p.id %>_seo_description'></div></p>
|
13
|
-
<p><div id='product_<%= p.id %>_status'></div></p>
|
14
|
-
<p><div id='product_<%= p.id %>_alternate_id'></div></p>
|
15
|
-
<p><div id='product_<%= p.id %>_date_available'></div></p>
|
6
|
+
<p><div id='product_<%= p.id %>_vendor_id' ></div></p>
|
7
|
+
<p><div id='product_<%= p.id %>_title' ></div></p>
|
8
|
+
<p><div id='product_<%= p.id %>_caption' ></div></p>
|
9
|
+
<p><div id='product_<%= p.id %>_handle' ></div></p>
|
10
|
+
<p><div id='product_<%= p.id %>_featured' ></div></p>
|
11
|
+
<p><div id='product_<%= p.id %>_seo_title' ></div></p>
|
12
|
+
<p><div id='product_<%= p.id %>_seo_description' ></div></p>
|
13
|
+
<p><div id='product_<%= p.id %>_status' ></div></p>
|
14
|
+
<p><div id='product_<%= p.id %>_alternate_id' ></div></p>
|
15
|
+
<p><div id='product_<%= p.id %>_date_available' ></div></p>
|
16
|
+
<p><div id='product_<%= p.id %>_allow_gift_wrap' ></div></p>
|
17
|
+
<p><div id='product_<%= p.id %>_gift_wrap_price' ></div></p>
|
16
18
|
|
17
19
|
<div id='message'><%= raw flash[:message] ? flash[:message] : "" %></div>
|
18
20
|
|
@@ -40,7 +42,9 @@ $(document).ready(function() {
|
|
40
42
|
{ name: 'seo_description' , nice_name: 'SEO Meta Description' , type: 'textarea' , value: <%= raw Caboose.json(p.seo_description ) %>, width: 500, height: 150 },
|
41
43
|
{ name: 'alternate_id' , nice_name: 'Alternate ID' , type: 'text' , value: <%= raw Caboose.json(p.alternate_id ) %>, width: 500 },
|
42
44
|
{ name: 'date_available' , nice_name: 'Date Available' , type: 'text' , value: <%= raw Caboose.json(date_available ) %>, width: 500 },
|
43
|
-
{ name: 'featured' , nice_name: 'Featured' , type: 'checkbox' , value: <%= raw Caboose.json(p.featured ) %>, width: 500 }
|
45
|
+
{ name: 'featured' , nice_name: 'Featured' , type: 'checkbox' , value: <%= raw Caboose.json(p.featured ) %>, width: 500 },
|
46
|
+
{ name: 'allow_gift_wrap' , nice_name: 'Allow Gift Wrap' , type: 'checkbox' , value: <%= raw Caboose.json(p.allow_gift_wrap ? 1 : 0) %>, width: 500 },
|
47
|
+
{ name: 'gift_wrap_price' , nice_name: 'Gift Wrap Price' , type: 'text' , value: <%= raw Caboose.json(p.gift_wrap_price ? number_with_delimiter(p.gift_wrap_price, :precision => 2) : '') %>, width: 500 }
|
44
48
|
]
|
45
49
|
});
|
46
50
|
});
|
File without changes
|
data/config/routes.rb
CHANGED
@@ -401,7 +401,7 @@ Caboose::Engine.routes.draw do
|
|
401
401
|
#=============================================================================
|
402
402
|
# Products
|
403
403
|
#=============================================================================
|
404
|
-
|
404
|
+
|
405
405
|
get '/products/:id/info' => 'products#info'
|
406
406
|
get '/products/:id' => 'products#index', :constraints => { :id => /.*/ }
|
407
407
|
get '/products' => 'products#index'
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.130
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -680,6 +680,7 @@ files:
|
|
680
680
|
- app/views/caboose/blocks/_product_category.html.erb
|
681
681
|
- app/views/caboose/blocks/_product_crumbtrail.html.erb
|
682
682
|
- app/views/caboose/blocks/_product_details.html.erb
|
683
|
+
- app/views/caboose/blocks/_product_sales.html.erb
|
683
684
|
- app/views/caboose/blocks/_products.html.erb
|
684
685
|
- app/views/caboose/blocks/_render_function.html.erb
|
685
686
|
- app/views/caboose/blocks/_richtext.html.erb
|
@@ -822,6 +823,7 @@ files:
|
|
822
823
|
- app/views/caboose/products/details.html.erb
|
823
824
|
- app/views/caboose/products/index.html.erb
|
824
825
|
- app/views/caboose/products/not_available.html.erb
|
826
|
+
- app/views/caboose/products/sales.html.erb
|
825
827
|
- app/views/caboose/redirects/admin_edit.html.erb
|
826
828
|
- app/views/caboose/redirects/admin_index.html.erb
|
827
829
|
- app/views/caboose/redirects/admin_new.html.erb
|