Class: Caboose::AbVariantsController
Instance Method Summary
collapse
#add_ga_event, #admin_add, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_delete, #admin_json, #admin_json_single, #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_create ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/caboose/ab_variants_controller.rb', line 35
def admin_create
return unless user_is_allowed_to 'edit', 'ab_variants'
resp = StdClass.new({
'error' => nil,
'redirect' => nil
})
variant = AbVariant.new
variant.name = params[:name]
variant.analytics_name = params[:name].gsub(' ', '_').downcase
if (variant.name.length == 0)
resp.error = "A name is required."
elsif variant.save
resp.redirect = "/admin/ab-variants/#{variant.id}"
end
render json: resp
end
|
#admin_destroy ⇒ Object
80
81
82
83
84
85
|
# File 'app/controllers/caboose/ab_variants_controller.rb', line 80
def admin_destroy
return unless user_is_allowed_to 'delete', 'ab_variants'
AbVariants.find(params[:id]).destroy
resp = StdClass.new('redirect' => '/admin/ab-variants')
render :json => resp
end
|
#admin_edit ⇒ Object
29
30
31
32
|
# File 'app/controllers/caboose/ab_variants_controller.rb', line 29
def admin_edit
return unless user_is_allowed_to 'edit', 'ab_variants'
@variant = AbVariant.find(params[:id])
end
|
#admin_index ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/caboose/ab_variants_controller.rb', line 10
def admin_index
return unless user_is_allowed_to 'view', 'ab_variants'
@gen = PageBarGenerator.new(params, {'name' => '', 'analytics_name' => ''}, {
'model' => 'Caboose::AbVariant',
'sort' => 'name',
'desc' => 'false',
'base_url' => '/admin/ab-variants'
})
@variants = @gen.items
end
|
#admin_new ⇒ Object
23
24
25
26
|
# File 'app/controllers/caboose/ab_variants_controller.rb', line 23
def admin_new
return unless user_is_allowed_to 'add', 'ab_variants'
@variant = AbVariant.new
end
|
#admin_update ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/controllers/caboose/ab_variants_controller.rb', line 57
def admin_update
return unless user_is_allowed_to 'edit', 'ab_variants'
resp = StdClass.new
variant = AbVariant.find(params[:id])
save = true
params.each do |k,v|
case k
when 'name'
variant.name = v
break
when 'analytics_name'
variant.analytics_name = v
break
end
end
resp.success = save && variant.save
render :json => resp
end
|
#before_action ⇒ Object
5
6
7
|
# File 'app/controllers/caboose/ab_variants_controller.rb', line 5
def before_action
@page = Page.page_with_uri(request.host_with_port, '/admin')
end
|