Sha256: a54502e73c0884241726f70e49f24923c2419fe1c5eb0f5679593b89bf710db8

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

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

    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, t('fine_print.signature.errors.contract.must_agree'))
        render :action => 'new'
        return
      end

      @signature.user = @user
      @signature.contract = @contract
  
      if @signature.save
        fine_print_return
      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 => t('fine_print.signature.notices.deleted')
    end

    protected

    def can_sign
      instance_exec @user, &FinePrint.can_sign_proc
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fine_print-2.3.1 app/controllers/fine_print/signatures_controller.rb
fine_print-2.3.0 app/controllers/fine_print/signatures_controller.rb