Permalink
Browse files

Merge branch 'rc'

  • Loading branch information...
2 parents 4c190fe + d4d4d8a commit a2a75a76bc39fc8f750dfb89338003cb3cd8feae Dirk Kelly committed Oct 23, 2010
Showing with 1,005 additions and 5,376 deletions.
  1. +42 −0 LICENSE
  2. +0 −20 MIT-LICENSE
  3. +41 −25 README.md
  4. +1 −2 Rakefile
  5. +1 −0 app/controllers/admin/shop/categories_controller.rb
  6. +0 −44 app/controllers/admin/shop/discounts/discountables_controller.rb
  7. +0 −64 app/controllers/admin/shop/discounts_controller.rb
  8. +0 −90 app/controllers/admin/shop/packages/packings_controller.rb
  9. +0 −63 app/controllers/admin/shop/packages_controller.rb
  10. +0 −27 app/controllers/admin/shop/products/variant_templates_controller.rb
  11. +0 −60 app/controllers/admin/shop/products/variants_controller.rb
  12. +2 −7 app/controllers/admin/shop/products_controller.rb
  13. +0 −48 app/controllers/admin/shop/variants_controller.rb
  14. +5 −5 app/models/form_address.rb
  15. +25 −17 app/models/form_checkout.rb
  16. +0 −39 app/models/form_discount.rb
  17. +15 −5 app/models/shop_category.rb
  18. +0 −37 app/models/shop_discount.rb
  19. +0 −64 app/models/shop_discountable.rb
  20. +0 −15 app/models/shop_group.rb
  21. +0 −6 app/models/shop_grouping.rb
  22. +15 −24 app/models/shop_line_item.rb
  23. +0 −2 app/models/shop_order.rb
  24. +0 −74 app/models/shop_package.rb
  25. +0 −22 app/models/shop_packing.rb
  26. +14 −17 app/models/shop_product.rb
  27. +0 −34 app/models/shop_product_variant.rb
  28. +0 −23 app/models/shop_variant.rb
  29. BIN app/views/.DS_Store
  30. +0 −4 app/views/admin/pages/_shop_category.html.haml
  31. +0 −4 app/views/admin/pages/_shop_product.html.haml
  32. +2 −0 app/views/admin/shop/categories/edit/meta/_status.html.haml
  33. +0 −11 app/views/admin/shop/discounts/edit.html.haml
  34. +0 −16 app/views/admin/shop/discounts/edit/_foot.html.haml
  35. +0 −15 app/views/admin/shop/discounts/edit/_form.html.haml
  36. +0 −4 app/views/admin/shop/discounts/edit/_head.html.haml
  37. +0 −2 app/views/admin/shop/discounts/edit/_inputs.html.haml
  38. +0 −8 app/views/admin/shop/discounts/edit/_meta.html.haml
  39. +0 −9 app/views/admin/shop/discounts/edit/_parts.html.haml
  40. +0 −4 app/views/admin/shop/discounts/edit/_popups.html.haml
  41. +0 −1 app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml
  42. +0 −1 app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml
  43. +0 −3 app/views/admin/shop/discounts/edit/inputs/_amount.html.haml
  44. +0 −3 app/views/admin/shop/discounts/edit/inputs/_code.html.haml
  45. +0 −3 app/views/admin/shop/discounts/edit/inputs/_name.html.haml
  46. +0 −5 app/views/admin/shop/discounts/edit/meta/_finish.html.haml
  47. +0 −5 app/views/admin/shop/discounts/edit/meta/_start.html.haml
  48. +0 −3 app/views/admin/shop/discounts/edit/parts/_categories.html.haml
  49. +0 −3 app/views/admin/shop/discounts/edit/parts/_products.html.haml
  50. +0 −6 app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml
  51. +0 −6 app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml
  52. +0 −11 app/views/admin/shop/discounts/edit/shared/_category.html.haml
  53. +0 −12 app/views/admin/shop/discounts/edit/shared/_product.html.haml
  54. +0 −13 app/views/admin/shop/discounts/index.html.haml
  55. +0 −13 app/views/admin/shop/discounts/index/_discount.html.haml
  56. +0 −5 app/views/admin/shop/discounts/index/_foot.html.haml
  57. +0 −2 app/views/admin/shop/discounts/index/_head.html.haml
  58. +0 −1 app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml
  59. +0 −11 app/views/admin/shop/discounts/new.html.haml
  60. +0 −12 app/views/admin/shop/discounts/remove.html.haml
  61. +0 −11 app/views/admin/shop/packages/edit.html.haml
  62. +0 −17 app/views/admin/shop/packages/edit/_foot.html.haml
  63. +0 −15 app/views/admin/shop/packages/edit/_form.html.haml
  64. +0 −4 app/views/admin/shop/packages/edit/_head.html.haml
  65. +0 −2 app/views/admin/shop/packages/edit/_inputs.html.haml
  66. +0 −8 app/views/admin/shop/packages/edit/_meta.html.haml
  67. +0 −9 app/views/admin/shop/packages/edit/_parts.html.haml
  68. +0 −4 app/views/admin/shop/packages/edit/_popups.html.haml
  69. +0 −1 app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml
  70. +0 −3 app/views/admin/shop/packages/edit/inputs/_name.html.haml
  71. +0 −3 app/views/admin/shop/packages/edit/inputs/_price.html.haml
  72. +0 −5 app/views/admin/shop/packages/edit/meta/_sku.html.haml
  73. +0 −1 app/views/admin/shop/packages/edit/parts/_description.html.haml
  74. +0 −3 app/views/admin/shop/packages/edit/parts/_products.html.haml
  75. +0 −7 app/views/admin/shop/packages/edit/popups/_browse_products.html.haml
  76. +0 −8 app/views/admin/shop/packages/edit/shared/_product.html.haml
  77. +0 −13 app/views/admin/shop/packages/index.html.haml
  78. +0 −8 app/views/admin/shop/packages/index/_foot.html.haml
  79. +0 −2 app/views/admin/shop/packages/index/_head.html.haml
  80. +0 −9 app/views/admin/shop/packages/index/_package.html.haml
  81. +0 −1 app/views/admin/shop/packages/index/buttons/_new_package.html.haml
  82. +0 −11 app/views/admin/shop/packages/new.html.haml
  83. +0 −12 app/views/admin/shop/packages/remove.html.haml
  84. +0 −1 app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml
  85. +0 −1 app/views/admin/shop/products/edit/buttons/_new_variant.html.haml
  86. +6 −0 app/views/admin/shop/products/edit/meta/_layout.html.haml
  87. +2 −0 app/views/admin/shop/products/edit/meta/_status.html.haml
  88. +0 −3 app/views/admin/shop/products/edit/parts/_variants.html.haml
  89. +0 −6 app/views/admin/shop/products/edit/popups/_browse_templates.html.haml
  90. +0 −16 app/views/admin/shop/products/edit/popups/_new_variant.html.haml
  91. +0 −6 app/views/admin/shop/products/edit/shared/_template.html.haml
  92. +0 −10 app/views/admin/shop/products/edit/shared/_variant.html.haml
  93. +0 −1 app/views/admin/shop/products/index/buttons/_variants.html.haml
  94. +0 −11 app/views/admin/shop/variants/edit.html.haml
  95. +0 −9 app/views/admin/shop/variants/edit/_foot.html.haml
  96. +0 −13 app/views/admin/shop/variants/edit/_form.html.haml
  97. +0 −4 app/views/admin/shop/variants/edit/_head.html.haml
  98. +0 −2 app/views/admin/shop/variants/edit/_inputs.html.haml
  99. +0 −8 app/views/admin/shop/variants/edit/_meta.html.haml
  100. +0 −9 app/views/admin/shop/variants/edit/_parts.html.haml
  101. +0 −4 app/views/admin/shop/variants/edit/_popups.html.haml
  102. +0 −3 app/views/admin/shop/variants/edit/inputs/_name.html.haml
  103. +0 −3 app/views/admin/shop/variants/edit/inputs/_options.html.haml
  104. +0 −13 app/views/admin/shop/variants/index.html.haml
  105. +0 −5 app/views/admin/shop/variants/index/_foot.html.haml
  106. +0 −2 app/views/admin/shop/variants/index/_head.html.haml
  107. +0 −9 app/views/admin/shop/variants/index/_variant.html.haml
  108. +0 −1 app/views/admin/shop/variants/index/buttons/_add_variant.html.haml
  109. +0 −1 app/views/admin/shop/variants/index/buttons/_categories.html.haml
  110. +0 −11 app/views/admin/shop/variants/new.html.haml
  111. +0 −12 app/views/admin/shop/variants/remove.html.haml
  112. +0 −1 app/views/shop/categories/show.html.haml
  113. +0 −1 app/views/shop/orders/show.html.haml
  114. +0 −1 app/views/shop/products/index.html.haml
  115. +0 −1 app/views/shop/products/show.html.haml
  116. +0 −153 db/migrate/20100311053701_initial.rb
  117. +0 −16 db/migrate/20100927041219_remove_payment_methods.rb
  118. +0 −11 db/migrate/20100927041624_change_payments_add_gateway.rb
  119. +0 −11 db/migrate/20100927140446_change_payment_add_card_type_card_number.rb
  120. +0 −101 db/migrate/20100929011106_fix_relationship_foreign_keys.rb
  121. +0 −25 db/migrate/20100929011607_drop_shop_addressables.rb
  122. +0 −19 db/migrate/20100929030510_create_shop_groups.rb
  123. +0 −11 db/migrate/20100929080301_shop_groups_change_add_description.rb
  124. +0 −20 db/migrate/20100929081200_create_variants.rb
  125. +0 −25 db/migrate/20100929143531_change_variants_add_updated_by.rb
  126. +0 −75 db/migrate/20100929145641_change_created_by_to_id.rb
  127. +0 −9 db/migrate/20100929235221_change_category_add_variant_id.rb
  128. +0 −31 db/migrate/20100930235221_create_packages.rb
  129. +0 −11 db/migrate/20101005231713_create_page_ids.rb
  130. +0 −73 db/migrate/20101006051214_create_pages_for_products_and_categories.rb
  131. +0 −9 db/migrate/20101007111845_add_default_position_to_attachment.rb
  132. +0 −29 db/migrate/20101010071143_create_discounts.rb
  133. +0 −9 db/migrate/20101010072225_modify_categories_remove_variant.rb
  134. +0 −15 db/migrate/20101010130034_change_discountables_add_observer.rb
  135. +0 −11 db/migrate/20101011063133_change_orders_set_limits_to_null.rb
  136. +93 −0 db/migrate/20101011063133_setup_shop.rb
  137. +113 −154 db/seeds/forms.rb
  138. +70 −103 db/seeds/layouts.rb
  139. +101 −0 db/seeds/pages.rb
  140. +21 −0 db/seeds/products.rb
  141. +36 −21 db/seeds/snippets.rb
  142. +5 −3 lib/shop/controllers/application_controller.rb
  143. +0 −34 lib/shop/interface/packages.rb
  144. +0 −34 lib/shop/interface/variants.rb
  145. +1 −2 lib/shop/models/form_extension.rb
  146. +0 −1 lib/shop/models/page.rb
  147. +0 −1 lib/shop/models/user.rb
  148. +8 −2 lib/shop/tags/card.rb
  149. +5 −1 lib/shop/tags/cart.rb
  150. +16 −59 lib/shop/tags/helpers.rb
  151. +2 −16 lib/shop/tags/item.rb
  152. +0 −95 lib/shop/tags/package.rb
  153. +0 −52 lib/shop/tags/product_variant.rb
  154. +34 −17 lib/shop/tags/responses.rb
  155. +9 −4 lib/tasks/shop_extension_tasks.rake
  156. +0 −76 public/javascripts/admin/extensions/shop/discounts/edit.js
  157. +0 −109 public/javascripts/admin/extensions/shop/packages/edit.js
  158. +0 −25 public/javascripts/admin/extensions/shop/products/edit.js
  159. +0 −125 public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass
  160. +0 −162 public/stylesheets/sass/admin/extensions/shop/packages/edit.sass
  161. +11 −17 shop_extension.rb
  162. +0 −73 spec/controllers/admin/shop/discounts/discountables_controller_spec.rb
  163. +0 −81 spec/controllers/admin/shop/discounts_controller_spec.rb
  164. +0 −188 spec/controllers/admin/shop/packages/packings_controller_spec.rb
  165. +0 −32 spec/controllers/admin/shop/packages_controller_spec.rb
  166. +0 −53 spec/controllers/admin/shop/products/variant_templates_controller_spec.rb
  167. +0 −116 spec/controllers/admin/shop/products/variants_controller_spec.rb
  168. +0 −67 spec/controllers/admin/shop/variants_controller_spec.rb
  169. +25 −28 spec/datasets/forms.rb
  170. +2 −2 spec/datasets/shop_categories.rb
  171. +24 −0 spec/datasets/shop_config.rb
  172. +0 −22 spec/datasets/shop_discountables.rb
  173. +0 −29 spec/datasets/shop_discounts.rb
  174. +0 −15 spec/datasets/shop_groups.rb
  175. +2 −0 spec/datasets/shop_line_items.rb
  176. +0 −25 spec/datasets/shop_packages.rb
  177. +0 −22 spec/datasets/shop_product_variants.rb
  178. +2 −0 spec/datasets/shop_products.rb
  179. +0 −17 spec/datasets/shop_variants.rb
  180. +19 −0 spec/datasets/tags.rb
  181. +1 −1 spec/lib/shop/models/page_spec.rb
  182. +30 −4 spec/lib/shop/tags/card_spec.rb
  183. +30 −13 spec/lib/shop/tags/cart_spec.rb
  184. +2 −66 spec/lib/shop/tags/helpers_spec.rb
  185. +7 −11 spec/lib/shop/tags/item_spec.rb
  186. +0 −342 spec/lib/shop/tags/package_spec.rb
  187. +2 −2 spec/lib/shop/tags/product_spec.rb
  188. +0 −175 spec/lib/shop/tags/product_variant_spec.rb
  189. +61 −81 spec/lib/shop/tags/responses_spec.rb
  190. +9 −8 spec/models/form_address_spec.rb
  191. +28 −22 spec/models/form_checkout_spec.rb
  192. +0 −63 spec/models/form_discount_spec.rb
  193. +0 −8 spec/models/shop_category_spec.rb
  194. +0 −130 spec/models/shop_discount_spec.rb
  195. +0 −114 spec/models/shop_discountable_spec.rb
  196. +0 −38 spec/models/shop_group_spec.rb
  197. +56 −34 spec/models/shop_line_item_spec.rb
  198. +5 −5 spec/models/shop_order_spec.rb
  199. +0 −117 spec/models/shop_package_spec.rb
  200. +0 −67 spec/models/shop_packing_spec.rb
  201. +1 −44 spec/models/shop_product_spec.rb
  202. +0 −92 spec/models/shop_product_variant_spec.rb
  203. +0 −32 spec/models/shop_variant_spec.rb
  204. +3 −5 spec/spec.opts
