forgeos_commerce 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +339 -0
- data/COPYING.LESSER +165 -0
- data/Gemfile +2 -0
- data/LICENSE +2 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +27 -0
- data/app/assets/images/forgeos/admin/favicon.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/bubble-quantity-products.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/check-checked.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/check-unchecked.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/context.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/create.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/dark-blue-minus.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/dark-blue-plus.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/dot.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/f.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/fminus.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/fminus_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/folder.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/fplus.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/fplus_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/lastli.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/lastli_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/li.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/remove.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/rename.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/association_product/throbber.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/bubble-quantity-products.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/check-checked.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/check-unchecked.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/context.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/create.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/dark-blue-minus.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/dark-blue-plus.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/dot.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/drag-drop.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/f.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/fminus.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/fminus_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/folder.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/fplus.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/fplus_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/grey-drag-drop.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/lastli.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/lastli_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/li.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/remove.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/rename.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product-types/throbber.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/brown-minus.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/brown-plus.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/bubble-quantity-products.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/context.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/create.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/dot.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/f.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/fminus.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/fminus_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/fplus.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/fplus_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/lastli.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/lastli_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/li.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/remove.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/rename.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/product_category/throbber.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/bubble-quantity-products.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/check-checked.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/check-unchecked.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/context.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/create.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/dark-blue-minus.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/dark-blue-plus.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/dot.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/f.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/fminus.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/fminus_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/folder.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/fplus.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/fplus_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/lastli.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/lastli_rtl.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/li.gif +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/remove.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/rename.png +0 -0
- data/app/assets/images/forgeos/jstree/themes/zone-tree/throbber.gif +0 -0
- data/app/assets/javascripts/forgeos/admin/functions.js +3 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/all.js +1 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/attributes.js +18 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/cross-sellings.js +18 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/orders.js +88 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/products.js +46 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/rules.js +98 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/transporters.js +60 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/trees.js +35 -0
- data/app/assets/javascripts/forgeos/admin/functions/forgeos_commerce/uploads.js +10 -0
- data/app/assets/javascripts/forgeos/admin/inits.js +3 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/all.js +1 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/clicks.js +25 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/cross-sellings.js +69 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/customer.js +64 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/orders.js +83 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/overlays.js +45 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/products.js +103 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/settings.js +15 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/special-offers.js +23 -0
- data/app/assets/javascripts/forgeos/admin/inits/forgeos_commerce/trees.js +71 -0
- data/app/assets/stylesheets/forgeos/admin/base.css.sass +3 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_all.css.sass +9 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_attributes.css.sass +59 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_customer.css.sass +84 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_delivery.css.sass +81 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_dropdowns.css.sass +171 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_order.css.sass +208 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_payment.css.sass +34 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_products.css.sass +341 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_special_offers.css.sass +198 -0
- data/app/assets/stylesheets/forgeos/admin/forgeos_commerce/_transporters.css.sass +5 -0
- data/app/assets/stylesheets/forgeos/jstree/themes/association_product/style.css.sass +50 -0
- data/app/assets/stylesheets/forgeos/jstree/themes/product-types/style.css.sass +129 -0
- data/app/assets/stylesheets/forgeos/jstree/themes/product_category/style.css.sass +109 -0
- data/app/assets/stylesheets/forgeos/jstree/themes/zone-tree/style.css.sass +103 -0
- data/app/controllers/addresses_controller.rb +51 -0
- data/app/controllers/admin/attributes_controller.rb +161 -0
- data/app/controllers/admin/base_controller.rb +5 -0
- data/app/controllers/admin/brands_controller.rb +119 -0
- data/app/controllers/admin/forms_controller.rb +66 -0
- data/app/controllers/admin/geo_zones_controller.rb +74 -0
- data/app/controllers/admin/import_controller.rb +50 -0
- data/app/controllers/admin/orders_controller.rb +248 -0
- data/app/controllers/admin/product_types_controller.rb +122 -0
- data/app/controllers/admin/products_controller.rb +204 -0
- data/app/controllers/admin/special_offers_controller.rb +236 -0
- data/app/controllers/admin/statistics_controller.rb +64 -0
- data/app/controllers/admin/transporter_rules_controller.rb +307 -0
- data/app/controllers/admin/users_controller.rb +100 -0
- data/app/controllers/admin/vouchers_controller.rb +207 -0
- data/app/controllers/application_controller.rb +75 -0
- data/app/controllers/order_controller.rb +229 -0
- data/app/helpers/admin/payment_fields_helper.rb +31 -0
- data/app/helpers/application_helper.rb +7 -0
- data/app/helpers/cart_helper.rb +40 -0
- data/app/helpers/category_helper.rb +36 -0
- data/app/helpers/product_helper.rb +118 -0
- data/app/helpers/routes_helper.rb +60 -0
- data/app/helpers/wishlist_helper.rb +142 -0
- data/app/models/address_delivery.rb +2 -0
- data/app/models/address_invoice.rb +2 -0
- data/app/models/attribute.rb +38 -0
- data/app/models/attribute_category.rb +3 -0
- data/app/models/attribute_value.rb +10 -0
- data/app/models/brand.rb +22 -0
- data/app/models/brand_category.rb +3 -0
- data/app/models/cart.rb +190 -0
- data/app/models/cart_item.rb +21 -0
- data/app/models/checkbox_attribute.rb +2 -0
- data/app/models/country.rb +4 -0
- data/app/models/cross_sellings_product.rb +4 -0
- data/app/models/currencies_exchanges_rate.rb +2 -0
- data/app/models/currency.rb +13 -0
- data/app/models/date_attribute.rb +2 -0
- data/app/models/dynamic_attribute.rb +6 -0
- data/app/models/dynamic_attribute_value.rb +5 -0
- data/app/models/form.rb +7 -0
- data/app/models/form_attribute.rb +3 -0
- data/app/models/geo_zone.rb +6 -0
- data/app/models/longtext_attribute.rb +2 -0
- data/app/models/number_attribute.rb +2 -0
- data/app/models/order.rb +483 -0
- data/app/models/order_detail.rb +129 -0
- data/app/models/order_shipping.rb +25 -0
- data/app/models/pack.rb +9 -0
- data/app/models/picklist_attribute.rb +2 -0
- data/app/models/product.rb +294 -0
- data/app/models/product_attribute.rb +4 -0
- data/app/models/product_category.rb +9 -0
- data/app/models/product_link.rb +9 -0
- data/app/models/product_price_variation.rb +3 -0
- data/app/models/product_sold_counter.rb +2 -0
- data/app/models/product_sweeper.rb +30 -0
- data/app/models/product_type.rb +27 -0
- data/app/models/product_type_category.rb +3 -0
- data/app/models/product_viewed_counter.rb +2 -0
- data/app/models/products_wishlist.rb +25 -0
- data/app/models/radio_attribute.rb +2 -0
- data/app/models/radiobutton_attribute.rb +2 -0
- data/app/models/setting.rb +46 -0
- data/app/models/size.rb +5 -0
- data/app/models/special_offer_category.rb +3 -0
- data/app/models/special_offer_rule.rb +21 -0
- data/app/models/text_attribute.rb +2 -0
- data/app/models/text_field_attribute.rb +2 -0
- data/app/models/transporter_category.rb +3 -0
- data/app/models/transporter_rule.rb +3 -0
- data/app/models/url_attribute.rb +2 -0
- data/app/models/user.rb +45 -0
- data/app/models/user_address.rb +6 -0
- data/app/models/voucher_category.rb +3 -0
- data/app/models/voucher_rule.rb +3 -0
- data/app/models/wishlist.rb +134 -0
- data/app/views/admin/addresses/_form.html.haml +42 -0
- data/app/views/admin/attributes/_categories.html.haml +7 -0
- data/app/views/admin/attributes/_choice.html.haml +24 -0
- data/app/views/admin/attributes/_date.html.haml +5 -0
- data/app/views/admin/attributes/_form.html.haml +36 -0
- data/app/views/admin/attributes/_longtext.html.haml +5 -0
- data/app/views/admin/attributes/_number.html.haml +5 -0
- data/app/views/admin/attributes/_tabs.html.haml +6 -0
- data/app/views/admin/attributes/_text.html.haml +5 -0
- data/app/views/admin/attributes/_url.html.haml +5 -0
- data/app/views/admin/attributes/destroy.js.erb +1 -0
- data/app/views/admin/attributes/edit.html.haml +2 -0
- data/app/views/admin/attributes/index.html.haml +33 -0
- data/app/views/admin/attributes/index.json.erb +24 -0
- data/app/views/admin/attributes/new.html.haml +2 -0
- data/app/views/admin/attributes/show.html.haml +51 -0
- data/app/views/admin/brands/_form.html.haml +29 -0
- data/app/views/admin/brands/_tabs.html.haml +6 -0
- data/app/views/admin/brands/destroy.js.erb +1 -0
- data/app/views/admin/brands/edit.html.haml +2 -0
- data/app/views/admin/brands/index.html.haml +15 -0
- data/app/views/admin/brands/index.json.erb +23 -0
- data/app/views/admin/brands/new.html.haml +2 -0
- data/app/views/admin/dashboard/index.html.haml +230 -0
- data/app/views/admin/forms/_form.html.haml +38 -0
- data/app/views/admin/forms/_tabs.html.haml +6 -0
- data/app/views/admin/forms/destroy.js.erb +1 -0
- data/app/views/admin/forms/edit.html.haml +2 -0
- data/app/views/admin/forms/index.html.haml +11 -0
- data/app/views/admin/forms/index.json.erb +20 -0
- data/app/views/admin/forms/new.html.haml +2 -0
- data/app/views/admin/geo_zones/_form.html.haml +20 -0
- data/app/views/admin/geo_zones/_list.html.haml +9 -0
- data/app/views/admin/geo_zones/edit.html.haml +3 -0
- data/app/views/admin/geo_zones/index.html.haml +49 -0
- data/app/views/admin/geo_zones/new.html.haml +3 -0
- data/app/views/admin/geo_zones/show.html.haml +4 -0
- data/app/views/admin/import/create_product.html.haml +2 -0
- data/app/views/admin/menus/_types_popups.html.haml +22 -0
- data/app/views/admin/orders/_address_form.html.haml +29 -0
- data/app/views/admin/orders/_form.html.haml +198 -0
- data/app/views/admin/orders/_list.html.haml +29 -0
- data/app/views/admin/orders/_products_popup.html.haml +15 -0
- data/app/views/admin/orders/create.html.haml +1 -0
- data/app/views/admin/orders/destroy.js.erb +1 -0
- data/app/views/admin/orders/edit.html.haml +1 -0
- data/app/views/admin/orders/index.html.haml +24 -0
- data/app/views/admin/orders/index.json.erb +48 -0
- data/app/views/admin/orders/show.html.haml +130 -0
- data/app/views/admin/product_types/_form.html.haml +46 -0
- data/app/views/admin/product_types/_list.html.haml +6 -0
- data/app/views/admin/product_types/_options_categories.html.haml +19 -0
- data/app/views/admin/product_types/_tabs.html.haml +6 -0
- data/app/views/admin/product_types/destroy.js.erb +1 -0
- data/app/views/admin/product_types/edit.html.haml +3 -0
- data/app/views/admin/product_types/index.html.haml +14 -0
- data/app/views/admin/product_types/index.json.erb +24 -0
- data/app/views/admin/product_types/new.html.haml +3 -0
- data/app/views/admin/product_types/show.html.haml +23 -0
- data/app/views/admin/products/_attributes.html.haml +37 -0
- data/app/views/admin/products/_cross_popup.html.haml +56 -0
- data/app/views/admin/products/_cross_sell_tr.html.haml +13 -0
- data/app/views/admin/products/_cross_sells.html.haml +1 -0
- data/app/views/admin/products/_form.html.haml +26 -0
- data/app/views/admin/products/_general.html.haml +153 -0
- data/app/views/admin/products/_list.html.haml +18 -0
- data/app/views/admin/products/_prices.html.haml +17 -0
- data/app/views/admin/products/_products_popup.html.haml +41 -0
- data/app/views/admin/products/_seo.html.haml +75 -0
- data/app/views/admin/products/_shippings.html.haml +0 -0
- data/app/views/admin/products/_sizes.html.haml +23 -0
- data/app/views/admin/products/_tabs.html.haml +2 -0
- data/app/views/admin/products/activate.js.erb +1 -0
- data/app/views/admin/products/destroy.js.erb +1 -0
- data/app/views/admin/products/edit.html.haml +1 -0
- data/app/views/admin/products/index.html.haml +20 -0
- data/app/views/admin/products/index.json.erb +65 -0
- data/app/views/admin/products/new.html.haml +1 -0
- data/app/views/admin/products/show.html.haml +158 -0
- data/app/views/admin/settings/_colissimo.html.haml +7 -0
- data/app/views/admin/settings/_godfather.html.haml +11 -0
- data/app/views/admin/settings/_google_shopping.html.haml +5 -0
- data/app/views/admin/settings/_payment.html.haml +63 -0
- data/app/views/admin/settings/_tabs.html.haml +5 -0
- data/app/views/admin/settings/edit.html.haml +33 -0
- data/app/views/admin/special_offers/_form.html.haml +88 -0
- data/app/views/admin/special_offers/_patterns.html.haml +151 -0
- data/app/views/admin/special_offers/_tabs.html.haml +5 -0
- data/app/views/admin/special_offers/_top_links.html.haml +6 -0
- data/app/views/admin/special_offers/activate.js.erb +1 -0
- data/app/views/admin/special_offers/destroy.js.erb +1 -0
- data/app/views/admin/special_offers/edit.html.haml +4 -0
- data/app/views/admin/special_offers/index.html.haml +15 -0
- data/app/views/admin/special_offers/index.json.erb +28 -0
- data/app/views/admin/special_offers/new.html.haml +2 -0
- data/app/views/admin/special_offers/show.html.haml +28 -0
- data/app/views/admin/special_offers/special_offer.html.haml +166 -0
- data/app/views/admin/statistics/index.html.haml +158 -0
- data/app/views/admin/transporter_rules/_delivery_rules.html.haml +83 -0
- data/app/views/admin/transporter_rules/_form.html.haml +90 -0
- data/app/views/admin/transporter_rules/_left_sidebar.html.haml +9 -0
- data/app/views/admin/transporter_rules/_sidebar.html.haml +10 -0
- data/app/views/admin/transporter_rules/_tabs.html.haml +8 -0
- data/app/views/admin/transporter_rules/activate.js.erb +1 -0
- data/app/views/admin/transporter_rules/destroy.js.erb +1 -0
- data/app/views/admin/transporter_rules/edit.html.haml +1 -0
- data/app/views/admin/transporter_rules/index.html.haml +13 -0
- data/app/views/admin/transporter_rules/index.json.erb +30 -0
- data/app/views/admin/transporter_rules/new.html.haml +1 -0
- data/app/views/admin/transporter_rules/show.html.haml +30 -0
- data/app/views/admin/users/_fields_for_addresses_deliveries.html.haml +38 -0
- data/app/views/admin/users/_fields_for_addresses_invoices.html.haml +34 -0
- data/app/views/admin/users/_form.html.haml +88 -0
- data/app/views/admin/users/edit.json.erb +35 -0
- data/app/views/admin/users/index.html.haml +12 -0
- data/app/views/admin/users/index.json.erb +32 -0
- data/app/views/admin/users/index2.html.haml +33 -0
- data/app/views/admin/users/show.html.haml +72 -0
- data/app/views/admin/vouchers/_form.html.haml +92 -0
- data/app/views/admin/vouchers/_tabs.html.haml +3 -0
- data/app/views/admin/vouchers/activate.js.erb +1 -0
- data/app/views/admin/vouchers/destroy.js.erb +1 -0
- data/app/views/admin/vouchers/index.html.haml +15 -0
- data/app/views/admin/vouchers/index.json.erb +28 -0
- data/app/views/admin/vouchers/new.html.haml +2 -0
- data/config/locales/activerecord/en.yml +6 -0
- data/config/locales/activerecord/fr.yml +18 -0
- data/config/locales/admin/address/en.yml +3 -0
- data/config/locales/admin/address/fr.yml +3 -0
- data/config/locales/admin/attribute/en.yml +76 -0
- data/config/locales/admin/attribute/fr.yml +75 -0
- data/config/locales/admin/brands/en.yml +24 -0
- data/config/locales/admin/brands/fr.yml +27 -0
- data/config/locales/admin/dashboard/en.yml +6 -0
- data/config/locales/admin/dashboard/fr.yml +6 -0
- data/config/locales/admin/order/en.yml +54 -0
- data/config/locales/admin/order/fr.yml +54 -0
- data/config/locales/admin/product/en.yml +105 -0
- data/config/locales/admin/product/fr.yml +106 -0
- data/config/locales/admin/settings/en.yml +90 -0
- data/config/locales/admin/settings/fr.yml +87 -0
- data/config/locales/admin/special_offer/en.yml +59 -0
- data/config/locales/admin/special_offer/fr.yml +60 -0
- data/config/locales/admin/transporter/en.yml +36 -0
- data/config/locales/admin/transporter/fr.yml +36 -0
- data/config/locales/admin/voucher/en.yml +3 -0
- data/config/locales/admin/voucher/fr.yml +3 -0
- data/config/locales/admin/wishlist/en.yml +89 -0
- data/config/locales/admin/wishlist/fr.yml +89 -0
- data/config/locales/common/en.yml +424 -0
- data/config/locales/common/fr.yml +422 -0
- data/config/routes.rb +109 -0
- data/config/search.example.yml +8 -0
- data/db/fixtures/currencies.yml +10 -0
- data/db/fixtures/currencies_exchanges_rates.yml +9 -0
- data/db/fixtures/page_translations.yml +11 -0
- data/db/fixtures/pages.yml +5 -0
- data/db/fixtures/people.yml +11 -0
- data/db/fixtures/product_type_translations.yml +11 -0
- data/db/fixtures/product_types.yml +2 -0
- data/db/migrate/20091009134433_create_attribute_values.rb +15 -0
- data/db/migrate/20091009134440_create_attribute_values_products.rb +14 -0
- data/db/migrate/20091009134448_create_attributes.rb +17 -0
- data/db/migrate/20091009134455_create_attributes_product_types.rb +14 -0
- data/db/migrate/20091009134525_create_carts.rb +15 -0
- data/db/migrate/20091009134532_create_cart_items.rb +14 -0
- data/db/migrate/20091009134609_create_cross_sellings_products.rb +11 -0
- data/db/migrate/20091009134616_create_currencies.rb +15 -0
- data/db/migrate/20091009134624_create_currencies_exchanges_rates.rb +13 -0
- data/db/migrate/20091009134631_create_dynamic_attribute_values.rb +17 -0
- data/db/migrate/20091009134659_create_order_details.rb +24 -0
- data/db/migrate/20091009134706_create_order_shippings.rb +16 -0
- data/db/migrate/20091009134714_create_orders.rb +21 -0
- data/db/migrate/20091009134721_create_packs_products.rb +13 -0
- data/db/migrate/20091009134805_create_product_types.rb +11 -0
- data/db/migrate/20091009134813_create_products.rb +37 -0
- data/db/migrate/20091009134821_create_products_wishlists.rb +13 -0
- data/db/migrate/20091009134947_create_wishlists.rb +12 -0
- data/db/migrate/20100323143123_create_geo_zones_transporter_rules.rb +12 -0
- data/db/migrate/20100414090950_create_brands.rb +15 -0
- data/db/migrate/20100414091706_create_sizes.rb +15 -0
- data/db/migrate/20100928123009_add_patronage_to_people.rb +20 -0
- data/db/migrate/20101007074306_create_product_price_variations.rb +13 -0
- data/db/migrate/20110311111210_create_forms.rb +13 -0
- data/db/migrate/20110311112646_attributes_forms.rb +13 -0
- data/db/migrate/20110322165950_add_payment_methods_to_settings.rb +13 -0
- data/db/migrate/20110405084454_add_colissimo_methods_to_settings.rb +13 -0
- data/db/migrate/20110516075553_add_google_infos_to_settings.rb +11 -0
- data/db/migrate/20110831164213_add_order_fields_to_addresses.rb +9 -0
- data/lib/CMCIC_Config.rb +16 -0
- data/lib/CMCIC_Tpe.rb +227 -0
- data/lib/forgeos/commerce.rb +9 -0
- data/lib/forgeos/commerce/admin_menu.rb +28 -0
- data/lib/forgeos/commerce/engine.rb +11 -0
- data/lib/forgeos/commerce/float.rb +10 -0
- data/lib/forgeos/commerce/statistics.rb +62 -0
- data/lib/forgeos/commerce/version.rb +5 -0
- data/lib/forgeos_commerce.rb +1 -0
- data/lib/special_offer.rb +61 -0
- data/lib/tasks/install.rake +9 -0
- data/lib/transporter.rb +26 -0
- data/lib/voucher.rb +41 -0
- data/recipes/deploy.rb +15 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +42 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +27 -0
- data/test/dummy/config/environments/production.rb +51 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/forgeos_commerce_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +539 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
class OrderDetail < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :order
|
4
|
+
belongs_to :product
|
5
|
+
|
6
|
+
#validates_presence_of :name, :price, :rate_tax, :order_id, :sku
|
7
|
+
validates :name, :price, :sku, :presence => true
|
8
|
+
|
9
|
+
def rate_tax
|
10
|
+
value = read_attribute(:rate_tax)
|
11
|
+
(not value or value < 1.0) ? 1.0 : value
|
12
|
+
end
|
13
|
+
|
14
|
+
# Returns price's string with currency symbol
|
15
|
+
#
|
16
|
+
# This method is an overload of <i>price</i> attribute.
|
17
|
+
#
|
18
|
+
# ==== Parameters
|
19
|
+
# * <tt>:with_tax</tt> - false by defaults. Returns price with tax if true
|
20
|
+
# * <tt>:with_currency</tt> - true by defaults. The currency of user is considered if true
|
21
|
+
def price(*args)
|
22
|
+
passed_options = args.extract_options!
|
23
|
+
options = {
|
24
|
+
:tax => true,
|
25
|
+
:voucher_discount => true,
|
26
|
+
:special_offer_discount => true,
|
27
|
+
:packaging => false,
|
28
|
+
}.update(passed_options.symbolize_keys)
|
29
|
+
|
30
|
+
price = read_attribute(:price) || 0.0
|
31
|
+
price *= rate_tax if options[:tax]
|
32
|
+
price -= self.special_offer_discount_price || 0.0 if options[:special_offer_discount]
|
33
|
+
price -= self.voucher_discount_price || 0.0 if options[:voucher_discount]
|
34
|
+
price += self.packaging_price.to_f || 0.0 if options[:packaging]
|
35
|
+
price
|
36
|
+
end
|
37
|
+
|
38
|
+
def discount(*args)
|
39
|
+
passed_options = args.extract_options!
|
40
|
+
options = {
|
41
|
+
:voucher_discount => true,
|
42
|
+
:special_offer_discount => true,
|
43
|
+
}.update(passed_options.symbolize_keys)
|
44
|
+
|
45
|
+
discount = 0.0
|
46
|
+
discount += self.special_offer_discount_price.to_f || 0.0 if options[:special_offer_discount]
|
47
|
+
discount += self.voucher_discount_price.to_f || 0.0 if options[:voucher_discount]
|
48
|
+
discount
|
49
|
+
end
|
50
|
+
|
51
|
+
def old_price(with_tax=false, with_currency=true, with_special_offer=false, with_voucher=false)
|
52
|
+
ActiveSupport::Deprecation.warn('use price instead of old_price')
|
53
|
+
price({
|
54
|
+
:tax => with_tax,
|
55
|
+
:special_offer_discount => with_special_offer,
|
56
|
+
:voucher_discount => with_voucher,
|
57
|
+
})
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns total product's tax
|
61
|
+
#
|
62
|
+
# ==== Parameters
|
63
|
+
# * <tt>:with_currency</tt> - true by defaults. The currency of user is considered if true
|
64
|
+
#
|
65
|
+
# This method use <i>price</i> : <i>price(false, with_currency)</i>
|
66
|
+
def tax(with_currency=true)
|
67
|
+
price(:tax => true, :with_currency => with_currency) / rate_tax
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns tax * quantity
|
71
|
+
#
|
72
|
+
# ==== Parameters
|
73
|
+
# * <tt>:with_currency</tt> - true by defaults. The currency of user is considered if true
|
74
|
+
def total_tax(with_currency=true)
|
75
|
+
tax(with_currency)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns price * quantity
|
79
|
+
#
|
80
|
+
# ==== Parameters
|
81
|
+
# * <tt>:with_tax</tt> - false by defaults. Returns price with tax if true
|
82
|
+
# * <tt>:with_currency</tt> - true by defaults. The currency of user is considered if true
|
83
|
+
def total
|
84
|
+
price.to_f * quantity.to_f
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.from_cart_product(cart_product)
|
88
|
+
object = self.new(
|
89
|
+
:name => cart_product.product.name,
|
90
|
+
:description => cart_product.product.description,
|
91
|
+
:price => cart_product.product.price(
|
92
|
+
:voucher_discount => false,
|
93
|
+
:special_offer_discount => false
|
94
|
+
),
|
95
|
+
:rate_tax => cart_product.product.rate_tax,
|
96
|
+
:sku => cart_product.product.sku,
|
97
|
+
:product_id => cart_product.product.id,
|
98
|
+
:voucher_discount => cart_product.product.voucher_discount,
|
99
|
+
:voucher_discount_price => cart_product.product.voucher_discount_price,
|
100
|
+
:special_offer_discount => cart_product.product.special_offer_discount,
|
101
|
+
:special_offer_discount_price => cart_product.product.special_offer_discount_price,
|
102
|
+
:quantity => cart_product.quantity
|
103
|
+
)
|
104
|
+
self.after_from_cart_product(object,cart_product) if self.respond_to?(:after_from_cart_product)
|
105
|
+
return object
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.from_free_product(gift)
|
109
|
+
self.new(
|
110
|
+
:name => gift.name,
|
111
|
+
:description => gift.description,
|
112
|
+
:price => 0,
|
113
|
+
:rate_tax => 0,
|
114
|
+
:sku => gift.sku,
|
115
|
+
:product_id => gift.id,
|
116
|
+
:special_offer_discount => I18n.t(:free_product),
|
117
|
+
:special_offer_discount_price => 0
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
def increment_product_sold_counter
|
123
|
+
if product
|
124
|
+
quantity.times do
|
125
|
+
product.sold_counters.new.increment_counter
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class OrderShipping < ActiveRecord::Base
|
2
|
+
belongs_to :order
|
3
|
+
|
4
|
+
def self.from_cart(cart)
|
5
|
+
options = {}
|
6
|
+
|
7
|
+
unless cart.options[:colissimo].nil?
|
8
|
+
params= cart.options[:colissimo]
|
9
|
+
options[:name] = 'So Colissimo'
|
10
|
+
options[:price] = params['DYFORWARDINGCHARGES']
|
11
|
+
options[:colissimo_type] = params['DELIVERYMODE']
|
12
|
+
else
|
13
|
+
if cart.options[:free_shipping] == true
|
14
|
+
options[:name] = I18n.t(:free_shipping)
|
15
|
+
options[:price] = 0
|
16
|
+
elsif transporter = TransporterRule.find_by_id(cart.options[:transporter_rule_id])
|
17
|
+
options[:name] = transporter.name
|
18
|
+
options[:price] = transporter.variables
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
self.new(options)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/app/models/pack.rb
ADDED
@@ -0,0 +1,294 @@
|
|
1
|
+
class Product < ActiveRecord::Base
|
2
|
+
translates :name, :description, :summary, :url
|
3
|
+
attr_accessor :voucher_discount, :voucher_discount_price,
|
4
|
+
:special_offer_discount, :special_offer_discount_price,
|
5
|
+
:price_variation_id, :price_variation
|
6
|
+
|
7
|
+
acts_as_taggable
|
8
|
+
has_and_belongs_to_many_attachments
|
9
|
+
|
10
|
+
has_and_belongs_to_many :packs
|
11
|
+
|
12
|
+
has_many :sizes, :dependent => :destroy
|
13
|
+
accepts_nested_attributes_for :sizes, :allow_destroy => true
|
14
|
+
|
15
|
+
has_many :cross_sellings_products, :dependent => :destroy
|
16
|
+
has_many :cross_sellings, :through => :cross_sellings_products, :class_name => 'Product'
|
17
|
+
accepts_nested_attributes_for :cross_sellings
|
18
|
+
accepts_nested_attributes_for :cross_sellings_products
|
19
|
+
|
20
|
+
has_many :price_variations, :dependent => :destroy, :class_name => 'ProductPriceVariation'
|
21
|
+
accepts_nested_attributes_for :price_variations
|
22
|
+
|
23
|
+
has_and_belongs_to_many :categories, :readonly => true, :join_table => 'categories_elements', :foreign_key => 'element_id', :association_foreign_key => 'category_id', :class_name => 'ProductCategory'
|
24
|
+
has_and_belongs_to_many :attribute_values, :readonly => true, :uniq => true
|
25
|
+
|
26
|
+
has_many :dynamic_attribute_values, :dependent => :destroy
|
27
|
+
has_many :dynamic_attributes, :through => :dynamic_attribute_values, :class_name => 'DynamicAttribute', :source => 'product'
|
28
|
+
accepts_nested_attributes_for :dynamic_attribute_values
|
29
|
+
|
30
|
+
has_many :viewed_counters, :as => :element, :class_name => 'ProductViewedCounter', :dependent => :destroy
|
31
|
+
has_many :sold_counters, :as => :element, :class_name => 'ProductSoldCounter', :dependent => :destroy
|
32
|
+
|
33
|
+
belongs_to :product_type
|
34
|
+
validates_associated :product_type
|
35
|
+
|
36
|
+
belongs_to :brand
|
37
|
+
belongs_to :redirection_product, :class_name => 'Product'
|
38
|
+
|
39
|
+
has_one :meta_info, :as => :target
|
40
|
+
accepts_nested_attributes_for :meta_info
|
41
|
+
|
42
|
+
validates :sku, :url, :presence => true
|
43
|
+
|
44
|
+
before_save :clean_strings, :force_url_format
|
45
|
+
after_save :synchronize_stock
|
46
|
+
|
47
|
+
scope :actives, where(:active => true, :deleted => false)
|
48
|
+
scope :deleted, where(:deleted => true)
|
49
|
+
scope :hiddens, where(:active => false, :deleted => false)
|
50
|
+
#scope :out_of_stock, where{:stock.lte => 0}
|
51
|
+
|
52
|
+
define_index do
|
53
|
+
indexes sku, :sortable => true
|
54
|
+
indexes stock, :sortable => true
|
55
|
+
indexes price, :sortable => true
|
56
|
+
indexes brand(:name), :as => :brand
|
57
|
+
indexes product_type.translations(:name), :as => :product_type_name
|
58
|
+
|
59
|
+
indexes attachments(:name), :as => :firstnames
|
60
|
+
indexes categories.translations(:name), :as => :category_names
|
61
|
+
|
62
|
+
has active, deleted
|
63
|
+
has categories(:id), :as => :category_ids
|
64
|
+
set_property :min_prefix_len => 1
|
65
|
+
set_property :enable_star => 1
|
66
|
+
end
|
67
|
+
|
68
|
+
define_translated_index :name, :description, :url
|
69
|
+
|
70
|
+
def redirection_product_with_deleted
|
71
|
+
return (redirection_product_without_deleted && redirection_product_without_deleted.deleted? ? redirection_product_without_deleted.redirection_product : redirection_product_without_deleted)
|
72
|
+
end
|
73
|
+
alias_method_chain :redirection_product, :deleted
|
74
|
+
|
75
|
+
# Returns month's offers
|
76
|
+
def self.get_offer_month
|
77
|
+
find_by_active_and_deleted_and_offer_month(true,false,true)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns the first page products
|
81
|
+
def self.get_on_first_page
|
82
|
+
find_all_by_active_and_deleted_and_on_first_page(true,false,true)
|
83
|
+
end
|
84
|
+
|
85
|
+
def attribute_of(attribute)
|
86
|
+
attribute_values.find_by_attribute_id(attribute.id)
|
87
|
+
end
|
88
|
+
|
89
|
+
def clone
|
90
|
+
product_cloned = super
|
91
|
+
product_cloned.meta_info = meta_info.clone if meta_info
|
92
|
+
product_cloned.translations = translations.clone unless translations.empty?
|
93
|
+
product_cloned.dynamic_attribute_values = dynamic_attribute_values.collect(&:clone)
|
94
|
+
%w(attachment_ids picture_ids tag_list category_ids attribute_value_ids).each do |assoc|
|
95
|
+
product_cloned.send(assoc+'=', self.send(assoc))
|
96
|
+
end
|
97
|
+
return product_cloned
|
98
|
+
end
|
99
|
+
|
100
|
+
def synchronize_stock
|
101
|
+
if stop_sales? && active? && stock.to_i < 1
|
102
|
+
self.update_attribute('active', false)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def activate
|
107
|
+
self.update_attribute('active', !self.active? )
|
108
|
+
end
|
109
|
+
|
110
|
+
def soft_delete
|
111
|
+
self.update_attribute('deleted', !self.deleted? )
|
112
|
+
end
|
113
|
+
|
114
|
+
def packaging_price
|
115
|
+
#TODO get real variable
|
116
|
+
return 0
|
117
|
+
end
|
118
|
+
|
119
|
+
def price(*args)
|
120
|
+
passed_options = args.extract_options!
|
121
|
+
options = {
|
122
|
+
:tax => true,
|
123
|
+
:voucher_discount => true,
|
124
|
+
:special_offer_discount => true,
|
125
|
+
:variation => false,
|
126
|
+
:packaging => false
|
127
|
+
}.update(passed_options.symbolize_keys)
|
128
|
+
|
129
|
+
price = read_attribute(:price) || 0.0
|
130
|
+
price += tax(false)
|
131
|
+
price -= self.discount if options[:special_offer_discount]
|
132
|
+
price -= self.voucher_discount_price || 0.0 if options[:voucher_discount]
|
133
|
+
price -= (price * price_variation.discount).to_f / 100.0 if options[:variation] && price_variation
|
134
|
+
price += self.packaging_price.to_f || 0.0 if options[:packaging]
|
135
|
+
price = 0.0 if price < 0
|
136
|
+
|
137
|
+
price
|
138
|
+
end
|
139
|
+
|
140
|
+
def old_price
|
141
|
+
price(:voucher_discount => false, :special_offer_discount => false)
|
142
|
+
end
|
143
|
+
|
144
|
+
def has_discount?
|
145
|
+
not discount.zero?
|
146
|
+
end
|
147
|
+
|
148
|
+
# Returns price's string with currency symbol
|
149
|
+
#
|
150
|
+
# This method is an overload of <i>price</i> attribute.
|
151
|
+
#
|
152
|
+
# ==== Parameters
|
153
|
+
# * <tt>:with_tax</tt> - false by defaults. Returns price with tax if true
|
154
|
+
# * <tt>:with_currency</tt> - true by defaults. The currency of user is considered if true
|
155
|
+
def price_to_s(*args)
|
156
|
+
price(args).to_s
|
157
|
+
end
|
158
|
+
|
159
|
+
def discount
|
160
|
+
self.special_offer_discount_price || 0.0
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns total product's tax
|
164
|
+
#
|
165
|
+
# ==== Parameters
|
166
|
+
# * <tt>:with_currency</tt> - true by defaults. The currency of user is considered if true
|
167
|
+
#
|
168
|
+
# This method use <i>price</i> : <i>price(false, with_currency)</i>
|
169
|
+
def tax(with_currency=true)
|
170
|
+
return 0.0
|
171
|
+
#return ("%01.2f" % (price(false, with_currency) * self.rate_tax/100)).to_f
|
172
|
+
end
|
173
|
+
|
174
|
+
def has_special_offers?
|
175
|
+
if self.old_price != self.price
|
176
|
+
return true
|
177
|
+
else
|
178
|
+
selected_products = []
|
179
|
+
engine :special_offer_engine do |e|
|
180
|
+
begin
|
181
|
+
rule_builder = SpecialOffer.new(e)
|
182
|
+
rule_builder.selected_products = selected_products
|
183
|
+
rule_builder.rules
|
184
|
+
rescue Exception
|
185
|
+
end
|
186
|
+
e.assert self
|
187
|
+
e.match
|
188
|
+
end
|
189
|
+
return !selected_products.blank?
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def method_missing(method_id,*args,&block)
|
194
|
+
method_name = method_id.to_s
|
195
|
+
if cat_id = method_name.match(/has_category_(\d+)/)
|
196
|
+
return categories.find_by_id(cat_id[1].to_i, :select => 'id').present?
|
197
|
+
elsif custom_attribute = load_custom_attribute(method_name, ['_value'])
|
198
|
+
read_custom_attribute(custom_attribute, args.first || :value)
|
199
|
+
elsif custom_attribute = load_custom_attribute(method_name, ['='])
|
200
|
+
write_custom_attribute(custom_attribute, args.first)
|
201
|
+
else
|
202
|
+
super
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def respond_to?(method, include_priv = false)
|
207
|
+
method_name = method.to_s
|
208
|
+
if load_custom_attribute(method_name)
|
209
|
+
true
|
210
|
+
else
|
211
|
+
super
|
212
|
+
end
|
213
|
+
end
|
214
|
+
private
|
215
|
+
|
216
|
+
def load_custom_attribute(method_name, suffix = ['_value', '='])
|
217
|
+
skipped_method_names = ("#{self.class}::Translation".constantize.column_names + self.class.column_names).map{ |n| "_#{n}" } + %w(to_ary product_type)
|
218
|
+
|
219
|
+
if not skipped_method_names.include?(method_name) and
|
220
|
+
access_method = method_name.match(/^(\w|\d|_|-)*(#{suffix.join('|')})*$/) and
|
221
|
+
product_type
|
222
|
+
|
223
|
+
product_type.product_attributes.find_by_access_method(access_method[0].sub(/(#{suffix.join('|')})/,''))
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def read_custom_attribute(attribute, method)
|
228
|
+
method ||= :value
|
229
|
+
if attribute.dynamic?
|
230
|
+
if attribute_value = dynamic_attribute_values.find_by_attribute_id(attribute.id)
|
231
|
+
method != :object ? attribute_value.send(method.to_sym) : attribute_value
|
232
|
+
else
|
233
|
+
nil
|
234
|
+
end
|
235
|
+
else
|
236
|
+
values = attribute_values.find_all_by_attribute_id(attribute.id)
|
237
|
+
value = (method != :object ? values.map(&method.to_sym) : values)
|
238
|
+
return case attribute
|
239
|
+
when RadiobuttonAttribute, PicklistAttribute
|
240
|
+
value.first
|
241
|
+
else
|
242
|
+
value
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def write_custom_attribute(attribute, new_value)
|
248
|
+
if attribute.dynamic?
|
249
|
+
if attribute_value = dynamic_attribute_values.find_by_attribute_id(attribute.id)
|
250
|
+
self.dynamic_attribute_values_attributes= { attribute_value.id => { :id => attribute_value.id, :value => new_value } }
|
251
|
+
else
|
252
|
+
self.dynamic_attribute_values_attributes= { '-1' => { :value => new_value, :attribute_id => attribute.id} }
|
253
|
+
end
|
254
|
+
else
|
255
|
+
other_attributes = self.attribute_values.all(:conditions => {:attribute_id_not => attribute.id})
|
256
|
+
if new_value.nil?
|
257
|
+
new_attributes = []
|
258
|
+
elsif new_value.kind_of?(AttributeValue)
|
259
|
+
new_attributes = [new_value]
|
260
|
+
elsif new_value.kind_of?(Array) && new_value.first.kind_of?(AttributeValue)
|
261
|
+
new_attributes = new_value.flatten
|
262
|
+
else
|
263
|
+
new_attributes = AttributeValue.find_all_by_attribute_id(
|
264
|
+
attribute.id,
|
265
|
+
:include => [:translations],
|
266
|
+
:conditions => { :attribute_value_translations => { :name => [new_value].flatten } }
|
267
|
+
)
|
268
|
+
end
|
269
|
+
self.attribute_values = new_attributes + other_attributes
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
# Call by <i>before_save</i>
|
275
|
+
# convert all blank strings to nil for attribute inheritance save
|
276
|
+
def clean_strings
|
277
|
+
self.class.columns.find_all{ |column| column.type == :string }.each do |field|
|
278
|
+
send("#{field.name}=", nil) if self.attributes[field.name].blank?
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def force_url_format
|
283
|
+
if url.present?
|
284
|
+
self.url = url.parameterize
|
285
|
+
elsif name.present?
|
286
|
+
self.url = name.parameterize
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def self.modify_import_attributes(attributes)
|
291
|
+
attributes[:category_ids] = attributes.delete(:categories) unless attributes[:categories].blank?
|
292
|
+
attributes
|
293
|
+
end
|
294
|
+
end
|