2010-05-10 22:39:52 +00:00
|
|
|
module Admin
|
|
|
|
class SitesController < BaseController
|
|
|
|
|
|
|
|
sections 'settings'
|
|
|
|
|
|
|
|
def new
|
|
|
|
@site = Site.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@site = Site.new(params[:site])
|
|
|
|
|
|
|
|
if @site.save
|
2010-06-10 22:07:59 +00:00
|
|
|
@site.memberships.create :account => @current_admin, :admin => true
|
2010-05-10 22:39:52 +00:00
|
|
|
flash_success!
|
|
|
|
redirect_to edit_admin_my_account_url
|
|
|
|
else
|
|
|
|
flash_error!
|
|
|
|
render :action => 'new'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2010-06-10 22:07:59 +00:00
|
|
|
@site = current_admin.sites.detect { |s| s._id == params[:id] }
|
2010-05-10 22:39:52 +00:00
|
|
|
|
|
|
|
if @site != current_site
|
|
|
|
@site.destroy
|
|
|
|
flash_success!
|
|
|
|
else
|
|
|
|
flash_error!
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to edit_admin_my_account_url
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def new_host_if_subdomain_changed
|
|
|
|
host_from_site = "#{@site.subdomain}.#{Locomotive.config.default_domain}"
|
|
|
|
if request.host == host_from_site
|
|
|
|
{}
|
|
|
|
else
|
|
|
|
{ :host => "#{host_from_site}:#{request.port}" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|