Sha256: bcfc275af3d7109afd42c8b19ad67fa9231549351a4bcc32268d6b7ad2e8fc39

Contents?: true

Size: 997 Bytes

Versions: 8

Compression:

Stored size: 997 Bytes

Contents

module Locomotive
  class CurrentSiteController < BaseController

    sections 'settings', 'site'

    skip_load_and_authorize_resource

    load_and_authorize_resource :class => 'Site'

    helper 'Locomotive::Sites'

    before_filter :filter_attributes

    respond_to :json, :only => :update

    def edit
      @site = current_site
      respond_with @site
    end

    def update
      @site = current_site
      @site.update_attributes(params[:site])
      respond_with @site, :location => edit_current_site_url(new_host_if_subdomain_changed)
    end

    protected

    def filter_attributes
      unless can?(:manage, Locomotive::Membership)
        params[:site].delete(:memberships_attributes) if params[:site]
      end
    end

    def new_host_if_subdomain_changed
      if !Locomotive.config.manage_subdomain? || @site.domains.include?(request.host)
        {}
      else
        { :host => site_url(@site, { :fullpath => false, :protocol => false }) }
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc9 app/controllers/locomotive/current_site_controller.rb
locomotive_cms-2.0.0.rc8 app/controllers/locomotive/current_site_controller.rb
locomotive_cms-2.0.0.rc7 app/controllers/locomotive/current_site_controller.rb
locomotive_cms-2.0.0.rc6 app/controllers/locomotive/current_site_controller.rb
locomotive_cms-2.0.0.rc5 app/controllers/locomotive/current_site_controller.rb
locomotive_cms-2.0.0.rc4 app/controllers/locomotive/current_site_controller.rb
locomotive_cms-2.0.0.rc2 app/controllers/locomotive/current_site_controller.rb
locomotive_cms-2.0.0.rc1 app/controllers/locomotive/current_site_controller.rb