radiant-shop-extension 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +26 -0
  3. data/Gemfile.lock +75 -0
  4. data/HISTORY.md +77 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +26 -0
  7. data/Rakefile +141 -0
  8. data/VERSION +1 -0
  9. data/app/.DS_Store +0 -0
  10. data/app/controllers/admin/shop/categories_controller.rb +206 -0
  11. data/app/controllers/admin/shop/customers_controller.rb +137 -0
  12. data/app/controllers/admin/shop/orders_controller.rb +171 -0
  13. data/app/controllers/admin/shop/products/images_controller.rb +144 -0
  14. data/app/controllers/admin/shop/products_controller.rb +217 -0
  15. data/app/controllers/admin/shops_controller.rb +9 -0
  16. data/app/controllers/shop/categories_controller.rb +49 -0
  17. data/app/controllers/shop/line_items_controller.rb +165 -0
  18. data/app/controllers/shop/orders_controller.rb +16 -0
  19. data/app/controllers/shop/products_controller.rb +48 -0
  20. data/app/models/form_checkout.rb +245 -0
  21. data/app/models/shop_address.rb +13 -0
  22. data/app/models/shop_addressable.rb +11 -0
  23. data/app/models/shop_category.rb +85 -0
  24. data/app/models/shop_category_page.rb +7 -0
  25. data/app/models/shop_customer.rb +27 -0
  26. data/app/models/shop_line_item.rb +32 -0
  27. data/app/models/shop_order.rb +108 -0
  28. data/app/models/shop_payment.rb +6 -0
  29. data/app/models/shop_payment_method.rb +5 -0
  30. data/app/models/shop_product.rb +87 -0
  31. data/app/models/shop_product_attachment.rb +30 -0
  32. data/app/models/shop_product_page.rb +7 -0
  33. data/app/views/.DS_Store +0 -0
  34. data/app/views/admin/.DS_Store +0 -0
  35. data/app/views/admin/pages/_shop_category.html.haml +4 -0
  36. data/app/views/admin/pages/_shop_product.html.haml +4 -0
  37. data/app/views/admin/shop/categories/edit.html.haml +12 -0
  38. data/app/views/admin/shop/categories/edit/_fields.html.haml +28 -0
  39. data/app/views/admin/shop/categories/edit/_head.html.haml +2 -0
  40. data/app/views/admin/shop/categories/edit/_meta.html.haml +7 -0
  41. data/app/views/admin/shop/categories/edit/_part.html.haml +3 -0
  42. data/app/views/admin/shop/categories/edit/_popup.html.haml +3 -0
  43. data/app/views/admin/shop/categories/edit/meta/_handle.html.haml +5 -0
  44. data/app/views/admin/shop/categories/edit/meta/_layouts.html.haml +10 -0
  45. data/app/views/admin/shop/categories/edit/parts/_description.html.haml +1 -0
  46. data/app/views/admin/shop/categories/index/_category.html.haml +16 -0
  47. data/app/views/admin/shop/categories/new.html.haml +10 -0
  48. data/app/views/admin/shop/categories/remove.html.haml +12 -0
  49. data/app/views/admin/shop/customers/index.html.haml +36 -0
  50. data/app/views/admin/shop/orders/index.html.haml +33 -0
  51. data/app/views/admin/shop/products/edit.html.haml +14 -0
  52. data/app/views/admin/shop/products/edit/_fields.html.haml +38 -0
  53. data/app/views/admin/shop/products/edit/_head.html.haml +2 -0
  54. data/app/views/admin/shop/products/edit/_image.html.haml +12 -0
  55. data/app/views/admin/shop/products/edit/_meta.html.haml +8 -0
  56. data/app/views/admin/shop/products/edit/_part.html.haml +3 -0
  57. data/app/views/admin/shop/products/edit/_popup.html.haml +3 -0
  58. data/app/views/admin/shop/products/edit/buttons/_browse_images.html.haml +1 -0
  59. data/app/views/admin/shop/products/edit/buttons/_new_image.html.haml +1 -0
  60. data/app/views/admin/shop/products/edit/meta/_category.html.haml +5 -0
  61. data/app/views/admin/shop/products/edit/meta/_sku.html.haml +5 -0
  62. data/app/views/admin/shop/products/edit/parts/_description.html.haml +1 -0
  63. data/app/views/admin/shop/products/edit/parts/_images.html.haml +5 -0
  64. data/app/views/admin/shop/products/edit/popups/_browse_images.html.haml +6 -0
  65. data/app/views/admin/shop/products/edit/popups/_new_image.html.haml +18 -0
  66. data/app/views/admin/shop/products/index.html.haml +10 -0
  67. data/app/views/admin/shop/products/index/_bottom.html.haml +5 -0
  68. data/app/views/admin/shop/products/index/_product.html.haml +13 -0
  69. data/app/views/admin/shop/products/new.html.haml +10 -0
  70. data/app/views/admin/shop/products/remove.html.haml +12 -0
  71. data/app/views/shop/categories/show.html.haml +1 -0
  72. data/app/views/shop/orders/show.html.haml +1 -0
  73. data/app/views/shop/products/index.html.haml +1 -0
  74. data/app/views/shop/products/show.html.haml +1 -0
  75. data/config/locales/en.yml +50 -0
  76. data/config/routes.rb +38 -0
  77. data/config/shop_cart.yml +16 -0
  78. data/cucumber.yml +1 -0
  79. data/db/migrate/20100311053701_initial.rb +153 -0
  80. data/db/migrate/20100520033059_create_layouts.rb +119 -0
  81. data/db/migrate/20100903122123_create_forms.rb +44 -0
  82. data/db/migrate/20100908063639_create_snippets.rb +22 -0
  83. data/features/support/env.rb +16 -0
  84. data/features/support/paths.rb +14 -0
  85. data/lib/shop/controllers/application_controller.rb +39 -0
  86. data/lib/shop/controllers/site_controller.rb +12 -0
  87. data/lib/shop/interface/products.rb +49 -0
  88. data/lib/shop/models/image.rb +14 -0
  89. data/lib/shop/models/page.rb +14 -0
  90. data/lib/shop/tags/address.rb +40 -0
  91. data/lib/shop/tags/cart.rb +49 -0
  92. data/lib/shop/tags/category.rb +83 -0
  93. data/lib/shop/tags/core.rb +12 -0
  94. data/lib/shop/tags/helpers.rb +142 -0
  95. data/lib/shop/tags/item.rb +109 -0
  96. data/lib/shop/tags/product.rb +109 -0
  97. data/lib/shop/tags/responses.rb +34 -0
  98. data/lib/tasks/shop_extension_tasks.rake +54 -0
  99. data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
  100. data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
  101. data/public/images/admin/extensions/shop/products/sort.png +0 -0
  102. data/public/javascripts/admin/extensions/shop/products/edit.js +115 -0
  103. data/public/javascripts/admin/extensions/shop/products/index.js +65 -0
  104. data/public/stylesheets/sass/admin/extensions/shop/edit.sass +86 -0
  105. data/public/stylesheets/sass/admin/extensions/shop/products/edit.sass +158 -0
  106. data/public/stylesheets/sass/admin/extensions/shop/products/index.sass +129 -0
  107. data/radiant-shop-extension.gemspec +245 -0
  108. data/shop_extension.rb +62 -0
  109. data/spec/controllers/admin/shop/categories_controller_spec.rb +443 -0
  110. data/spec/controllers/admin/shop/products/images_controller_spec.rb +477 -0
  111. data/spec/controllers/admin/shop/products_controller_spec.rb +394 -0
  112. data/spec/controllers/admin/shops_controller_spec.rb +19 -0
  113. data/spec/controllers/shop/categories_controller_spec.rb +42 -0
  114. data/spec/controllers/shop/line_items_controller_spec.rb +256 -0
  115. data/spec/controllers/shop/orders_controller_specs.rb +37 -0
  116. data/spec/controllers/shop/products_controller_spec.rb +51 -0
  117. data/spec/datasets/forms.rb +153 -0
  118. data/spec/datasets/images.rb +13 -0
  119. data/spec/datasets/shop_addresses.rb +27 -0
  120. data/spec/datasets/shop_categories.rb +13 -0
  121. data/spec/datasets/shop_line_items.rb +9 -0
  122. data/spec/datasets/shop_orders.rb +21 -0
  123. data/spec/datasets/shop_products.rb +34 -0
  124. data/spec/helpers/nested_tag_helper.rb +33 -0
  125. data/spec/lib/shop/models/image_spec.rb +28 -0
  126. data/spec/lib/shop/models/page_spec.rb +38 -0
  127. data/spec/lib/shop/tags/address_spec.rb +196 -0
  128. data/spec/lib/shop/tags/cart_spec.rb +169 -0
  129. data/spec/lib/shop/tags/category_spec.rb +201 -0
  130. data/spec/lib/shop/tags/core_spec.rb +16 -0
  131. data/spec/lib/shop/tags/helpers_spec.rb +381 -0
  132. data/spec/lib/shop/tags/item_spec.rb +313 -0
  133. data/spec/lib/shop/tags/product_spec.rb +334 -0
  134. data/spec/matchers/comparison.rb +72 -0
  135. data/spec/matchers/render_matcher.rb +33 -0
  136. data/spec/models/form_checkout_spec.rb +376 -0
  137. data/spec/models/shop_category_page_spec.rb +10 -0
  138. data/spec/models/shop_category_spec.rb +58 -0
  139. data/spec/models/shop_line_item_spec.rb +42 -0
  140. data/spec/models/shop_order_spec.rb +228 -0
  141. data/spec/models/shop_product_attachment_spec.rb +72 -0
  142. data/spec/models/shop_product_page_spec.rb +10 -0
  143. data/spec/models/shop_product_spec.rb +135 -0
  144. data/spec/spec.opts +6 -0
  145. data/spec/spec_helper.rb +22 -0
  146. data/vendor/plugins/acts_as_list/README +23 -0
  147. data/vendor/plugins/acts_as_list/init.rb +3 -0
  148. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  149. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  150. data/vendor/plugins/json_fields/.gitignore +3 -0
  151. data/vendor/plugins/json_fields/MIT-LICENSE +20 -0
  152. data/vendor/plugins/json_fields/README.rdoc +65 -0
  153. data/vendor/plugins/json_fields/Rakefile +55 -0
  154. data/vendor/plugins/json_fields/init.rb +2 -0
  155. data/vendor/plugins/json_fields/lib/json_fields.rb +99 -0
  156. data/vendor/plugins/json_fields/spec/lib/json_fields_spec.rb +124 -0
  157. data/vendor/plugins/json_fields/spec/spec.opts +6 -0
  158. data/vendor/plugins/json_fields/spec/spec_helper.rb +29 -0
  159. data/vendor/plugins/json_fields/spec/test_models.rb +12 -0
  160. metadata +324 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .svn
