Class: Caboose::SitesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Caboose::SitesController
- Defined in:
- app/controllers/caboose/sites_controller.rb
Instance Method Summary collapse
-
#admin_add ⇒ Object
POST /admin/sites.
-
#admin_add_member ⇒ Object
POST /admin/sites/:id/members.
-
#admin_delete ⇒ Object
DELETE /admin/sites/:id.
-
#admin_delete_form ⇒ Object
GET /admin/sites/:id/delete.
-
#admin_edit ⇒ Object
GET /admin/sites/:id.
-
#admin_edit_block_types ⇒ Object
GET /admin/sites/:id/block-types.
-
#admin_index ⇒ Object
GET /admin/sites.
-
#admin_new ⇒ Object
GET /admin/sites/new.
-
#admin_remove_member ⇒ Object
DELETE /admin/sites/:id/members/:user_id.
-
#admin_update ⇒ Object
PUT /admin/sites/:id.
- #before_action ⇒ Object
-
#options ⇒ Object
GET /admin/sites/options.
Methods inherited from ApplicationController
#admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #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, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in
Instance Method Details
#admin_add ⇒ Object
POST /admin/sites
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/caboose/sites_controller.rb', line 52 def admin_add return if !user_is_allowed('sites', 'add') resp = StdClass.new site = Site.new site.name = params[:name].strip if site.name.length == 0 resp.error = "Please enter a valid domain." else site.save StoreConfig.create(:site_id => site.id) SmtpConfig.create( :site_id => site.id) resp.redirect = "/admin/sites/#{site.id}" end render :json => resp end |
#admin_add_member ⇒ Object
POST /admin/sites/:id/members
105 106 107 108 109 110 111 112 |
# File 'app/controllers/caboose/sites_controller.rb', line 105 def admin_add_member return if !user_is_allowed('sites', 'edit') sm = SiteMembership.where(:site_id => params[:id], :user_id => params[:user_id]).first sm = SiteMembership.create(:site_id => params[:id], :user_id => params[:user_id]) if sm.nil? sm.role = params[:role] sm.save render :json => true end |
#admin_delete ⇒ Object
DELETE /admin/sites/:id
93 94 95 96 97 98 99 100 101 102 |
# File 'app/controllers/caboose/sites_controller.rb', line 93 def admin_delete return if !user_is_allowed('sites', 'delete') site = Site.find(params[:id]) site.destroy resp = StdClass.new({ 'redirect' => '/admin/sites' }) render :json => resp end |
#admin_delete_form ⇒ Object
GET /admin/sites/:id/delete
46 47 48 49 |
# File 'app/controllers/caboose/sites_controller.rb', line 46 def admin_delete_form return if !user_is_allowed('sites', 'edit') @site = Site.find(params[:id]) end |
#admin_edit ⇒ Object
GET /admin/sites/:id
34 35 36 37 |
# File 'app/controllers/caboose/sites_controller.rb', line 34 def admin_edit return if !user_is_allowed('sites', 'edit') @site = Site.find(params[:id]) end |
#admin_edit_block_types ⇒ Object
GET /admin/sites/:id/block-types
40 41 42 43 |
# File 'app/controllers/caboose/sites_controller.rb', line 40 def admin_edit_block_types return if !user_is_allowed('sites', 'edit') @site = Site.find(params[:id]) end |
#admin_index ⇒ Object
GET /admin/sites
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/caboose/sites_controller.rb', line 12 def admin_index return if !user_is_allowed('sites', 'view') @pager = PageBarGenerator.new(params, { 'name_like' => '', },{ 'model' => 'Caboose::Site', 'sort' => 'name', 'desc' => false, 'base_url' => '/admin/sites', 'use_url_params' => false }) @sites = @pager.items end |
#admin_new ⇒ Object
GET /admin/sites/new
28 29 30 31 |
# File 'app/controllers/caboose/sites_controller.rb', line 28 def admin_new return if !user_is_allowed('sites', 'add') @site = Site.new end |
#admin_remove_member ⇒ Object
DELETE /admin/sites/:id/members/:user_id
115 116 117 118 119 |
# File 'app/controllers/caboose/sites_controller.rb', line 115 def admin_remove_member return if !user_is_allowed('sites', 'edit') SiteMembership.where(:site_id => params[:id], :user_id => params[:user_id]).destroy_all render :json => true end |
#admin_update ⇒ Object
PUT /admin/sites/:id
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/caboose/sites_controller.rb', line 72 def admin_update return if !user_is_allowed('sites', 'edit') resp = StdClass.new site = Site.find(params[:id]) save = true params.each do |name,value| case name when 'name' then site.name = value when 'description' then site.description = value when 'under_construction_html' then site.under_construction_html = value when 'use_store' then site.use_store = value end end resp.success = save && site.save render :json => resp end |
#before_action ⇒ Object
7 8 9 |
# File 'app/controllers/caboose/sites_controller.rb', line 7 def before_action @page = Page.page_with_uri(request.host_with_port, '/admin') end |
#options ⇒ Object
GET /admin/sites/options
122 123 124 125 126 |
# File 'app/controllers/caboose/sites_controller.rb', line 122 def return if !user_is_allowed('sites', 'view') = Site.reorder('name').all.collect { |s| { 'value' => s.id, 'text' => s.name }} render :json => end |