git-svn-id: https://192.168.0.254/svn/Rodax.redmine_rodax_crm/trunk@4 ff88604e-da85-c949-a72f-fc3aa3ba3724
56 lines
1.3 KiB
Ruby
56 lines
1.3 KiB
Ruby
class ContractContactsController < ApplicationController
|
|
unloadable
|
|
|
|
before_filter :find_project_by_project_id, :authorize
|
|
before_filter :find_contact, :only => :delete
|
|
before_filter :find_contract
|
|
|
|
helper :contracts
|
|
|
|
def add
|
|
@show_form = "true"
|
|
|
|
if params[:contact_id] && request.post? then
|
|
find_contact
|
|
if !@contract.all_contacts.include?(@contact)
|
|
@contract.related_contacts << @contact
|
|
@contract.save
|
|
end
|
|
end
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to :back }
|
|
format.js do
|
|
render :update do |page|
|
|
page.replace_html 'contract_contacts', :partial => 'contract_contacts/contacts'
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def delete
|
|
@contract.related_contacts.delete(@contact)
|
|
respond_to do |format|
|
|
format.html { redirect_to :back }
|
|
format.js do
|
|
render :update do |page|
|
|
page.replace_html 'contract_contacts', :partial => 'contract_contacts/contacts'
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
private
|
|
def find_contact
|
|
@contact = Contact.find(params[:contact_id])
|
|
rescue ActiveRecord::RecordNotFound
|
|
render_404
|
|
end
|
|
|
|
def find_contract
|
|
@contract = Contract.find(params[:contract_id])
|
|
rescue ActiveRecord::RecordNotFound
|
|
render_404
|
|
end
|
|
end |