2
+ .*.swp
3
+ .DS_Store
4
+ coverage
5
+ .bundle
6
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,26 @@
1
+ source :gemcutter
2
+
3
+ gem 'activemerchant'
4
+ gem 'will_paginate'
5
+ gem 'radiant-layouts-extension', '0.9.1'
6
+
7
+ group :development do
8
+ gem 'reek'
9
+ gem 'roodi'
10
+ gem 'rspec'
11
+ gem 'rspec-rails'
12
+ gem 'cucumber'
13
+ gem 'cucumber-rails'
14
+ gem 'database_cleaner'
15
+ gem 'ruby-debug'
16
+ gem 'webrat'
17
+ end
18
+
19
+ group :test do
20
+ gem 'rspec'
21
+ gem 'cucumber-rails'
22
+ gem 'database_cleaner'
23
+ gem 'webrat'
24
+ gem 'rspec-rails'
25
+ gem 'rr'
26
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,75 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemerchant (1.7.2)
5
+ activesupport (>= 2.3.2)
6
+ braintree (>= 2.0.0)
7
+ builder (>= 2.0.0)
8
+ activesupport (2.3.8)
9
+ braintree (2.5.0)
10
+ builder
11
+ builder (2.1.2)
12
+ columnize (0.3.1)
13
+ cucumber (0.8.5)
14
+ builder (~> 2.1.2)
15
+ diff-lcs (~> 1.1.2)
16
+ gherkin (~> 2.1.4)
17
+ json_pure (~> 1.4.3)
18
+ term-ansicolor (~> 1.0.4)
19
+ cucumber-rails (0.2.4)
20
+ cucumber (>= 0.6.2)
21
+ database_cleaner (0.4.3)
22
+ diff-lcs (1.1.2)
23
+ gherkin (2.1.5)
24
+ trollop (~> 1.16.2)
25
+ json_pure (1.4.6)
26
+ linecache (0.43)
27
+ nokogiri (1.4.3.1)
28
+ rack (1.2.1)
29
+ radiant-layouts-extension (0.9.1)
30
+ reek (1.2.8)
31
+ ruby2ruby (~> 1.2)
32
+ ruby_parser (~> 2.0)
33
+ sexp_processor (~> 3.0)
34
+ roodi (2.1.0)
35
+ ruby_parser
36
+ rr (0.10.11)
37
+ rspec (1.3.0)
38
+ rspec-rails (1.3.2)
39
+ rack (>= 1.0.0)
40
+ rspec (>= 1.3.0)
41
+ ruby-debug (0.10.3)
42
+ columnize (>= 0.1)
43
+ ruby-debug-base (~> 0.10.3.0)
44
+ ruby-debug-base (0.10.3)
45
+ linecache (>= 0.3)
46
+ ruby2ruby (1.2.4)
47
+ ruby_parser (~> 2.0)
48
+ sexp_processor (~> 3.0)
49
+ ruby_parser (2.0.4)
50
+ sexp_processor (~> 3.0)
51
+ sexp_processor (3.0.4)
52
+ term-ansicolor (1.0.5)
53
+ trollop (1.16.2)
54
+ webrat (0.6.0)
55
+ nokogiri (>= 1.2.0)
56
+ rack (>= 1.0)
57
+ will_paginate (2.3.14)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ activemerchant
64
+ cucumber
65
+ cucumber-rails
66
+ database_cleaner
67
+ radiant-layouts-extension (= 0.9.1)
68
+ reek
69
+ roodi
70
+ rr
71
+ rspec
72
+ rspec-rails
73
+ ruby-debug
74
+ webrat
75
+ will_paginate
data/HISTORY.md ADDED
@@ -0,0 +1,77 @@
1
+ ## History
2
+
3
+ ### 0.9+ (September 2010) @dirkkelly | sponsored by @frontiergroup
4
+
5
+ * SPECS! Yes, lots of them.
6
+ * Merged shop_products and shop_cart with the eventual goal being a standalone shop solution
7
+ * Restructure of lib to make things more obvious
8
+ * Working towards making this into a gem
9
+
10
+ ### 0.9 (August 2010) @dirkkelly
11
+
12
+ * Moved to Images for base image handling
13
+ * Started creating specs
14
+
15
+ ### 0.8 (15 Jun 2010) @dirkkelly
16
+
17
+ * Started pulling apart the database, removing overkill columns and tidying up codebase
18
+ * Making it easier to understand, and less feature bloated
19
+
20
+ ### 0.7 (11 Mar 2010)
21
+
22
+ * @dirkkelly and CR decide to make this the core for an entire shop extension
23
+
24
+ ### 0.6 (26 Sep 2009)
25
+
26
+ * Products and Categories can be arbitrarily ordered by the admin
27
+
28
+ ### 0.5.2 (22 Sep 2009)
29
+
30
+ * Product Images can now be tagged
31
+ * Moved repository under the http://www.github.com/aurorasoft user
32
+
33
+ ### 0.5.1 (21 Sep 2009)
34
+
35
+ * Bugfix with Category and Product links not always selecting correctly
36
+ * Cleaned up url code (possibly leading into customizable product root)
37
+
38
+ ### 0.5 (21 Sep 2009)
39
+
40
+ * Relevant Category:link and Product:link tags now include a "selected" class when used on generated pages
41
+ * Product image sizes can be changed, and referenced by <r:product:image type="SIZE" />
42
+
43
+ ### 0.4.2 (18 Sep 2009)
44
+
45
+ * Added ability to attach multiple images to a product
46
+
47
+ ### 0.4.1 (18 Sep 2009)
48
+
49
+ * Added custom layouts selected at Category level
50
+
51
+ ### 0.4 (17 Sep 2009)
52
+
53
+ * Added subcategory support, and subcategory tags
54
+ * Added support for public Category and Product pages
55
+ * Added custom field support
56
+
57
+ ### 0.3 (26 Aug 2009)
58
+
59
+ * Added ability to tag Categories
60
+
61
+ ### 0.2 (15 Aug 2009)
62
+
63
+ * Updated to work with Radiant-0.8.0
64
+
65
+ ### 0.1
66
+
67
+ * Original version by Jason Stirk - http://griffin.oobleyboo.com/
68
+
69
+ ### Thanks
70
+
71
+ Thanks to John Reilly, Justin Grammens who did most of the work to get the original extension working under Radiant-0.7.1 and 0.8.0.
72
+
73
+ Huge thanks to Ingvi Gudmundsson (http://www.ingvithor.net/) for sponsoring and helping test v0.4 to v0.6.
74
+
75
+ ### Licensing
76
+
77
+ Copyright (C) 2009-2010 Square Talent (http://www.squaretalent.com) released under the MIT license
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2009 Aurora Software (http://www.aurorasoft.com.au)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Radiant Shop
2
+
3
+ ## Checkout
4
+
5
+ ### Form Configuration
6
+
7
+ checkout:
8
+ gateway:
9
+ name: PayWay
10
+ username: 123456
11
+ password: abcdef
12
+ merchant: test
13
+ pem: /var/www/certificate.pem
14
+
15
+ # Development
16
+
17
+ unless ENV["RAILS_ENV"] == "production"
18
+ config.gem 'rspec', :version => '1.3.0'
19
+ config.gem 'rspec-rails', :version => '1.3.2'
20
+ config.gem 'cucumber', :verison => '0.8.5'
21
+ config.gem 'cucumber-rails', :version => '0.3.2'
22
+ config.gem 'database_cleaner', :version => '0.4.3'
23
+ config.gem 'ruby-debug', :version => '0.10.3'
24
+ config.gem 'webrat', :version => '0.7.1'
25
+ config.gem 'rr', :version => '0.10.11'
26
+ end
data/Rakefile ADDED
@@ -0,0 +1,141 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "radiant-shop-extension"
5
+ gem.summary = %Q{Shop Extension for Radiant CMS}
6
+ gem.description = %Q{Shop adds an easy to use api for creating products sold in a shop}
7
+ gem.email = "dk@dirkkelly.com"
8
+ gem.homepage = "http://github.com/squaretalent/radiant-shop-extension"
9
+ gem.authors = ["Dirk Kelly", "John Barker"]
10
+ gem.add_dependency 'radiant-forms-extension', '>= 3.1.0'
11
+ gem.add_dependency 'radiant-images-extension', '>= 0.1.1'
12
+ gem.add_dependency 'radiant-layouts-extension', '>= 0.9.1'
13
+ gem.add_dependency 'radiant-settings-extension', '>= 1.1.1'
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. This is only required if you plan to package shop as a gem."
19
+ end
20
+
21
+ # In rails 1.2, plugins aren't available in the path until they're loaded.
22
+ # Check to see if the rspec plugin is installed first and require
23
+ # it if it is. If not, use the gem version.
24
+
25
+ # Determine where the RSpec plugin is by loading the boot
26
+ unless defined? RADIANT_ROOT
27
+ ENV["RAILS_ENV"] = "test"
28
+ case
29
+ when ENV["RADIANT_ENV_FILE"]
30
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
31
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
32
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
33
+ else
34
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
35
+ end
36
+ end
37
+
38
+ require 'rake'
39
+ require 'rake/rdoctask'
40
+ require 'rake/testtask'
41
+
42
+ rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
43
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
44
+ require 'spec/rake/spectask'
45
+ require 'cucumber'
46
+ require 'cucumber/rake/task'
47
+
48
+ # Cleanup the RADIANT_ROOT constant so specs will load the environment
49
+ Object.send(:remove_const, :RADIANT_ROOT)
50
+
51
+ extension_root = File.expand_path(File.dirname(__FILE__))
52
+
53
+ task :default => :spec
54
+ task :stats => "spec:statsetup"
55
+
56
+ desc "Run all specs in spec directory"
57
+ Spec::Rake::SpecTask.new(:spec) do |t|
58
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
59
+ t.spec_files = FileList['spec/**/*_spec.rb']
60
+ end
61
+
62
+ task :features => 'spec:integration'
63
+
64
+ namespace :spec do
65
+ desc "Run all specs in spec directory with RCov"
66
+ Spec::Rake::SpecTask.new(:rcov) do |t|
67
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
68
+ t.spec_files = FileList['spec/**/*_spec.rb']
69
+ t.rcov = true
70
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
71
+ end
72
+
73
+ desc "Print Specdoc for all specs"
74
+ Spec::Rake::SpecTask.new(:doc) do |t|
75
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
76
+ t.spec_files = FileList['spec/**/*_spec.rb']
77
+ end
78
+
79
+ [:models, :controllers, :views, :helpers].each do |sub|
80
+ desc "Run the specs under spec/#{sub}"
81
+ Spec::Rake::SpecTask.new(sub) do |t|
82
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
83
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
84
+ end
85
+ end
86
+
87
+ desc "Run the Cucumber features"
88
+ Cucumber::Rake::Task.new(:integration) do |t|
89
+ t.fork = true
90
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
91
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
92
+ t.profile = "default"
93
+ end
94
+
95
+ # Setup specs for stats
96
+ task :statsetup do
97
+ require 'code_statistics'
98
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
99
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
100
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
101
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
102
+ ::CodeStatistics::TEST_TYPES << "Model specs"
103
+ ::CodeStatistics::TEST_TYPES << "View specs"
104
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
105
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
106
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
107
+ end
108
+
109
+ namespace :db do
110
+ namespace :fixtures do
111
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
112
+ task :load => :environment do
113
+ require 'active_record/fixtures'
114
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
115
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
116
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
122
+
123
+ desc 'Generate documentation for the shop extension.'
124
+ Rake::RDocTask.new(:rdoc) do |rdoc|
125
+ rdoc.rdoc_dir = 'rdoc'
126
+ rdoc.title = 'ShopExtension'
127
+ rdoc.options << '--line-numbers' << '--inline-source'
128
+ rdoc.rdoc_files.include('README')
129
+ rdoc.rdoc_files.include('lib/**/*.rb')
130
+ end
131
+
132
+ # For extensions that are in transition
133
+ desc 'Test the shop extension.'
134
+ Rake::TestTask.new(:test) do |t|
135
+ t.libs << 'lib'
136
+ t.pattern = 'test/**/*_test.rb'
137
+ t.verbose = true
138
+ end
139
+
140
+ # Load any custom rakefiles for extension
141
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.2
data/app/.DS_Store ADDED
Binary file
@@ -0,0 +1,206 @@
1
+ class Admin::Shop::CategoriesController < Admin::ResourceController
2
+
3
+ model_class ShopCategory
4
+
5
+ before_filter :config_global
6
+ before_filter :config_new, :only => [ :new, :create ]
7
+ before_filter :config_edit, :only => [ :edit, :update ]
8
+ before_filter :assets_global
9
+
10
+ before_filter :set_layouts, :only => [ :new ]
11
+
12
+ # GET /admin/shop/products/categories
13
+ # GET /admin/shop/products/categories.js
14
+ # GET /admin/shop/products/categories.json AJAX and HTML
15
+ #----------------------------------------------------------------------------
16
+ def index
17
+ @shop_categories = ShopCategory.search(params[:search])
18
+
19
+ respond_to do |format|
20
+ format.html { redirect_to admin_shop_products_path }
21
+ format.js { render :partial => '/admin/shop/categories/index/category', :collection => @shop_categories }
22
+ format.json { render :json => @shop_categories.to_json(ShopCategory.params) }
23
+ end
24
+ end
25
+
26
+ # GET /admin/shop/products/categories/1/products
27
+ # GET /admin/shop/products/categories/1/products.js
28
+ # GET /admin/shop/products/categories/1/products.json AJAX and HTML
29
+ #----------------------------------------------------------------------------
30
+ def products
31
+ @shop_category = ShopCategory.find(params[:id])
32
+ @shop_products = @shop_category.products
33
+
34
+ respond_to do |format|
35
+ format.html { render :template => '/admin/shop/products/index' }
36
+ format.js { render :partial => '/admin/shop/products/index/product', :collection => @shop_products }
37
+ format.json { render :json => @shop_products.to_json(ShopProduct.params) }
38
+ end
39
+ end
40
+
41
+ # PUT /admin/shop/categories/sort
42
+ # PUT /admin/shop/categories/sort.js
43
+ # PUT /admin/shop/categories/sort.json AJAX and HTML
44
+ #----------------------------------------------------------------------------
45
+ def sort
46
+ notice = 'Categories successfully sorted.'
47
+ error = 'Could not sort Categories.'
48
+
49
+ begin
50
+ @shop_categories = CGI::parse(params[:categories])["shop_categories[]"]
51
+
52
+ @shop_categories.each_with_index do |id, index|
53
+ ShopCategory.find(id).update_attributes!({:position => index+1})
54
+ end
55
+
56
+ respond_to do |format|
57
+ format.html {
58
+ flash[:notice] = notice
59
+ redirect_to admin_shop_products_path
60
+ }
61
+ format.js { render :text => notice, :status => :ok }
62
+ format.json { render :json => { :notice => notice }, :status => :ok }
63
+ end
64
+ rescue
65
+ respond_to do |format|
66
+ format.html {
67
+ flash[:error] = error
68
+ redirect_to admin_shop_products_path
69
+ }
70
+ format.js { render :text => error, :status => :unprocessable_entity }
71
+ format.json { render :json => { :error => error }, :status => :unprocessable_entity }
72
+ end
73
+ end
74
+ end
75
+
76
+ # POST /admin/shop/products/categories
77
+ # POST /admin/shop/products/categories.js
78
+ # POST /admin/shop/products/categories.json AJAX and HTML
79
+ #----------------------------------------------------------------------------
80
+ def create
81
+ notice = 'Category created successfully.'
82
+ error = 'Could not create Category.'
83
+
84
+ @shop_category.attributes = params[:shop_category]
85
+
86
+ begin
87
+ @shop_category.save!
88
+
89
+ respond_to do |format|
90
+ format.html {
91
+ flash[:notice] = notice
92
+
93
+ redirect_to edit_admin_shop_category_path(@shop_category) if params[:continue]
94
+ redirect_to admin_shop_categories_path unless params[:continue]
95
+ }
96
+ format.js { render :partial => '/admin/shop/categories/index/category', :locals => { :product => @shop_category } }
97
+ format.json { render :json => @shop_category.to_json(ShopCategory.params) }
98
+ end
99
+ rescue
100
+ respond_to do |format|
101
+ format.html {
102
+ flash[:error] = error
103
+ render :new
104
+ }
105
+ format.js { render :text => error, :status => :unprocessable_entity }
106
+ format.json { render :json => { :error => error }, :status => :unprocessable_entity }
107
+ end
108
+ end
109
+ end
110
+
111
+ # PUT /admin/shop/products/categories/1
112
+ # PUT /admin/shop/products/categories/1.js
113
+ # PUT /admin/shop/products/categories/1.json AJAX and HTML
114
+ #----------------------------------------------------------------------------
115
+ def update
116
+ notice = 'Category updated successfully.'
117
+ error = 'Could not update Category.'
118
+
119
+ begin
120
+ @shop_category.update_attributes!(params[:shop_category])
121
+
122
+ respond_to do |format|
123
+ format.html {
124
+ flash[:notice] = notice
125
+ redirect_to edit_admin_shop_category_path(@shop_category) if params[:continue]
126
+ redirect_to admin_shop_categories_path unless params[:continue]
127
+ }
128
+ format.js { render :partial => '/admin/shop/categories/index/category', :locals => { :product => @shop_category } }
129
+ format.json { render :json => @shop_category.to_json(ShopCategory.params) }
130
+ end
131
+ rescue
132
+ respond_to do |format|
133
+ format.html {
134
+ flash[:error] = error
135
+ render :edit
136
+ }
137
+ format.js { render :text => error, :status => :unprocessable_entity }
138
+ format.json { render :json => { :error => error }, :status => :unprocessable_entity }
139
+ end
140
+ end
141
+ end
142
+
143
+ # DELETE /admin/shop/products/categories/1
144
+ # DELETE /admin/shop/products/categories/1.js
145
+ # DELETE /admin/shop/products/categories/1.json AJAX and HTML
146
+ #----------------------------------------------------------------------------
147
+ def destroy
148
+ notice = 'Category deleted successfully.'
149
+ error = 'Could not delete Category.'
150
+
151
+ begin
152
+ @shop_category.destroy
153
+
154
+ respond_to do |format|
155
+ format.html {
156
+ flash[:notice] = notice
157
+ redirect_to admin_shop_categories_path
158
+ }
159
+ format.js { render :text => notice, :status => :ok }
160
+ format.json { render :json => { :notice => notice }, :status => :ok }
161
+ end
162
+ rescue
163
+ respond_to do |format|
164
+ format.html {
165
+ flash[:error] = error
166
+ render :remove
167
+ }
168
+ format.js { render :text => error, :status => :unprocessable_entity }
169
+ format.json { render :json => { :error => error }, :status => :unprocessable_entity }
170
+ end
171
+ end
172
+ end
173
+
174
+ private
175
+
176
+ def config_global
177
+ @meta ||= []
178
+ @buttons ||= []
179
+ @parts ||= []
180
+ @popups ||= []
181
+ end
182
+
183
+ def config_new
184
+ @meta << 'layouts'
185
+ @meta << 'handle'
186
+
187
+ @parts << 'description'
188
+ end
189
+
190
+ def config_edit
191
+ @meta << 'layouts'
192
+ @meta << 'handle'
193
+
194
+ @parts << 'description'
195
+ end
196
+
197
+ def assets_global
198
+ include_stylesheet 'admin/extensions/shop/edit'
199
+ end
200
+
201
+ def set_layouts
202
+ @shop_category.layout = Layout.find_by_name(Radiant::Config['shop.category_layout'])
203
+ @shop_category.product_layout = Layout.find_by_name(Radiant::Config['shop.product_layout'])
204
+ end
205
+
206
+ end