Class: Caboose::BlockTypeCategoriesController
Instance Method Summary
collapse
#add_ga_event, #admin_add, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_json, #admin_json_single, #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_create ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/caboose/block_type_categories_controller.rb', line 23
def admin_create
render :json => false and return if !logged_in_user.is_super_admin?
resp = StdClass.new
if params[:name].blank?
resp.error = "Name is required."
else
par = BlockTypeCategory.where(:name => 'Content').first
max = BlockTypeCategory.where(:parent_id => par.id).maximum(:sort_order) if par
btc = BlockTypeCategory.new
btc.name = params[:name]
btc.parent_id = par.id if par
btc.sort_order = max + 1 if max
btc.save
resp.redirect = "/admin/block-type-categories/#{btc.id}"
end
render :json => resp
end
|
#admin_delete ⇒ Object
54
55
56
|
# File 'app/controllers/caboose/block_type_categories_controller.rb', line 54
def admin_delete
render :json => false and return if !logged_in_user.is_super_admin?
end
|
#admin_edit ⇒ Object
42
43
44
45
46
|
# File 'app/controllers/caboose/block_type_categories_controller.rb', line 42
def admin_edit
redirect_to '/admin' and return if !logged_in_user.is_super_admin?
@btc = BlockTypeCategory.find(params[:id])
render :layout => 'caboose/admin'
end
|
#admin_index ⇒ Object
5
6
7
8
9
|
# File 'app/controllers/caboose/block_type_categories_controller.rb', line 5
def admin_index
redirect_to '/admin' and return if !logged_in_user.is_super_admin?
@btc = BlockTypeCategory.where(:parent_id => nil).order(:sort_order).all
render :layout => 'caboose/admin'
end
|
#admin_new ⇒ Object
18
19
20
|
# File 'app/controllers/caboose/block_type_categories_controller.rb', line 18
def admin_new
render :layout => 'caboose/admin'
end
|
#admin_options ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'app/controllers/caboose/block_type_categories_controller.rb', line 59
def admin_options
btc = BlockTypeCategory.find(params[:id])
options = params[:default] == 'yes' ? [{:text => 'Default', :value => 'Default'}] : []
options << { 'value' => 'none', 'text' => "No Header" } if params[:none] == 'yes'
BlockType.joins(:block_type_site_memberships).where("block_type_site_memberships.site_id = ?",@site.id).where("block_type_site_memberships.block_type_id = block_types.id").where("block_types.block_type_category_id = ?",btc.id).reorder('block_types.description').all.each do |s|
options << { 'value' => s.id, 'text' => s.description }
end
render :json => options
end
|
#admin_tree_options ⇒ Object
12
13
14
15
|
# File 'app/controllers/caboose/block_type_categories_controller.rb', line 12
def admin_tree_options
return unless user_is_allowed('pages', 'edit')
render :json => BlockTypeCategory.tree
end
|
#admin_update ⇒ Object
49
50
51
|
# File 'app/controllers/caboose/block_type_categories_controller.rb', line 49
def admin_update
render :json => false and return if !logged_in_user.is_super_admin?
end
|