2010-05-10 22:39:52 +00:00
|
|
|
module Admin
|
|
|
|
class CurrentSitesController < BaseController
|
|
|
|
|
|
|
|
sections 'settings', 'site'
|
2010-07-13 00:46:17 +00:00
|
|
|
|
|
|
|
actions :edit, :update
|
2010-05-10 22:39:52 +00:00
|
|
|
|
2010-07-13 20:01:40 +00:00
|
|
|
respond_to :json, :only => :update
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def update
|
2010-07-13 00:46:17 +00:00
|
|
|
update! do |success, failure|
|
|
|
|
success.html { redirect_to edit_admin_current_site_url(new_host_if_subdomain_changed) }
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
def resource
|
|
|
|
@site = current_site
|
|
|
|
end
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def new_host_if_subdomain_changed
|
2010-06-16 14:43:29 +00:00
|
|
|
if @site.domains.include?(request.host)
|
2010-05-10 22:39:52 +00:00
|
|
|
{}
|
|
|
|
else
|
2010-06-16 14:43:29 +00:00
|
|
|
{ :host => "#{@site.subdomain}.#{Locomotive.config.default_domain}:#{request.port}" }
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|