radiant-shop-extension 0.11.6 → 0.90.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data/HISTORY.md +21 -3
  2. data/LICENSE +42 -0
  3. data/README.md +62 -25
  4. data/Rakefile +4 -5
  5. data/VERSION +1 -1
  6. data/app/controllers/admin/shop/categories_controller.rb +1 -0
  7. data/app/controllers/admin/shop/orders_controller.rb +1 -1
  8. data/app/controllers/admin/shop/products_controller.rb +18 -7
  9. data/app/helpers/shop_helper.rb +8 -0
  10. data/app/models/form_address.rb +5 -5
  11. data/app/models/form_checkout.rb +25 -17
  12. data/app/models/form_line_item.rb +1 -1
  13. data/app/models/shop_category.rb +22 -7
  14. data/app/models/shop_customer.rb +1 -1
  15. data/app/models/shop_line_item.rb +26 -26
  16. data/app/models/shop_order.rb +0 -2
  17. data/app/models/shop_product.rb +15 -18
  18. data/app/views/.DS_Store +0 -0
  19. data/app/views/admin/shop/categories/edit/meta/_status.html.haml +3 -0
  20. data/app/views/admin/shop/products/edit/_foot.html.haml +1 -8
  21. data/app/views/admin/shop/products/edit/meta/_layout.html.haml +6 -0
  22. data/app/views/admin/shop/products/edit/meta/_status.html.haml +3 -0
  23. data/app/views/admin/shop/products/index/_product.html.haml +1 -1
  24. data/config/locales/en.yml +8 -7
  25. data/config/routes.rb +4 -16
  26. data/db/migrate/20101011063133_setup_shop.rb +94 -0
  27. data/db/seeds/forms.rb +113 -154
  28. data/db/seeds/layouts.rb +67 -103
  29. data/db/seeds/pages.rb +101 -0
  30. data/db/seeds/products.rb +29 -0
  31. data/db/seeds/snippets.rb +36 -21
  32. data/lib/shop/controllers/application_controller.rb +5 -3
  33. data/lib/shop/models/form_extension.rb +1 -2
  34. data/lib/shop/models/page.rb +0 -1
  35. data/lib/shop/models/user.rb +0 -1
  36. data/lib/shop/tags/card.rb +8 -2
  37. data/lib/shop/tags/cart.rb +5 -1
  38. data/lib/shop/tags/helpers.rb +35 -60
  39. data/lib/shop/tags/item.rb +2 -16
  40. data/lib/shop/tags/product.rb +7 -0
  41. data/lib/tasks/shop_extension_tasks.rake +9 -4
  42. data/public/javascripts/admin/extensions/shop/products/edit.js +0 -25
  43. data/radiant-shop-extension.gemspec +25 -201
  44. data/shop_extension.rb +18 -19
  45. data/spec/datasets/forms.rb +25 -28
  46. data/spec/datasets/shop_categories.rb +2 -2
  47. data/spec/datasets/shop_config.rb +24 -0
  48. data/spec/datasets/shop_customers.rb +1 -0
  49. data/spec/datasets/shop_line_items.rb +21 -3
  50. data/spec/datasets/shop_products.rb +4 -1
  51. data/spec/datasets/tags.rb +19 -0
  52. data/spec/lib/shop/models/page_spec.rb +1 -1
  53. data/spec/lib/shop/tags/card_spec.rb +30 -4
  54. data/spec/lib/shop/tags/cart_spec.rb +29 -12
  55. data/spec/lib/shop/tags/helpers_spec.rb +45 -66
  56. data/spec/lib/shop/tags/item_spec.rb +6 -10
  57. data/spec/lib/shop/tags/product_spec.rb +27 -2
  58. data/spec/models/form_address_spec.rb +9 -8
  59. data/spec/models/form_checkout_spec.rb +28 -22
  60. data/spec/models/shop_category_spec.rb +2 -10
  61. data/spec/models/shop_line_item_spec.rb +71 -34
  62. data/spec/models/shop_order_spec.rb +5 -5
  63. data/spec/models/shop_product_attachment_spec.rb +1 -0
  64. data/spec/models/shop_product_spec.rb +4 -47
  65. data/spec/spec.opts +3 -5
  66. metadata +60 -248
  67. data/Gemfile +0 -26
  68. data/Gemfile.lock +0 -75
  69. data/MIT-LICENSE +0 -20
  70. data/app/controllers/admin/shop/discounts/discountables_controller.rb +0 -44
  71. data/app/controllers/admin/shop/discounts_controller.rb +0 -64
  72. data/app/controllers/admin/shop/packages/packings_controller.rb +0 -90
  73. data/app/controllers/admin/shop/packages_controller.rb +0 -63
  74. data/app/controllers/admin/shop/products/variant_templates_controller.rb +0 -27
  75. data/app/controllers/admin/shop/products/variants_controller.rb +0 -60
  76. data/app/controllers/admin/shop/variants_controller.rb +0 -48
  77. data/app/models/form_discount.rb +0 -39
  78. data/app/models/shop_discount.rb +0 -37
  79. data/app/models/shop_discountable.rb +0 -64
  80. data/app/models/shop_group.rb +0 -15
  81. data/app/models/shop_grouping.rb +0 -6
  82. data/app/models/shop_package.rb +0 -74
  83. data/app/models/shop_packing.rb +0 -22
  84. data/app/models/shop_product_variant.rb +0 -34
  85. data/app/models/shop_variant.rb +0 -23
  86. data/app/views/admin/pages/_shop_category.html.haml +0 -4
  87. data/app/views/admin/pages/_shop_product.html.haml +0 -4
  88. data/app/views/admin/shop/discounts/edit/_foot.html.haml +0 -16
  89. data/app/views/admin/shop/discounts/edit/_form.html.haml +0 -15
  90. data/app/views/admin/shop/discounts/edit/_head.html.haml +0 -4
  91. data/app/views/admin/shop/discounts/edit/_inputs.html.haml +0 -2
  92. data/app/views/admin/shop/discounts/edit/_meta.html.haml +0 -8
  93. data/app/views/admin/shop/discounts/edit/_parts.html.haml +0 -9
  94. data/app/views/admin/shop/discounts/edit/_popups.html.haml +0 -4
  95. data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +0 -1
  96. data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +0 -1
  97. data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +0 -3
  98. data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +0 -3
  99. data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +0 -3
  100. data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +0 -5
  101. data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +0 -5
  102. data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +0 -3
  103. data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +0 -3
  104. data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +0 -6
  105. data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +0 -6
  106. data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +0 -11
  107. data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +0 -12
  108. data/app/views/admin/shop/discounts/edit.html.haml +0 -11
  109. data/app/views/admin/shop/discounts/index/_discount.html.haml +0 -13
  110. data/app/views/admin/shop/discounts/index/_foot.html.haml +0 -5
  111. data/app/views/admin/shop/discounts/index/_head.html.haml +0 -2
  112. data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +0 -1
  113. data/app/views/admin/shop/discounts/index.html.haml +0 -13
  114. data/app/views/admin/shop/discounts/new.html.haml +0 -11
  115. data/app/views/admin/shop/discounts/remove.html.haml +0 -12
  116. data/app/views/admin/shop/packages/edit/_foot.html.haml +0 -17
  117. data/app/views/admin/shop/packages/edit/_form.html.haml +0 -15
  118. data/app/views/admin/shop/packages/edit/_head.html.haml +0 -4
  119. data/app/views/admin/shop/packages/edit/_inputs.html.haml +0 -2
  120. data/app/views/admin/shop/packages/edit/_meta.html.haml +0 -8
  121. data/app/views/admin/shop/packages/edit/_parts.html.haml +0 -9
  122. data/app/views/admin/shop/packages/edit/_popups.html.haml +0 -4
  123. data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +0 -1
  124. data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +0 -3
  125. data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +0 -3
  126. data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +0 -5
  127. data/app/views/admin/shop/packages/edit/parts/_description.html.haml +0 -1
  128. data/app/views/admin/shop/packages/edit/parts/_products.html.haml +0 -3
  129. data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +0 -7
  130. data/app/views/admin/shop/packages/edit/shared/_product.html.haml +0 -8
  131. data/app/views/admin/shop/packages/edit.html.haml +0 -11
  132. data/app/views/admin/shop/packages/index/_foot.html.haml +0 -8
  133. data/app/views/admin/shop/packages/index/_head.html.haml +0 -2
  134. data/app/views/admin/shop/packages/index/_package.html.haml +0 -9
  135. data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +0 -1
  136. data/app/views/admin/shop/packages/index.html.haml +0 -13
  137. data/app/views/admin/shop/packages/new.html.haml +0 -11
  138. data/app/views/admin/shop/packages/remove.html.haml +0 -12
  139. data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +0 -1
  140. data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +0 -1
  141. data/app/views/admin/shop/products/edit/parts/_variants.html.haml +0 -3
  142. data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +0 -6
  143. data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +0 -16
  144. data/app/views/admin/shop/products/edit/shared/_template.html.haml +0 -6
  145. data/app/views/admin/shop/products/edit/shared/_variant.html.haml +0 -10
  146. data/app/views/admin/shop/products/index/buttons/_variants.html.haml +0 -1
  147. data/app/views/admin/shop/variants/edit/_foot.html.haml +0 -9
  148. data/app/views/admin/shop/variants/edit/_form.html.haml +0 -13
  149. data/app/views/admin/shop/variants/edit/_head.html.haml +0 -4
  150. data/app/views/admin/shop/variants/edit/_inputs.html.haml +0 -2
  151. data/app/views/admin/shop/variants/edit/_meta.html.haml +0 -8
  152. data/app/views/admin/shop/variants/edit/_parts.html.haml +0 -9
  153. data/app/views/admin/shop/variants/edit/_popups.html.haml +0 -4
  154. data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +0 -3
  155. data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +0 -3
  156. data/app/views/admin/shop/variants/edit.html.haml +0 -11
  157. data/app/views/admin/shop/variants/index/_foot.html.haml +0 -5
  158. data/app/views/admin/shop/variants/index/_head.html.haml +0 -2
  159. data/app/views/admin/shop/variants/index/_variant.html.haml +0 -9
  160. data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +0 -1
  161. data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +0 -1
  162. data/app/views/admin/shop/variants/index.html.haml +0 -13
  163. data/app/views/admin/shop/variants/new.html.haml +0 -11
  164. data/app/views/admin/shop/variants/remove.html.haml +0 -12
  165. data/app/views/shop/categories/show.html.haml +0 -1
  166. data/app/views/shop/orders/show.html.haml +0 -1
  167. data/app/views/shop/products/index.html.haml +0 -1
  168. data/app/views/shop/products/show.html.haml +0 -1
  169. data/cucumber.yml +0 -1
  170. data/db/migrate/20100311053701_initial.rb +0 -153
  171. data/db/migrate/20100927041219_remove_payment_methods.rb +0 -16
  172. data/db/migrate/20100927041624_change_payments_add_gateway.rb +0 -11
  173. data/db/migrate/20100927140446_change_payment_add_card_type_card_number.rb +0 -11
  174. data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +0 -101
  175. data/db/migrate/20100929011607_drop_shop_addressables.rb +0 -25
  176. data/db/migrate/20100929030510_create_shop_groups.rb +0 -19
  177. data/db/migrate/20100929080301_shop_groups_change_add_description.rb +0 -11
  178. data/db/migrate/20100929081200_create_variants.rb +0 -20
  179. data/db/migrate/20100929143531_change_variants_add_updated_by.rb +0 -25
  180. data/db/migrate/20100929145641_change_created_by_to_id.rb +0 -75
  181. data/db/migrate/20100929235221_change_category_add_variant_id.rb +0 -9
  182. data/db/migrate/20100930235221_create_packages.rb +0 -31
  183. data/db/migrate/20101005231713_create_page_ids.rb +0 -11
  184. data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +0 -73
  185. data/db/migrate/20101007111845_add_default_position_to_attachment.rb +0 -9
  186. data/db/migrate/20101010071143_create_discounts.rb +0 -29
  187. data/db/migrate/20101010072225_modify_categories_remove_variant.rb +0 -9
  188. data/db/migrate/20101010130034_change_discountables_add_observer.rb +0 -15
  189. data/db/migrate/20101011063133_change_orders_set_limits_to_null.rb +0 -11
  190. data/features/support/env.rb +0 -16
  191. data/features/support/paths.rb +0 -14
  192. data/lib/shop/interface/packages.rb +0 -34
  193. data/lib/shop/interface/variants.rb +0 -34
  194. data/lib/shop/tags/package.rb +0 -95
  195. data/lib/shop/tags/product_variant.rb +0 -52
  196. data/lib/shop/tags/responses.rb +0 -34
  197. data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
  198. data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
  199. data/mockups/discounts/new-edit.bmml +0 -492
  200. data/public/javascripts/admin/extensions/shop/discounts/edit.js +0 -76
  201. data/public/javascripts/admin/extensions/shop/packages/edit.js +0 -109
  202. data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +0 -125
  203. data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +0 -162
  204. data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +0 -73
  205. data/spec/controllers/admin/shop/discounts_controller_spec.rb +0 -81
  206. data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +0 -188
  207. data/spec/controllers/admin/shop/packages_controller_spec.rb +0 -32
  208. data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +0 -53
  209. data/spec/controllers/admin/shop/products/variants_controller_spec.rb +0 -116
  210. data/spec/controllers/admin/shop/variants_controller_spec.rb +0 -67
  211. data/spec/datasets/shop_discountables.rb +0 -22
  212. data/spec/datasets/shop_discounts.rb +0 -29
  213. data/spec/datasets/shop_groups.rb +0 -15
  214. data/spec/datasets/shop_packages.rb +0 -25
  215. data/spec/datasets/shop_product_variants.rb +0 -22
  216. data/spec/datasets/shop_variants.rb +0 -17
  217. data/spec/lib/shop/tags/package_spec.rb +0 -342
  218. data/spec/lib/shop/tags/product_variant_spec.rb +0 -175
  219. data/spec/lib/shop/tags/responses_spec.rb +0 -129
  220. data/spec/models/form_discount_spec.rb +0 -63
  221. data/spec/models/shop_discount_spec.rb +0 -130
  222. data/spec/models/shop_discountable_spec.rb +0 -114
  223. data/spec/models/shop_group_spec.rb +0 -38
  224. data/spec/models/shop_package_spec.rb +0 -117
  225. data/spec/models/shop_packing_spec.rb +0 -67
  226. data/spec/models/shop_product_variant_spec.rb +0 -92
  227. data/spec/models/shop_variant_spec.rb +0 -32
