2011-10-30 23:02:41 +00:00
|
|
|
module Locomotive
|
2010-05-10 22:39:52 +00:00
|
|
|
class SitesController < BaseController
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
sections 'settings'
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-12-11 22:33:38 +00:00
|
|
|
respond_to :json, :only => [:create, :destroy]
|
2011-12-02 14:59:41 +00:00
|
|
|
|
2011-11-28 14:40:25 +00:00
|
|
|
def new
|
|
|
|
@site = Site.new
|
|
|
|
respond_with @site
|
|
|
|
end
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def create
|
|
|
|
@site = Site.new(params[:site])
|
2011-11-04 15:55:51 +00:00
|
|
|
@site.memberships.build :account => @current_locomotive_account, :role => 'admin'
|
2011-11-28 14:40:25 +00:00
|
|
|
@site.save
|
|
|
|
respond_with @site, :location => edit_my_account_url
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def destroy
|
2011-11-04 15:55:51 +00:00
|
|
|
@site = current_locomotive_account.sites.find(params[:id])
|
2010-07-13 00:46:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
if @site != current_site
|
|
|
|
@site.destroy
|
|
|
|
else
|
2010-07-13 00:46:17 +00:00
|
|
|
@site.errors.add(:base, 'Can not destroy the site you are logging in now')
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-10-31 23:44:23 +00:00
|
|
|
respond_with @site, :location => edit_my_account_url
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|