Sha256: 5b30651d675eed02f06710b14a03d1a48f14154ce3013f9bfa93a7d57893936c

Contents?: true

Size: 1.87 KB

Versions: 11

Compression:

Stored size: 1.87 KB

Contents

module FinePrint
  class ContractsController < FinePrint::ApplicationController
    include FinePrint::ApplicationHelper
    before_filter :get_contract, :except => [:index, :new, :create]

    def index
      @contracts = Contract.all
    end
  
    def show
    end

    def new
      @contract = Contract.new
    end
  
    def edit
    end
  
    def create
      @contract = Contract.new
      @contract.name = params[:contract][:name]
      @contract.title = params[:contract][:title]
      @contract.content = params[:contract][:content]
  
      if @contract.save
        redirect_to @contract, :notice => 'Contract was successfully created.'
      else
        render :action => 'new'
      end
    end
  
    def update
      @contract.name = params[:contract][:name]
      @contract.title = params[:contract][:title]
      @contract.content = params[:contract][:content]

      if @contract.save
        redirect_to @contract, :notice => 'Contract was successfully updated.'
      else
        render :action => 'edit'
      end
    end

    def destroy
      if @contract.destroy
        redirect_to contracts_path, :notice => 'Contract was successfully deleted.'
      else
        redirect_to contracts_path, :alert => merge_errors_for(@contract)
      end
    end

    def publish
      if @contract.publish
        redirect_to contracts_path, :notice => 'Contract was successfully published.'
      else
        redirect_to contracts_path, :alert => merge_errors_for(@contract)
      end
    end

    def unpublish
      if @contract.unpublish
        redirect_to contracts_path, :notice => 'Contract was successfully unpublished.'
      else
        redirect_to contracts_path, :alert => merge_errors_for(@contract)
      end
    end

    def new_version
      @contract = @contract.draft_copy
    end

    protected

    def get_contract
      @contract = Contract.find(params[:id])
    end
  end
end

Version data entries

11 entries across 6 versions & 1 rubygems

Version Path
fine_print-1.4.1 app/controllers/fine_print/contracts_controller.rb
fine_print-1.3.0 app/controllers/fine_print/contracts_controller.rb~
fine_print-1.3.0 app/controllers/fine_print/contracts_controller.rb
fine_print-1.2.0 app/controllers/fine_print/contracts_controller.rb~
fine_print-1.2.0 app/controllers/fine_print/contracts_controller.rb
fine_print-1.1.1 app/controllers/fine_print/contracts_controller.rb~
fine_print-1.1.1 app/controllers/fine_print/contracts_controller.rb
fine_print-1.1.0 app/controllers/fine_print/contracts_controller.rb~
fine_print-1.1.0 app/controllers/fine_print/contracts_controller.rb
fine_print-1.0.0 app/controllers/fine_print/contracts_controller.rb
fine_print-1.0.0 app/controllers/fine_print/contracts_controller.rb~