2010-05-10 22:39:52 +00:00
|
|
|
module Admin
|
|
|
|
class SitesController < BaseController
|
|
|
|
|
|
|
|
sections 'settings'
|
|
|
|
|
|
|
|
def create
|
|
|
|
@site = Site.new(params[:site])
|
2010-07-13 00:46:17 +00:00
|
|
|
@site.memberships.build :account => @current_admin, :admin => true
|
|
|
|
|
|
|
|
create! { edit_admin_my_account_url }
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-13 00:46:17 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def destroy
|
2010-06-10 22:07:59 +00:00
|
|
|
@site = current_admin.sites.detect { |s| s._id == 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-13 00:46:17 +00:00
|
|
|
respond_with @site, :location => edit_admin_my_account_url
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-13 00:46:17 +00:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def begin_of_association_chain; nil; end # not related directly to current_site
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
|
|
|
end
|