Sha256: 80f18fe509aecd13fec74cba4eaf0682e945a5aa7c7c67ac6c97fa70150a6ac7

Contents?: true

Size: 1.45 KB

Versions: 20

Compression:

Stored size: 1.45 KB

Contents

class Admin::SitesController < ApplicationController
  before_filter :authenticate_user! if Object.const_defined?('Devise')

  def index
    @sites = Site.all
  end

  def show
    params[:labels] = {
      :updated_at => 'Last Updated',
      :humanize_path => 'URL'
    }
    @site = Site.find(params[:id])
    params[:by] ||= 'humanize_path'
    params[:dir] ||= 'asc'
    @pages = @site.pages.sort_by{ |p| p.send(params[:by]).to_s }
    @pages.reverse! if params[:dir] == 'desc'
    @redirects = @site.redirects
    @nav_items = @site.nav_items.roots.sort_by{ |ni| ni.position.to_i }
  end

  def new
    @site = Site.new
  end

  def create
    @site = Site.new(params[:site])
    if @site.save
      @site.activate! if params[:site][:state] == 'Active'
      flash[:notice] = "Successfully created site."
      redirect_to admin_site_path(@site)
    else
      render :action => 'new'
    end
  end

  def edit
    @site = Site.find(params[:id])
  end

  def update
    @site = Site.find(params[:id])
    if @site.update_attributes(params[:site])
      @site.activate! if params[:site][:state] == 'Active'
      @site.deactivate! if params[:site][:state] == 'Inactive'
      flash[:notice] = "Successfully updated site."
      redirect_to admin_site_path(@site)
    else
      render :action => 'edit'
    end
  end

  def destroy
    @site = Site.find(params[:id])
    @site.destroy
    flash[:notice] = "Successfully destroyed site."
    redirect_to admin_sites_url
  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
site_logic-1.9.13 app/controllers/admin/sites_controller.rb
site_logic-1.9.12 app/controllers/admin/sites_controller.rb
site_logic-1.9.11 app/controllers/admin/sites_controller.rb
site_logic-1.9.10 app/controllers/admin/sites_controller.rb
site_logic-1.9.9 app/controllers/admin/sites_controller.rb
site_logic-1.9.8 app/controllers/admin/sites_controller.rb
site_logic-1.9.7 app/controllers/admin/sites_controller.rb
site_logic-1.9.6 app/controllers/admin/sites_controller.rb
site_logic-1.9.5 app/controllers/admin/sites_controller.rb
site_logic-1.9.4 app/controllers/admin/sites_controller.rb
site_logic-1.9.3 app/controllers/admin/sites_controller.rb
site_logic-1.9.2 app/controllers/admin/sites_controller.rb
site_logic-1.9.1 app/controllers/admin/sites_controller.rb
site_logic-1.9.0 app/controllers/admin/sites_controller.rb
site_logic-1.8.0 app/controllers/admin/sites_controller.rb
site_logic-1.7.1 app/controllers/admin/sites_controller.rb
site_logic-1.7.0 app/controllers/admin/sites_controller.rb
site_logic-1.6.10 app/controllers/admin/sites_controller.rb
site_logic-1.6.9 app/controllers/admin/sites_controller.rb
site_logic-1.6.8 app/controllers/admin/sites_controller.rb