radiant-shop-extension 0.91.7 → 0.92.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.91.7
1
+ 0.92.0
@@ -39,6 +39,14 @@ class ShopCategory < ActiveRecord::Base
39
39
  ).map(&:shop_product)
40
40
  end
41
41
 
42
+ # Returns the categories nested directly beneath this
43
+ def categories
44
+ pages = page.children.all(
45
+ :conditions => { :class_name => 'ShopCategoryPage' },
46
+ :order => 'pages.position ASC'
47
+ ).map(&:shop_category)
48
+ end
49
+
42
50
  # Returns the url of the page
43
51
  def url; page.url; end
44
52
 
@@ -9,12 +9,13 @@
9
9
  = image_tag product.images.first.url(:icon)
10
10
  - body.name do
11
11
  %span.name.attribute
12
- - link_to [:edit_admin, product] do
13
- = number_to_currency(product.price)
14
- = product.name
12
+ = link_to product.name, [:edit_admin, product]
15
13
  - body.sku do
16
14
  %span.sku.attribute
17
15
  = product.sku
16
+ - body.price do
17
+ %span.price.attribute
18
+ = number_to_currency(product.price)
18
19
  - body.modify do
19
20
  .modify
20
21
  %span.remove
@@ -23,7 +23,7 @@ module Shop
23
23
  index.head.concat %w{}
24
24
  index.category.concat %w{move name handle modify}
25
25
  index.products.concat %w{body}
26
- index.product.concat %w{move icon name sku modify}
26
+ index.product.concat %w{move icon name sku price modify}
27
27
  index.foot.concat %w{buttons}
28
28
  end
29
29
  products.remove = products.index
@@ -33,6 +33,8 @@ module Shop
33
33
 
34
34
  tag 'shop:category' do |tag|
35
35
  tag.locals.shop_category = Helpers.current_category(tag)
36
+ tag.locals.shop_categories = tag.locals.shop_category.categories
37
+
36
38
  tag.expand unless tag.locals.shop_category.nil?
37
39
  end
38
40
 
@@ -76,6 +78,12 @@ module Shop
76
78
  %{<a href="#{category.url}"#{attributes}>#{text}</a>}
77
79
  end
78
80
 
81
+ tag 'shop:category:images' do |tag|
82
+ tag.locals.images = tag.locals.shop_category.attachments
83
+
84
+ tag.expand
85
+ end
86
+
79
87
  end
80
88
  end
81
89
  end
@@ -78,35 +78,6 @@ module Shop
78
78
  tag.expand
79
79
  end
80
80
 
81
- desc %{ expands if the product has a valid image }
82
- tag 'shop:product:images:if_images' do |tag|
83
- tag.expand if tag.locals.images.present?
84
- end
85
-
86
- desc %{ expands if the product does not have a valid image }
87
- tag 'shop:product:images:unless_images' do |tag|
88
- tag.expand unless tag.locals.images.present?
89
- end
90
-
91
- desc %{ iterates through each of the products images }
92
- tag 'shop:product:images:each' do |tag|
93
- content = ''
94
-
95
- tag.locals.images.each do |image|
96
- tag.locals.image = image
97
- content << tag.expand
98
- end
99
-
100
- content
101
- end
102
-
103
- desc %{ iterates through each of the products images }
104
- tag 'shop:product:images:image' do |tag|
105
- tag.locals.image = Helpers.current_image(tag)
106
-
107
- tag.expand
108
- end
109
-
110
81
  end
111
82
  end
112
83
  end
@@ -40,7 +40,7 @@
40
40
  text:
41
41
  decoration: none
42
42
 
43
- &:hover
43
+ a:hover
44
44
  color: #0066ce
45
45
  text:
46
46
  decoration: underline
@@ -46,8 +46,8 @@
46
46
  size: 16px
47
47
  text:
48
48
  decoration: none
49
-
50
- &:hover
49
+
50
+ a:hover
51
51
  color: #0066ce
52
52
  text:
53
53
  decoration: underline
@@ -57,6 +57,12 @@
57
57
  style: italic
58
58
  size: 0.9em
59
59
  color: #000000
60
+
61
+ .price
62
+ position: absolute
63
+ right: 90px
64
+ font-size: 0.8em
65
+ font-weight: bold
60
66
 
61
67
  .modify
62
68
  float: right
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-shop-extension}
8
- s.version = "0.91.7"
8
+ s.version = "0.92.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dirk Kelly", "John Barker", "Darcy Laycock"]
12
- s.date = %q{2010-12-09}
12
+ s.date = %q{2010-12-14}
13
13
  s.description = %q{Radiant Shop is an attempt at a simple but complete store. It includes Products, Categories, Orders and Credit Card Payments}