data/Gemfile.lock DELETED
@@ -1,75 +0,0 @@
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/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
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.
@@ -1,44 +0,0 @@
1
- class Admin::Shop::Discounts::DiscountablesController < Admin::ResourceController
2
-
3
- model_class ShopDiscountable
4
-
5
- def create
6
- error = 'Could not attach Discount.'
7
- begin
8
- @shop_discountable.attributes = {
9
- :discount_id => params[:discount_id],
10
- :discounted_id => params[:discounted_id],
11
- :discounted_type => params[:discounted_type]
12
- }
13
- @shop_discountable.save!
14
-
15
- discounted_type = @shop_discountable.discounted_type.gsub('Shop','').underscore
16
-
17
- respond_to do |format|
18
- format.js { render :partial => "admin/shop/discounts/edit/shared/#{discounted_type}", :locals => { discounted_type.to_sym => @shop_discountable } }
19
- end
20
- rescue
21
- respond_to do |format|
22
- format.js { render :text => error, :status => :unprocessable_entity }
23
- end
24
- end
25
- end
26
-
27
- def destroy
28
- error = 'Could not remove Discount.'
29
- begin
30
- discounted_type = @shop_discountable.discounted_type.gsub('Shop','').underscore
31
-
32
- @shop_discountable.destroy
33
-
34
- respond_to do |format|
35
- format.js { render :partial => "admin/shop/discounts/edit/shared/#{discounted_type}", :locals => { discounted_type.to_sym => @shop_discountable } }
36
- end
37
- rescue
38
- respond_to do |format|
39
- format.js { render :text => error, :status => :unprocessable_entity }
40
- end
41
- end
42
- end
43
-
44
- end
@@ -1,64 +0,0 @@
1
- class Admin::Shop::DiscountsController < Admin::ResourceController
2
-
3
- model_class ShopDiscount
4
-
5
- before_filter :config_global
6
- before_filter :config_index, :only => [ :index ]
7
- before_filter :config_new, :only => [ :new, :create ]
8
- before_filter :config_edit, :only => [ :edit, :update ]
9
- before_filter :assets_global, :except => [ :remove, :destroy ]
10
- before_filter :assets_edit, :only => [ :edit, :update ]
11
-
12
- private
13
-
14
- def config_global
15
- @inputs ||= []
16
- @meta ||= []
17
- @buttons ||= []
18
- @parts ||= []
19
- @popups ||= []
20
- end
21
-
22
- def config_index
23
- @buttons << 'new_discount'
24
- end
25
-
26
- def config_new
27
- @inputs << 'name'
28
- @inputs << 'amount'
29
- @inputs << 'code'
30
-
31
- @meta << 'start'
32
- @meta << 'finish'
33
- end
34
-
35
- def config_edit
36
- @buttons << 'browse_categories'
37
- @buttons << 'browse_products'
38
-
39
- @inputs << 'name'
40
- @inputs << 'amount'
41
- @inputs << 'code'
42
-
43
- @meta << 'start'
44
- @meta << 'finish'
45
-
46
- @parts << 'categories'
47
- @parts << 'products'
48
-
49
- @popups << 'browse_categories'
50
- @popups << 'browse_products'
51
- end
52
-
53
- def assets_global
54
- include_stylesheet 'admin/extensions/shop/edit'
55
- include_stylesheet 'admin/extensions/shop/index'
56
- end
57
-
58
- def assets_edit
59
- include_javascript 'admin/extensions/shop/edit'
60
- include_javascript 'admin/extensions/shop/discounts/edit'
61
- include_stylesheet 'admin/extensions/shop/discounts/edit'
62
- end
63
-
64
- end
@@ -1,90 +0,0 @@
1
- class Admin::Shop::Packages::PackingsController < Admin::ResourceController
2
- model_class ShopPacking
3
-
4
- def sort
5
- notice = 'Products successfully sorted.'
6
- error = 'Could not sort products.'
7
-
8
- begin
9
- @shop_packings = CGI::parse(params[:packings])["package_products[]"]
10
-
11
- @shop_packings.each_with_index do |id, index|
12
- ShopPacking.find(id).update_attributes!({ :position, index+1 })
13
- end
14
-
15
- respond_to do |format|
16
- format.html {
17
- redirect_to admin_shop_packages_path
18
- }
19
- format.js { render :text => notice, :status => :ok }
20
- format.json { render :json => { :notice => notice }, :status => :ok }
21
- end
22
- rescue
23
- respond_to do |format|
24
- format.html {
25
- flash[:error] = error
26
- redirect_to admin_shop_packages_path
27
- }
28
- format.js { render :text => error, :status => :unprocessable_entity }
29
- format.json { render :json => { :error => error }, :status => :unprocessable_entity }
30
- end
31
- end
32
- end
33
-
34
- def create
35
- notice = 'Product successfully attached.'
36
- error = 'Could not attach product.'
37
-
38
- begin
39
- @shop_packing.package = ShopPackage.find(params[:package_id])
40
- @shop_packing.product = ShopProduct.find(params[:product_id])
41
- @shop_packing.save!
42
-
43
- respond_to do |format|
44
- format.js { render :partial => 'admin/shop/packages/edit/shared/product', :locals => { :product => @shop_packing.product, :packing => @shop_packing } }
45
- end
46
- rescue
47
- respond_to do |format|
48
- format.js { render :text => error, :status => :unprocessable_entity }
49
- end
50
- end
51
- end
52
-
53
- def update
54
- notice = 'Product Quantity successfully updated.'
55
- error = 'Could not update Product Quantity.'
56
-
57
- begin
58
- @shop_packing.update_attributes!({ :quantity => params[:quantity] })
59
- respond_to do |format|
60
- format.js { render :text => notice, :status => :ok }
61
- end
62
- rescue
63
- respond_to do |format|
64
- format.js { render :text => error, :status => :unprocessable_entity }
65
- end
66
- end
67
-
68
- end
69
-
70
- def destroy
71
- notice = 'Product successfully removed.'
72
- error = 'Could not remove product.'
73
-
74
- begin
75
- @shop_product = @shop_packing.product
76
- @shop_package = @shop_packing.package
77
-
78
- @shop_packing.destroy
79
-
80
- respond_to do |format|
81
- format.js { render :partial => 'admin/shop/packages/edit/shared/product', :locals => { :product => @shop_product } }
82
- end
83
- rescue
84
- respond_to do |format|
85
- format.js { render :text => error, :status => :unprocessable_entity }
86
- end
87
- end
88
- end
89
-
90
- end
@@ -1,63 +0,0 @@
1
- class Admin::Shop::PackagesController < Admin::ResourceController
2
- model_class ShopPackage
3
-
4
- helper :shop
5
-
6
- before_filter :config_global
7
- before_filter :config_index, :only => [ :index ]
8
- before_filter :config_new, :only => [ :new, :create ]
9
- before_filter :config_edit, :only => [ :edit, :update ]
10
- before_filter :assets_global
11
- before_filter :assets_index, :only => :index
12
- before_filter :assets_edit, :only => [ :edit, :update ]
13
-
14
- private
15
-
16
- def config_global
17
- @inputs ||= []
18
- @meta ||= []
19
- @buttons ||= []
20
- @parts ||= []
21
- @popups ||= []
22
-
23
- @inputs << 'name'
24
- @inputs << 'price'
25
- end
26
-
27
- def config_index
28
- @buttons << 'new_package'
29
- end
30
-
31
- def config_new
32
- @meta << 'sku'
33
-
34
- @parts << 'description'
35
- end
36
-
37
- def config_edit
38
- @meta << 'sku'
39
-
40
- @parts << 'description'
41
- @parts << 'products'
42
-
43
- @buttons << 'browse_products'
44
-
45
- @popups << 'browse_products'
46
- end
47
-
48
- def assets_global
49
- end
50
-
51
- def assets_index
52
- include_stylesheet 'admin/extensions/shop/index'
53
- end
54
-
55
- def assets_edit
56
- include_javascript 'admin/dragdrop'
57
- include_javascript 'admin/extensions/shop/edit'
58
- include_stylesheet 'admin/extensions/shop/edit'
59
- include_stylesheet 'admin/extensions/shop/packages/edit'
60
- include_javascript 'admin/extensions/shop/packages/edit'
61
- end
62
-
63
- end
@@ -1,27 +0,0 @@
1
- class Admin::Shop::Products::VariantTemplatesController < Admin::ResourceController
2
-
3
- model_class ShopVariant
4
-
5
- def update
6
- error = 'Could not attach all Variants to Product.'
7
-
8
- @shop_product = ShopProduct.find(params[:product_id])
9
-
10
- if @shop_product.apply_variant_template(@shop_variant)
11
- respond_to do |format|
12
- format.html {
13
- redirect_to [ :edit_admin, @shop_product ]
14
- }
15
- end
16
- else
17
- respond_to do |format|
18
- format.html {
19
- flash[:error] = error
20
- redirect_to [ :edit_admin, @shop_product ]
21
- }
22
- end
23
- end
24
-
25
- end
26
-
27
- end
@@ -1,60 +0,0 @@
1
- class Admin::Shop::Products::VariantsController < Admin::ResourceController
2
-
3
- model_class ShopProductVariant
4
-
5
- before_filter :find_product
6
-
7
- def create
8
- notice = 'Successfully created variant.'
9
- error = 'Could not create variant.'
10
-
11
- begin
12
- @shop_product_variant.attributes = params[:shop_product_variant]
13
- @shop_product_variant.save!
14
-
15
- respond_to do |format|
16
- format.html {
17
- redirect_to edit_admin_shop_product_path(@shop_product)
18
- }
19
- format.js { render :partial => '/admin/shop/products/edit/shared/variant', :locals => { :variant => @shop_product_variant } }
20
- end
21
- rescue
22
- respond_to do |format|
23
- format.html {
24
- flash[:error] = error
25
- redirect_to edit_admin_shop_product_path(@shop_product)
26
- }
27
- format.js { render :text => error, :status => :unprocessable_entity }
28
- end
29
- end
30
- end
31
-
32
- def destroy
33
- notice = 'Successfully destroyed variant.'
34
- error = 'Could not destroy variant.'
35
-
36
- if @shop_product_variant.destroy
37
- respond_to do |format|
38
- format.html {
39
- redirect_to edit_admin_shop_product_path(@shop_product)
40
- }
41
- format.js { render :text => notice, :status => :ok }
42
- end
43
- else
44
- respond_to do |format|
45
- format.html {
46
- flash[:error] = error
47
- redirect_to edit_admin_shop_product_path(@shop_product)
48
- }
49
- format.js { render :text => error, :status => :unprocessable_entity }
50
- end
51
- end
52
- end
53
-
54
- private
55
-
56
- def find_product
57
- @shop_product = @shop_product_variant.product || ShopProduct.find(params[:product_id])
58
- end
59
-
60
- end
@@ -1,48 +0,0 @@
1
- class Admin::Shop::VariantsController < Admin::ResourceController
2
-
3
- model_class ShopVariant
4
-
5
- before_filter :config_global
6
- before_filter :config_index, :only => [ :index ]
7
- before_filter :config_new, :only => [ :new, :create ]
8
- before_filter :config_edit, :only => [ :edit, :update ]
9
- before_filter :assets_global
10
- before_filter :assets_index, :only => [ :index ]
11
- before_filter :assets_edit, :only => [ :edit, :update ]
12
-
13
- private
14
-
15
- def config_global
16
- @inputs ||= []
17
- @meta ||= []
18
- @buttons ||= []
19
- @parts ||= []
20
- @popups ||= []
21
-
22
- @inputs << 'name'
23
- @inputs << 'options'
24
- end
25
-
26
- def config_index
27
- @buttons << 'add_variant'
28
- @buttons << 'categories'
29
- end
30
-
31
- def config_new
32
- end
33
-
34
- def config_edit
35
- end
36
-
37
- def assets_global
38
- include_stylesheet 'admin/extensions/shop/edit'
39
- include_stylesheet 'admin/extensions/shop/index'
40
- end
41
-
42
- def assets_index
43
- end
44
-
45
- def assets_edit
46
- end
47
-
48
- end
@@ -1,39 +0,0 @@
1
- class FormDiscount
2
- include Forms::Models::Extension
3
- include Shop::Models::FormExtension
4
-
5
- def create
6
- @result ||= { process.to_sym => false }
7
-
8
- find_current_order
9
-
10
- case process
11
- when 'add'
12
- if @discount = ShopDiscount.find_by_code(discount_code)
13
- @discountable = @discount.discountables.create(:discounted_id => @order.id, :discounted_type => @order.class.name)
14
- @result[process.to_sym] = @discountable.valid?
15
- end
16
- when 'remove'
17
- if @discountable = @order.discountables.find(discountable_id)
18
- @result[process.to_sym] = @discountable.destroy
19
- end
20
- end
21
-
22
- @result
23
- end
24
-
25
- protected
26
-
27
- def process
28
- @config[:process]
29
- end
30
-
31
- def discount_code
32
- @data[:discount][:code]
33
- end
34
-
35
- def discountable_id
36
- @data[:discountable][:id]
37
- end
38
-
39
- end
@@ -1,37 +0,0 @@
1
- class ShopDiscount < ActiveRecord::Base
2
-
3
- # Return all discounts which are valid
4
- default_scope :conditions => [
5
- '(starts_at IS NULL and finishes_at IS NULL) OR (starts_at >= :now AND finishes_at <= :now) OR (starts_at IS NULL and finishes_at <= :now)',
6
- { :now => Time.now }
7
- ]
8
-
9
- belongs_to :created_by, :class_name => 'User'
10
- belongs_to :updated_by, :class_name => 'User'
11
-
12
- has_many :discountables, :class_name => 'ShopDiscountable', :foreign_key => :discount_id
13
- has_many :categories, :through => :discountables, :source => :category, :conditions => "shop_discountables.discounted_type = 'ShopCategory'"
14
- has_many :products, :through => :discountables, :source => :product, :conditions => "shop_discountables.discounted_type = 'ShopProduct'"
15
- has_many :orders, :through => :discountables, :source => :order, :conditions => "shop_discountables.discounted_type = 'ShopOrder'"
16
- has_many :line_items, :through => :discountables, :source => :line_item,:conditions => "shop_discountables.discounted_type = 'ShopLineItem'"
17
-
18
- validates_presence_of :name, :code, :amount
19
- validates_uniqueness_of :name, :code
20
- validates_numericality_of :amount
21
-
22
- # This will override the default scope
23
- def self.all_including_invalid(*attrs)
24
- with_exclusive_scope{find(:all,*attrs)}
25
- end
26
-
27
- # Return all categories minus its own
28
- def available_categories
29
- ShopCategory.all - categories
30
- end
31
-
32
- # Returns all products minus its own
33
- def available_products
34
- ShopProduct.all - products
35
- end
36
-
37
- end
@@ -1,64 +0,0 @@
1
- class ShopDiscountable < ActiveRecord::Base
2
-
3
- belongs_to :discount, :class_name => 'ShopDiscount', :foreign_key => :discount_id
4
- belongs_to :discounted, :foreign_key => :discounted_id, :polymorphic => true
5
- belongs_to :category, :class_name => 'ShopCategory', :foreign_key => :discounted_id
6
- belongs_to :product, :class_name => 'ShopProduct', :foreign_key => :discounted_id
7
- belongs_to :order, :class_name => 'ShopOrder', :foreign_key => :discounted_id
8
- belongs_to :line_item, :class_name => 'ShopLineItem', :foreign_key => :discounted_id
9
-
10
- validates_presence_of :discount, :discounted
11
- validates_uniqueness_of :discounted_id, :scope => [ :discount_id, :discounted_type ]
12
-
13
- before_validation :create_shop_products_if_shop_category
14
- before_destroy :destroy_shop_products_if_shop_category
15
-
16
- before_validation :create_shop_line_items_if_shop_order
17
- before_destroy :destroy_shop_line_items_if_shop_order
18
-
19
- # Returns discount of a class
20
- def self.for(type)
21
- all(:conditions => { :discounted_type => type.pluralize.classify })
22
- end
23
-
24
- # Adds discount to a category's products
25
- def create_shop_products_if_shop_category
26
- if discounted_type === 'ShopCategory'
27
- discounted.products.each do |product|
28
- # Attach discount to the child product
29
- ShopDiscountable.create(:discount => discount, :discounted => product)
30
- end
31
- end
32
- end
33
-
34
- # Removes discount from a category's products
35
- def destroy_shop_products_if_shop_category
36
- if discounted_type === 'ShopCategory'
37
- discount.discountables.for('ShopProduct').each do |discountable|
38
- discountable.destroy
39
- end
40
- end
41
- end
42
-
43
- # Adds discount to an order's line_items
44
- def create_shop_line_items_if_shop_order
45
- if discounted_type === 'ShopOrder'
46
- discounted.line_items.each do |line_item|
47
- if line_item.item.discounts.include?(discount)
48
- # We're here if the item associated with the line item can be discounted
49
- discount = ShopDiscountable.create(:discount_id => discount_id, :discounted => line_item)
50
- end
51
- end
52
- end
53
- end
54
-
55
- # Removes discount from an order's line_items
56
- def destroy_shop_line_items_if_shop_order
57
- if discounted_type === 'ShopOrder'
58
- discount.discountables.for('ShopLineItem').each do |discountable|
59
- discountable.destroy
60
- end
61
- end
62
- end
63
-
64
- end
@@ -1,15 +0,0 @@
1
- class ShopGroup < ActiveRecord::Base
2
-
3
- belongs_to :created_by, :class_name => 'User'
4
- belongs_to :updated_by, :class_name => 'User'
5
-
6
- has_many :groupings, :class_name => 'ShopGrouping', :foreign_key => :group_id
7
- has_many :products, :class_name => 'ShopProduct', :through => :groupings
8
-
9
- validates_presence_of :name
10
-
11
- def available_products
12
- ShopProduct.all - self.products
13
- end
14
-
15
- end
@@ -1,6 +0,0 @@
1
- class ShopGrouping < ActiveRecord::Base
2
-
3
- belongs_to :group, :class_name => 'ShopGroup'
4
- belongs_to :product, :class_name => 'ShopProduct'
5
-
6
- end