Class: Caboose::PageBlockTypesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Caboose::PageBlockTypesController
- Defined in:
- app/controllers/caboose/page_block_types_controller.rb
Instance Method Summary collapse
-
#admin_create ⇒ Object
POST /admin/page-block-types.
-
#admin_delete ⇒ Object
DELETE /admin/page-block-types/:id.
-
#admin_edit ⇒ Object
GET /admin/page-block-types/:id/edit.
-
#admin_index ⇒ Object
GET /admin/page-block-types.
-
#admin_new ⇒ Object
GET /admin/page-block-types/new.
-
#admin_show ⇒ Object
GET /admin/page-block-types/:id.
-
#admin_update ⇒ Object
PUT /admin/page-block-types/:id.
Methods inherited from ApplicationController
#before_action, #before_before_action, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in
Instance Method Details
#admin_create ⇒ Object
POST /admin/page-block-types
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/caboose/page_block_types_controller.rb', line 38 def admin_create return unless user_is_allowed('pages', 'add') resp = Caboose::StdClass.new({ 'error' => nil, 'redirect' => nil }) bt = PageBlockType.new( :name => params[:name].downcase.gsub(' ', '_'), :description => params[:name], :use_render_function => false ) bt.save # Send back the response resp.redirect = "/admin/page-block-types/#{bt.id}/edit" render :json => resp end |
#admin_delete ⇒ Object
DELETE /admin/page-block-types/:id
90 91 92 93 94 95 96 97 |
# File 'app/controllers/caboose/page_block_types_controller.rb', line 90 def admin_delete return unless user_is_allowed('pages', 'delete') PageBlockType.find(params[:id]).destroy resp = StdClass.new({ 'redirect' => "/admin/page-block-types" }) render :json => resp end |
#admin_edit ⇒ Object
GET /admin/page-block-types/:id/edit
31 32 33 34 35 |
# File 'app/controllers/caboose/page_block_types_controller.rb', line 31 def admin_edit return unless user_is_allowed('pages', 'edit') @block_type = PageBlockType.find(params[:id]) render :layout => 'caboose/admin' end |
#admin_index ⇒ Object
GET /admin/page-block-types
10 11 12 13 14 |
# File 'app/controllers/caboose/page_block_types_controller.rb', line 10 def admin_index return if !user_is_allowed('pages', 'view') @block_types = PageBlockType.reorder(:name).all render :layout => 'caboose/admin' end |
#admin_new ⇒ Object
GET /admin/page-block-types/new
24 25 26 27 28 |
# File 'app/controllers/caboose/page_block_types_controller.rb', line 24 def admin_new return unless user_is_allowed('pages', 'add') @block_type = PageBlockType.new render :layout => 'caboose/admin' end |
#admin_show ⇒ Object
GET /admin/page-block-types/:id
17 18 19 20 21 |
# File 'app/controllers/caboose/page_block_types_controller.rb', line 17 def admin_show return if !user_is_allowed('pages', 'view') block_type = PageBlockType.find(params[:id]) render :json => block_type end |
#admin_update ⇒ Object
PUT /admin/page-block-types/:id
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/caboose/page_block_types_controller.rb', line 59 def admin_update return unless user_is_allowed('pages', 'edit') resp = StdClass.new({'attributes' => {}}) bt = PageBlockType.find(params[:id]) save = true user = logged_in_user params.each do |k,v| case k when 'name' bt.name = v break when 'description' bt.description = v break when 'use_render_function' bt.use_render_function = v break when 'render_function' bt.render_function = v break end end resp.success = save && bt.save render :json => resp end |