caboose-cms 0.4.151 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/admin_products.js +79 -0
- data/app/assets/javascripts/caboose/application.js +2 -1
- data/app/assets/javascripts/caboose/cart.js +168 -0
- data/app/assets/javascripts/caboose/checkout.js +151 -0
- data/app/assets/javascripts/caboose/checkout_module.js +312 -0
- data/app/assets/javascripts/caboose/checkout_step1.js +179 -0
- data/app/assets/javascripts/caboose/checkout_step2.js +39 -0
- data/app/assets/javascripts/caboose/checkout_step3.js +34 -0
- data/app/assets/javascripts/caboose/checkout_step4.js +97 -0
- data/app/assets/javascripts/caboose/main.js +99 -8
- data/app/assets/javascripts/caboose/product.js +284 -0
- data/app/assets/stylesheets/caboose/admin_products.css +86 -0
- data/app/assets/templates/caboose/cart/add_to_cart.jst.ejs +7 -0
- data/app/assets/templates/caboose/cart/line_items.jst.ejs +41 -0
- data/app/assets/templates/caboose/checkout/address.jst.ejs +53 -0
- data/app/assets/templates/caboose/checkout/forms/guest.jst.ejs +8 -0
- data/app/assets/templates/caboose/checkout/forms/register.jst.ejs +11 -0
- data/app/assets/templates/caboose/checkout/forms/signin.jst.ejs +7 -0
- data/app/assets/templates/caboose/checkout/line_items.jst.ejs +31 -0
- data/app/assets/templates/caboose/checkout/login.jst.ejs +21 -0
- data/app/assets/templates/caboose/checkout/payment.jst.ejs +5 -0
- data/app/assets/templates/caboose/checkout/shipping.jst.ejs +18 -0
- data/app/assets/templates/caboose/product/images.jst.ejs +8 -0
- data/app/assets/templates/caboose/product/options.jst.ejs +19 -0
- data/app/controllers/caboose/application_controller.rb +29 -1
- data/app/controllers/caboose/cart_controller.rb +52 -0
- data/app/controllers/caboose/categories_controller.rb +108 -0
- data/app/controllers/caboose/checkout_controller.rb +325 -0
- data/app/controllers/caboose/orders_controller.rb +439 -0
- data/app/controllers/caboose/product_images_controller.rb +38 -0
- data/app/controllers/caboose/products_controller.rb +737 -0
- data/app/controllers/caboose/reviews_controller.rb +15 -0
- data/app/controllers/caboose/variants_controller.rb +218 -0
- data/app/controllers/caboose/vendors_controller.rb +73 -0
- data/app/helpers/caboose/application_helper.rb +4 -0
- data/app/helpers/caboose/categories_helper.rb +82 -0
- data/app/helpers/caboose/checkout_helper.rb +20 -0
- data/app/helpers/caboose/products_helper.rb +8 -0
- data/app/mailers/caboose/orders_mailer.rb +30 -0
- data/app/models/caboose/address.rb +26 -0
- data/app/models/caboose/category.rb +89 -0
- data/app/models/caboose/category_membership.rb +10 -0
- data/app/models/caboose/core_plugin.rb +15 -37
- data/app/models/caboose/customization_membership.rb +10 -0
- data/app/models/caboose/discount.rb +16 -0
- data/app/models/caboose/line_item.rb +81 -0
- data/app/models/caboose/message.rb +20 -0
- data/app/models/caboose/order.rb +191 -0
- data/app/models/caboose/order_discount.rb +10 -0
- data/app/models/caboose/order_pdf.rb +78 -0
- data/app/models/caboose/payment_processors/authorizenet.rb +53 -0
- data/app/models/caboose/payment_processors/base.rb +39 -0
- data/app/models/caboose/payment_processors/payscape.rb +94 -0
- data/app/models/caboose/product.rb +145 -0
- data/app/models/caboose/product_image.rb +62 -0
- data/app/models/caboose/product_image_variant.rb +10 -0
- data/app/models/caboose/review.rb +13 -0
- data/app/models/caboose/schema.rb +205 -1
- data/app/models/caboose/search_filter.rb +191 -0
- data/app/models/caboose/shipping_calculator.rb +81 -0
- data/app/models/caboose/states.rb +61 -52
- data/app/models/caboose/tax_calculator.rb +23 -0
- data/app/models/caboose/tax_line.rb +9 -0
- data/app/models/caboose/variant.rb +99 -0
- data/app/models/caboose/vendor.rb +22 -0
- data/app/views/caboose/cart/index.html.erb +8 -0
- data/app/views/caboose/categories/admin_edit.html.erb +79 -0
- data/app/views/caboose/categories/admin_index.html.erb +11 -0
- data/app/views/caboose/categories/admin_new.html.erb +62 -0
- data/app/views/caboose/checkout/_address_form.html.erb +111 -0
- data/app/views/caboose/checkout/_billing_form.html.erb +47 -0
- data/app/views/caboose/checkout/_cart.html.erb +52 -0
- data/app/views/caboose/checkout/_confirm.html.erb +61 -0
- data/app/views/caboose/checkout/_order_discount.html.erb +40 -0
- data/app/views/caboose/checkout/_shipping_address.html.erb +10 -0
- data/app/views/caboose/checkout/_shipping_method.html.erb +2 -0
- data/app/views/caboose/checkout/_shipping_method_form.html.erb +21 -0
- data/app/views/caboose/checkout/billing.html.erb +11 -0
- data/app/views/caboose/checkout/discount.html.erb +11 -0
- data/app/views/caboose/checkout/empty.html.erb +2 -0
- data/app/views/caboose/checkout/error.html.erb +2 -0
- data/app/views/caboose/checkout/index.html.erb +43 -0
- data/app/views/caboose/checkout/login.html.erb +2 -0
- data/app/views/caboose/checkout/payment.html.erb +79 -0
- data/app/views/caboose/checkout/relay.html.erb +23 -0
- data/app/views/caboose/checkout/relay_old.html.erb +12 -0
- data/app/views/caboose/checkout/relay_postMessage.html.erb +19 -0
- data/app/views/caboose/checkout/shipping.html.erb +15 -0
- data/app/views/caboose/checkout/step_four.html.erb +93 -0
- data/app/views/caboose/checkout/step_one.html.erb +56 -0
- data/app/views/caboose/checkout/step_one_old.html.erb +13 -0
- data/app/views/caboose/checkout/step_three.html.erb +23 -0
- data/app/views/caboose/checkout/step_two.html.erb +52 -0
- data/app/views/caboose/checkout/step_two_old.html.erb +14 -0
- data/app/views/caboose/checkout/thanks.html.erb +5 -0
- data/app/views/caboose/orders/_admin_footer.html.erb +2 -0
- data/app/views/caboose/orders/_admin_header.html.erb +31 -0
- data/app/views/caboose/orders/_quickbooks_order.html.erb +0 -0
- data/app/views/caboose/orders/admin_delete_form.html.erb +21 -0
- data/app/views/caboose/orders/admin_edit.html.erb +271 -0
- data/app/views/caboose/orders/admin_index.html.erb +89 -0
- data/app/views/caboose/orders/admin_new.html.erb +42 -0
- data/app/views/caboose/orders/admin_print.html.erb +72 -0
- data/app/views/caboose/orders_mailer/customer_new_order.html.erb +1 -0
- data/app/views/caboose/orders_mailer/customer_status_updated.html.erb +1 -0
- data/app/views/caboose/orders_mailer/fulfillment_new_order.html.erb +1 -0
- data/app/views/caboose/orders_mailer/shipping_order_ready.html.erb +1 -0
- data/app/views/caboose/products/_admin_footer.html.erb +2 -0
- data/app/views/caboose/products/_admin_header.html.erb +32 -0
- data/app/views/caboose/products/_sort_options.html.erb +19 -0
- data/app/views/caboose/products/admin_add_upcs.html.erb +58 -0
- data/app/views/caboose/products/admin_delete_form.html.erb +21 -0
- data/app/views/caboose/products/admin_edit_categories.html.erb +73 -0
- data/app/views/caboose/products/admin_edit_category_images.html.erb +233 -0
- data/app/views/caboose/products/admin_edit_description.html.erb +38 -0
- data/app/views/caboose/products/admin_edit_general.html.erb +104 -0
- data/app/views/caboose/products/admin_edit_images.html.erb +236 -0
- data/app/views/caboose/products/admin_edit_options.html.erb +51 -0
- data/app/views/caboose/products/admin_edit_seo.html.erb +37 -0
- data/app/views/caboose/products/admin_edit_variant_columns.html.erb +75 -0
- data/app/views/caboose/products/admin_edit_variant_sort_order.html.erb +63 -0
- data/app/views/caboose/products/admin_edit_variants.html.erb +171 -0
- data/app/views/caboose/products/admin_edit_variants_single.html.erb +68 -0
- data/app/views/caboose/products/admin_group_variants.html.erb +433 -0
- data/app/views/caboose/products/admin_index.html.erb +95 -0
- data/app/views/caboose/products/admin_new.html.erb +41 -0
- data/app/views/caboose/products/admin_sort.html copy.erb +155 -0
- data/app/views/caboose/products/admin_sort.html.erb +254 -0
- data/app/views/caboose/products/details.html.erb +438 -0
- data/app/views/caboose/products/index.html.erb +46 -0
- data/app/views/caboose/products/not_available.html.erb +35 -0
- data/app/views/caboose/variants/admin_edit.html.erb +82 -0
- data/app/views/caboose/variants/admin_group.html.erb +184 -0
- data/app/views/caboose/variants/admin_new.html.erb +59 -0
- data/app/views/caboose/vendors/admin_edit.html.erb +24 -0
- data/app/views/caboose/vendors/admin_index.html.erb +30 -0
- data/app/views/caboose/vendors/admin_new.html.erb +34 -0
- data/app/views/layouts/caboose/store/_banner.html.erb +10 -0
- data/app/views/layouts/caboose/store/_banner2.html.erb +10 -0
- data/app/views/layouts/caboose/store/_footer.html.erb +55 -0
- data/app/views/layouts/caboose/store/_header.html.erb +69 -0
- data/app/views/layouts/caboose/store/_sidebar.html.erb +27 -0
- data/app/views/layouts/caboose/store/application.html.erb +33 -0
- data/app/views/layouts/caboose/store/authorize_net.erb +18 -0
- data/app/views/layouts/caboose/store/layout_about.html.erb +42 -0
- data/app/views/layouts/caboose/store/layout_blog.html.erb +159 -0
- data/app/views/layouts/caboose/store/layout_confirm.html.erb +85 -0
- data/app/views/layouts/caboose/store/layout_contact.html.erb +38 -0
- data/app/views/layouts/caboose/store/layout_default.html.erb +10 -0
- data/app/views/layouts/caboose/store/layout_detail.html.erb +114 -0
- data/app/views/layouts/caboose/store/layout_order.html.erb +77 -0
- data/app/views/layouts/caboose/store/layout_pricing.html.erb +182 -0
- data/app/views/layouts/caboose/store/layout_product.html.erb +110 -0
- data/app/views/layouts/caboose/store/layout_profile.html.erb +55 -0
- data/app/views/layouts/caboose/store/layout_single.html.erb +3 -0
- data/app/views/layouts/caboose/store/layout_testimonial.html.erb +110 -0
- data/app/views/layouts/caboose/store/layout_testing.html.erb +4 -0
- data/config/routes.rb +126 -0
- data/lib/caboose.rb +46 -1
- data/lib/caboose/engine.rb +39 -1
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +12 -0
- metadata +151 -4
- data/app/assets/javascripts/caboose/admin_page_edit_content_bak.js +0 -164
- data/app/assets/javascripts/caboose/model/#Untitled-1# +0 -2
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'active_shipping'
|
2
|
+
include ActiveMerchant::Shipping
|
3
|
+
|
4
|
+
module Caboose
|
5
|
+
class ShippingCalculator
|
6
|
+
def self.rates(order)
|
7
|
+
return [] if Caboose::shipping.nil?
|
8
|
+
|
9
|
+
total = 0.0
|
10
|
+
weight = 0.0
|
11
|
+
|
12
|
+
order.line_items.each do |li|
|
13
|
+
total = total + (li.variant.shipping_unit_value.nil? ? 0 : li.variant.shipping_unit_value)
|
14
|
+
weight = weight + (li.variant.weight || 0)
|
15
|
+
end
|
16
|
+
|
17
|
+
length = 0
|
18
|
+
width = 0
|
19
|
+
height = 0
|
20
|
+
|
21
|
+
if total <= 5
|
22
|
+
length = 15.5
|
23
|
+
width = 9.5
|
24
|
+
height = 6
|
25
|
+
elsif total <= 10
|
26
|
+
length = 12
|
27
|
+
width = 8
|
28
|
+
height = 5
|
29
|
+
else
|
30
|
+
length = 20
|
31
|
+
width = 16
|
32
|
+
height = 14
|
33
|
+
end
|
34
|
+
|
35
|
+
origin = Location.new(
|
36
|
+
:country => Caboose::shipping[:origin][:country],
|
37
|
+
:state => Caboose::shipping[:origin][:state],
|
38
|
+
:city => Caboose::shipping[:origin][:city],
|
39
|
+
:zip => Caboose::shipping[:origin][:zip]
|
40
|
+
)
|
41
|
+
|
42
|
+
destination = Location.new(
|
43
|
+
:country => Caboose::shipping[:origin][:country],
|
44
|
+
:state => order.shipping_address.state,
|
45
|
+
:city => order.shipping_address.city,
|
46
|
+
:postal_code => order.shipping_address.zip
|
47
|
+
)
|
48
|
+
|
49
|
+
packages = [Package.new(weight, [length, width, height], :units => :imperial)]
|
50
|
+
|
51
|
+
ups = UPS.new(
|
52
|
+
:key => Caboose::shipping[:ups][:key],
|
53
|
+
:login => Caboose::shipping[:ups][:username],
|
54
|
+
:password => Caboose::shipping[:ups][:password],
|
55
|
+
:origin_account => Caboose::shipping[:ups][:origin_account]
|
56
|
+
)
|
57
|
+
|
58
|
+
ups_response = ups.find_rates(origin, destination, packages)
|
59
|
+
|
60
|
+
rates = ups_response.rates.collect do |rate|
|
61
|
+
next if Caboose::allowed_shipping_method_codes && !Caboose::allowed_shipping_method_codes.index(rate.service_code)
|
62
|
+
|
63
|
+
{
|
64
|
+
:service_code => rate.service_code,
|
65
|
+
:service_name => rate.service_name,
|
66
|
+
:total_price => rate.total_price.to_d / 100,
|
67
|
+
:negotiated_rate => rate.negotiated_rate
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
return rates.compact
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.rate(order)
|
75
|
+
return nil if !order.shipping_method_code
|
76
|
+
self.rates(order).each { |rate| return rate if rate[:service_code] == order.shipping_method_code }
|
77
|
+
return nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -1,57 +1,66 @@
|
|
1
1
|
class Caboose::States
|
2
2
|
def self.all
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
3
|
+
{
|
4
|
+
"AL" => "Alabama",
|
5
|
+
"AK" => "Alaska",
|
6
|
+
"AS" => "American Samoa",
|
7
|
+
"AZ" => "Arizona",
|
8
|
+
"AR" => "Arkansas",
|
9
|
+
"CA" => "California",
|
10
|
+
"CO" => "Colorado",
|
11
|
+
"CT" => "Connecticut",
|
12
|
+
"DE" => "Delaware",
|
13
|
+
"DC" => "District Of Columbia",
|
14
|
+
"FM" => "Federated States Of Micronesia",
|
15
|
+
"FL" => "Florida",
|
16
|
+
"GA" => "Georgia",
|
17
|
+
"GU" => "Guam",
|
18
|
+
"HI" => "Hawaii",
|
19
|
+
"ID" => "Idaho",
|
20
|
+
"IL" => "Illinois",
|
21
|
+
"IN" => "Indiana",
|
22
|
+
"IA" => "Iowa",
|
23
|
+
"KS" => "Kansas",
|
24
|
+
"KY" => "Kentucky",
|
25
|
+
"LA" => "Louisiana",
|
26
|
+
"ME" => "Maine",
|
27
|
+
"MH" => "Marshall Islands",
|
28
|
+
"MD" => "Maryland",
|
29
|
+
"MA" => "Massachusetts",
|
30
|
+
"MI" => "Michigan",
|
31
|
+
"MN" => "Minnesota",
|
32
|
+
"MS" => "Mississippi",
|
33
|
+
"MO" => "Missouri",
|
34
|
+
"MT" => "Montana",
|
35
|
+
"NE" => "Nebraska",
|
36
|
+
"NV" => "Nevada",
|
37
|
+
"NH" => "New Hampshire",
|
38
|
+
"NJ" => "New Jersey",
|
39
|
+
"NM" => "New Mexico",
|
40
|
+
"NY" => "New York",
|
41
|
+
"NC" => "North Carolina",
|
42
|
+
"ND" => "North Dakota",
|
43
|
+
"MP" => "Northern Mariana Islands",
|
44
|
+
"OH" => "Ohio",
|
45
|
+
"OK" => "Oklahoma",
|
46
|
+
"OR" => "Oregon",
|
47
|
+
"PW" => "Palau",
|
48
|
+
"PA" => "Pennsylvania",
|
49
|
+
"PR" => "Puerto Rico",
|
50
|
+
"RI" => "Rhode Island",
|
51
|
+
"SC" => "South Carolina",
|
52
|
+
"SD" => "South Dakota",
|
53
|
+
"TN" => "Tennessee",
|
54
|
+
"TX" => "Texas",
|
55
|
+
"UT" => "Utah",
|
56
|
+
"VT" => "Vermont",
|
57
|
+
"VI" => "Virgin Islands",
|
58
|
+
"VA" => "Virginia",
|
59
|
+
"WA" => "Washington",
|
60
|
+
"WV" => "West Virginia",
|
61
|
+
"WI" => "Wisconsin",
|
62
|
+
"WY" => "Wyoming"
|
55
63
|
}
|
56
64
|
end
|
57
65
|
end
|
66
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Caboose
|
2
|
+
class TaxCalculator
|
3
|
+
def self.tax_rate(address)
|
4
|
+
ap '--HOOK calculate tax'
|
5
|
+
return 0 if address.state.downcase != 'al'
|
6
|
+
city = address.city.downcase
|
7
|
+
rate = 0.00
|
8
|
+
rate = rate + 0.05 if city == 'brookwood'
|
9
|
+
rate = rate + 0.05 if city == 'coaling'
|
10
|
+
rate = rate + 0.05 if city == 'coker'
|
11
|
+
rate = rate + 0.05 if city == 'holt'
|
12
|
+
rate = rate + 0.05 if city == 'holt CDP'
|
13
|
+
rate = rate + 0.05 if city == 'lake View'
|
14
|
+
rate = rate + 0.05 if city == 'moundville'
|
15
|
+
rate = rate + 0.05 if city == 'northport'
|
16
|
+
rate = rate + 0.05 if city == 'tuscaloosa'
|
17
|
+
rate = rate + 0.05 if city == 'vance'
|
18
|
+
rate = rate + 0.05 if city == 'woodstock'
|
19
|
+
rate = rate + 0.04 if address.state.downcase == 'al' || address.state.downcase == 'alabama'
|
20
|
+
return rate.round(2)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Caboose
|
2
|
+
class TaxLine < ActiveRecord::Base
|
3
|
+
attr_accessible :id,
|
4
|
+
:title, # The name of the tax, eg. QST or VAT
|
5
|
+
:price, # The amount
|
6
|
+
:rate, # The rate. It will return 0.175 if it is 17.5%
|
7
|
+
:rate_percentage # The tax rate in human readable form. It will return 17.5 if the rate is 0.175
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#
|
2
|
+
# Variant
|
3
|
+
#
|
4
|
+
# :: Class Methods
|
5
|
+
# :: Instance Methods
|
6
|
+
|
7
|
+
module Caboose
|
8
|
+
class Variant < ActiveRecord::Base
|
9
|
+
self.table_name = 'store_variants'
|
10
|
+
|
11
|
+
belongs_to :product
|
12
|
+
has_many :product_image_variants
|
13
|
+
has_many :product_images, :through => :product_image_variants
|
14
|
+
|
15
|
+
attr_accessible :id,
|
16
|
+
:alternate_id,
|
17
|
+
:product_id,
|
18
|
+
:barcode, # Returns the barcode value of the variant.
|
19
|
+
:price, # Variant’s price.
|
20
|
+
:ignore_quantity,
|
21
|
+
:quantity,
|
22
|
+
:quantity_in_stock,
|
23
|
+
:allow_backorder, # Whether to allow items with no inventory to be added to the cart
|
24
|
+
:status, # Current status: active, inactive, deleted
|
25
|
+
:weight, # The weight of the variant. This will always be in metric grams.
|
26
|
+
:length, # Length of variant in inches
|
27
|
+
:width, # Width of variant in inches
|
28
|
+
:height, # Height of variant in inches
|
29
|
+
:option1, # Returns the value of option1 for given variant
|
30
|
+
:option2, # If a product has a second option defined, then returns the value of this variant's option2.
|
31
|
+
:option3, # If a product has a third option defined, then returns the value of this variant's option3.
|
32
|
+
:requires_shipping, # Returns true if the variant is shippable or false if it is a service or a digital good.
|
33
|
+
:taxable, # Returns true if the variant is taxable or false if it is not.
|
34
|
+
:sku,
|
35
|
+
:available,
|
36
|
+
:cylinder,
|
37
|
+
:shipping_unit_value
|
38
|
+
|
39
|
+
#
|
40
|
+
# Class Methods
|
41
|
+
#
|
42
|
+
|
43
|
+
def self.find_by_options(product_id, option1=nil, option2=nil, option3=nil)
|
44
|
+
|
45
|
+
# Create the vars that will become the full conditions statement
|
46
|
+
where = ['product_id=?']
|
47
|
+
values = [product_id.to_i]
|
48
|
+
|
49
|
+
# Append option values if they exist
|
50
|
+
|
51
|
+
if option1
|
52
|
+
where << 'option1=?'
|
53
|
+
values << option1
|
54
|
+
end
|
55
|
+
|
56
|
+
if option2
|
57
|
+
where << 'option2=?'
|
58
|
+
values << option2
|
59
|
+
end
|
60
|
+
|
61
|
+
if option3
|
62
|
+
where << 'option3=?'
|
63
|
+
values << option3
|
64
|
+
end
|
65
|
+
|
66
|
+
# Combine all the options into a single conditions statement
|
67
|
+
conditions = [ where.join(' AND ') ].concat(values)
|
68
|
+
|
69
|
+
# Return whatever is found
|
70
|
+
return Variant.where(conditions).first
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Instance Methods
|
75
|
+
#
|
76
|
+
|
77
|
+
def as_json(options={})
|
78
|
+
self.attributes.merge({
|
79
|
+
:images => if self.product_images.any?
|
80
|
+
self.product_images
|
81
|
+
else
|
82
|
+
[self.product.product_images.first]
|
83
|
+
end
|
84
|
+
})
|
85
|
+
end
|
86
|
+
|
87
|
+
def title
|
88
|
+
return self.options.join(' / ')
|
89
|
+
end
|
90
|
+
|
91
|
+
def options
|
92
|
+
arr = []
|
93
|
+
arr << self.option1 if self.option1 && self.option1.strip.length > 0
|
94
|
+
arr << self.option2 if self.option2 && self.option2.strip.length > 0
|
95
|
+
arr << self.option3 if self.option3 && self.option3.strip.length > 0
|
96
|
+
return arr
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module Caboose
|
3
|
+
class Vendor < ActiveRecord::Base
|
4
|
+
self.table_name = 'store_vendors'
|
5
|
+
|
6
|
+
has_many :products
|
7
|
+
attr_accessible :id, :name, :status, :sort_order
|
8
|
+
after_save :clear_filters
|
9
|
+
|
10
|
+
def self.active
|
11
|
+
where(:status => 'Active')
|
12
|
+
end
|
13
|
+
|
14
|
+
def update_products
|
15
|
+
self.products.each { |product| product.update_attribute(:vendor_status, self.status) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def clear_filters
|
19
|
+
SearchFilter.delete_all
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
<h1>Edit Category</h1>
|
2
|
+
|
3
|
+
<p><div class="push-below" id="category_<%= @category.id %>_name"></div></p>
|
4
|
+
<p><div class="push-below" id="category_<%= @category.id %>_slug"></div></p>
|
5
|
+
<p><div class="push-below" id="category_<%= @category.id %>_status"></div></p>
|
6
|
+
<p><div class="push-below" id="category_<%= @category.id %>_image"></div></p>
|
7
|
+
|
8
|
+
<h2>Products</h2>
|
9
|
+
|
10
|
+
<% if @category.products.any? %>
|
11
|
+
<ul>
|
12
|
+
<% @category.products.each do |product| %>
|
13
|
+
<li><a href="/admin/products/<%= product.id %>/general"><%= product.title %></a></li>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
<% else %>
|
17
|
+
<p>This category has no associated products.</p>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<div id="message"></div>
|
21
|
+
<input type="button" value="< Back" onclick="window.location='/admin/categories'" />
|
22
|
+
<input type="button" value="Delete Category" onclick="delete_category(<%= @category.id %>)" />
|
23
|
+
|
24
|
+
<% content_for :caboose_css do %>
|
25
|
+
<style>
|
26
|
+
.push-below { margin-bottom: 24px; }
|
27
|
+
</style>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<% content_for :caboose_js do %>
|
31
|
+
<%= javascript_include_tag "caboose/model/all" %>
|
32
|
+
|
33
|
+
<script type='text/javascript'>
|
34
|
+
var modal = false;
|
35
|
+
|
36
|
+
$(window).load(function() {
|
37
|
+
modal = new CabooseModal(800);
|
38
|
+
});
|
39
|
+
|
40
|
+
$(document).ready(function() {
|
41
|
+
m = new ModelBinder({
|
42
|
+
name: 'Category',
|
43
|
+
id: <%= @category.id %>,
|
44
|
+
update_url: '/admin/categories/<%= @category.id %>',
|
45
|
+
authenticity_token: '<%= form_authenticity_token %>',
|
46
|
+
attributes: [
|
47
|
+
{ name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(@category.name) %> , width: 400 },
|
48
|
+
{ name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(@category.slug) %> , width: 400 },
|
49
|
+
{ name: 'status', nice_name: 'Status', type: 'select', value: <%= raw Caboose.json(@category.status) %> , width: 400 , text: <%= raw Caboose.json(@category.status) %>, options_url: '/admin/categories/status-options' },
|
50
|
+
{ name: 'image' , nice_name: 'Image' , type: 'image' , value: <%= raw Caboose.json(@category.image.url(:medium)) %> , width: 200 }
|
51
|
+
]
|
52
|
+
});
|
53
|
+
});
|
54
|
+
|
55
|
+
function delete_category(cat_id, confirm) {
|
56
|
+
if (!confirm) {
|
57
|
+
var p = $('<p/>').addClass('note error').css('margin-bottom', '10px')
|
58
|
+
.append("Are you sure you want to delete the category?<br />This can't be undone.<br /><br />")
|
59
|
+
.append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_category(cat_id, true); })).append(' ')
|
60
|
+
.append($('<input/>').attr('type', 'button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
|
61
|
+
|
62
|
+
modal.autosize(p, 'message');
|
63
|
+
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
modal.autosize("<p class='loading'>Deleting the category...</p>");
|
68
|
+
|
69
|
+
$.ajax({
|
70
|
+
url: '/admin/categories/' + cat_id,
|
71
|
+
type: 'delete',
|
72
|
+
success: function(resp) {
|
73
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
74
|
+
if (resp.redirect) window.location = resp.redirect;
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
</script>
|
79
|
+
<% end %>
|