Class: Caboose::ProductImagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/caboose/product_images_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_ga_event, #admin_add, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_edit, #admin_index, #admin_json, #admin_json_single, #admin_update, #before_action, #before_before_action, #hashify_query_string, #init_cart, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #under_construction_or_forwarding_domain?, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in

Instance Method Details

#admin_deleteObject


24
25
26
27
28
# File 'app/controllers/caboose/product_images_controller.rb', line 24

def admin_delete
  return if !user_is_allowed('variants', 'delete')
  img = ProductImage.find(params[:id]).destroy    
  render :json => true
end

#admin_update_sort_orderObject


38
39
40
41
42
43
44
45
46
# File 'app/controllers/caboose/product_images_controller.rb', line 38

def admin_update_sort_order
  return if !user_is_allowed('products', 'edit')
        
  ids = params[:product_image_ids]            
  ids.each_with_index do |id, i|
    ProductImage.find(id).update_attribute(:position, i)
  end
  render :json => { :success => true }
end

#admin_variant_idsObject


9
10
11
12
13
14
# File 'app/controllers/caboose/product_images_controller.rb', line 9

def admin_variant_ids
  return if !user_is_allowed('variants', 'edit')
  img = ProductImage.find(params[:id])
  ids = img.variants.collect{ |v| v.id }
  render :json => ids
end

#admin_variantsObject


17
18
19
20
21
# File 'app/controllers/caboose/product_images_controller.rb', line 17

def admin_variants
  return if !user_is_allowed('variants', 'edit')
  img = ProductImage.find(params[:id])    
  render :json => img.variants
end

#variant_imagesObject


31
32
33
34
35
# File 'app/controllers/caboose/product_images_controller.rb', line 31

def variant_images
  var = Variant.find(params[:id])
  img = var.product_images.first
  render :json => img
end