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
|
|
|
|
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'
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-10-31 23:44:23 +00:00
|
|
|
create! { 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-07-13 00:46:17 +00:00
|
|
|
protected
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
def begin_of_association_chain; nil; end # not related directly to current_site
|
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
|