14
14
  s.email = %q{dk@dirkkelly.com}
15
15
  s.extra_rdoc_files = [
@@ -156,7 +156,6 @@ Gem::Specification.new do |s|
156
156
  "lib/shop/interface/orders.rb",
157
157
  "lib/shop/interface/products.rb",
158
158
  "lib/shop/models/form_extension.rb",
159
- "lib/shop/models/image.rb",
160
159
  "lib/shop/models/page.rb",
161
160
  "lib/shop/models/user.rb",
162
161
  "lib/shop/tags/address.rb",
@@ -187,13 +186,13 @@ Gem::Specification.new do |s|
187
186
  "spec/controllers/admin/shops_controller_spec.rb",
188
187
  "spec/datasets/forms.rb",
189
188
  "spec/datasets/shop_addresses.rb",
189
+ "spec/datasets/shop_attachments.rb",
190
190
  "spec/datasets/shop_categories.rb",
191
191
  "spec/datasets/shop_config.rb",
192
192
  "spec/datasets/shop_customers.rb",
193
193
  "spec/datasets/shop_line_items.rb",
194
194
  "spec/datasets/shop_orders.rb",
195
195
  "spec/datasets/shop_payments.rb",
196
- "spec/datasets/shop_product_attachments.rb",
197
196
  "spec/datasets/shop_products.rb",
198
197
  "spec/datasets/tags.rb",
199
198
  "spec/helpers/nested_tag_helper.rb",
@@ -238,13 +237,13 @@ Gem::Specification.new do |s|
238
237
  "spec/controllers/admin/shops_controller_spec.rb",
239
238
  "spec/datasets/forms.rb",
240
239
  "spec/datasets/shop_addresses.rb",
240
+ "spec/datasets/shop_attachments.rb",
241
241
  "spec/datasets/shop_categories.rb",
242
242
  "spec/datasets/shop_config.rb",
243
243
  "spec/datasets/shop_customers.rb",
244
244
  "spec/datasets/shop_line_items.rb",
245
245
  "spec/datasets/shop_orders.rb",
246
246
  "spec/datasets/shop_payments.rb",
247
- "spec/datasets/shop_product_attachments.rb",
248
247
  "spec/datasets/shop_products.rb",
249
248
  "spec/datasets/tags.rb",
250
249
  "spec/helpers/nested_tag_helper.rb",
data/shop_extension.rb CHANGED
@@ -36,7 +36,6 @@ class ShopExtension < Radiant::Extension
36
36
  end
37
37
 
38
38
  Page.send :include, Shop::Models::Page
39
- Image.send :include, Shop::Models::Image
40
39
  User.send :include, Shop::Models::User
41
40
 
42
41
  ApplicationController.send :include, Shop::Controllers::ApplicationController
@@ -0,0 +1,35 @@
1
+ class ShopAttachmentsDataset < Dataset::Base
2
+
3
+ uses :shop_products
4
+
5
+ def load
6
+ category_images = [ :bread, :milk, :salad ]
7
+ product_images = [ :soft_bread_front, :soft_bread_back, :soft_bread_top, :crusty_bread_front, :warm_bread_front ]
8
+
9
+ product_images.each_with_index do |image, i|
10
+ create_record :image, image,
11
+ :title => image.to_s,
12
+ :asset_file_name => "#{image.to_s}_file_name.png",
13
+ :asset_content_type => "image/png",
14
+ :asset_file_size => i+1*1000
15
+
16
+ create_record :attachment, image,
17
+ :image => images(image.to_sym),
18
+ :page => shop_products(image.to_s.split('_')[0,2].join('_').to_sym).page,
19
+ :position => i + 1
20
+ end
21
+
22
+ category_images.each_with_index do |image, i|
23
+ create_record :image, image,
24
+ :title => image.to_s,
25
+ :asset_file_name => "#{image.to_s}_file_name.png",
26
+ :asset_content_type => "image/png",
27
+ :asset_file_size => i+1*1000
28
+
29
+ create_record :attachment, image,
30
+ :image => images(image.to_sym),
31
+ :page => shop_categories(image).page,
32
+ :position => i + 1
33
+ end
34
+ end
35
+ end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + "/../../../spec_helper"
2
2
 
3
3
  describe Shop::Tags::Category do
4
4
 
5
- dataset :pages, :shop_categories, :shop_products
5
+ dataset :pages, :shop_categories, :shop_products, :shop_attachments
6
6
 
7
7
  it 'should describe these tags' do
8
8
  Shop::Tags::Category.tags.sort.should == [
@@ -17,7 +17,8 @@ describe Shop::Tags::Category do
17
17
  'shop:category:if_current',
18
18
  'shop:category:link',
19
19
  'shop:category:name',
20
- 'shop:category:slug'].sort
20
+ 'shop:category:slug',
21
+ 'shop:category:images'].sort
21
22
  end
