Sha256: b04061206901df0e719b4ce7367db39741f7adec84ffa9d4093bc5ce7620ad24

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

module FinePrint
  class SignaturesController < FinePrint::ApplicationController
    include FinePrint::ApplicationHelper

    acts_as_interceptor :override_url_options => true

    skip_before_filter :can_manage, :only => [:new, :create]
    before_filter :can_sign, :only => [:new, :create]
    before_filter :get_contract, :only => [:index, :new, :create]

    def index
      @signatures = @contract.signatures
    end

    def new
      @signature = Signature.new
    end

    def create
      @signature = Signature.new

      unless params[:signature_accept]
        @signature.errors.add(:contract, 'must be accepted to proceed')
        render :action => 'new'
        return
      end

      @signature.user = @user
      @signature.contract = @contract
  
      if @signature.save
        redirect_back
      else
        render :action => 'new', :alert => merge_errors_for(@signature)
      end
    end
  
    def destroy
      @signature = Signature.find(params[:id])

      @signature.destroy
      redirect_to contract_signatures_path(@signature.contract),
                  :notice => 'Signature was successfully deleted.'
    end

    protected

    def can_sign
      with_interceptor { instance_exec @user, &FinePrint.can_sign_proc }
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fine_print-2.0.3 app/controllers/fine_print/signatures_controller.rb
fine_print-2.0.2 app/controllers/fine_print/signatures_controller.rb
fine_print-2.0.1 app/controllers/fine_print/signatures_controller.rb
fine_print-2.0.0 app/controllers/fine_print/signatures_controller.rb