Class: Caboose::DomainsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Caboose::DomainsController
- Defined in:
- app/controllers/caboose/domains_controller.rb
Instance Method Summary collapse
-
#admin_add ⇒ Object
POST /admin/sites/:site_id/domains.
-
#admin_delete ⇒ Object
DELETE /admin/sites/:site_id/domains/:id.
-
#admin_set_primary ⇒ Object
PUT /admin/sites/:site_id/domains/:id/set-primary.
-
#admin_update ⇒ Object
PUT /admin/sites/:site_id/domains/:id.
- #before_action ⇒ Object
Methods inherited from ApplicationController
#admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_edit, #admin_index, #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/:site_id/domains
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/caboose/domains_controller.rb', line 12 def admin_add return if !user_is_allowed('domains', 'edit') resp = Caboose::StdClass.new d = Domain.where(:domain => params[:domain]).first if d && d.site_id != params[:site_id] resp.error = "That domain is already associated with another site." elsif d && d.site_id == params[:site_id] resp.refresh = true elsif d.nil? primary = Domain.where(:site_id => params[:site_id]).count == 0 d = Domain.create(:site_id => params[:site_id], :domain => params[:domain], :primary => primary) resp.refresh = true end render :json => resp end |
#admin_delete ⇒ Object
DELETE /admin/sites/:site_id/domains/:id
57 58 59 60 61 |
# File 'app/controllers/caboose/domains_controller.rb', line 57 def admin_delete return if !user_is_allowed('sites', 'delete') Domain.find(params[:id]).destroy render :json => { 'refresh' => "/admin/sites/#{params[:site_id]}" } end |
#admin_set_primary ⇒ Object
PUT /admin/sites/:site_id/domains/:id/set-primary
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/caboose/domains_controller.rb', line 64 def admin_set_primary return if !user_is_allowed('domains', 'edit') resp = StdClass.new d = Domain.find(params[:id]) save = true # d.primary = value Domain.where(:site_id => params[:site_id]).all.each do |d2| d2.primary = d2.id == d.id ? true : false d2.save end resp.success = save && d.save render :json => resp end |
#admin_update ⇒ Object
PUT /admin/sites/:site_id/domains/:id
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/caboose/domains_controller.rb', line 31 def admin_update return if !user_is_allowed('domains', 'edit') resp = StdClass.new d = Domain.find(params[:id]) save = true params.each do |name,value| case name when 'site_id' then d.site_id = value when 'domain' then d.domain = value when 'under_construction' then d.under_construction = value when 'primary' then d.primary = value Domain.where(:site_id => params[:site_id]).all.each do |d2| d2.primary = d2.id == d.id ? true : false d2.save end end end resp.success = save && d.save render :json => resp end |
#before_action ⇒ Object
7 8 9 |
# File 'app/controllers/caboose/domains_controller.rb', line 7 def before_action @page = Page.page_with_uri(request.host_with_port, '/admin') end |