22
23
 
23
24
  before :each do
@@ -186,4 +187,38 @@ describe Shop::Tags::Category do
186
187
  end
187
188
  end
188
189
 
190
+ describe '<r:shop:category:images>' do
191
+ before :each do
192
+ mock(Shop::Tags::Helpers).current_category(anything) { @category }
193
+ end
194
+
195
+ context 'success' do
196
+ it 'should open if images exist' do
197
+ tag = %{<r:shop:category:images>success</r:shop:category:images>}
198
+ exp = %{success}
199
+ @page.should render(tag).as(exp)
200
+ end
201
+ it 'should assign images for default tags' do
202
+ tag = %{<r:shop:category:images:each:image>success</r:shop:category:images:each:image>}
203
+ exp = @category.images.map{'success'}.join('')
204
+ @page.should render(tag).as(exp)
205
+ end
206
+ end
207
+ context 'failure' do
208
+ before :each do
209
+ @category.page.attachments.destroy_all { [] }
210
+ end
211
+ it 'should render' do
212
+ tag = %{<r:shop:category:images>success</r:shop:category:images>}
213
+ exp = %{success}
214
+ @page.should render(tag).as(exp)
215
+ end
216
+ it 'should not assign images for default tags' do
217
+ tag = %{<r:shop:category:images:each:image>failure</r:shop:category:images:each:image>}
218
+ exp = %{}
219
+ @page.should render(tag).as(exp)
220
+ end
221
+ end
222
+ end
223
+
189
224
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + "/../../../spec_helper"
2
2
 
3
3
  describe Shop::Tags::Helpers do
4
4
 
5
- dataset :pages, :tags, :shop_products, :shop_orders, :shop_addresses, :shop_line_items, :shop_product_attachments
5
+ dataset :pages, :tags, :shop_products, :shop_orders, :shop_addresses, :shop_line_items, :shop_attachments
6
6
 
7
7
  before :all do
8
8
  @page = pages(:home)
@@ -45,6 +45,8 @@ describe Shop::Tags::Helpers do
45
45
  end
46
46
  end
47
47
 
48
+ it 'should test nested categories'
49
+
48
50
  describe '#current_category' do
49
51
  before :each do
50
52
  @category = shop_categories(:bread)
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + "/../../../spec_helper"
2
2
 
3
3
  describe Shop::Tags::Product do
4
4
 
5
- dataset :pages, :shop_config, :shop_products, :shop_product_attachments
5
+ dataset :pages, :shop_config, :shop_products, :shop_attachments
6
6
 
7
7
  it 'should describe these tags' do
8
8
  Shop::Tags::Product.tags.sort.should == [
@@ -18,11 +18,7 @@ describe Shop::Tags::Product do
18
18
  'shop:product:slug',
19
19
  'shop:product:description',
20
20
  'shop:product:link',
21
- 'shop:product:images',
22
- 'shop:product:images:if_images',
23
- 'shop:product:images:unless_images',
24
- 'shop:product:images:each',
25
- 'shop:product:images:image'].sort
21
+ 'shop:product:images'].sort
26
22
  end
27
23
 