View
42 LICENSE
@@ -0,0 +1,42 @@
+Copyright (c) 2010 Dirk Kelly (dk@dirkkelly.com) (SquareTalent)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+---------------------------------------------------------------------------
+
+Copyright (c) 2008-2009 Aurora Software (http://www.aurorasoft.com.au)
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,20 +0,0 @@
-Copyright (c) 2008-2009 Aurora Software (http://www.aurorasoft.com.au)
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,36 +1,52 @@
# Radiant Shop
-ps: [wiki](http://github.com/squaretalent/radiant-shop-extension/wiki)
+## [Wiki]([wiki.github.com/squaretalent/radiant-shop-extension] "Github Wiki Page")
-pps: heavily under development means "it might not work out of the box after every commit"
+## Quickstart
-ppps: I am working on the wiki as quickly as I can, but specs are more important at this point in time
+Install RadiantShop Gem
-pppps: love heart
+ gem install radiant-shop-extension
+ # This will install Radiant and the Gems RadiantShop requires
+
+Create a Radiant project
+
+ radiant myshop --database sqlite3
+ cd myshop
+
+Edit your Gemfile
-## Checkout
+ gem 'radiant', '0.9.1'
+ gem 'radiant-shop-extension', :require => false
+
+Add to your config/environment.rb
-### Form Configuration
+ config.gem 'radiant-settings-extension', :lib => false
+ config.gem 'radiant-scoped-extension', :lib => false
+ config.gem 'radiant-images-extension', :lib => false
+ config.gem 'radiant-forms-extension', :lib => false
+ config.gem 'radiant-shop-extension', :lib => false
+
+Bootstrap Radiant (answer questions, I suggest an empty template)
- checkout:
- gateway:
- name: Eway
- username: 123456
- password: abcdef
-
-# Development
+ rake db:bootstrap
+
+Migrate shop
- unless ENV["RAILS_ENV"] == "production"
- config.gem 'rspec', :version => '1.3.0'
- config.gem 'rspec-rails', :version => '1.3.2'
- config.gem 'cucumber', :verison => '0.8.5'
- config.gem 'cucumber-rails', :version => '0.3.2'
- config.gem 'database_cleaner', :version => '0.4.3'
- config.gem 'ruby-debug', :version => '0.10.3'
- config.gem 'webrat', :version => '0.7.1'
- config.gem 'rr', :version => '0.10.11'
- end
+ rake radiant:extensions:update_all
+ rake radiant:extensions:shop:migrate
-# Migrating in Development
+Seed shop (optional, will help you get on your way)
+
+ rake radiant:extensions:shop:seed
+
+## Licence
+
+This extension started as a fork of aurora-soft's simple product manager
+and has since undergone a rewrite.
+
+http://github.com/squaretalent/radiant-shop-extension/compare/master
+
+Copyright 2010 Dirk Kelly (dk@dirkkelly.com) and licenced under MIT.
- rm db/development.sqlite3.db; rake db:migrate; rake radiant:extensions:scoped:migrate; rake radiant:extensions:settings:migrate; rake radiant:extensions:drag:migrate; rake radiant:extensions:forms:migrate; rake radiant:extensions:images:migrate; rake radiant:extensions:shop:migrate; rake radiant:extensions:export:load;
+See LICENCE for further information.
View
@@ -6,11 +6,10 @@ begin
gem.description = %Q{Radiant Shop is an attempt at a simple but complete store. It includes Products, Categories, Orders and Credit Card Payments}
gem.email = "dk@dirkkelly.com"
gem.homepage = "http://github.com/squaretalent/radiant-shop-extension"
- gem.authors = ["Dirk Kelly", "John Barker"]
+ gem.authors = ["Dirk Kelly", "John Barker", "Darcy Laycock"]
gem.add_dependency 'radiant', '>= 0.9.1'
gem.add_dependency 'activemerchant', '>= 1.8.0'
gem.add_dependency 'fastercsv', '>= 1.5.3'
- gem.add_dependency 'radiant-layouts-extension', '>= 0.9.1'
gem.add_dependency 'radiant-settings-extension', '>= 1.1.1'
gem.add_dependency 'radiant-images-extension', '>= 0.3.2'
gem.add_dependency 'radiant-forms-extension', '>= 3.1.1'
@@ -147,6 +147,7 @@ def config_global
@meta << 'handle'
@meta << 'layouts'
@meta << 'page'
+ @meta << 'status'
@parts << 'description'
end
@@ -1,44 +0,0 @@
-class Admin::Shop::Discounts::DiscountablesController < Admin::ResourceController
-
- model_class ShopDiscountable
-
- def create
- error = 'Could not attach Discount.'
- begin
- @shop_discountable.attributes = {
- :discount_id => params[:discount_id],
- :discounted_id => params[:discounted_id],
- :discounted_type => params[:discounted_type]
- }
- @shop_discountable.save!
-
- discounted_type = @shop_discountable.discounted_type.gsub('Shop','').underscore
-
- respond_to do |format|
- format.js { render :partial => "admin/shop/discounts/edit/shared/#{discounted_type}", :locals => { discounted_type.to_sym => @shop_discountable } }
- end
- rescue
- respond_to do |format|
- format.js { render :text => error, :status => :unprocessable_entity }
- end
- end
- end
-
- def destroy
- error = 'Could not remove Discount.'
- begin
- discounted_type = @shop_discountable.discounted_type.gsub('Shop','').underscore
-
- @shop_discountable.destroy
-
- respond_to do |format|
- format.js { render :partial => "admin/shop/discounts/edit/shared/#{discounted_type}", :locals => { discounted_type.to_sym => @shop_discountable } }
- end
- rescue
- respond_to do |format|
- format.js { render :text => error, :status => :unprocessable_entity }
- end
- end
- end
-
-end
@@ -1,64 +0,0 @@
-class Admin::Shop::DiscountsController < Admin::ResourceController
-
- model_class ShopDiscount
-
- before_filter :config_global
- before_filter :config_index, :only => [ :index ]
- before_filter :config_new, :only => [ :new, :create ]
- before_filter :config_edit, :only => [ :edit, :update ]
- before_filter :assets_global, :except => [ :remove, :destroy ]
- before_filter :assets_edit, :only => [ :edit, :update ]
-
- private
-
- def config_global
- @inputs ||= []
- @meta ||= []
- @buttons ||= []
- @parts ||= []
- @popups ||= []
- end
-
- def config_index
- @buttons << 'new_discount'
- end
-
- def config_new
- @inputs << 'name'
- @inputs << 'amount'
- @inputs << 'code'
-
- @meta << 'start'
- @meta << 'finish'
- end
-
- def config_edit
- @buttons << 'browse_categories'
- @buttons << 'browse_products'
-
- @inputs << 'name'
- @inputs << 'amount'
- @inputs << 'code'
-
- @meta << 'start'
- @meta << 'finish'
-
- @parts << 'categories'
- @parts << 'products'
-
- @popups << 'browse_categories'
- @popups << 'browse_products'
- end
-
- def assets_global
- include_stylesheet 'admin/extensions/shop/edit'
- include_stylesheet 'admin/extensions/shop/index'
- end
-
- def assets_edit
- include_javascript 'admin/extensions/shop/edit'
- include_javascript 'admin/extensions/shop/discounts/edit'
- include_stylesheet 'admin/extensions/shop/discounts/edit'
- end
-
-end
@@ -1,90 +0,0 @@
-class Admin::Shop::Packages::PackingsController < Admin::ResourceController
- model_class ShopPacking
-
- def sort
- notice = 'Products successfully sorted.'
- error = 'Could not sort products.'
-
- begin
- @shop_packings = CGI::parse(params[:packings])["package_products[]"]
-
- @shop_packings.each_with_index do |id, index|
- ShopPacking.find(id).update_attributes!({ :position, index+1 })
- end
-
- respond_to do |format|
- format.html {
- redirect_to admin_shop_packages_path
- }
- format.js { render :text => notice, :status => :ok }
- format.json { render :json => { :notice => notice }, :status => :ok }
- end
- rescue
- respond_to do |format|
- format.html {
- flash[:error] = error
- redirect_to admin_shop_packages_path
- }
- format.js { render :text => error, :status => :unprocessable_entity }
- format.json { render :json => { :error => error }, :status => :unprocessable_entity }
- end
- end
- end
-
- def create
- notice = 'Product successfully attached.'
- error = 'Could not attach product.'
-
- begin
- @shop_packing.package = ShopPackage.find(params[:package_id])
- @shop_packing.product = ShopProduct.find(params[:product_id])
- @shop_packing.save!
-
- respond_to do |format|
- format.js { render :partial => 'admin/shop/packages/edit/shared/product', :locals => { :product => @shop_packing.product, :packing => @shop_packing } }
- end
- rescue
- respond_to do |format|
- format.js { render :text => error, :status => :unprocessable_entity }
- end
- end
- end
-
- def update
- notice = 'Product Quantity successfully updated.'
- error = 'Could not update Product Quantity.'
-
- begin
- @shop_packing.update_attributes!({ :quantity => params[:quantity] })
- respond_to do |format|
- format.js { render :text => notice, :status => :ok }
- end
- rescue
- respond_to do |format|
- format.js { render :text => error, :status => :unprocessable_entity }
- end
- end
-
- end
-
- def destroy
- notice = 'Product successfully removed.'
- error = 'Could not remove product.'
-
- begin
- @shop_product = @shop_packing.product
- @shop_package = @shop_packing.package
-
- @shop_packing.destroy
-
- respond_to do |format|
- format.js { render :partial => 'admin/shop/packages/edit/shared/product', :locals => { :product => @shop_product } }
- end
- rescue
- respond_to do |format|
- format.js { render :text => error, :status => :unprocessable_entity }
- end
- end
- end
-
-end
Oops, something went wrong.

0 comments on commit a2a75a7

Please sign in to comment.