28
24
  before :all do
@@ -265,107 +261,35 @@ describe Shop::Tags::Product do
265
261
  end
266
262
  end
267
263
 
268
- describe '<r:shop:product:images:if_images>' do
264
+ describe '<r:shop:product:images>' do
269
265
  before :each do
270
266
  mock(Shop::Tags::Helpers).current_product(anything) { @product }
271
267
  end
272
268
 
273
269
  context 'success' do
274
- it 'should render' do
275
- tag = %{<r:shop:product:images:if_images>success</r:shop:product:images:if_images>}
270
+ it 'should open if images exist' do
271
+ tag = %{<r:shop:product:images>success</r:shop:product:images>}
276
272
  exp = %{success}
277
273
  @page.should render(tag).as(exp)
278
274
  end
279
- end
280
- context 'failure' do
281
- it 'should not render' do
282
- @product.page.images.delete_all
283
-
284
- tag = %{<r:shop:product:images:if_images>failure</r:shop:product:images:if_images>}
285
- exp = %{}
275
+ it 'should assign images for default tags' do
276
+ tag = %{<r:shop:product:images:each:image>success</r:shop:product:images:each:image>}
277
+ exp = @product.images.map{'success'}.join('')
286
278
  @page.should render(tag).as(exp)
287
279
  end
288
280
  end
289
- end
290
-
291
- describe '<r:shop:product:images:unless_images>' do
292
- before :each do
293
- mock(Shop::Tags::Helpers).current_product(anything) { @product }
294
- end
295
-
296
- context 'success' do
297
- it 'should render' do
298
- @product.page.images.delete_all
299
-
300
- tag = %{<r:shop:product:images:unless_images>success</r:shop:product:images:unless_images>}
301
- exp = %{success}
302
- @page.should render(tag).as(exp)
303
- end
304
- end
305
-
306
281
  context 'failure' do
307
- it 'should not render' do
308
- tag = %{<r:shop:product:images:unless_images>failure</r:shop:product:images:unless_images>}
309
- exp = %{}
310
- @page.should render(tag).as(exp)
282
+ before :each do
283
+ @product.page.attachments.destroy_all
311
284
  end
312
- end
313
- end
314
-
315
- describe '<r:shop:product:images>' do
316
- before :each do
317
- mock(Shop::Tags::Helpers).current_product(anything) { @product }
318
- end
319
-
320
- it 'should render' do
321
- tag = %{<r:shop:product:images>success</r:shop:product:images>}
322
- exp = %{success}
323
- @page.should render(tag).as(exp)
324
- end
325
- end
326
-
327
- describe '<r:shop:product:images:each>' do
328
- before :each do
329
- mock(Shop::Tags::Helpers).current_product(anything) { @product }
330
- end
331
-
332
- context 'success' do
333
- it 'should assign the local image for each' do
334
- tag = %{<r:shop:product:images:each><r:image:id /></r:shop:product:images:each>}
335
- exp = @product.attachments.map{ |i| i.id }.join('')
336
- @page.should render(tag).as(exp)
337
- end
338
- end
339
- context 'failure' do
340
- it 'should not render' do
341
- @product.page.images.delete_all
342
-
343
- tag = %{<r:shop:product:images:each>failure</r:shop:product:images:each>}
344
- exp = %{}
345
- @page.should render(tag).as(exp)
346
- end
347
- end
348
- end
349
-
350
- describe '<r:shop:product:images:image>' do
351
- before :each do
352
- mock(Shop::Tags::Helpers).current_product(anything) { @product }
353
- end
354
- context 'image exists' do
355
- it 'should expand' do
356
- mock(Shop::Tags::Helpers).current_image(anything) { @product.images.first }
357
-
358
- tag = %{<r:shop:product:images:image>success</r:shop:product:images:image>}
285
+ it 'should render' do
286
+ tag = %{<r:shop:product:images>success</r:shop:product:images>}
359
287
  exp = %{success}
360
288
  @page.should render(tag).as(exp)
361
289
  end
362
- end
363
- context 'image does not exist' do
364
- it 'should expand' do
365
- mock(Shop::Tags::Helpers).current_image(anything) { nil }
366
-
367
- tag = %{<r:shop:product:images:image>success</r:shop:product:images:image>}
368
- exp = %{success}
290
+ it 'should not assign images for default tags' do
291
+ tag = %{<r:shop:product:images:each:image>failure</r:shop:product:images:each:image>}
292
+ exp = %{}
369
293
  @page.should render(tag).as(exp)
370
294
  end
371
295
  end
@@ -51,6 +51,10 @@ describe ShopCategory do
51
51
  end
52
52
  end
53
53
 
54
+ it 'should test #products'
55
+
56
+ it 'should test #categories'
57
+
54
58
  context '#handle' do
55
59
  it 'should return a handle formatted url' do
56
60
  @category.handle.should === ShopProduct.to_sku(@category.page.url)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-shop-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 381
4
+ hash: 367
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 91
9
- - 7
10
- version: 0.91.7
8
+ - 92
9
+ - 0
10
+ version: 0.92.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dirk Kelly
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-12-09 00:00:00 +08:00
20
+ date: 2010-12-14 00:00:00 +08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -313,7 +313,6 @@ files:
313
313
  - lib/shop/interface/orders.rb
314
314
  - lib/shop/interface/products.rb
315
315
  - lib/shop/models/form_extension.rb
316
- - lib/shop/models/image.rb
317
316
  - lib/shop/models/page.rb
318
317
  - lib/shop/models/user.rb
319
318
  - lib/shop/tags/address.rb
@@ -344,13 +343,13 @@ files:
344
343
  - spec/controllers/admin/shops_controller_spec.rb
345
344
  - spec/datasets/forms.rb
346
345
  - spec/datasets/shop_addresses.rb
346
+ - spec/datasets/shop_attachments.rb
347
347
  - spec/datasets/shop_categories.rb
348
348
  - spec/datasets/shop_config.rb
349
349
  - spec/datasets/shop_customers.rb
350
350
  - spec/datasets/shop_line_items.rb
351
351
  - spec/datasets/shop_orders.rb
352
352
  - spec/datasets/shop_payments.rb
353
- - spec/datasets/shop_product_attachments.rb
354
353
  - spec/datasets/shop_products.rb
355
354
  - spec/datasets/tags.rb
356
355
  - spec/helpers/nested_tag_helper.rb
@@ -424,13 +423,13 @@ test_files:
424
423
  - spec/controllers/admin/shops_controller_spec.rb
425
424
  - spec/datasets/forms.rb
426
425
  - spec/datasets/shop_addresses.rb
426
+ - spec/datasets/shop_attachments.rb
427
427
  - spec/datasets/shop_categories.rb
428
428
  - spec/datasets/shop_config.rb
429
429
  - spec/datasets/shop_customers.rb
430
430
  - spec/datasets/shop_line_items.rb
431
431
  - spec/datasets/shop_orders.rb
432
432
  - spec/datasets/shop_payments.rb
433
- - spec/datasets/shop_product_attachments.rb
434
433
  - spec/datasets/shop_products.rb
435
434
  - spec/datasets/tags.rb
436
435
  - spec/helpers/nested_tag_helper.rb
@@ -1,14 +0,0 @@
1
- module Shop
2
- module Models
3
- module Image
4
-
5
- def self.included(base)
6
- base.class_eval do
7
- has_many :shop_product_attachments, :dependent => :destroy
8
- has_many :shop_products, :through => :shop_product_attachments, :source => :product
9
- end
10
- end
11
-
12
- end
13
- end
14
- end
@@ -1,21 +0,0 @@
1
- class ShopProductAttachmentsDataset < Dataset::Base
2
-
3
- uses :shop_products
4
-
5
- def load
6
- images = [ :soft_bread_front, :soft_bread_back, :soft_bread_top, :crusty_bread_front, :warm_bread_front ]
7
-
8
- images.each_with_index do |image, i|
9
- create_record :image, image,
10
- :title => image.to_s,
11
- :asset_file_name => "#{image.to_s}_file_name.png",
12
- :asset_content_type => "image/png",
13
- :asset_file_size => i+1*1000
14
-
15
- create_record :attachment, image,
16
- :image => images(image.to_sym),
17
- :page => shop_products(image.to_s.split('_')[0,2].join('_').to_sym).page,
18
- :position => i + 1
19
- end
20
- end
21
- end